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

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

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: 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..41e2a8ff7da42f6baddcbb252ddb4d62665ac652 100644
--- a/content/renderer/accessibility/blink_ax_tree_source.cc
+++ b/content/renderer/accessibility/blink_ax_tree_source.cc
@@ -55,6 +55,84 @@ namespace content {
namespace {
+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.empty())
+ dst->AddIntListAttribute(attr, ids);
+}
+
+class SparseAttributeMap : public blink::WebAXSparseAttributeMap {
aboxhall 2017/01/10 05:59:59 The name "SparseAttributeMap" is confusing me a bi
dmazzoni 2017/01/12 03:36:24 Done.
+ public:
+ SparseAttributeMap(AXContentNodeData* dst) : dst_(dst) {}
+ ~SparseAttributeMap() override {}
+
+ private:
+ AXContentNodeData* dst_;
+
+ void addBoolAttribute(blink::WebAXBoolAttribute attribute,
+ bool value) override {
+ switch (attribute) {
+ case blink::WebAXBoolAttribute::AriaModal:
+ // TODO(dmazzoni): implement aria-modal. http://crbug.com/644766
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
+ void addStringAttribute(blink::WebAXStringAttribute attribute,
+ const blink::WebString& value) override {
+ switch (attribute) {
+ case blink::WebAXStringAttribute::AriaKeyShortcuts:
+ // TODO(dmazzoni): implement aria-keyshortcuts. http://crbug.com/644766
+ break;
+ case blink::WebAXStringAttribute::AriaRoleDescription:
+ // TODO(dmazzoni): implement aria-roledescription.
+ // http://crbug.com/644766
+ break;
+ default:
+ 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;
+ case blink::WebAXObjectAttribute::AriaErrorMessage:
+ // TODO
aboxhall 2017/01/10 05:59:59 Any chance we could add these values in the follow
dmazzoni 2017/01/12 03:36:24 Sure. I'll pull the new attributes into a middle c
+ 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::AriaDetails:
+ // TODO
+ 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 +187,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 +392,9 @@ void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src,
if (!offset_container.isDetached())
dst->offset_container_id = offset_container.axID();
+ SparseAttributeMap sparse_map(dst);
+ src.getSparseAXAttributes(sparse_map);
+
blink::WebAXNameFrom nameFrom;
blink::WebVector<blink::WebAXObject> nameObjects;
blink::WebString web_name = src.name(nameFrom, nameObjects);
@@ -755,14 +826,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());

Powered by Google App Engine
This is Rietveld 408576698