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

Unified Diff: components/test_runner/web_ax_object_proxy.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: components/test_runner/web_ax_object_proxy.cc
diff --git a/components/test_runner/web_ax_object_proxy.cc b/components/test_runner/web_ax_object_proxy.cc
index a2728a98ba25fefe2342170342191ac6a29491c6..45c89d72037939963f48b11abc4e1ea0bec4012d 100644
--- a/components/test_runner/web_ax_object_proxy.cc
+++ b/components/test_runner/web_ax_object_proxy.cc
@@ -512,6 +512,41 @@ class AttributesCollector {
DISALLOW_COPY_AND_ASSIGN(AttributesCollector);
};
+class SparseAttributeMap : public blink::WebAXSparseAttributeMap {
+ public:
+ SparseAttributeMap() {}
+ ~SparseAttributeMap() override {}
+
+ std::map<blink::WebAXBoolAttribute, bool> bool_attributes;
+ std::map<blink::WebAXStringAttribute, blink::WebString> string_attributes;
+ std::map<blink::WebAXObjectAttribute, blink::WebAXObject> object_attributes;
+ std::map<blink::WebAXObjectVectorAttribute,
+ blink::WebVector<blink::WebAXObject>>
+ object_vector_attributes;
+
+ private:
+ void addBoolAttribute(blink::WebAXBoolAttribute attribute,
+ bool value) override {
+ bool_attributes[attribute] = value;
+ }
+
+ void addStringAttribute(blink::WebAXStringAttribute attribute,
+ const blink::WebString& value) override {
+ string_attributes[attribute] = value;
+ }
+
+ void addObjectAttribute(blink::WebAXObjectAttribute attribute,
+ const blink::WebAXObject& value) override {
+ object_attributes[attribute] = value;
+ }
+
+ void addObjectVectorAttribute(
+ blink::WebAXObjectVectorAttribute attribute,
+ const blink::WebVector<blink::WebAXObject>& value) override {
+ object_vector_attributes[attribute] = value;
+ }
+};
+
} // namespace
gin::WrapperInfo WebAXObjectProxy::kWrapperInfo = {
@@ -1100,11 +1135,13 @@ bool WebAXObjectProxy::IsButtonStateMixed() {
}
v8::Local<v8::Object> WebAXObjectProxy::AriaControlsElementAtIndex(
- unsigned index)
-{
+ unsigned index) {
accessibility_object_.updateLayoutAndCheckValidity();
- blink::WebVector<blink::WebAXObject> elements;
- accessibility_object_.ariaControls(elements);
+ SparseAttributeMap attribute_map;
+ accessibility_object_.getSparseAXAttributes(attribute_map);
+ blink::WebVector<blink::WebAXObject> elements =
+ attribute_map.object_vector_attributes
+ [blink::WebAXObjectVectorAttribute::AriaControls];
size_t elementCount = elements.size();
if (index >= elementCount)
return v8::Local<v8::Object>();
@@ -1113,11 +1150,13 @@ v8::Local<v8::Object> WebAXObjectProxy::AriaControlsElementAtIndex(
}
v8::Local<v8::Object> WebAXObjectProxy::AriaFlowToElementAtIndex(
- unsigned index)
-{
+ unsigned index) {
accessibility_object_.updateLayoutAndCheckValidity();
- blink::WebVector<blink::WebAXObject> elements;
- accessibility_object_.ariaFlowTo(elements);
+ SparseAttributeMap attribute_map;
+ accessibility_object_.getSparseAXAttributes(attribute_map);
+ blink::WebVector<blink::WebAXObject> elements =
+ attribute_map.object_vector_attributes
+ [blink::WebAXObjectVectorAttribute::AriaFlowTo];
size_t elementCount = elements.size();
if (index >= elementCount)
return v8::Local<v8::Object>();

Powered by Google App Engine
This is Rietveld 408576698