| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/test_runner/web_ax_object_proxy.h" | 5 #include "components/test_runner/web_ax_object_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 505 } |
| 506 | 506 |
| 507 std::string attributes() const { return attributes_; } | 507 std::string attributes() const { return attributes_; } |
| 508 | 508 |
| 509 private: | 509 private: |
| 510 std::string attributes_; | 510 std::string attributes_; |
| 511 | 511 |
| 512 DISALLOW_COPY_AND_ASSIGN(AttributesCollector); | 512 DISALLOW_COPY_AND_ASSIGN(AttributesCollector); |
| 513 }; | 513 }; |
| 514 | 514 |
| 515 class SparseAttributeAdapter : public blink::WebAXSparseAttributeClient { |
| 516 public: |
| 517 SparseAttributeAdapter() {} |
| 518 ~SparseAttributeAdapter() override {} |
| 519 |
| 520 std::map<blink::WebAXBoolAttribute, bool> bool_attributes; |
| 521 std::map<blink::WebAXStringAttribute, blink::WebString> string_attributes; |
| 522 std::map<blink::WebAXObjectAttribute, blink::WebAXObject> object_attributes; |
| 523 std::map<blink::WebAXObjectVectorAttribute, |
| 524 blink::WebVector<blink::WebAXObject>> |
| 525 object_vector_attributes; |
| 526 |
| 527 private: |
| 528 void addBoolAttribute(blink::WebAXBoolAttribute attribute, |
| 529 bool value) override { |
| 530 bool_attributes[attribute] = value; |
| 531 } |
| 532 |
| 533 void addStringAttribute(blink::WebAXStringAttribute attribute, |
| 534 const blink::WebString& value) override { |
| 535 string_attributes[attribute] = value; |
| 536 } |
| 537 |
| 538 void addObjectAttribute(blink::WebAXObjectAttribute attribute, |
| 539 const blink::WebAXObject& value) override { |
| 540 object_attributes[attribute] = value; |
| 541 } |
| 542 |
| 543 void addObjectVectorAttribute( |
| 544 blink::WebAXObjectVectorAttribute attribute, |
| 545 const blink::WebVector<blink::WebAXObject>& value) override { |
| 546 object_vector_attributes[attribute] = value; |
| 547 } |
| 548 }; |
| 549 |
| 515 } // namespace | 550 } // namespace |
| 516 | 551 |
| 517 gin::WrapperInfo WebAXObjectProxy::kWrapperInfo = { | 552 gin::WrapperInfo WebAXObjectProxy::kWrapperInfo = { |
| 518 gin::kEmbedderNativeGin}; | 553 gin::kEmbedderNativeGin}; |
| 519 | 554 |
| 520 WebAXObjectProxy::WebAXObjectProxy(const blink::WebAXObject& object, | 555 WebAXObjectProxy::WebAXObjectProxy(const blink::WebAXObject& object, |
| 521 WebAXObjectProxy::Factory* factory) | 556 WebAXObjectProxy::Factory* factory) |
| 522 : accessibility_object_(object), | 557 : accessibility_object_(object), |
| 523 factory_(factory) { | 558 factory_(factory) { |
| 524 } | 559 } |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 accessibility_object_.updateLayoutAndCheckValidity(); | 1128 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1094 return accessibility_object_.isClickable(); | 1129 return accessibility_object_.isClickable(); |
| 1095 } | 1130 } |
| 1096 | 1131 |
| 1097 bool WebAXObjectProxy::IsButtonStateMixed() { | 1132 bool WebAXObjectProxy::IsButtonStateMixed() { |
| 1098 accessibility_object_.updateLayoutAndCheckValidity(); | 1133 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1099 return accessibility_object_.isButtonStateMixed(); | 1134 return accessibility_object_.isButtonStateMixed(); |
| 1100 } | 1135 } |
| 1101 | 1136 |
| 1102 v8::Local<v8::Object> WebAXObjectProxy::AriaControlsElementAtIndex( | 1137 v8::Local<v8::Object> WebAXObjectProxy::AriaControlsElementAtIndex( |
| 1103 unsigned index) | 1138 unsigned index) { |
| 1104 { | |
| 1105 accessibility_object_.updateLayoutAndCheckValidity(); | 1139 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1106 blink::WebVector<blink::WebAXObject> elements; | 1140 SparseAttributeAdapter attribute_adapter; |
| 1107 accessibility_object_.ariaControls(elements); | 1141 accessibility_object_.getSparseAXAttributes(attribute_adapter); |
| 1142 blink::WebVector<blink::WebAXObject> elements = |
| 1143 attribute_adapter.object_vector_attributes |
| 1144 [blink::WebAXObjectVectorAttribute::AriaControls]; |
| 1108 size_t elementCount = elements.size(); | 1145 size_t elementCount = elements.size(); |
| 1109 if (index >= elementCount) | 1146 if (index >= elementCount) |
| 1110 return v8::Local<v8::Object>(); | 1147 return v8::Local<v8::Object>(); |
| 1111 | 1148 |
| 1112 return factory_->GetOrCreate(elements[index]); | 1149 return factory_->GetOrCreate(elements[index]); |
| 1113 } | 1150 } |
| 1114 | 1151 |
| 1115 v8::Local<v8::Object> WebAXObjectProxy::AriaFlowToElementAtIndex( | 1152 v8::Local<v8::Object> WebAXObjectProxy::AriaFlowToElementAtIndex( |
| 1116 unsigned index) | 1153 unsigned index) { |
| 1117 { | |
| 1118 accessibility_object_.updateLayoutAndCheckValidity(); | 1154 accessibility_object_.updateLayoutAndCheckValidity(); |
| 1119 blink::WebVector<blink::WebAXObject> elements; | 1155 SparseAttributeAdapter attribute_adapter; |
| 1120 accessibility_object_.ariaFlowTo(elements); | 1156 accessibility_object_.getSparseAXAttributes(attribute_adapter); |
| 1157 blink::WebVector<blink::WebAXObject> elements = |
| 1158 attribute_adapter.object_vector_attributes |
| 1159 [blink::WebAXObjectVectorAttribute::AriaFlowTo]; |
| 1121 size_t elementCount = elements.size(); | 1160 size_t elementCount = elements.size(); |
| 1122 if (index >= elementCount) | 1161 if (index >= elementCount) |
| 1123 return v8::Local<v8::Object>(); | 1162 return v8::Local<v8::Object>(); |
| 1124 | 1163 |
| 1125 return factory_->GetOrCreate(elements[index]); | 1164 return factory_->GetOrCreate(elements[index]); |
| 1126 } | 1165 } |
| 1127 | 1166 |
| 1128 v8::Local<v8::Object> WebAXObjectProxy::AriaOwnsElementAtIndex(unsigned index) | 1167 v8::Local<v8::Object> WebAXObjectProxy::AriaOwnsElementAtIndex(unsigned index) |
| 1129 { | 1168 { |
| 1130 accessibility_object_.updateLayoutAndCheckValidity(); | 1169 accessibility_object_.updateLayoutAndCheckValidity(); |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 v8::Local<v8::Value> value_handle = gin::CreateHandle( | 1752 v8::Local<v8::Value> value_handle = gin::CreateHandle( |
| 1714 isolate, new WebAXObjectProxy(object, this)).ToV8(); | 1753 isolate, new WebAXObjectProxy(object, this)).ToV8(); |
| 1715 if (value_handle.IsEmpty()) | 1754 if (value_handle.IsEmpty()) |
| 1716 return v8::Local<v8::Object>(); | 1755 return v8::Local<v8::Object>(); |
| 1717 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); | 1756 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); |
| 1718 elements_.Append(handle); | 1757 elements_.Append(handle); |
| 1719 return handle; | 1758 return handle; |
| 1720 } | 1759 } |
| 1721 | 1760 |
| 1722 } // namespace test_runner | 1761 } // namespace test_runner |
| OLD | NEW |