Index: third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp |
diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp |
index 8d5ef06e1ec24ddb0f96f0a89e5ce1f895eef226..235cd9b5e1263f50375f057e118ea7b78008e28d 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp |
@@ -327,29 +327,54 @@ std::unique_ptr<AXProperty> createRelatedNodeListProperty( |
return createProperty(key, std::move(nodeListValue)); |
} |
-void fillRelationships(AXObject& axObject, |
- protocol::Array<AXProperty>& properties) { |
- if (AXObject* activeDescendant = axObject.activeDescendant()) { |
- properties.addItem( |
- createProperty(AXRelationshipAttributesEnum::Activedescendant, |
- createRelatedNodeListValue(*activeDescendant))); |
+class SparseAttributeAXPropertyAdapter |
+ : public GarbageCollected<SparseAttributeAXPropertyAdapter>, |
+ public AXSparseAttributeClient { |
+ public: |
+ SparseAttributeAXPropertyAdapter(AXObject& axObject, |
+ protocol::Array<AXProperty>& properties) |
+ : m_axObject(&axObject), m_properties(properties) {} |
+ |
+ DEFINE_INLINE_TRACE() { visitor->trace(m_axObject); } |
+ |
+ private: |
+ Member<AXObject> m_axObject; |
+ protocol::Array<AXProperty>& m_properties; |
+ |
+ void addBoolAttribute(AXBoolAttribute attribute, bool value) {} |
+ |
+ void addStringAttribute(AXStringAttribute attribute, const String& value) {} |
+ |
+ void addObjectAttribute(AXObjectAttribute attribute, AXObject& object) { |
+ switch (attribute) { |
+ case AXObjectAttribute::AriaActiveDescendant: |
+ m_properties.addItem( |
+ createProperty(AXRelationshipAttributesEnum::Activedescendant, |
+ createRelatedNodeListValue(object))); |
+ break; |
+ } |
} |
- AXObject::AXObjectVector results; |
- axObject.ariaFlowToElements(results); |
- if (!results.isEmpty()) |
- properties.addItem( |
- createRelatedNodeListProperty(AXRelationshipAttributesEnum::Flowto, |
- results, aria_flowtoAttr, axObject)); |
- results.clear(); |
- |
- axObject.ariaControlsElements(results); |
- if (!results.isEmpty()) |
- properties.addItem( |
- createRelatedNodeListProperty(AXRelationshipAttributesEnum::Controls, |
- results, aria_controlsAttr, axObject)); |
- results.clear(); |
+ void addObjectVectorAttribute(AXObjectVectorAttribute attribute, |
+ HeapVector<Member<AXObject>>& objects) { |
+ switch (attribute) { |
+ case AXObjectVectorAttribute::AriaControls: |
+ m_properties.addItem(createRelatedNodeListProperty( |
+ AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, |
+ *m_axObject)); |
+ break; |
+ case AXObjectVectorAttribute::AriaFlowTo: |
+ m_properties.addItem(createRelatedNodeListProperty( |
+ AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, |
+ *m_axObject)); |
+ break; |
+ } |
+ } |
+}; |
+void fillRelationships(AXObject& axObject, |
+ protocol::Array<AXProperty>& properties) { |
+ AXObject::AXObjectVector results; |
axObject.ariaDescribedbyElements(results); |
if (!results.isEmpty()) |
properties.addItem( |
@@ -545,6 +570,9 @@ std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject( |
fillWidgetStates(axObject, *(properties.get())); |
fillRelationships(axObject, *(properties.get())); |
+ SparseAttributeAXPropertyAdapter adapter(axObject, *properties); |
+ axObject.getSparseAXAttributes(adapter); |
+ |
AXObject::NameSources nameSources; |
String computedName = axObject.name(&nameSources); |
if (!nameSources.isEmpty()) { |