Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp

Issue 2589273002: Add sparse accessibility attribute interface to Blink (Closed)
Patch Set: Address feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()) {
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXObject.h ('k') | third_party/WebKit/Source/web/AssertMatchingEnums.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698