| 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 36bad05fdae17eb1258e795cf047b3e1843b27bf..d0fdeed6c13ad0ea308ff8e9fd6f168b94d0ed5d 100644
|
| --- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
|
| @@ -30,6 +30,7 @@
|
|
|
| #include "SkMatrix44.h"
|
| #include "core/css/resolver/StyleResolver.h"
|
| +#include "core/dom/AccessibleNode.h"
|
| #include "core/dom/DocumentUserGestureToken.h"
|
| #include "core/editing/EditingUtilities.h"
|
| #include "core/editing/VisibleUnits.h"
|
| @@ -378,6 +379,49 @@ bool AXObject::isDetached() const {
|
| return !m_axObjectCache;
|
| }
|
|
|
| +using AOMStringPropertyToAriaMap = HashMap<AOMStringProperty,
|
| + QualifiedName,
|
| + WTF::IntHash<AOMStringProperty>,
|
| + AOMStringPropertyHashTraits>;
|
| +
|
| +static AOMStringPropertyToAriaMap& getAOMStringPropertyToAriaMap() {
|
| + DEFINE_STATIC_LOCAL(AOMStringPropertyToAriaMap, map, ());
|
| + if (map.isEmpty()) {
|
| + map.set(AOMStringProperty::Role, roleAttr);
|
| + map.set(AOMStringProperty::Label, aria_labelAttr);
|
| + }
|
| + return map;
|
| +}
|
| +
|
| +AccessibleNode* AXObject::getAccessibleNode() const {
|
| + if (!RuntimeEnabledFeatures::accessibilityObjectModelEnabled())
|
| + return nullptr;
|
| +
|
| + Node* node = getNode();
|
| + if (!node || !node->isElementNode())
|
| + return nullptr;
|
| +
|
| + Element* element = toElement(node);
|
| + return element->accessibleNode();
|
| +}
|
| +
|
| +const AtomicString& AXObject::getAriaAttributeOrAOMProperty(
|
| + AOMStringProperty property) const {
|
| + AOMStringPropertyToAriaMap& ariaMap = getAOMStringPropertyToAriaMap();
|
| + QualifiedName attrName = ariaMap.at(property);
|
| + if (attrName != QualifiedName::null()) {
|
| + const AtomicString& result = getAttribute(attrName);
|
| + if (!result.isNull())
|
| + return result;
|
| + }
|
| +
|
| + AccessibleNode* aomNode = getAccessibleNode();
|
| + if (aomNode)
|
| + return aomNode->getProperty(property);
|
| +
|
| + return nullAtom;
|
| +}
|
| +
|
| bool AXObject::isARIATextControl() const {
|
| return ariaRoleAttribute() == TextFieldRole ||
|
| ariaRoleAttribute() == SearchBoxRole ||
|
| @@ -803,7 +847,8 @@ String AXObject::ariaTextAlternative(bool recursive,
|
| nameSources->push_back(NameSource(*foundTextAlternative, aria_labelAttr));
|
| nameSources->back().type = nameFrom;
|
| }
|
| - const AtomicString& ariaLabel = getAttribute(aria_labelAttr);
|
| + const AtomicString& ariaLabel =
|
| + getAriaAttributeOrAOMProperty(AOMStringProperty::Label);
|
| if (!ariaLabel.isEmpty()) {
|
| textAlternative = ariaLabel;
|
|
|
|
|