| Index: third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| index c775e1841b31db753dbbede7365803ab245bc922..2d14648238598f7448c13c1302ed77ed95310e3f 100644
|
| --- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| @@ -385,11 +385,36 @@ bool AXObject::IsDetached() const {
|
|
|
| const AtomicString& AXObject::GetAOMPropertyOrARIAAttribute(
|
| AOMStringProperty property) const {
|
| - Node* node = this->GetNode();
|
| - if (!node || !node->IsElementNode())
|
| - return g_null_atom;
|
| + if (Element* element = this->GetElement())
|
| + return AccessibleNode::GetProperty(element, property);
|
| + return g_null_atom;
|
| +}
|
| +
|
| +bool AXObject::HasAOMPropertyOrARIAAttribute(AOMBooleanProperty property,
|
| + bool& result) const {
|
| + Element* element = this->GetElement();
|
| + if (!element)
|
| + return false;
|
| +
|
| + bool is_null = true;
|
| + result = AccessibleNode::GetProperty(element, property, is_null);
|
| + return !is_null;
|
| +}
|
| +
|
| +bool AXObject::AOMPropertyOrARIAAttributeIsTrue(
|
| + AOMBooleanProperty property) const {
|
| + bool result;
|
| + if (HasAOMPropertyOrARIAAttribute(property, result))
|
| + return result;
|
| + return false;
|
| +}
|
|
|
| - return AccessibleNode::GetProperty(ToElement(node), property);
|
| +bool AXObject::AOMPropertyOrARIAAttributeIsFalse(
|
| + AOMBooleanProperty property) const {
|
| + bool result;
|
| + if (HasAOMPropertyOrARIAAttribute(property, result))
|
| + return !result;
|
| + return false;
|
| }
|
|
|
| bool AXObject::IsARIATextControl() const {
|
| @@ -567,8 +592,8 @@ void AXObject::UpdateCachedAttributeValuesIfNeeded() const {
|
| }
|
|
|
| bool AXObject::AccessibilityIsIgnoredByDefault(
|
| - IgnoredReasons* ignored_reasons) const {
|
| - return DefaultObjectInclusion(ignored_reasons) == kIgnoreObject;
|
| + IgnoredReasons* ignoredReasons) const {
|
| + return DefaultObjectInclusion(ignoredReasons) == kIgnoreObject;
|
| }
|
|
|
| AXObjectInclusion AXObject::AccessibilityPlatformIncludesObject() const {
|
| @@ -604,21 +629,21 @@ bool AXObject::IsInertOrAriaHidden() const {
|
| }
|
|
|
| bool AXObject::ComputeIsInertOrAriaHidden(
|
| - IgnoredReasons* ignored_reasons) const {
|
| + IgnoredReasons* ignoredReasons) const {
|
| if (GetNode()) {
|
| if (GetNode()->IsInert()) {
|
| - if (ignored_reasons) {
|
| + if (ignoredReasons) {
|
| HTMLDialogElement* dialog = GetActiveDialogElement(GetNode());
|
| if (dialog) {
|
| AXObject* dialog_object = AxObjectCache().GetOrCreate(dialog);
|
| if (dialog_object)
|
| - ignored_reasons->push_back(
|
| + ignoredReasons->push_back(
|
| IgnoredReason(kAXActiveModalDialog, dialog_object));
|
| else
|
| - ignored_reasons->push_back(IgnoredReason(kAXInert));
|
| + ignoredReasons->push_back(IgnoredReason(kAXInert));
|
| } else {
|
| // TODO(aboxhall): handle inert attribute if it eventuates
|
| - ignored_reasons->push_back(IgnoredReason(kAXInert));
|
| + ignoredReasons->push_back(IgnoredReason(kAXInert));
|
| }
|
| }
|
| return true;
|
| @@ -626,19 +651,19 @@ bool AXObject::ComputeIsInertOrAriaHidden(
|
| } else {
|
| AXObject* parent = ParentObject();
|
| if (parent && parent->IsInertOrAriaHidden()) {
|
| - if (ignored_reasons)
|
| - parent->ComputeIsInertOrAriaHidden(ignored_reasons);
|
| + if (ignoredReasons)
|
| + parent->ComputeIsInertOrAriaHidden(ignoredReasons);
|
| return true;
|
| }
|
| }
|
|
|
| const AXObject* hidden_root = AriaHiddenRoot();
|
| if (hidden_root) {
|
| - if (ignored_reasons) {
|
| + if (ignoredReasons) {
|
| if (hidden_root == this)
|
| - ignored_reasons->push_back(IgnoredReason(kAXAriaHidden));
|
| + ignoredReasons->push_back(IgnoredReason(kAXAriaHidden));
|
| else
|
| - ignored_reasons->push_back(
|
| + ignoredReasons->push_back(
|
| IgnoredReason(kAXAriaHiddenRoot, hidden_root));
|
| }
|
| return true;
|
| @@ -665,7 +690,7 @@ AXObject* AXObject::LeafNodeAncestor() const {
|
|
|
| const AXObject* AXObject::AriaHiddenRoot() const {
|
| for (const AXObject* object = this; object; object = object->ParentObject()) {
|
| - if (EqualIgnoringASCIICase(object->GetAttribute(aria_hiddenAttr), "true"))
|
| + if (object->AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kHidden))
|
| return object;
|
| }
|
|
|
| @@ -678,16 +703,17 @@ bool AXObject::IsDescendantOfDisabledNode() const {
|
| }
|
|
|
| const AXObject* AXObject::DisabledAncestor() const {
|
| - const AtomicString& disabled = GetAttribute(aria_disabledAttr);
|
| - if (EqualIgnoringASCIICase(disabled, "true"))
|
| - return this;
|
| - if (EqualIgnoringASCIICase(disabled, "false"))
|
| - return 0;
|
| + bool disabled = false;
|
| + if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kDisabled, disabled)) {
|
| + if (disabled)
|
| + return this;
|
| + return nullptr;
|
| + }
|
|
|
| if (AXObject* parent = ParentObject())
|
| return parent->DisabledAncestor();
|
|
|
| - return 0;
|
| + return nullptr;
|
| }
|
|
|
| bool AXObject::LastKnownIsIgnoredValue() {
|
| @@ -792,7 +818,7 @@ String AXObject::RecursiveTextAlternative(const AXObject& ax_obj,
|
| }
|
|
|
| bool AXObject::IsHiddenForTextAlternativeCalculation() const {
|
| - if (EqualIgnoringASCIICase(GetAttribute(aria_hiddenAttr), "false"))
|
| + if (AOMPropertyOrARIAAttributeIsFalse(AOMBooleanProperty::kHidden))
|
| return false;
|
|
|
| if (GetLayoutObject())
|
| @@ -938,10 +964,6 @@ String AXObject::TextFromElements(
|
|
|
| void AXObject::TokenVectorFromAttribute(Vector<String>& tokens,
|
| const QualifiedName& attribute) const {
|
| - Node* node = this->GetNode();
|
| - if (!node || !node->IsElementNode())
|
| - return;
|
| -
|
| String attribute_value = GetAttribute(attribute).GetString();
|
| if (attribute_value.IsEmpty())
|
| return;
|
| @@ -1038,7 +1060,7 @@ bool AXObject::IsMultiline() const {
|
| if (!IsNativeTextControl() && !IsNonNativeTextControl())
|
| return false;
|
|
|
| - return EqualIgnoringASCIICase(GetAttribute(aria_multilineAttr), "true");
|
| + return AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kMultiline);
|
| }
|
|
|
| bool AXObject::AriaPressedIsPresent() const {
|
| @@ -1215,6 +1237,11 @@ void AXObject::ClearChildren() {
|
| have_children_ = false;
|
| }
|
|
|
| +Element* AXObject::GetElement() const {
|
| + Node* node = GetNode();
|
| + return node && node->IsElementNode() ? ToElement(node) : nullptr;
|
| +}
|
| +
|
| Document* AXObject::GetDocument() const {
|
| FrameView* frame_view = DocumentFrameView();
|
| if (!frame_view)
|
| @@ -1254,28 +1281,16 @@ String AXObject::Language() const {
|
| }
|
|
|
| bool AXObject::HasAttribute(const QualifiedName& attribute) const {
|
| - Node* element_node = GetNode();
|
| - if (!element_node)
|
| - return false;
|
| -
|
| - if (!element_node->IsElementNode())
|
| - return false;
|
| -
|
| - Element* element = ToElement(element_node);
|
| - return element->FastHasAttribute(attribute);
|
| + if (Element* element = GetElement())
|
| + return element->FastHasAttribute(attribute);
|
| + return false;
|
| }
|
|
|
| const AtomicString& AXObject::GetAttribute(
|
| const QualifiedName& attribute) const {
|
| - Node* element_node = GetNode();
|
| - if (!element_node)
|
| - return g_null_atom;
|
| -
|
| - if (!element_node->IsElementNode())
|
| - return g_null_atom;
|
| -
|
| - Element* element = ToElement(element_node);
|
| - return element->FastGetAttribute(attribute);
|
| + if (Element* element = GetElement())
|
| + return element->FastGetAttribute(attribute);
|
| + return g_null_atom;
|
| }
|
|
|
| //
|
| @@ -1720,15 +1735,15 @@ int AXObject::LineForPosition(const VisiblePosition& position) const {
|
| return line_count;
|
| }
|
|
|
| -bool AXObject::IsARIAControl(AccessibilityRole aria_role) {
|
| - return IsARIAInput(aria_role) || aria_role == kButtonRole ||
|
| - aria_role == kComboBoxRole || aria_role == kSliderRole;
|
| +bool AXObject::IsARIAControl(AccessibilityRole ariaRole) {
|
| + return IsARIAInput(ariaRole) || ariaRole == kButtonRole ||
|
| + ariaRole == kComboBoxRole || ariaRole == kSliderRole;
|
| }
|
|
|
| -bool AXObject::IsARIAInput(AccessibilityRole aria_role) {
|
| - return aria_role == kRadioButtonRole || aria_role == kCheckBoxRole ||
|
| - aria_role == kTextFieldRole || aria_role == kSwitchRole ||
|
| - aria_role == kSearchBoxRole;
|
| +bool AXObject::IsARIAInput(AccessibilityRole ariaRole) {
|
| + return ariaRole == kRadioButtonRole || ariaRole == kCheckBoxRole ||
|
| + ariaRole == kTextFieldRole || ariaRole == kSwitchRole ||
|
| + ariaRole == kSearchBoxRole;
|
| }
|
|
|
| AccessibilityRole AXObject::AriaRoleToWebCoreRole(const String& value) {
|
| @@ -1827,8 +1842,8 @@ bool AXObject::NameFromContents() const {
|
| if (AncestorExposesActiveDescendant()) {
|
| return true;
|
| }
|
| - const Node* node = this->GetNode();
|
| - return node && node->IsElementNode() && ToElement(node)->IsFocusable();
|
| + const Element* element = this->GetElement();
|
| + return element && element->IsFocusable();
|
| }
|
| default:
|
| return false;
|
|
|