Chromium Code Reviews| Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| index ef93a929b436fd4bec20042a24be1a06e346e6a5..f2d987f2e50be208880987f827497d64b7b94c7a 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
| @@ -817,7 +817,8 @@ static Element* siblingWithAriaRole(String role, Node* node) { |
| for (Element* sibling = ElementTraversal::firstChild(*parent); sibling; |
| sibling = ElementTraversal::nextSibling(*sibling)) { |
| - const AtomicString& siblingAriaRole = sibling->getAttribute(roleAttr); |
| + const AtomicString& siblingAriaRole = |
| + AccessibleNode::getProperty(sibling, AOMStringProperty::kRole); |
| if (equalIgnoringCase(siblingAriaRole, role)) |
| return sibling; |
| } |
| @@ -922,6 +923,23 @@ void AXNodeObject::getSparseAXAttributes( |
| if (setter) |
| setter->run(*this, sparseAttributeClient, attr.value()); |
| } |
| + |
| + // TODO(dmazzoni): Efficiently iterate over AccessibleNode properties that are |
| + // set and merge the two loops somehow. |
| + if (toElement(node)->existingAccessibleNode()) { |
| + AtomicString keyShortcuts = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kKeyShortcuts); |
| + if (!keyShortcuts.isNull()) { |
| + axSparseAttributeSetterMap.at(aria_keyshortcutsAttr) |
| + ->run(*this, sparseAttributeClient, keyShortcuts); |
| + } |
| + AtomicString roleDescription = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kRoleDescription); |
| + if (!roleDescription.isNull()) { |
| + axSparseAttributeSetterMap.at(aria_roledescriptionAttr) |
| + ->run(*this, sparseAttributeClient, roleDescription); |
| + } |
| + } |
| } |
| bool AXNodeObject::isAnchor() const { |
| @@ -1113,7 +1131,9 @@ bool AXNodeObject::isChecked() const { |
| case MenuItemRadioRole: |
| case RadioButtonRole: |
| case SwitchRole: |
| - if (equalIgnoringCase(getAttribute(aria_checkedAttr), "true")) |
| + if (equalIgnoringCase( |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kChecked), |
| + "true")) |
| return true; |
| return false; |
| default: |
| @@ -1375,7 +1395,7 @@ String AXNodeObject::ariaAutoComplete() const { |
| return String(); |
| const AtomicString& ariaAutoComplete = |
| - getAttribute(aria_autocompleteAttr).lower(); |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kAutocomplete).lower(); |
| if (ariaAutoComplete == "inline" || ariaAutoComplete == "list" || |
| ariaAutoComplete == "both") |
| @@ -1437,7 +1457,8 @@ AXObject* AXNodeObject::inPageLinkTarget() const { |
| } |
| AccessibilityOrientation AXNodeObject::orientation() const { |
| - const AtomicString& ariaOrientation = getAttribute(aria_orientationAttr); |
| + const AtomicString& ariaOrientation = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kOrientation); |
| AccessibilityOrientation orientation = AccessibilityOrientationUndefined; |
| if (equalIgnoringCase(ariaOrientation, "horizontal")) |
| orientation = AccessibilityOrientationHorizontal; |
| @@ -1583,10 +1604,10 @@ RGBA32 AXNodeObject::colorValue() const { |
| } |
| AriaCurrentState AXNodeObject::ariaCurrentState() const { |
| - if (!hasAttribute(aria_currentAttr)) |
| - return AXObject::ariaCurrentState(); |
| - |
| - const AtomicString& attributeValue = getAttribute(aria_currentAttr); |
| + const AtomicString& attributeValue = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kCurrent); |
| + if (attributeValue.isNull()) |
| + return AriaCurrentStateUndefined; |
| if (attributeValue.isEmpty() || equalIgnoringCase(attributeValue, "false")) |
| return AriaCurrentStateFalse; |
| if (equalIgnoringCase(attributeValue, "true")) |
| @@ -1609,20 +1630,19 @@ AriaCurrentState AXNodeObject::ariaCurrentState() const { |
| } |
| InvalidState AXNodeObject::getInvalidState() const { |
| - if (hasAttribute(aria_invalidAttr)) { |
| - const AtomicString& attributeValue = getAttribute(aria_invalidAttr); |
| - if (equalIgnoringCase(attributeValue, "false")) |
| - return InvalidStateFalse; |
| - if (equalIgnoringCase(attributeValue, "true")) |
| - return InvalidStateTrue; |
| - if (equalIgnoringCase(attributeValue, "spelling")) |
| - return InvalidStateSpelling; |
| - if (equalIgnoringCase(attributeValue, "grammar")) |
| - return InvalidStateGrammar; |
| - // A yet unknown value. |
| - if (!attributeValue.isEmpty()) |
| - return InvalidStateOther; |
| - } |
| + const AtomicString& attributeValue = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); |
| + if (equalIgnoringCase(attributeValue, "false")) |
| + return InvalidStateFalse; |
| + if (equalIgnoringCase(attributeValue, "true")) |
| + return InvalidStateTrue; |
| + if (equalIgnoringCase(attributeValue, "spelling")) |
| + return InvalidStateSpelling; |
| + if (equalIgnoringCase(attributeValue, "grammar")) |
| + return InvalidStateGrammar; |
| + // A yet unknown value. |
| + if (!attributeValue.isEmpty()) |
|
aboxhall
2017/03/31 00:23:39
This doesn't seem right. This is a token value; if
dmazzoni
2017/03/31 04:34:58
The spec says: "Any value not recognized in the li
|
| + return InvalidStateOther; |
| if (getNode() && getNode()->isElementNode() && |
| toElement(getNode())->isFormControlElement()) { |
| @@ -1673,7 +1693,7 @@ int AXNodeObject::setSize() const { |
| String AXNodeObject::ariaInvalidValue() const { |
| if (getInvalidState() == InvalidStateOther) |
| - return getAttribute(aria_invalidAttr); |
| + return getAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); |
| return String(); |
| } |
| @@ -1682,7 +1702,8 @@ String AXNodeObject::valueDescription() const { |
| if (!supportsRangeValue()) |
| return String(); |
| - return getAttribute(aria_valuetextAttr).getString(); |
| + return getAOMPropertyOrARIAAttribute(AOMStringProperty::kValueText) |
| + .getString(); |
| } |
| float AXNodeObject::valueForRange() const { |
| @@ -1846,7 +1867,8 @@ String AXNodeObject::textAlternative(bool recursive, |
| return text(); |
| if (isRange()) { |
| - const AtomicString& ariaValuetext = getAttribute(aria_valuetextAttr); |
| + const AtomicString& ariaValuetext = |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kValueText); |
| if (!ariaValuetext.isNull()) |
| return ariaValuetext.getString(); |
| return String::number(valueForRange()); |
| @@ -2709,7 +2731,7 @@ String AXNodeObject::nativeTextAlternative( |
| source.type = nameFrom; |
| } |
| const AtomicString& ariaPlaceholder = |
| - htmlElement->fastGetAttribute(aria_placeholderAttr); |
| + getAOMPropertyOrARIAAttribute(AOMStringProperty::kPlaceholder); |
| if (!ariaPlaceholder.isEmpty()) { |
| textAlternative = ariaPlaceholder; |
| if (nameSources) { |