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

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

Issue 2589273002: Add sparse accessibility attribute interface to Blink (Closed)
Patch Set: Try to fix win component build compile Created 4 years 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 a2d00ddaa9267ef1190a55bc6214f6a8a3d0c94a..a3c0f837ae6b3a2d4a3e82454de75b6ee740cf4b 100644
--- a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
@@ -327,29 +327,75 @@ 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 AXSparseAttributeMap {
+ 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) {
+ switch (attribute) {
+ case AXBoolAttribute::AriaModal:
+ // TODO
+ break;
+ }
}
- AXObject::AXObjectVector results;
- axObject.ariaFlowToElements(results);
- if (!results.isEmpty())
- properties.addItem(
- createRelatedNodeListProperty(AXRelationshipAttributesEnum::Flowto,
- results, aria_flowtoAttr, axObject));
- results.clear();
+ void addStringAttribute(AXStringAttribute attribute, const String& value) {
+ switch (attribute) {
+ case AXStringAttribute::AriaKeyShortcuts:
+ // TODO
+ break;
+ case AXStringAttribute::AriaRoleDescription:
+ // TODO
+ break;
+ }
+ }
- axObject.ariaControlsElements(results);
- if (!results.isEmpty())
- properties.addItem(
- createRelatedNodeListProperty(AXRelationshipAttributesEnum::Controls,
- results, aria_controlsAttr, axObject));
- results.clear();
+ void addObjectAttribute(AXObjectAttribute attribute, AXObject* object) {
+ switch (attribute) {
+ case AXObjectAttribute::AriaActiveDescendant:
+ m_properties.addItem(
+ createProperty(AXRelationshipAttributesEnum::Activedescendant,
+ createRelatedNodeListValue(*object)));
+ break;
+ case AXObjectAttribute::AriaErrorMessage:
+ // TODO
+ break;
+ }
+ }
+ 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::AriaDetails:
+ // TODO
+ 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(
@@ -622,6 +668,10 @@ std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject(
fillWidgetStates(axObject, *(properties.get()));
fillRelationships(axObject, *(properties.get()));
+ Member<SparseAttributeAXPropertyAdapter> adapter =
+ new SparseAttributeAXPropertyAdapter(axObject, *(properties.get()));
+ axObject.getSparseAXAttributes(*adapter.get());
+
AXObject::NameSources nameSources;
String computedName = axObject.name(&nameSources);
if (!nameSources.isEmpty()) {

Powered by Google App Engine
This is Rietveld 408576698