Chromium Code Reviews| 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 3e18e556d466beaf250314eaee1346ca0c2f1955..4a20d1a95c5bb6829f76c6f17284d89e2aebe668 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| @@ -389,6 +389,39 @@ const AtomicString& AXObject::getAOMPropertyOrARIAAttribute( |
| return AccessibleNode::getProperty(toElement(node), property); |
| } |
| +bool AXObject::getAOMPropertyOrARIAAttribute(AOMBooleanProperty property, |
|
aboxhall
2017/04/07 05:22:35
Ok, now I see what you were talking about.
This i
dmazzoni
2017/04/21 07:11:37
Thanks for the discussion.
I went with this form:
|
| + bool& result) const { |
| + Node* node = this->getNode(); |
|
aboxhall
2017/04/07 05:22:35
Would it help to make a convenience protected/priv
dmazzoni
2017/04/21 07:11:37
Good idea. Used it throughout the file.
|
| + if (!node || !node->isElementNode()) |
| + return false; |
| + |
| + bool isNull = true; |
| + result = AccessibleNode::getProperty(toElement(node), property, isNull); |
| + return !isNull; |
| +} |
| + |
| +bool AXObject::hasAOMPropertyOrARIAAttribute( |
| + AOMBooleanProperty property) const { |
| + bool dummyResult; |
| + return getAOMPropertyOrARIAAttribute(property, dummyResult); |
| +} |
| + |
| +bool AXObject::AOMPropertyOrARIAAttributeIsTrue( |
| + AOMBooleanProperty property) const { |
| + bool result; |
| + if (getAOMPropertyOrARIAAttribute(property, result)) |
| + return result; |
| + return false; |
| +} |
| + |
| +bool AXObject::AOMPropertyOrARIAAttributeIsFalse( |
| + AOMBooleanProperty property) const { |
| + bool result; |
| + if (getAOMPropertyOrARIAAttribute(property, result)) |
| + return !result; |
| + return false; |
| +} |
| + |
| bool AXObject::isARIATextControl() const { |
| return ariaRoleAttribute() == TextFieldRole || |
| ariaRoleAttribute() == SearchBoxRole || |
| @@ -596,7 +629,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; |
| } |
| @@ -609,16 +642,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 (getAOMPropertyOrARIAAttribute(AOMBooleanProperty::kDisabled, disabled)) { |
| + if (disabled) |
| + return this; |
| + return nullptr; |
| + } |
| if (AXObject* parent = parentObject()) |
| return parent->disabledAncestor(); |
| - return 0; |
| + return nullptr; |
| } |
| bool AXObject::lastKnownIsIgnoredValue() { |
| @@ -723,7 +757,7 @@ String AXObject::recursiveTextAlternative(const AXObject& axObj, |
| } |
| bool AXObject::isHiddenForTextAlternativeCalculation() const { |
| - if (equalIgnoringASCIICase(getAttribute(aria_hiddenAttr), "false")) |
| + if (AOMPropertyOrARIAAttributeIsFalse(AOMBooleanProperty::kHidden)) |
| return false; |
| if (getLayoutObject()) |
| @@ -982,7 +1016,7 @@ bool AXObject::isMultiline() const { |
| if (!isNativeTextControl() && !isNonNativeTextControl()) |
| return false; |
| - return equalIgnoringASCIICase(getAttribute(aria_multilineAttr), "true"); |
| + return AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kMultiline); |
| } |
| bool AXObject::ariaPressedIsPresent() const { |