Chromium Code Reviews| 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..407c19a12eea17cfeec177598ebd5455fe41f0cc 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,10 @@ std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject( |
| fillWidgetStates(axObject, *(properties.get())); |
| fillRelationships(axObject, *(properties.get())); |
| + Member<SparseAttributeAXPropertyAdapter> adapter = |
| + new SparseAttributeAXPropertyAdapter(axObject, *(properties.get())); |
|
dcheng
2017/01/19 23:02:45
Nit: just write *properties
dmazzoni
2017/01/21 00:16:35
Done.
|
| + axObject.getSparseAXAttributes(*adapter.get()); |
| + |
| AXObject::NameSources nameSources; |
| String computedName = axObject.name(&nameSources); |
| if (!nameSources.isEmpty()) { |