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 caf768238d37c02b1abc06aa43b4ef737e0959de..9a7ac4ff375cdfdf8b02b281d175a76eee5f17c2 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp |
| @@ -41,6 +41,7 @@ |
| #include "core/html/parser/HTMLParserIdioms.h" |
| #include "core/layout/LayoutBoxModelObject.h" |
| #include "modules/accessibility/AXObjectCacheImpl.h" |
| +#include "modules/accessibility/AccessibleNode.h" |
| #include "platform/UserGestureIndicator.h" |
| #include "platform/text/PlatformLocale.h" |
| #include "wtf/HashSet.h" |
| @@ -348,6 +349,7 @@ AXObject::AXObject(AXObjectCacheImpl& axObjectCache) |
| m_lastKnownIsIgnoredValue(DefaultBehavior), |
| m_explicitContainerID(0), |
| m_parent(nullptr), |
| + m_accessibleNode(nullptr), |
| m_lastModificationCount(-1), |
| m_cachedIsIgnored(false), |
| m_cachedIsInertOrAriaHidden(false), |
| @@ -378,6 +380,37 @@ 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; |
| +} |
| + |
| +const AtomicString& AXObject::getAomPropertyOrAriaAttribute( |
|
aboxhall
2017/03/16 05:49:34
maybe just getAuthorDefinedProperty?
dmazzoni
2017/03/16 20:43:14
Hmmm, I wouldn't intuitively know how to interpret
|
| + AomStringProperty property) const { |
| + AccessibleNode* aomNode = getAccessibleNode(); |
| + if (aomNode) { |
|
aboxhall
2017/03/16 05:49:34
As discussed, swap this and the following block.
dmazzoni
2017/03/16 20:43:15
Done.
|
| + const AtomicString& result = aomNode->getProperty(property); |
| + if (!result.isNull()) |
| + return result; |
| + } |
| + |
| + AomStringPropertyToAriaMap& ariaMap = getAomStringPropertyToAriaMap(); |
| + QualifiedName attrName = ariaMap.at(property); |
| + if (attrName != QualifiedName::null()) |
| + return getAttribute(attrName); |
| + |
| + return nullAtom; |
| +} |
| + |
| bool AXObject::isARIATextControl() const { |
| return ariaRoleAttribute() == TextFieldRole || |
| ariaRoleAttribute() == SearchBoxRole || |
| @@ -803,7 +836,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 = |
| + getAomPropertyOrAriaAttribute(AomStringProperty::Label); |
| if (!ariaLabel.isEmpty()) { |
| textAlternative = ariaLabel; |
| @@ -1766,6 +1800,7 @@ DEFINE_TRACE(AXObject) { |
| visitor->trace(m_parent); |
| visitor->trace(m_cachedLiveRegionRoot); |
| visitor->trace(m_axObjectCache); |
| + visitor->trace(m_accessibleNode); |
| } |
| } // namespace blink |