/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (mContent) { // We still simulate a click on an accessible even if there is no // known actions. For the sake of bad markup.
DoCommand(); returntrue;
}
returnfalse;
}
Accessible* AccessibleWrap::DoPivot(Accessible* aAccessible,
int32_t aGranularity, bool aForward, bool aInclusive) {
Accessible* pivotRoot = nullptr; if (aAccessible->IsRemote()) { // If this is a remote accessible provide the top level // remote doc as the pivot root for thread safety reasons.
DocAccessibleParent* doc = aAccessible->AsRemote()->Document(); while (doc && !doc->IsTopLevel()) {
doc = doc->ParentDoc();
}
MOZ_ASSERT(doc, "Failed to get top level DocAccessibleParent");
pivotRoot = doc;
}
a11y::Pivot pivot(pivotRoot); // Depending on the start accessible, the pivot rule will either traverse // local or remote accessibles exclusively.
TraversalRule rule(aGranularity, aAccessible->IsLocal());
Accessible* result = aForward ? pivot.Next(aAccessible, rule, aInclusive)
: pivot.Prev(aAccessible, rule, aInclusive);
Accessible* AccessibleWrap::ExploreByTouch(Accessible* aAccessible, float aX, float aY) {
Accessible* root; if (LocalAccessible* local = aAccessible->AsLocal()) {
root = local->RootAccessible();
} else { // If this is a RemoteAccessible, provide the top level // remote doc as the pivot root for thread safety reasons.
DocAccessibleParent* doc = aAccessible->AsRemote()->Document(); while (doc && !doc->IsTopLevel()) {
doc = doc->ParentDoc();
}
MOZ_ASSERT(doc, "Failed to get top level DocAccessibleParent");
root = doc;
}
a11y::Pivot pivot(root);
TraversalRule rule(java::SessionAccessibility::HTML_GRANULARITY_DEFAULT,
aAccessible->IsLocal());
Accessible* result = pivot.AtPoint(aX, aY, rule); if (result == aAccessible) { return nullptr;
} return result;
}
// If the accessible is an editable, set the virtual cursor position // to its caret offset. Otherwise use the document's virtual cursor // position as a starting offset. if (aAccessible->State() & states::EDITABLE) {
startOffset = endOffset = aAccessible->AsHyperTextBase()->CaretOffset();
}
if (!resultRange.Crop(aAccessible)) { // If the new range does not intersect at all with the given // accessible/container this navigation has failed or reached an edge. return Nothing();
}
if (resultRange == currentRange || resultRange.Start() == resultRange.End()) { // If the result range equals the current range, or if the result range is // collapsed, we failed or reached an edge. return Nothing();
}
if (HyperTextAccessibleBase* ht = aAccessible->AsHyperTextBase()) {
DebugOnly<bool> ok = false;
std::tie(ok, startOffset) = ht->TransformOffset(
resultRange.Start().mAcc, resultRange.Start().mOffset, false);
MOZ_ASSERT(ok, "Accessible of range start should be in container.");
std::tie(ok, endOffset) = ht->TransformOffset(
resultRange.End().mAcc, resultRange.End().mOffset, false);
MOZ_ASSERT(ok, "Accessible range end should be in container.");
} else {
startOffset = resultRange.Start().mOffset;
endOffset = resultRange.End().mOffset;
}
if (aRole == roles::PASSWORD_TEXT) {
flags |= java::SessionAccessibility::FLAG_PASSWORD;
}
return flags;
}
void AccessibleWrap::GetRoleDescription(role aRole, AccAttributes* aAttributes,
nsAString& aGeckoRole,
nsAString& aRoleDescription) { if (aRole == roles::HEADING && aAttributes) { // The heading level is an attribute, so we need that.
nsAutoString headingLevel; if (aAttributes->GetAttribute(nsGkAtoms::level, headingLevel)) {
nsAutoString token(u"heading-");
token.Append(headingLevel); if (LocalizeString(token, aRoleDescription)) { return;
}
}
}
if ((aRole == roles::LANDMARK || aRole == roles::REGION) && aAttributes) {
nsAutoString xmlRoles; if (aAttributes->GetAttribute(nsGkAtoms::xmlroles, xmlRoles)) {
nsWhitespaceTokenizer tokenizer(xmlRoles); while (tokenizer.hasMoreTokens()) { if (LocalizeString(tokenizer.nextToken(), aRoleDescription)) { return;
}
}
}
}
if (aInputTypeAttr.EqualsIgnoreCase("number")) { return java::sdk::InputType::TYPE_CLASS_NUMBER;
}
if (aInputTypeAttr.EqualsIgnoreCase("password")) { return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_PASSWORD;
}
if (aInputTypeAttr.EqualsIgnoreCase("tel")) { return java::sdk::InputType::TYPE_CLASS_PHONE;
}
if (aInputTypeAttr.EqualsIgnoreCase("text")) { return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
}
if (aInputTypeAttr.EqualsIgnoreCase("url")) { return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_URI;
}
return 0;
}
void AccessibleWrap::GetTextEquiv(nsString& aText) { // 1. Start with the name, since it might have been explicitly specified. if (Name(aText) != eNameFromSubtree) { // 2. If the name didn't come from the subtree, add the text from the // subtree. if (aText.IsEmpty()) {
nsTextEquivUtils::GetTextEquivFromSubtree(this, aText);
} else {
nsAutoString subtree;
nsTextEquivUtils::GetTextEquivFromSubtree(this, subtree); if (!subtree.IsEmpty()) {
aText.Append(' ');
aText.Append(subtree);
}
}
}
}
bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) { auto eventType = aEvent->GetEventType(); if (eventType != nsIAccessibleEvent::EVENT_TEXT_INSERTED &&
eventType != nsIAccessibleEvent::EVENT_NAME_CHANGE) { // XXX: Right now only announce text inserted events. aria-relevant=removals // is potentially on the chopping block[1]. We also don't support editable // text because we currently can't descern the source of the change[2]. // 1. https://github.com/w3c/aria/issues/712 // 2. https://bugzilla.mozilla.org/show_bug.cgi?id=1531189 returnfalse;
}
if (aEvent->IsFromUserInput()) { returnfalse;
}
RefPtr<AccAttributes> attributes = new AccAttributes();
nsAccUtils::SetLiveContainerAttributes(attributes, this);
nsString live; if (!attributes->GetAttribute(nsGkAtoms::containerLive, live)) { returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.