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

Side by Side Diff: third_party/WebKit/Source/core/dom/AccessibleNode.cpp

Issue 2945773002: Relation properties for Accessibility Object Model phase 1 (Closed)
Patch Set: Add tests for details and error message too Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "core/dom/AccessibleNode.h" 5 #include "core/dom/AccessibleNode.h"
6 6
7 #include "core/dom/AXObjectCache.h" 7 #include "core/dom/AXObjectCache.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/QualifiedName.h" 9 #include "core/dom/QualifiedName.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 using namespace HTMLNames; 14 using namespace HTMLNames;
15 15
16 namespace {
17
18 QualifiedName GetCorrespondingARIAAttribute(AOMStringProperty property) {
19 switch (property) {
20 case AOMStringProperty::kAutocomplete:
21 return aria_autocompleteAttr;
22 case AOMStringProperty::kChecked:
23 return aria_checkedAttr;
24 case AOMStringProperty::kCurrent:
25 return aria_currentAttr;
26 case AOMStringProperty::kInvalid:
27 return aria_invalidAttr;
28 case AOMStringProperty::kKeyShortcuts:
29 return aria_keyshortcutsAttr;
30 case AOMStringProperty::kLabel:
31 return aria_labelAttr;
32 case AOMStringProperty::kLive:
33 return aria_liveAttr;
34 case AOMStringProperty::kOrientation:
35 return aria_orientationAttr;
36 case AOMStringProperty::kPlaceholder:
37 return aria_placeholderAttr;
38 case AOMStringProperty::kPressed:
39 return aria_pressedAttr;
40 case AOMStringProperty::kRelevant:
41 return aria_relevantAttr;
42 case AOMStringProperty::kRole:
43 return roleAttr;
44 case AOMStringProperty::kRoleDescription:
45 return aria_roledescriptionAttr;
46 case AOMStringProperty::kSort:
47 return aria_sortAttr;
48 case AOMStringProperty::kValueText:
49 return aria_valuetextAttr;
50 }
51
52 NOTREACHED();
53 return g_null_name;
54 }
55
56 QualifiedName GetCorrespondingARIAAttribute(AOMRelationProperty property) {
57 switch (property) {
58 case AOMRelationProperty::kActiveDescendant:
59 return aria_activedescendantAttr;
60 break;
61 case AOMRelationProperty::kDetails:
62 return aria_detailsAttr;
63 break;
64 case AOMRelationProperty::kErrorMessage:
65 return aria_errormessageAttr;
66 break;
67 }
68
69 NOTREACHED();
70 return g_null_name;
71 }
72
73 QualifiedName GetCorrespondingARIAAttribute(AOMBooleanProperty property) {
74 switch (property) {
75 case AOMBooleanProperty::kAtomic:
76 return aria_atomicAttr;
77 break;
78 case AOMBooleanProperty::kBusy:
79 return aria_busyAttr;
80 break;
81 case AOMBooleanProperty::kDisabled:
82 return aria_disabledAttr;
83 break;
84 case AOMBooleanProperty::kExpanded:
85 return aria_expandedAttr;
86 break;
87 case AOMBooleanProperty::kHidden:
88 return aria_hiddenAttr;
89 break;
90 case AOMBooleanProperty::kModal:
91 return aria_modalAttr;
92 break;
93 case AOMBooleanProperty::kMultiline:
94 return aria_multilineAttr;
95 break;
96 case AOMBooleanProperty::kMultiselectable:
97 return aria_multiselectableAttr;
98 break;
99 case AOMBooleanProperty::kReadOnly:
100 return aria_readonlyAttr;
101 break;
102 case AOMBooleanProperty::kRequired:
103 return aria_requiredAttr;
104 break;
105 case AOMBooleanProperty::kSelected:
106 return aria_selectedAttr;
107 break;
108 }
109
110 NOTREACHED();
111 return g_null_name;
112 }
113
114 QualifiedName GetCorrespondingARIAAttribute(AOMFloatProperty property) {
115 AtomicString attr_value;
116 switch (property) {
117 case AOMFloatProperty::kValueMax:
118 return aria_valuemaxAttr;
119 break;
120 case AOMFloatProperty::kValueMin:
121 return aria_valueminAttr;
122 break;
123 case AOMFloatProperty::kValueNow:
124 return aria_valuenowAttr;
125 break;
126 }
127
128 NOTREACHED();
129 return g_null_name;
130 }
131
132 QualifiedName GetCorrespondingARIAAttribute(AOMUIntProperty property) {
133 switch (property) {
134 case AOMUIntProperty::kColIndex:
135 return aria_colindexAttr;
136 break;
137 case AOMUIntProperty::kColSpan:
138 return aria_colspanAttr;
139 break;
140 case AOMUIntProperty::kLevel:
141 return aria_levelAttr;
142 break;
143 case AOMUIntProperty::kPosInSet:
144 return aria_posinsetAttr;
145 break;
146 case AOMUIntProperty::kRowIndex:
147 return aria_rowindexAttr;
148 break;
149 case AOMUIntProperty::kRowSpan:
150 return aria_rowspanAttr;
151 break;
152 }
153
154 NOTREACHED();
155 return g_null_name;
156 }
157
158 QualifiedName GetCorrespondingARIAAttribute(AOMIntProperty property) {
159 switch (property) {
160 case AOMIntProperty::kColCount:
161 return aria_colcountAttr;
162 break;
163 case AOMIntProperty::kRowCount:
164 return aria_rowcountAttr;
165 break;
166 case AOMIntProperty::kSetSize:
167 return aria_setsizeAttr;
168 break;
169 }
170
171 NOTREACHED();
172 return g_null_name;
173 }
174
175 } // namespace
176
16 AccessibleNode::AccessibleNode(Element* element) : element_(element) { 177 AccessibleNode::AccessibleNode(Element* element) : element_(element) {
17 DCHECK(RuntimeEnabledFeatures::AccessibilityObjectModelEnabled()); 178 DCHECK(RuntimeEnabledFeatures::AccessibilityObjectModelEnabled());
18 } 179 }
19 180
20 AccessibleNode::~AccessibleNode() {} 181 AccessibleNode::~AccessibleNode() {}
21 182
22 // static 183 // static
23 const AtomicString& AccessibleNode::GetProperty(Element* element, 184 const AtomicString& AccessibleNode::GetProperty(Element* element,
24 AOMStringProperty property) { 185 AOMStringProperty property) {
25 if (!element) 186 if (!element)
26 return g_null_atom; 187 return g_null_atom;
27 188
28 if (AccessibleNode* accessible_node = element->ExistingAccessibleNode()) { 189 if (AccessibleNode* accessible_node = element->ExistingAccessibleNode()) {
29 for (const auto& item : accessible_node->string_properties_) { 190 for (const auto& item : accessible_node->string_properties_) {
30 if (item.first == property && !item.second.IsNull()) 191 if (item.first == property && !item.second.IsNull())
31 return item.second; 192 return item.second;
32 } 193 }
33 } 194 }
34 195
35 return g_null_atom; 196 return g_null_atom;
36 } 197 }
37 198
199 // static
200 AccessibleNode* AccessibleNode::GetProperty(Element* element,
201 AOMRelationProperty property) {
202 if (!element)
203 return nullptr;
204
205 if (AccessibleNode* accessible_node = element->ExistingAccessibleNode()) {
206 for (const auto& item : accessible_node->relation_properties_) {
207 if (item.first == property && item.second)
208 return item.second;
209 }
210 }
211
212 return nullptr;
213 }
214
38 template <typename P, typename T> 215 template <typename P, typename T>
39 static T FindPropertyValue(P property, 216 static T FindPropertyValue(P property,
40 bool& is_null, 217 bool& is_null,
41 Vector<std::pair<P, T>>& properties, 218 Vector<std::pair<P, T>>& properties,
42 T default_value) { 219 T default_value) {
43 for (const auto& item : properties) { 220 for (const auto& item : properties) {
44 if (item.first == property) { 221 if (item.first == property) {
45 is_null = false; 222 is_null = false;
46 return item.second; 223 return item.second;
47 } 224 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Element* element, 292 Element* element,
116 AOMStringProperty property) { 293 AOMStringProperty property) {
117 if (!element) 294 if (!element)
118 return g_null_atom; 295 return g_null_atom;
119 296
120 const AtomicString& result = GetProperty(element, property); 297 const AtomicString& result = GetProperty(element, property);
121 if (!result.IsNull()) 298 if (!result.IsNull())
122 return result; 299 return result;
123 300
124 // Fall back on the equivalent ARIA attribute. 301 // Fall back on the equivalent ARIA attribute.
125 switch (property) { 302 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
aboxhall 2017/06/20 01:11:43 Nice.
126 case AOMStringProperty::kAutocomplete: 303 return element->FastGetAttribute(attribute);
127 return element->FastGetAttribute(aria_autocompleteAttr);
128 case AOMStringProperty::kChecked:
129 return element->FastGetAttribute(aria_checkedAttr);
130 case AOMStringProperty::kCurrent:
131 return element->FastGetAttribute(aria_currentAttr);
132 case AOMStringProperty::kInvalid:
133 return element->FastGetAttribute(aria_invalidAttr);
134 case AOMStringProperty::kKeyShortcuts:
135 return element->FastGetAttribute(aria_keyshortcutsAttr);
136 case AOMStringProperty::kLabel:
137 return element->FastGetAttribute(aria_labelAttr);
138 case AOMStringProperty::kLive:
139 return element->FastGetAttribute(aria_liveAttr);
140 case AOMStringProperty::kOrientation:
141 return element->FastGetAttribute(aria_orientationAttr);
142 case AOMStringProperty::kPlaceholder:
143 return element->FastGetAttribute(aria_placeholderAttr);
144 case AOMStringProperty::kPressed:
145 return element->FastGetAttribute(aria_pressedAttr);
146 case AOMStringProperty::kRelevant:
147 return element->FastGetAttribute(aria_relevantAttr);
148 case AOMStringProperty::kRole:
149 return element->FastGetAttribute(roleAttr);
150 case AOMStringProperty::kRoleDescription:
151 return element->FastGetAttribute(aria_roledescriptionAttr);
152 case AOMStringProperty::kSort:
153 return element->FastGetAttribute(aria_sortAttr);
154 case AOMStringProperty::kValueText:
155 return element->FastGetAttribute(aria_valuetextAttr);
156 }
157
158 NOTREACHED();
159 return g_null_atom;
160 } 304 }
161 305
162 // static 306 // static
307 AccessibleNode* AccessibleNode::GetPropertyOrARIAAttribute(
308 Element* element,
309 AOMRelationProperty property) {
310 if (!element)
311 return nullptr;
312
313 if (AccessibleNode* result = GetProperty(element, property))
314 return result;
315
316 // Fall back on the equivalent ARIA attribute.
317 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
318 AtomicString value = element->FastGetAttribute(attribute);
319 Element* target = element->GetTreeScope().getElementById(value);
320 if (!target)
321 return nullptr;
322
323 return target->accessibleNode();
324 }
325
326 // static
163 bool AccessibleNode::GetPropertyOrARIAAttribute(Element* element, 327 bool AccessibleNode::GetPropertyOrARIAAttribute(Element* element,
164 AOMBooleanProperty property, 328 AOMBooleanProperty property,
165 bool& is_null) { 329 bool& is_null) {
166 is_null = true; 330 is_null = true;
167 if (!element) 331 if (!element)
168 return false; 332 return false;
169 333
170 bool result = GetProperty(element, property, is_null); 334 bool result = GetProperty(element, property, is_null);
171 if (!is_null) 335 if (!is_null)
172 return result; 336 return result;
173 337
174 // Fall back on the equivalent ARIA attribute. 338 // Fall back on the equivalent ARIA attribute.
175 AtomicString attr_value; 339 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
176 switch (property) { 340 AtomicString attr_value = element->FastGetAttribute(attribute);
177 case AOMBooleanProperty::kAtomic:
178 attr_value = element->FastGetAttribute(aria_atomicAttr);
179 break;
180 case AOMBooleanProperty::kBusy:
181 attr_value = element->FastGetAttribute(aria_busyAttr);
182 break;
183 case AOMBooleanProperty::kDisabled:
184 attr_value = element->FastGetAttribute(aria_disabledAttr);
185 break;
186 case AOMBooleanProperty::kExpanded:
187 attr_value = element->FastGetAttribute(aria_expandedAttr);
188 break;
189 case AOMBooleanProperty::kHidden:
190 attr_value = element->FastGetAttribute(aria_hiddenAttr);
191 break;
192 case AOMBooleanProperty::kModal:
193 attr_value = element->FastGetAttribute(aria_modalAttr);
194 break;
195 case AOMBooleanProperty::kMultiline:
196 attr_value = element->FastGetAttribute(aria_multilineAttr);
197 break;
198 case AOMBooleanProperty::kMultiselectable:
199 attr_value = element->FastGetAttribute(aria_multiselectableAttr);
200 break;
201 case AOMBooleanProperty::kReadOnly:
202 attr_value = element->FastGetAttribute(aria_readonlyAttr);
203 break;
204 case AOMBooleanProperty::kRequired:
205 attr_value = element->FastGetAttribute(aria_requiredAttr);
206 break;
207 case AOMBooleanProperty::kSelected:
208 attr_value = element->FastGetAttribute(aria_selectedAttr);
209 break;
210 }
211
212 is_null = attr_value.IsNull(); 341 is_null = attr_value.IsNull();
213 return EqualIgnoringASCIICase(attr_value, "true"); 342 return EqualIgnoringASCIICase(attr_value, "true");
214 } 343 }
215 344
216 // static 345 // static
217 float AccessibleNode::GetPropertyOrARIAAttribute(Element* element, 346 float AccessibleNode::GetPropertyOrARIAAttribute(Element* element,
218 AOMFloatProperty property, 347 AOMFloatProperty property,
219 bool& is_null) { 348 bool& is_null) {
220 is_null = true; 349 is_null = true;
221 if (!element) 350 if (!element)
222 return 0.0; 351 return 0.0;
223 352
224 float result = GetProperty(element, property, is_null); 353 float result = GetProperty(element, property, is_null);
225 if (!is_null) 354 if (!is_null)
226 return result; 355 return result;
227 356
228 // Fall back on the equivalent ARIA attribute. 357 // Fall back on the equivalent ARIA attribute.
229 AtomicString attr_value; 358 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
230 switch (property) { 359 AtomicString attr_value = element->FastGetAttribute(attribute);
231 case AOMFloatProperty::kValueMax:
232 attr_value = element->FastGetAttribute(aria_valuemaxAttr);
233 break;
234 case AOMFloatProperty::kValueMin:
235 attr_value = element->FastGetAttribute(aria_valueminAttr);
236 break;
237 case AOMFloatProperty::kValueNow:
238 attr_value = element->FastGetAttribute(aria_valuenowAttr);
239 break;
240 }
241
242 is_null = attr_value.IsNull(); 360 is_null = attr_value.IsNull();
243 return attr_value.ToFloat(); 361 return attr_value.ToFloat();
244 } 362 }
245 363
246 // static 364 // static
247 uint32_t AccessibleNode::GetPropertyOrARIAAttribute(Element* element, 365 uint32_t AccessibleNode::GetPropertyOrARIAAttribute(Element* element,
248 AOMUIntProperty property, 366 AOMUIntProperty property,
249 bool& is_null) { 367 bool& is_null) {
250 is_null = true; 368 is_null = true;
251 if (!element) 369 if (!element)
252 return 0; 370 return 0;
253 371
254 int32_t result = GetProperty(element, property, is_null); 372 int32_t result = GetProperty(element, property, is_null);
255 if (!is_null) 373 if (!is_null)
256 return result; 374 return result;
257 375
258 // Fall back on the equivalent ARIA attribute. 376 // Fall back on the equivalent ARIA attribute.
259 AtomicString attr_value; 377 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
260 switch (property) { 378 AtomicString attr_value = element->FastGetAttribute(attribute);
261 case AOMUIntProperty::kColIndex:
262 attr_value = element->FastGetAttribute(aria_colindexAttr);
263 break;
264 case AOMUIntProperty::kColSpan:
265 attr_value = element->FastGetAttribute(aria_colspanAttr);
266 break;
267 case AOMUIntProperty::kLevel:
268 attr_value = element->FastGetAttribute(aria_levelAttr);
269 break;
270 case AOMUIntProperty::kPosInSet:
271 attr_value = element->FastGetAttribute(aria_posinsetAttr);
272 break;
273 case AOMUIntProperty::kRowIndex:
274 attr_value = element->FastGetAttribute(aria_rowindexAttr);
275 break;
276 case AOMUIntProperty::kRowSpan:
277 attr_value = element->FastGetAttribute(aria_rowspanAttr);
278 break;
279 }
280
281 is_null = attr_value.IsNull(); 379 is_null = attr_value.IsNull();
282 return attr_value.GetString().ToUInt(); 380 return attr_value.GetString().ToUInt();
283 } 381 }
284 382
285 // static 383 // static
286 int32_t AccessibleNode::GetPropertyOrARIAAttribute(Element* element, 384 int32_t AccessibleNode::GetPropertyOrARIAAttribute(Element* element,
287 AOMIntProperty property, 385 AOMIntProperty property,
288 bool& is_null) { 386 bool& is_null) {
289 is_null = true; 387 is_null = true;
290 if (!element) 388 if (!element)
291 return 0; 389 return 0;
292 390
293 int32_t result = GetProperty(element, property, is_null); 391 int32_t result = GetProperty(element, property, is_null);
294 if (!is_null) 392 if (!is_null)
295 return result; 393 return result;
296 394
297 // Fall back on the equivalent ARIA attribute. 395 // Fall back on the equivalent ARIA attribute.
298 AtomicString attr_value; 396 QualifiedName attribute = GetCorrespondingARIAAttribute(property);
299 switch (property) { 397 AtomicString attr_value = element->FastGetAttribute(attribute);
300 case AOMIntProperty::kColCount:
301 attr_value = element->FastGetAttribute(aria_colcountAttr);
302 break;
303 case AOMIntProperty::kRowCount:
304 attr_value = element->FastGetAttribute(aria_rowcountAttr);
305 break;
306 case AOMIntProperty::kSetSize:
307 attr_value = element->FastGetAttribute(aria_setsizeAttr);
308 break;
309 }
310
311 is_null = attr_value.IsNull(); 398 is_null = attr_value.IsNull();
312 return attr_value.ToInt(); 399 return attr_value.ToInt();
313 } 400 }
314 401
402 // static
403 void AccessibleNode::GetAllAOMProperties(
404 Element* element,
405 AOMPropertyClient* client,
406 HashSet<QualifiedName>& shadowed_aria_attributes) {
407 AccessibleNode* accessible_node = element->ExistingAccessibleNode();
408 if (!accessible_node)
409 return;
410
411 for (auto& item : accessible_node->string_properties_) {
412 client->AddStringProperty(item.first, item.second);
413 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
414 }
415 for (auto& item : accessible_node->boolean_properties_) {
416 client->AddBooleanProperty(item.first, item.second);
417 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
418 }
419 for (auto& item : accessible_node->float_properties_) {
420 client->AddFloatProperty(item.first, item.second);
421 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
422 }
423 for (auto& item : accessible_node->int_properties_) {
424 client->AddIntProperty(item.first, item.second);
425 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
426 }
427 for (auto& item : accessible_node->uint_properties_) {
428 client->AddUIntProperty(item.first, item.second);
429 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
430 }
431 for (auto& item : accessible_node->relation_properties_) {
432 client->AddRelationProperty(item.first, *item.second);
433 shadowed_aria_attributes.insert(GetCorrespondingARIAAttribute(item.first));
434 }
435 }
436
437 AccessibleNode* AccessibleNode::activeDescendant() const {
438 return GetProperty(element_, AOMRelationProperty::kActiveDescendant);
439 }
440
441 void AccessibleNode::setActiveDescendant(AccessibleNode* active_descendant) {
442 SetRelationProperty(AOMRelationProperty::kActiveDescendant,
443 active_descendant);
444 NotifyAttributeChanged(aria_activedescendantAttr);
445 }
446
315 bool AccessibleNode::atomic(bool& is_null) const { 447 bool AccessibleNode::atomic(bool& is_null) const {
316 return GetProperty(element_, AOMBooleanProperty::kAtomic, is_null); 448 return GetProperty(element_, AOMBooleanProperty::kAtomic, is_null);
317 } 449 }
318 450
319 void AccessibleNode::setAtomic(bool atomic, bool is_null) { 451 void AccessibleNode::setAtomic(bool atomic, bool is_null) {
320 SetBooleanProperty(AOMBooleanProperty::kAtomic, atomic, is_null); 452 SetBooleanProperty(AOMBooleanProperty::kAtomic, atomic, is_null);
321 NotifyAttributeChanged(aria_atomicAttr); 453 NotifyAttributeChanged(aria_atomicAttr);
322 } 454 }
323 455
324 AtomicString AccessibleNode::autocomplete() const { 456 AtomicString AccessibleNode::autocomplete() const {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return GetProperty(element_, AOMStringProperty::kCurrent); 511 return GetProperty(element_, AOMStringProperty::kCurrent);
380 } 512 }
381 513
382 void AccessibleNode::setCurrent(const AtomicString& current) { 514 void AccessibleNode::setCurrent(const AtomicString& current) {
383 SetStringProperty(AOMStringProperty::kCurrent, current); 515 SetStringProperty(AOMStringProperty::kCurrent, current);
384 516
385 if (AXObjectCache* cache = element_->GetDocument().ExistingAXObjectCache()) 517 if (AXObjectCache* cache = element_->GetDocument().ExistingAXObjectCache())
386 cache->HandleAttributeChanged(aria_currentAttr, element_); 518 cache->HandleAttributeChanged(aria_currentAttr, element_);
387 } 519 }
388 520
521 AccessibleNode* AccessibleNode::details() const {
522 return GetProperty(element_, AOMRelationProperty::kDetails);
523 }
524
525 void AccessibleNode::setDetails(AccessibleNode* details) {
526 SetRelationProperty(AOMRelationProperty::kDetails, details);
527 NotifyAttributeChanged(aria_detailsAttr);
528 }
529
389 bool AccessibleNode::disabled(bool& is_null) const { 530 bool AccessibleNode::disabled(bool& is_null) const {
390 return GetProperty(element_, AOMBooleanProperty::kDisabled, is_null); 531 return GetProperty(element_, AOMBooleanProperty::kDisabled, is_null);
391 } 532 }
392 533
393 void AccessibleNode::setDisabled(bool disabled, bool is_null) { 534 void AccessibleNode::setDisabled(bool disabled, bool is_null) {
394 SetBooleanProperty(AOMBooleanProperty::kDisabled, disabled, is_null); 535 SetBooleanProperty(AOMBooleanProperty::kDisabled, disabled, is_null);
395 NotifyAttributeChanged(aria_disabledAttr); 536 NotifyAttributeChanged(aria_disabledAttr);
396 } 537 }
397 538
539 AccessibleNode* AccessibleNode::errorMessage() const {
540 return GetProperty(element_, AOMRelationProperty::kErrorMessage);
541 }
542
543 void AccessibleNode::setErrorMessage(AccessibleNode* error_message) {
544 SetRelationProperty(AOMRelationProperty::kErrorMessage, error_message);
545 NotifyAttributeChanged(aria_errormessageAttr);
546 }
547
398 bool AccessibleNode::expanded(bool& is_null) const { 548 bool AccessibleNode::expanded(bool& is_null) const {
399 return GetProperty(element_, AOMBooleanProperty::kExpanded, is_null); 549 return GetProperty(element_, AOMBooleanProperty::kExpanded, is_null);
400 } 550 }
401 551
402 void AccessibleNode::setExpanded(bool expanded, bool is_null) { 552 void AccessibleNode::setExpanded(bool expanded, bool is_null) {
403 SetBooleanProperty(AOMBooleanProperty::kExpanded, expanded, is_null); 553 SetBooleanProperty(AOMBooleanProperty::kExpanded, expanded, is_null);
404 NotifyAttributeChanged(aria_expandedAttr); 554 NotifyAttributeChanged(aria_expandedAttr);
405 } 555 }
406 556
407 bool AccessibleNode::hidden(bool& is_null) const { 557 bool AccessibleNode::hidden(bool& is_null) const {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 for (auto& item : string_properties_) { 812 for (auto& item : string_properties_) {
663 if (item.first == property) { 813 if (item.first == property) {
664 item.second = value; 814 item.second = value;
665 return; 815 return;
666 } 816 }
667 } 817 }
668 818
669 string_properties_.push_back(std::make_pair(property, value)); 819 string_properties_.push_back(std::make_pair(property, value));
670 } 820 }
671 821
822 void AccessibleNode::SetRelationProperty(AOMRelationProperty property,
823 AccessibleNode* value) {
824 for (auto& item : relation_properties_) {
825 if (item.first == property) {
826 item.second = value;
827 return;
828 }
829 }
830
831 relation_properties_.push_back(std::make_pair(property, value));
832 }
833
672 template <typename P, typename T> 834 template <typename P, typename T>
673 static void SetProperty(P property, 835 static void SetProperty(P property,
674 T value, 836 T value,
675 bool is_null, 837 bool is_null,
676 Vector<std::pair<P, T>>& properties) { 838 Vector<std::pair<P, T>>& properties) {
677 for (size_t i = 0; i < properties.size(); i++) { 839 for (size_t i = 0; i < properties.size(); i++) {
678 auto& item = properties[i]; 840 auto& item = properties[i];
679 if (item.first == property) { 841 if (item.first == property) {
680 if (is_null) 842 if (is_null)
681 properties.erase(i); 843 properties.erase(i);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (AXObjectCache* cache = GetAXObjectCache()) 881 if (AXObjectCache* cache = GetAXObjectCache())
720 cache->HandleAttributeChanged(attribute, element_); 882 cache->HandleAttributeChanged(attribute, element_);
721 } 883 }
722 884
723 AXObjectCache* AccessibleNode::GetAXObjectCache() { 885 AXObjectCache* AccessibleNode::GetAXObjectCache() {
724 return element_->GetDocument().ExistingAXObjectCache(); 886 return element_->GetDocument().ExistingAXObjectCache();
725 } 887 }
726 888
727 DEFINE_TRACE(AccessibleNode) { 889 DEFINE_TRACE(AccessibleNode) {
728 visitor->Trace(element_); 890 visitor->Trace(element_);
891 visitor->Trace(relation_properties_);
729 } 892 }
730 893
731 } // namespace blink 894 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698