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

Unified Diff: content/renderer/accessibility/blink_ax_tree_source.cc

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
« no previous file with comments | « components/test_runner/web_ax_object_proxy.cc ('k') | third_party/WebKit/Source/core/dom/QualifiedName.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/accessibility/blink_ax_tree_source.cc
diff --git a/content/renderer/accessibility/blink_ax_tree_source.cc b/content/renderer/accessibility/blink_ax_tree_source.cc
index 0b86f3b64e71d1cc3c63870143f2595d1b05fe17..e6c45067b5254fef2441ef94681aa4fa88e99227 100644
--- a/content/renderer/accessibility/blink_ax_tree_source.cc
+++ b/content/renderer/accessibility/blink_ax_tree_source.cc
@@ -55,6 +55,65 @@ namespace content {
namespace {
+void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr,
+ const WebVector<WebAXObject>& objects,
+ AXContentNodeData* dst) {
+ std::vector<int32_t> ids;
+ for (size_t i = 0; i < objects.size(); i++)
+ ids.push_back(objects[i].axID());
+ if (!ids.empty())
+ dst->AddIntListAttribute(attr, ids);
+}
+
+class AXContentNodeDataSparseAttributeAdapter
+ : public blink::WebAXSparseAttributeClient {
+ public:
+ AXContentNodeDataSparseAttributeAdapter(AXContentNodeData* dst) : dst_(dst) {
+ DCHECK(dst_);
+ }
+ ~AXContentNodeDataSparseAttributeAdapter() override {}
+
+ private:
+ AXContentNodeData* dst_;
+
+ void addBoolAttribute(blink::WebAXBoolAttribute attribute,
+ bool value) override {
+ NOTREACHED();
+ }
+
+ void addStringAttribute(blink::WebAXStringAttribute attribute,
+ const blink::WebString& value) override {
+ NOTREACHED();
+ }
+
+ void addObjectAttribute(blink::WebAXObjectAttribute attribute,
+ const blink::WebAXObject& value) override {
+ switch (attribute) {
+ case blink::WebAXObjectAttribute::AriaActiveDescendant:
+ dst_->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, value.axID());
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
+ void addObjectVectorAttribute(
+ blink::WebAXObjectVectorAttribute attribute,
+ const blink::WebVector<WebAXObject>& value) override {
+ switch (attribute) {
+ case blink::WebAXObjectVectorAttribute::AriaControls:
+ AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, value,
+ dst_);
+ break;
+ case blink::WebAXObjectVectorAttribute::AriaFlowTo:
+ AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, value, dst_);
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+};
+
WebAXObject ParentObjectUnignored(WebAXObject child) {
WebAXObject parent = child.parentObject();
while (!parent.isDetached() && parent.accessibilityIsIgnored())
@@ -109,16 +168,6 @@ std::string GetEquivalentAriaRoleString(const ui::AXRole role) {
return std::string();
}
-void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr,
- WebVector<WebAXObject> objects,
- AXContentNodeData* dst) {
- std::vector<int32_t> ids;
- for(size_t i = 0; i < objects.size(); i++)
- ids.push_back(objects[i].axID());
- if (ids.size() > 0)
- dst->AddIntListAttribute(attr, ids);
-}
-
} // namespace
ScopedFreezeBlinkAXTreeSource::ScopedFreezeBlinkAXTreeSource(
@@ -324,6 +373,9 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src,
if (!offset_container.isDetached())
dst->offset_container_id = offset_container.axID();
+ AXContentNodeDataSparseAttributeAdapter sparse_attribute_adapter(dst);
+ src.getSparseAXAttributes(sparse_attribute_adapter);
+
blink::WebAXNameFrom nameFrom;
blink::WebVector<blink::WebAXObject> nameObjects;
blink::WebString web_name = src.name(nameFrom, nameObjects);
@@ -755,14 +807,6 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src,
}
}
- WebVector<WebAXObject> controls;
- if (src.ariaControls(controls))
- AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst);
-
- WebVector<WebAXObject> flowTo;
- if (src.ariaFlowTo(flowTo))
- AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst);
-
if (src.isScrollableContainer()) {
const gfx::Point& scrollOffset = src.getScrollOffset();
dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scrollOffset.x());
« no previous file with comments | « components/test_runner/web_ax_object_proxy.cc ('k') | third_party/WebKit/Source/core/dom/QualifiedName.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698