OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "platform/wtf/text/StringBuilder.h" | 73 #include "platform/wtf/text/StringBuilder.h" |
74 | 74 |
75 namespace blink { | 75 namespace blink { |
76 | 76 |
77 using namespace HTMLNames; | 77 using namespace HTMLNames; |
78 | 78 |
79 class SparseAttributeSetter { | 79 class SparseAttributeSetter { |
80 USING_FAST_MALLOC(SparseAttributeSetter); | 80 USING_FAST_MALLOC(SparseAttributeSetter); |
81 | 81 |
82 public: | 82 public: |
83 virtual void Run(const AXObject&, | 83 virtual void Run(const AXObjectImpl&, |
84 AXSparseAttributeClient&, | 84 AXSparseAttributeClient&, |
85 const AtomicString& value) = 0; | 85 const AtomicString& value) = 0; |
86 }; | 86 }; |
87 | 87 |
88 class BoolAttributeSetter : public SparseAttributeSetter { | 88 class BoolAttributeSetter : public SparseAttributeSetter { |
89 public: | 89 public: |
90 BoolAttributeSetter(AXBoolAttribute attribute) : attribute_(attribute) {} | 90 BoolAttributeSetter(AXBoolAttribute attribute) : attribute_(attribute) {} |
91 | 91 |
92 private: | 92 private: |
93 AXBoolAttribute attribute_; | 93 AXBoolAttribute attribute_; |
94 | 94 |
95 void Run(const AXObject& obj, | 95 void Run(const AXObjectImpl& obj, |
96 AXSparseAttributeClient& attribute_map, | 96 AXSparseAttributeClient& attribute_map, |
97 const AtomicString& value) override { | 97 const AtomicString& value) override { |
98 attribute_map.AddBoolAttribute(attribute_, | 98 attribute_map.AddBoolAttribute(attribute_, |
99 EqualIgnoringASCIICase(value, "true")); | 99 EqualIgnoringASCIICase(value, "true")); |
100 } | 100 } |
101 }; | 101 }; |
102 | 102 |
103 class StringAttributeSetter : public SparseAttributeSetter { | 103 class StringAttributeSetter : public SparseAttributeSetter { |
104 public: | 104 public: |
105 StringAttributeSetter(AXStringAttribute attribute) : attribute_(attribute) {} | 105 StringAttributeSetter(AXStringAttribute attribute) : attribute_(attribute) {} |
106 | 106 |
107 private: | 107 private: |
108 AXStringAttribute attribute_; | 108 AXStringAttribute attribute_; |
109 | 109 |
110 void Run(const AXObject& obj, | 110 void Run(const AXObjectImpl& obj, |
111 AXSparseAttributeClient& attribute_map, | 111 AXSparseAttributeClient& attribute_map, |
112 const AtomicString& value) override { | 112 const AtomicString& value) override { |
113 attribute_map.AddStringAttribute(attribute_, value); | 113 attribute_map.AddStringAttribute(attribute_, value); |
114 } | 114 } |
115 }; | 115 }; |
116 | 116 |
117 class ObjectAttributeSetter : public SparseAttributeSetter { | 117 class ObjectAttributeSetter : public SparseAttributeSetter { |
118 public: | 118 public: |
119 ObjectAttributeSetter(AXObjectAttribute attribute) : attribute_(attribute) {} | 119 ObjectAttributeSetter(AXObjectAttribute attribute) : attribute_(attribute) {} |
120 | 120 |
121 private: | 121 private: |
122 AXObjectAttribute attribute_; | 122 AXObjectAttribute attribute_; |
123 | 123 |
124 void Run(const AXObject& obj, | 124 void Run(const AXObjectImpl& obj, |
125 AXSparseAttributeClient& attribute_map, | 125 AXSparseAttributeClient& attribute_map, |
126 const AtomicString& value) override { | 126 const AtomicString& value) override { |
127 if (value.IsNull() || value.IsEmpty()) | 127 if (value.IsNull() || value.IsEmpty()) |
128 return; | 128 return; |
129 | 129 |
130 Node* node = obj.GetNode(); | 130 Node* node = obj.GetNode(); |
131 if (!node || !node->IsElementNode()) | 131 if (!node || !node->IsElementNode()) |
132 return; | 132 return; |
133 Element* target = ToElement(node)->GetTreeScope().getElementById(value); | 133 Element* target = ToElement(node)->GetTreeScope().getElementById(value); |
134 if (!target) | 134 if (!target) |
135 return; | 135 return; |
136 AXObject* ax_target = obj.AxObjectCache().GetOrCreate(target); | 136 AXObjectImpl* ax_target = obj.AxObjectCache().GetOrCreate(target); |
137 if (ax_target) | 137 if (ax_target) |
138 attribute_map.AddObjectAttribute(attribute_, *ax_target); | 138 attribute_map.AddObjectAttribute(attribute_, *ax_target); |
139 } | 139 } |
140 }; | 140 }; |
141 | 141 |
142 class ObjectVectorAttributeSetter : public SparseAttributeSetter { | 142 class ObjectVectorAttributeSetter : public SparseAttributeSetter { |
143 public: | 143 public: |
144 ObjectVectorAttributeSetter(AXObjectVectorAttribute attribute) | 144 ObjectVectorAttributeSetter(AXObjectVectorAttribute attribute) |
145 : attribute_(attribute) {} | 145 : attribute_(attribute) {} |
146 | 146 |
147 private: | 147 private: |
148 AXObjectVectorAttribute attribute_; | 148 AXObjectVectorAttribute attribute_; |
149 | 149 |
150 void Run(const AXObject& obj, | 150 void Run(const AXObjectImpl& obj, |
151 AXSparseAttributeClient& attribute_map, | 151 AXSparseAttributeClient& attribute_map, |
152 const AtomicString& value) override { | 152 const AtomicString& value) override { |
153 Node* node = obj.GetNode(); | 153 Node* node = obj.GetNode(); |
154 if (!node || !node->IsElementNode()) | 154 if (!node || !node->IsElementNode()) |
155 return; | 155 return; |
156 | 156 |
157 String attribute_value = value.GetString(); | 157 String attribute_value = value.GetString(); |
158 if (attribute_value.IsEmpty()) | 158 if (attribute_value.IsEmpty()) |
159 return; | 159 return; |
160 | 160 |
161 attribute_value.SimplifyWhiteSpace(); | 161 attribute_value.SimplifyWhiteSpace(); |
162 Vector<String> ids; | 162 Vector<String> ids; |
163 attribute_value.Split(' ', ids); | 163 attribute_value.Split(' ', ids); |
164 if (ids.IsEmpty()) | 164 if (ids.IsEmpty()) |
165 return; | 165 return; |
166 | 166 |
167 HeapVector<Member<AXObject>> objects; | 167 HeapVector<Member<AXObjectImpl>> objects; |
168 TreeScope& scope = node->GetTreeScope(); | 168 TreeScope& scope = node->GetTreeScope(); |
169 for (const auto& id : ids) { | 169 for (const auto& id : ids) { |
170 if (Element* id_element = scope.getElementById(AtomicString(id))) { | 170 if (Element* id_element = scope.getElementById(AtomicString(id))) { |
171 AXObject* ax_id_element = obj.AxObjectCache().GetOrCreate(id_element); | 171 AXObjectImpl* ax_id_element = |
| 172 obj.AxObjectCache().GetOrCreate(id_element); |
172 if (ax_id_element && !ax_id_element->AccessibilityIsIgnored()) | 173 if (ax_id_element && !ax_id_element->AccessibilityIsIgnored()) |
173 objects.push_back(ax_id_element); | 174 objects.push_back(ax_id_element); |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 attribute_map.AddObjectVectorAttribute(attribute_, objects); | 178 attribute_map.AddObjectVectorAttribute(attribute_, objects); |
178 } | 179 } |
179 }; | 180 }; |
180 | 181 |
181 using AXSparseAttributeSetterMap = | 182 using AXSparseAttributeSetterMap = |
(...skipping 26 matching lines...) Expand all Loading... |
208 aria_keyshortcutsAttr, | 209 aria_keyshortcutsAttr, |
209 new StringAttributeSetter(AXStringAttribute::kAriaKeyShortcuts)); | 210 new StringAttributeSetter(AXStringAttribute::kAriaKeyShortcuts)); |
210 ax_sparse_attribute_setter_map.Set( | 211 ax_sparse_attribute_setter_map.Set( |
211 aria_roledescriptionAttr, | 212 aria_roledescriptionAttr, |
212 new StringAttributeSetter(AXStringAttribute::kAriaRoleDescription)); | 213 new StringAttributeSetter(AXStringAttribute::kAriaRoleDescription)); |
213 } | 214 } |
214 return ax_sparse_attribute_setter_map; | 215 return ax_sparse_attribute_setter_map; |
215 } | 216 } |
216 | 217 |
217 AXNodeObject::AXNodeObject(Node* node, AXObjectCacheImpl& ax_object_cache) | 218 AXNodeObject::AXNodeObject(Node* node, AXObjectCacheImpl& ax_object_cache) |
218 : AXObject(ax_object_cache), | 219 : AXObjectImpl(ax_object_cache), |
219 aria_role_(kUnknownRole), | 220 aria_role_(kUnknownRole), |
220 children_dirty_(false), | 221 children_dirty_(false), |
221 node_(node) {} | 222 node_(node) {} |
222 | 223 |
223 AXNodeObject* AXNodeObject::Create(Node* node, | 224 AXNodeObject* AXNodeObject::Create(Node* node, |
224 AXObjectCacheImpl& ax_object_cache) { | 225 AXObjectCacheImpl& ax_object_cache) { |
225 return new AXNodeObject(node, ax_object_cache); | 226 return new AXNodeObject(node, ax_object_cache); |
226 } | 227 } |
227 | 228 |
228 AXNodeObject::~AXNodeObject() { | 229 AXNodeObject::~AXNodeObject() { |
229 DCHECK(!node_); | 230 DCHECK(!node_); |
230 } | 231 } |
231 | 232 |
232 void AXNodeObject::AlterSliderValue(bool increase) { | 233 void AXNodeObject::AlterSliderValue(bool increase) { |
233 if (RoleValue() != kSliderRole) | 234 if (RoleValue() != kSliderRole) |
234 return; | 235 return; |
235 | 236 |
236 float value = ValueForRange(); | 237 float value = ValueForRange(); |
237 float step = StepValueForRange(); | 238 float step = StepValueForRange(); |
238 | 239 |
239 value += increase ? step : -step; | 240 value += increase ? step : -step; |
240 | 241 |
241 SetValue(String::Number(value)); | 242 SetValue(String::Number(value)); |
242 AxObjectCache().PostNotification(GetNode(), | 243 AxObjectCache().PostNotification(GetNode(), |
243 AXObjectCacheImpl::kAXValueChanged); | 244 AXObjectCacheImpl::kAXValueChanged); |
244 } | 245 } |
245 | 246 |
246 AXObject* AXNodeObject::ActiveDescendant() { | 247 AXObjectImpl* AXNodeObject::ActiveDescendant() { |
247 if (!node_ || !node_->IsElementNode()) | 248 if (!node_ || !node_->IsElementNode()) |
248 return nullptr; | 249 return nullptr; |
249 | 250 |
250 const AtomicString& active_descendant_attr = | 251 const AtomicString& active_descendant_attr = |
251 GetAttribute(aria_activedescendantAttr); | 252 GetAttribute(aria_activedescendantAttr); |
252 if (active_descendant_attr.IsNull() || active_descendant_attr.IsEmpty()) | 253 if (active_descendant_attr.IsNull() || active_descendant_attr.IsEmpty()) |
253 return nullptr; | 254 return nullptr; |
254 | 255 |
255 Element* element = ToElement(GetNode()); | 256 Element* element = ToElement(GetNode()); |
256 Element* descendant = | 257 Element* descendant = |
257 element->GetTreeScope().getElementById(active_descendant_attr); | 258 element->GetTreeScope().getElementById(active_descendant_attr); |
258 if (!descendant) | 259 if (!descendant) |
259 return nullptr; | 260 return nullptr; |
260 | 261 |
261 AXObject* ax_descendant = AxObjectCache().GetOrCreate(descendant); | 262 AXObjectImpl* ax_descendant = AxObjectCache().GetOrCreate(descendant); |
262 return ax_descendant; | 263 return ax_descendant; |
263 } | 264 } |
264 | 265 |
265 bool AXNodeObject::ComputeAccessibilityIsIgnored( | 266 bool AXNodeObject::ComputeAccessibilityIsIgnored( |
266 IgnoredReasons* ignored_reasons) const { | 267 IgnoredReasons* ignored_reasons) const { |
267 #if DCHECK_IS_ON() | 268 #if DCHECK_IS_ON() |
268 // Double-check that an AXObject is never accessed before | 269 // Double-check that an AXObjectImpl is never accessed before |
269 // it's been initialized. | 270 // it's been initialized. |
270 DCHECK(initialized_); | 271 DCHECK(initialized_); |
271 #endif | 272 #endif |
272 | 273 |
273 // If this element is within a parent that cannot have children, it should not | 274 // If this element is within a parent that cannot have children, it should not |
274 // be exposed. | 275 // be exposed. |
275 if (IsDescendantOfLeafNode()) { | 276 if (IsDescendantOfLeafNode()) { |
276 if (ignored_reasons) | 277 if (ignored_reasons) |
277 ignored_reasons->push_back( | 278 ignored_reasons->push_back( |
278 IgnoredReason(kAXAncestorIsLeafNode, LeafNodeAncestor())); | 279 IgnoredReason(kAXAncestorIsLeafNode, LeafNodeAncestor())); |
279 return true; | 280 return true; |
280 } | 281 } |
281 | 282 |
282 // Ignore labels that are already referenced by a control. | 283 // Ignore labels that are already referenced by a control. |
283 AXObject* control_object = CorrespondingControlForLabelElement(); | 284 AXObjectImpl* control_object = CorrespondingControlForLabelElement(); |
284 if (control_object && control_object->IsCheckboxOrRadio() && | 285 if (control_object && control_object->IsCheckboxOrRadio() && |
285 control_object->NameFromLabelElement()) { | 286 control_object->NameFromLabelElement()) { |
286 if (ignored_reasons) { | 287 if (ignored_reasons) { |
287 HTMLLabelElement* label = LabelElementContainer(); | 288 HTMLLabelElement* label = LabelElementContainer(); |
288 if (label && label != GetNode()) { | 289 if (label && label != GetNode()) { |
289 AXObject* label_ax_object = AxObjectCache().GetOrCreate(label); | 290 AXObjectImpl* label_ax_object = AxObjectCache().GetOrCreate(label); |
290 ignored_reasons->push_back( | 291 ignored_reasons->push_back( |
291 IgnoredReason(kAXLabelContainer, label_ax_object)); | 292 IgnoredReason(kAXLabelContainer, label_ax_object)); |
292 } | 293 } |
293 | 294 |
294 ignored_reasons->push_back(IgnoredReason(kAXLabelFor, control_object)); | 295 ignored_reasons->push_back(IgnoredReason(kAXLabelFor, control_object)); |
295 } | 296 } |
296 return true; | 297 return true; |
297 } | 298 } |
298 | 299 |
299 Element* element = GetNode()->IsElementNode() ? ToElement(GetNode()) | 300 Element* element = GetNode()->IsElementNode() ? ToElement(GetNode()) |
(...skipping 11 matching lines...) Expand all Loading... |
311 return true; | 312 return true; |
312 } | 313 } |
313 return false; | 314 return false; |
314 } | 315 } |
315 | 316 |
316 static bool IsListElement(Node* node) { | 317 static bool IsListElement(Node* node) { |
317 return isHTMLUListElement(*node) || isHTMLOListElement(*node) || | 318 return isHTMLUListElement(*node) || isHTMLOListElement(*node) || |
318 isHTMLDListElement(*node); | 319 isHTMLDListElement(*node); |
319 } | 320 } |
320 | 321 |
321 static bool IsPresentationalInTable(AXObject* parent, | 322 static bool IsPresentationalInTable(AXObjectImpl* parent, |
322 HTMLElement* current_element) { | 323 HTMLElement* current_element) { |
323 if (!current_element) | 324 if (!current_element) |
324 return false; | 325 return false; |
325 | 326 |
326 Node* parent_node = parent->GetNode(); | 327 Node* parent_node = parent->GetNode(); |
327 if (!parent_node || !parent_node->IsHTMLElement()) | 328 if (!parent_node || !parent_node->IsHTMLElement()) |
328 return false; | 329 return false; |
329 | 330 |
330 // AXTable determines the role as checking isTableXXX. | 331 // AXTable determines the role as checking isTableXXX. |
331 // If Table has explicit role including presentation, AXTable doesn't assign | 332 // If Table has explicit role including presentation, AXTable doesn't assign |
332 // implicit Role to a whole Table. That's why we should check it based on | 333 // implicit Role to a whole Table. That's why we should check it based on |
333 // node. | 334 // node. |
334 // Normal Table Tree is that | 335 // Normal Table Tree is that |
335 // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> | 336 // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> |
336 // table(table role). | 337 // table(table role). |
337 // If table has presentation role, it will be like | 338 // If table has presentation role, it will be like |
338 // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> | 339 // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> |
339 // table(presentation). | 340 // table(presentation). |
340 if (IsHTMLTableCellElement(*current_element) && | 341 if (IsHTMLTableCellElement(*current_element) && |
341 isHTMLTableRowElement(*parent_node)) | 342 isHTMLTableRowElement(*parent_node)) |
342 return parent->HasInheritedPresentationalRole(); | 343 return parent->HasInheritedPresentationalRole(); |
343 | 344 |
344 if (isHTMLTableRowElement(*current_element) && | 345 if (isHTMLTableRowElement(*current_element) && |
345 IsHTMLTableSectionElement(ToHTMLElement(*parent_node))) { | 346 IsHTMLTableSectionElement(ToHTMLElement(*parent_node))) { |
346 // Because TableSections have ignored role, presentation should be checked | 347 // Because TableSections have ignored role, presentation should be checked |
347 // with its parent node. | 348 // with its parent node. |
348 AXObject* table_object = parent->ParentObject(); | 349 AXObjectImpl* table_object = parent->ParentObject(); |
349 Node* table_node = table_object ? table_object->GetNode() : 0; | 350 Node* table_node = table_object ? table_object->GetNode() : 0; |
350 return isHTMLTableElement(table_node) && | 351 return isHTMLTableElement(table_node) && |
351 table_object->HasInheritedPresentationalRole(); | 352 table_object->HasInheritedPresentationalRole(); |
352 } | 353 } |
353 return false; | 354 return false; |
354 } | 355 } |
355 | 356 |
356 static bool IsRequiredOwnedElement(AXObject* parent, | 357 static bool IsRequiredOwnedElement(AXObjectImpl* parent, |
357 AccessibilityRole current_role, | 358 AccessibilityRole current_role, |
358 HTMLElement* current_element) { | 359 HTMLElement* current_element) { |
359 Node* parent_node = parent->GetNode(); | 360 Node* parent_node = parent->GetNode(); |
360 if (!parent_node || !parent_node->IsHTMLElement()) | 361 if (!parent_node || !parent_node->IsHTMLElement()) |
361 return false; | 362 return false; |
362 | 363 |
363 if (current_role == kListItemRole) | 364 if (current_role == kListItemRole) |
364 return IsListElement(parent_node); | 365 return IsListElement(parent_node); |
365 if (current_role == kListMarkerRole) | 366 if (current_role == kListMarkerRole) |
366 return isHTMLLIElement(*parent_node); | 367 return isHTMLLIElement(*parent_node); |
367 if (current_role == kMenuItemCheckBoxRole || current_role == kMenuItemRole || | 368 if (current_role == kMenuItemCheckBoxRole || current_role == kMenuItemRole || |
368 current_role == kMenuItemRadioRole) | 369 current_role == kMenuItemRadioRole) |
369 return isHTMLMenuElement(*parent_node); | 370 return isHTMLMenuElement(*parent_node); |
370 | 371 |
371 if (!current_element) | 372 if (!current_element) |
372 return false; | 373 return false; |
373 if (IsHTMLTableCellElement(*current_element)) | 374 if (IsHTMLTableCellElement(*current_element)) |
374 return isHTMLTableRowElement(*parent_node); | 375 return isHTMLTableRowElement(*parent_node); |
375 if (isHTMLTableRowElement(*current_element)) | 376 if (isHTMLTableRowElement(*current_element)) |
376 return IsHTMLTableSectionElement(ToHTMLElement(*parent_node)); | 377 return IsHTMLTableSectionElement(ToHTMLElement(*parent_node)); |
377 | 378 |
378 // In case of ListboxRole and its child, ListBoxOptionRole, inheritance of | 379 // In case of ListboxRole and its child, ListBoxOptionRole, inheritance of |
379 // presentation role is handled in AXListBoxOption because ListBoxOption Role | 380 // presentation role is handled in AXListBoxOption because ListBoxOption Role |
380 // doesn't have any child. | 381 // doesn't have any child. |
381 // If it's just ignored because of presentation, we can't see any AX tree | 382 // If it's just ignored because of presentation, we can't see any AX tree |
382 // related to ListBoxOption. | 383 // related to ListBoxOption. |
383 return false; | 384 return false; |
384 } | 385 } |
385 | 386 |
386 const AXObject* AXNodeObject::InheritsPresentationalRoleFrom() const { | 387 const AXObjectImpl* AXNodeObject::InheritsPresentationalRoleFrom() const { |
387 // ARIA states if an item can get focus, it should not be presentational. | 388 // ARIA states if an item can get focus, it should not be presentational. |
388 if (CanSetFocusAttribute()) | 389 if (CanSetFocusAttribute()) |
389 return 0; | 390 return 0; |
390 | 391 |
391 if (IsPresentational()) | 392 if (IsPresentational()) |
392 return this; | 393 return this; |
393 | 394 |
394 // http://www.w3.org/TR/wai-aria/complete#presentation | 395 // http://www.w3.org/TR/wai-aria/complete#presentation |
395 // ARIA spec says that the user agent MUST apply an inherited role of | 396 // ARIA spec says that the user agent MUST apply an inherited role of |
396 // presentation | 397 // presentation |
397 // to any owned elements that do not have an explicit role defined. | 398 // to any owned elements that do not have an explicit role defined. |
398 if (AriaRoleAttribute() != kUnknownRole) | 399 if (AriaRoleAttribute() != kUnknownRole) |
399 return 0; | 400 return 0; |
400 | 401 |
401 AXObject* parent = ParentObject(); | 402 AXObjectImpl* parent = ParentObject(); |
402 if (!parent) | 403 if (!parent) |
403 return 0; | 404 return 0; |
404 | 405 |
405 HTMLElement* element = nullptr; | 406 HTMLElement* element = nullptr; |
406 if (GetNode() && GetNode()->IsHTMLElement()) | 407 if (GetNode() && GetNode()->IsHTMLElement()) |
407 element = ToHTMLElement(GetNode()); | 408 element = ToHTMLElement(GetNode()); |
408 if (!parent->HasInheritedPresentationalRole()) { | 409 if (!parent->HasInheritedPresentationalRole()) { |
409 if (!GetLayoutObject() || !GetLayoutObject()->IsBoxModelObject()) | 410 if (!GetLayoutObject() || !GetLayoutObject()->IsBoxModelObject()) |
410 return 0; | 411 return 0; |
411 | 412 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 role = RemapAriaRoleDueToParent(role); | 717 role = RemapAriaRoleDueToParent(role); |
717 | 718 |
718 if (role) | 719 if (role) |
719 return role; | 720 return role; |
720 | 721 |
721 return kUnknownRole; | 722 return kUnknownRole; |
722 } | 723 } |
723 | 724 |
724 void AXNodeObject::AccessibilityChildrenFromAttribute( | 725 void AXNodeObject::AccessibilityChildrenFromAttribute( |
725 QualifiedName attr, | 726 QualifiedName attr, |
726 AXObject::AXObjectVector& children) const { | 727 AXObjectImpl::AXObjectVector& children) const { |
727 HeapVector<Member<Element>> elements; | 728 HeapVector<Member<Element>> elements; |
728 ElementsFromAttribute(elements, attr); | 729 ElementsFromAttribute(elements, attr); |
729 | 730 |
730 AXObjectCacheImpl& cache = AxObjectCache(); | 731 AXObjectCacheImpl& cache = AxObjectCache(); |
731 for (const auto& element : elements) { | 732 for (const auto& element : elements) { |
732 if (AXObject* child = cache.GetOrCreate(element)) { | 733 if (AXObjectImpl* child = cache.GetOrCreate(element)) { |
733 // Only aria-labelledby and aria-describedby can target hidden elements. | 734 // Only aria-labelledby and aria-describedby can target hidden elements. |
734 if (child->AccessibilityIsIgnored() && attr != aria_labelledbyAttr && | 735 if (child->AccessibilityIsIgnored() && attr != aria_labelledbyAttr && |
735 attr != aria_labeledbyAttr && attr != aria_describedbyAttr) { | 736 attr != aria_labeledbyAttr && attr != aria_describedbyAttr) { |
736 continue; | 737 continue; |
737 } | 738 } |
738 children.push_back(child); | 739 children.push_back(child); |
739 } | 740 } |
740 } | 741 } |
741 } | 742 } |
742 | 743 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 797 |
797 // An SVG root is focusable by default, but it's probably not interactive, so | 798 // An SVG root is focusable by default, but it's probably not interactive, so |
798 // don't include it. It can still be made accessible by giving it an ARIA | 799 // don't include it. It can still be made accessible by giving it an ARIA |
799 // role. | 800 // role. |
800 if (RoleValue() == kSVGRootRole) | 801 if (RoleValue() == kSVGRootRole) |
801 return false; | 802 return false; |
802 | 803 |
803 return true; | 804 return true; |
804 } | 805 } |
805 | 806 |
806 AXObject* AXNodeObject::MenuButtonForMenu() const { | 807 AXObjectImpl* AXNodeObject::MenuButtonForMenu() const { |
807 Element* menu_item = MenuItemElementForMenu(); | 808 Element* menu_item = MenuItemElementForMenu(); |
808 | 809 |
809 if (menu_item) { | 810 if (menu_item) { |
810 // ARIA just has generic menu items. AppKit needs to know if this is a top | 811 // ARIA just has generic menu items. AppKit needs to know if this is a top |
811 // level items like MenuBarButton or MenuBarItem | 812 // level items like MenuBarButton or MenuBarItem |
812 AXObject* menu_item_ax = AxObjectCache().GetOrCreate(menu_item); | 813 AXObjectImpl* menu_item_ax = AxObjectCache().GetOrCreate(menu_item); |
813 if (menu_item_ax && menu_item_ax->IsMenuButton()) | 814 if (menu_item_ax && menu_item_ax->IsMenuButton()) |
814 return menu_item_ax; | 815 return menu_item_ax; |
815 } | 816 } |
816 return 0; | 817 return 0; |
817 } | 818 } |
818 | 819 |
819 static Element* SiblingWithAriaRole(String role, Node* node) { | 820 static Element* SiblingWithAriaRole(String role, Node* node) { |
820 Node* parent = node->parentNode(); | 821 Node* parent = node->parentNode(); |
821 if (!parent) | 822 if (!parent) |
822 return 0; | 823 return 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 AccessibilityRole role) const { | 873 AccessibilityRole role) const { |
873 // Some objects change their role based on their parent. | 874 // Some objects change their role based on their parent. |
874 // However, asking for the unignoredParent calls accessibilityIsIgnored(), | 875 // However, asking for the unignoredParent calls accessibilityIsIgnored(), |
875 // which can trigger a loop. While inside the call stack of creating an | 876 // which can trigger a loop. While inside the call stack of creating an |
876 // element, we need to avoid accessibilityIsIgnored(). | 877 // element, we need to avoid accessibilityIsIgnored(). |
877 // https://bugs.webkit.org/show_bug.cgi?id=65174 | 878 // https://bugs.webkit.org/show_bug.cgi?id=65174 |
878 | 879 |
879 if (role != kListBoxOptionRole && role != kMenuItemRole) | 880 if (role != kListBoxOptionRole && role != kMenuItemRole) |
880 return role; | 881 return role; |
881 | 882 |
882 for (AXObject* parent = ParentObject(); | 883 for (AXObjectImpl* parent = ParentObject(); |
883 parent && !parent->AccessibilityIsIgnored(); | 884 parent && !parent->AccessibilityIsIgnored(); |
884 parent = parent->ParentObject()) { | 885 parent = parent->ParentObject()) { |
885 AccessibilityRole parent_aria_role = parent->AriaRoleAttribute(); | 886 AccessibilityRole parent_aria_role = parent->AriaRoleAttribute(); |
886 | 887 |
887 // Selects and listboxes both have options as child roles, but they map to | 888 // Selects and listboxes both have options as child roles, but they map to |
888 // different roles within WebCore. | 889 // different roles within WebCore. |
889 if (role == kListBoxOptionRole && parent_aria_role == kMenuRole) | 890 if (role == kListBoxOptionRole && parent_aria_role == kMenuRole) |
890 return kMenuItemRole; | 891 return kMenuItemRole; |
891 // An aria "menuitem" may map to MenuButton or MenuItem depending on its | 892 // An aria "menuitem" may map to MenuButton or MenuItem depending on its |
892 // parent. | 893 // parent. |
(...skipping 11 matching lines...) Expand all Loading... |
904 | 905 |
905 void AXNodeObject::Init() { | 906 void AXNodeObject::Init() { |
906 #if DCHECK_IS_ON() | 907 #if DCHECK_IS_ON() |
907 DCHECK(!initialized_); | 908 DCHECK(!initialized_); |
908 initialized_ = true; | 909 initialized_ = true; |
909 #endif | 910 #endif |
910 role_ = DetermineAccessibilityRole(); | 911 role_ = DetermineAccessibilityRole(); |
911 } | 912 } |
912 | 913 |
913 void AXNodeObject::Detach() { | 914 void AXNodeObject::Detach() { |
914 AXObject::Detach(); | 915 AXObjectImpl::Detach(); |
915 node_ = nullptr; | 916 node_ = nullptr; |
916 } | 917 } |
917 | 918 |
918 void AXNodeObject::GetSparseAXAttributes( | 919 void AXNodeObject::GetSparseAXAttributes( |
919 AXSparseAttributeClient& sparse_attribute_client) const { | 920 AXSparseAttributeClient& sparse_attribute_client) const { |
920 Node* node = this->GetNode(); | 921 Node* node = this->GetNode(); |
921 if (!node || !node->IsElementNode()) | 922 if (!node || !node->IsElementNode()) |
922 return; | 923 return; |
923 | 924 |
924 AXSparseAttributeSetterMap& ax_sparse_attribute_setter_map = | 925 AXSparseAttributeSetterMap& ax_sparse_attribute_setter_map = |
(...skipping 27 matching lines...) Expand all Loading... |
952 bool AXNodeObject::IsAnchor() const { | 953 bool AXNodeObject::IsAnchor() const { |
953 return !IsNativeImage() && IsLink(); | 954 return !IsNativeImage() && IsLink(); |
954 } | 955 } |
955 | 956 |
956 bool AXNodeObject::IsControl() const { | 957 bool AXNodeObject::IsControl() const { |
957 Node* node = this->GetNode(); | 958 Node* node = this->GetNode(); |
958 if (!node) | 959 if (!node) |
959 return false; | 960 return false; |
960 | 961 |
961 return ((node->IsElementNode() && ToElement(node)->IsFormControlElement()) || | 962 return ((node->IsElementNode() && ToElement(node)->IsFormControlElement()) || |
962 AXObject::IsARIAControl(AriaRoleAttribute())); | 963 AXObjectImpl::IsARIAControl(AriaRoleAttribute())); |
963 } | 964 } |
964 | 965 |
965 bool AXNodeObject::IsControllingVideoElement() const { | 966 bool AXNodeObject::IsControllingVideoElement() const { |
966 Node* node = this->GetNode(); | 967 Node* node = this->GetNode(); |
967 if (!node) | 968 if (!node) |
968 return true; | 969 return true; |
969 | 970 |
970 return isHTMLVideoElement(ToParentMediaElement(node)); | 971 return isHTMLVideoElement(ToParentMediaElement(node)); |
971 } | 972 } |
972 | 973 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 | 1154 |
1154 // Note: we can't call getNode()->willRespondToMouseClickEvents() because | 1155 // Note: we can't call getNode()->willRespondToMouseClickEvents() because |
1155 // that triggers a style recalc and can delete this. | 1156 // that triggers a style recalc and can delete this. |
1156 if (GetNode()->HasEventListeners(EventTypeNames::mouseup) || | 1157 if (GetNode()->HasEventListeners(EventTypeNames::mouseup) || |
1157 GetNode()->HasEventListeners(EventTypeNames::mousedown) || | 1158 GetNode()->HasEventListeners(EventTypeNames::mousedown) || |
1158 GetNode()->HasEventListeners(EventTypeNames::click) || | 1159 GetNode()->HasEventListeners(EventTypeNames::click) || |
1159 GetNode()->HasEventListeners(EventTypeNames::DOMActivate)) | 1160 GetNode()->HasEventListeners(EventTypeNames::DOMActivate)) |
1160 return true; | 1161 return true; |
1161 } | 1162 } |
1162 | 1163 |
1163 return AXObject::IsClickable(); | 1164 return AXObjectImpl::IsClickable(); |
1164 } | 1165 } |
1165 | 1166 |
1166 bool AXNodeObject::IsEnabled() const { | 1167 bool AXNodeObject::IsEnabled() const { |
1167 if (IsDescendantOfDisabledNode()) | 1168 if (IsDescendantOfDisabledNode()) |
1168 return false; | 1169 return false; |
1169 | 1170 |
1170 Node* node = this->GetNode(); | 1171 Node* node = this->GetNode(); |
1171 if (!node || !node->IsElementNode()) | 1172 if (!node || !node->IsElementNode()) |
1172 return true; | 1173 return true; |
1173 | 1174 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 // for this information for all elements. | 1297 // for this information for all elements. |
1297 return !IsReadOnly(); | 1298 return !IsReadOnly(); |
1298 } | 1299 } |
1299 | 1300 |
1300 bool AXNodeObject::CanSetSelectedAttribute() const { | 1301 bool AXNodeObject::CanSetSelectedAttribute() const { |
1301 // ARIA list box options can be selected if they are children of an element | 1302 // ARIA list box options can be selected if they are children of an element |
1302 // with an aria-activedescendant attribute. | 1303 // with an aria-activedescendant attribute. |
1303 if (AriaRoleAttribute() == kListBoxOptionRole && | 1304 if (AriaRoleAttribute() == kListBoxOptionRole && |
1304 AncestorExposesActiveDescendant()) | 1305 AncestorExposesActiveDescendant()) |
1305 return true; | 1306 return true; |
1306 return AXObject::CanSetSelectedAttribute(); | 1307 return AXObjectImpl::CanSetSelectedAttribute(); |
1307 } | 1308 } |
1308 | 1309 |
1309 bool AXNodeObject::CanvasHasFallbackContent() const { | 1310 bool AXNodeObject::CanvasHasFallbackContent() const { |
1310 Node* node = this->GetNode(); | 1311 Node* node = this->GetNode(); |
1311 if (!isHTMLCanvasElement(node)) | 1312 if (!isHTMLCanvasElement(node)) |
1312 return false; | 1313 return false; |
1313 | 1314 |
1314 // If it has any children that are elements, we'll assume it might be fallback | 1315 // If it has any children that are elements, we'll assume it might be fallback |
1315 // content. If it has no children or its only children are not elements | 1316 // content. If it has no children or its only children are not elements |
1316 // (e.g. just text nodes), it doesn't have fallback content. | 1317 // (e.g. just text nodes), it doesn't have fallback content. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 return 1; | 1373 return 1; |
1373 } | 1374 } |
1374 | 1375 |
1375 // Only tree item will calculate its level through the DOM currently. | 1376 // Only tree item will calculate its level through the DOM currently. |
1376 if (RoleValue() != kTreeItemRole) | 1377 if (RoleValue() != kTreeItemRole) |
1377 return 0; | 1378 return 0; |
1378 | 1379 |
1379 // Hierarchy leveling starts at 1, to match the aria-level spec. | 1380 // Hierarchy leveling starts at 1, to match the aria-level spec. |
1380 // We measure tree hierarchy by the number of groups that the item is within. | 1381 // We measure tree hierarchy by the number of groups that the item is within. |
1381 unsigned level = 1; | 1382 unsigned level = 1; |
1382 for (AXObject* parent = ParentObject(); parent; | 1383 for (AXObjectImpl* parent = ParentObject(); parent; |
1383 parent = parent->ParentObject()) { | 1384 parent = parent->ParentObject()) { |
1384 AccessibilityRole parent_role = parent->RoleValue(); | 1385 AccessibilityRole parent_role = parent->RoleValue(); |
1385 if (parent_role == kGroupRole) | 1386 if (parent_role == kGroupRole) |
1386 level++; | 1387 level++; |
1387 else if (parent_role == kTreeRole) | 1388 else if (parent_role == kTreeRole) |
1388 break; | 1389 break; |
1389 } | 1390 } |
1390 | 1391 |
1391 return level; | 1392 return level; |
1392 } | 1393 } |
(...skipping 30 matching lines...) Expand all Loading... |
1423 marker_ranges.push_back( | 1424 marker_ranges.push_back( |
1424 AXRange(marker->StartOffset(), marker->EndOffset())); | 1425 AXRange(marker->StartOffset(), marker->EndOffset())); |
1425 break; | 1426 break; |
1426 case DocumentMarker::kComposition: | 1427 case DocumentMarker::kComposition: |
1427 // No need for accessibility to know about these marker types. | 1428 // No need for accessibility to know about these marker types. |
1428 break; | 1429 break; |
1429 } | 1430 } |
1430 } | 1431 } |
1431 } | 1432 } |
1432 | 1433 |
1433 AXObject* AXNodeObject::InPageLinkTarget() const { | 1434 AXObjectImpl* AXNodeObject::InPageLinkTarget() const { |
1434 if (!node_ || !isHTMLAnchorElement(node_) || !GetDocument()) | 1435 if (!node_ || !isHTMLAnchorElement(node_) || !GetDocument()) |
1435 return AXObject::InPageLinkTarget(); | 1436 return AXObjectImpl::InPageLinkTarget(); |
1436 | 1437 |
1437 HTMLAnchorElement* anchor = toHTMLAnchorElement(node_); | 1438 HTMLAnchorElement* anchor = toHTMLAnchorElement(node_); |
1438 DCHECK(anchor); | 1439 DCHECK(anchor); |
1439 KURL link_url = anchor->Href(); | 1440 KURL link_url = anchor->Href(); |
1440 if (!link_url.IsValid()) | 1441 if (!link_url.IsValid()) |
1441 return AXObject::InPageLinkTarget(); | 1442 return AXObjectImpl::InPageLinkTarget(); |
1442 String fragment = link_url.FragmentIdentifier(); | 1443 String fragment = link_url.FragmentIdentifier(); |
1443 if (fragment.IsEmpty()) | 1444 if (fragment.IsEmpty()) |
1444 return AXObject::InPageLinkTarget(); | 1445 return AXObjectImpl::InPageLinkTarget(); |
1445 | 1446 |
1446 KURL document_url = GetDocument()->Url(); | 1447 KURL document_url = GetDocument()->Url(); |
1447 if (!document_url.IsValid() || | 1448 if (!document_url.IsValid() || |
1448 !EqualIgnoringFragmentIdentifier(document_url, link_url)) { | 1449 !EqualIgnoringFragmentIdentifier(document_url, link_url)) { |
1449 return AXObject::InPageLinkTarget(); | 1450 return AXObjectImpl::InPageLinkTarget(); |
1450 } | 1451 } |
1451 | 1452 |
1452 TreeScope& tree_scope = anchor->GetTreeScope(); | 1453 TreeScope& tree_scope = anchor->GetTreeScope(); |
1453 Element* target = tree_scope.FindAnchor(fragment); | 1454 Element* target = tree_scope.FindAnchor(fragment); |
1454 if (!target) | 1455 if (!target) |
1455 return AXObject::InPageLinkTarget(); | 1456 return AXObjectImpl::InPageLinkTarget(); |
1456 // If the target is not in the accessibility tree, get the first unignored | 1457 // If the target is not in the accessibility tree, get the first unignored |
1457 // sibling. | 1458 // sibling. |
1458 return AxObjectCache().FirstAccessibleObjectFromNode(target); | 1459 return AxObjectCache().FirstAccessibleObjectFromNode(target); |
1459 } | 1460 } |
1460 | 1461 |
1461 AccessibilityOrientation AXNodeObject::Orientation() const { | 1462 AccessibilityOrientation AXNodeObject::Orientation() const { |
1462 const AtomicString& aria_orientation = | 1463 const AtomicString& aria_orientation = |
1463 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kOrientation); | 1464 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kOrientation); |
1464 AccessibilityOrientation orientation = kAccessibilityOrientationUndefined; | 1465 AccessibilityOrientation orientation = kAccessibilityOrientationUndefined; |
1465 if (EqualIgnoringASCIICase(aria_orientation, "horizontal")) | 1466 if (EqualIgnoringASCIICase(aria_orientation, "horizontal")) |
(...skipping 17 matching lines...) Expand all Loading... |
1483 case kTabListRole: | 1484 case kTabListRole: |
1484 case kToolbarRole: | 1485 case kToolbarRole: |
1485 if (orientation == kAccessibilityOrientationUndefined) | 1486 if (orientation == kAccessibilityOrientationUndefined) |
1486 orientation = kAccessibilityOrientationHorizontal; | 1487 orientation = kAccessibilityOrientationHorizontal; |
1487 | 1488 |
1488 return orientation; | 1489 return orientation; |
1489 case kRadioGroupRole: | 1490 case kRadioGroupRole: |
1490 case kTreeGridRole: | 1491 case kTreeGridRole: |
1491 return orientation; | 1492 return orientation; |
1492 default: | 1493 default: |
1493 return AXObject::Orientation(); | 1494 return AXObjectImpl::Orientation(); |
1494 } | 1495 } |
1495 } | 1496 } |
1496 | 1497 |
1497 AXObject::AXObjectVector AXNodeObject::RadioButtonsInGroup() const { | 1498 AXObjectImpl::AXObjectVector AXNodeObject::RadioButtonsInGroup() const { |
1498 AXObjectVector radio_buttons; | 1499 AXObjectVector radio_buttons; |
1499 if (!node_ || RoleValue() != kRadioButtonRole) | 1500 if (!node_ || RoleValue() != kRadioButtonRole) |
1500 return radio_buttons; | 1501 return radio_buttons; |
1501 | 1502 |
1502 if (isHTMLInputElement(node_)) { | 1503 if (isHTMLInputElement(node_)) { |
1503 HTMLInputElement* radio_button = toHTMLInputElement(node_); | 1504 HTMLInputElement* radio_button = toHTMLInputElement(node_); |
1504 HeapVector<Member<HTMLInputElement>> html_radio_buttons = | 1505 HeapVector<Member<HTMLInputElement>> html_radio_buttons = |
1505 FindAllRadioButtonsWithSameName(radio_button); | 1506 FindAllRadioButtonsWithSameName(radio_button); |
1506 for (size_t i = 0; i < html_radio_buttons.size(); ++i) { | 1507 for (size_t i = 0; i < html_radio_buttons.size(); ++i) { |
1507 AXObject* ax_radio_button = | 1508 AXObjectImpl* ax_radio_button = |
1508 AxObjectCache().GetOrCreate(html_radio_buttons[i]); | 1509 AxObjectCache().GetOrCreate(html_radio_buttons[i]); |
1509 if (ax_radio_button) | 1510 if (ax_radio_button) |
1510 radio_buttons.push_back(ax_radio_button); | 1511 radio_buttons.push_back(ax_radio_button); |
1511 } | 1512 } |
1512 return radio_buttons; | 1513 return radio_buttons; |
1513 } | 1514 } |
1514 | 1515 |
1515 // If the immediate parent is a radio group, return all its children that are | 1516 // If the immediate parent is a radio group, return all its children that are |
1516 // radio buttons. | 1517 // radio buttons. |
1517 AXObject* parent = ParentObject(); | 1518 AXObjectImpl* parent = ParentObject(); |
1518 if (parent && parent->RoleValue() == kRadioGroupRole) { | 1519 if (parent && parent->RoleValue() == kRadioGroupRole) { |
1519 for (size_t i = 0; i < parent->Children().size(); ++i) { | 1520 for (size_t i = 0; i < parent->Children().size(); ++i) { |
1520 AXObject* child = parent->Children()[i]; | 1521 AXObjectImpl* child = parent->Children()[i]; |
1521 DCHECK(child); | 1522 DCHECK(child); |
1522 if (child->RoleValue() == kRadioButtonRole && | 1523 if (child->RoleValue() == kRadioButtonRole && |
1523 !child->AccessibilityIsIgnored()) { | 1524 !child->AccessibilityIsIgnored()) { |
1524 radio_buttons.push_back(child); | 1525 radio_buttons.push_back(child); |
1525 } | 1526 } |
1526 } | 1527 } |
1527 } | 1528 } |
1528 | 1529 |
1529 return radio_buttons; | 1530 return radio_buttons; |
1530 } | 1531 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 return ToTextControlElement(*node).value(); | 1573 return ToTextControlElement(*node).value(); |
1573 | 1574 |
1574 if (!node->IsElementNode()) | 1575 if (!node->IsElementNode()) |
1575 return String(); | 1576 return String(); |
1576 | 1577 |
1577 return ToElement(node)->innerText(); | 1578 return ToElement(node)->innerText(); |
1578 } | 1579 } |
1579 | 1580 |
1580 RGBA32 AXNodeObject::ColorValue() const { | 1581 RGBA32 AXNodeObject::ColorValue() const { |
1581 if (!isHTMLInputElement(GetNode()) || !IsColorWell()) | 1582 if (!isHTMLInputElement(GetNode()) || !IsColorWell()) |
1582 return AXObject::ColorValue(); | 1583 return AXObjectImpl::ColorValue(); |
1583 | 1584 |
1584 HTMLInputElement* input = toHTMLInputElement(GetNode()); | 1585 HTMLInputElement* input = toHTMLInputElement(GetNode()); |
1585 const AtomicString& type = input->getAttribute(typeAttr); | 1586 const AtomicString& type = input->getAttribute(typeAttr); |
1586 if (!EqualIgnoringASCIICase(type, "color")) | 1587 if (!EqualIgnoringASCIICase(type, "color")) |
1587 return AXObject::ColorValue(); | 1588 return AXObjectImpl::ColorValue(); |
1588 | 1589 |
1589 // HTMLInputElement::value always returns a string parseable by Color. | 1590 // HTMLInputElement::value always returns a string parseable by Color. |
1590 Color color; | 1591 Color color; |
1591 bool success = color.SetFromString(input->value()); | 1592 bool success = color.SetFromString(input->value()); |
1592 DCHECK(success); | 1593 DCHECK(success); |
1593 return color.Rgb(); | 1594 return color.Rgb(); |
1594 } | 1595 } |
1595 | 1596 |
1596 AriaCurrentState AXNodeObject::GetAriaCurrentState() const { | 1597 AriaCurrentState AXNodeObject::GetAriaCurrentState() const { |
1597 const AtomicString& attribute_value = | 1598 const AtomicString& attribute_value = |
(...skipping 12 matching lines...) Expand all Loading... |
1610 if (EqualIgnoringASCIICase(attribute_value, "location")) | 1611 if (EqualIgnoringASCIICase(attribute_value, "location")) |
1611 return kAriaCurrentStateLocation; | 1612 return kAriaCurrentStateLocation; |
1612 if (EqualIgnoringASCIICase(attribute_value, "date")) | 1613 if (EqualIgnoringASCIICase(attribute_value, "date")) |
1613 return kAriaCurrentStateDate; | 1614 return kAriaCurrentStateDate; |
1614 if (EqualIgnoringASCIICase(attribute_value, "time")) | 1615 if (EqualIgnoringASCIICase(attribute_value, "time")) |
1615 return kAriaCurrentStateTime; | 1616 return kAriaCurrentStateTime; |
1616 // An unknown value should return true. | 1617 // An unknown value should return true. |
1617 if (!attribute_value.IsEmpty()) | 1618 if (!attribute_value.IsEmpty()) |
1618 return kAriaCurrentStateTrue; | 1619 return kAriaCurrentStateTrue; |
1619 | 1620 |
1620 return AXObject::GetAriaCurrentState(); | 1621 return AXObjectImpl::GetAriaCurrentState(); |
1621 } | 1622 } |
1622 | 1623 |
1623 InvalidState AXNodeObject::GetInvalidState() const { | 1624 InvalidState AXNodeObject::GetInvalidState() const { |
1624 const AtomicString& attribute_value = | 1625 const AtomicString& attribute_value = |
1625 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); | 1626 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); |
1626 if (EqualIgnoringASCIICase(attribute_value, "false")) | 1627 if (EqualIgnoringASCIICase(attribute_value, "false")) |
1627 return kInvalidStateFalse; | 1628 return kInvalidStateFalse; |
1628 if (EqualIgnoringASCIICase(attribute_value, "true")) | 1629 if (EqualIgnoringASCIICase(attribute_value, "true")) |
1629 return kInvalidStateTrue; | 1630 return kInvalidStateTrue; |
1630 if (EqualIgnoringASCIICase(attribute_value, "spelling")) | 1631 if (EqualIgnoringASCIICase(attribute_value, "spelling")) |
1631 return kInvalidStateSpelling; | 1632 return kInvalidStateSpelling; |
1632 if (EqualIgnoringASCIICase(attribute_value, "grammar")) | 1633 if (EqualIgnoringASCIICase(attribute_value, "grammar")) |
1633 return kInvalidStateGrammar; | 1634 return kInvalidStateGrammar; |
1634 // A yet unknown value. | 1635 // A yet unknown value. |
1635 if (!attribute_value.IsEmpty()) | 1636 if (!attribute_value.IsEmpty()) |
1636 return kInvalidStateOther; | 1637 return kInvalidStateOther; |
1637 | 1638 |
1638 if (GetNode() && GetNode()->IsElementNode() && | 1639 if (GetNode() && GetNode()->IsElementNode() && |
1639 ToElement(GetNode())->IsFormControlElement()) { | 1640 ToElement(GetNode())->IsFormControlElement()) { |
1640 HTMLFormControlElement* element = ToHTMLFormControlElement(GetNode()); | 1641 HTMLFormControlElement* element = ToHTMLFormControlElement(GetNode()); |
1641 HeapVector<Member<HTMLFormControlElement>> invalid_controls; | 1642 HeapVector<Member<HTMLFormControlElement>> invalid_controls; |
1642 bool is_invalid = !element->checkValidity(&invalid_controls, | 1643 bool is_invalid = !element->checkValidity(&invalid_controls, |
1643 kCheckValidityDispatchNoEvent); | 1644 kCheckValidityDispatchNoEvent); |
1644 return is_invalid ? kInvalidStateTrue : kInvalidStateFalse; | 1645 return is_invalid ? kInvalidStateTrue : kInvalidStateFalse; |
1645 } | 1646 } |
1646 | 1647 |
1647 return AXObject::GetInvalidState(); | 1648 return AXObjectImpl::GetInvalidState(); |
1648 } | 1649 } |
1649 | 1650 |
1650 int AXNodeObject::PosInSet() const { | 1651 int AXNodeObject::PosInSet() const { |
1651 if (SupportsSetSizeAndPosInSet()) { | 1652 if (SupportsSetSizeAndPosInSet()) { |
1652 String pos_in_set_str = GetAttribute(aria_posinsetAttr); | 1653 String pos_in_set_str = GetAttribute(aria_posinsetAttr); |
1653 if (!pos_in_set_str.IsEmpty()) { | 1654 if (!pos_in_set_str.IsEmpty()) { |
1654 int pos_in_set = pos_in_set_str.ToInt(); | 1655 int pos_in_set = pos_in_set_str.ToInt(); |
1655 if (pos_in_set > 0) | 1656 if (pos_in_set > 0) |
1656 return pos_in_set; | 1657 return pos_in_set; |
1657 return 1; | 1658 return 1; |
1658 } | 1659 } |
1659 | 1660 |
1660 return AXObject::IndexInParent() + 1; | 1661 return AXObjectImpl::IndexInParent() + 1; |
1661 } | 1662 } |
1662 | 1663 |
1663 return 0; | 1664 return 0; |
1664 } | 1665 } |
1665 | 1666 |
1666 int AXNodeObject::SetSize() const { | 1667 int AXNodeObject::SetSize() const { |
1667 if (SupportsSetSizeAndPosInSet()) { | 1668 if (SupportsSetSizeAndPosInSet()) { |
1668 String set_size_str = GetAttribute(aria_setsizeAttr); | 1669 String set_size_str = GetAttribute(aria_setsizeAttr); |
1669 if (!set_size_str.IsEmpty()) { | 1670 if (!set_size_str.IsEmpty()) { |
1670 int set_size = set_size_str.ToInt(); | 1671 int set_size = set_size_str.ToInt(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 | 1930 |
1930 return String(); | 1931 return String(); |
1931 } | 1932 } |
1932 | 1933 |
1933 String AXNodeObject::TextFromDescendants(AXObjectSet& visited, | 1934 String AXNodeObject::TextFromDescendants(AXObjectSet& visited, |
1934 bool recursive) const { | 1935 bool recursive) const { |
1935 if (!CanHaveChildren() && recursive) | 1936 if (!CanHaveChildren() && recursive) |
1936 return String(); | 1937 return String(); |
1937 | 1938 |
1938 StringBuilder accumulated_text; | 1939 StringBuilder accumulated_text; |
1939 AXObject* previous = nullptr; | 1940 AXObjectImpl* previous = nullptr; |
1940 | 1941 |
1941 AXObjectVector children; | 1942 AXObjectVector children; |
1942 | 1943 |
1943 HeapVector<Member<AXObject>> owned_children; | 1944 HeapVector<Member<AXObjectImpl>> owned_children; |
1944 ComputeAriaOwnsChildren(owned_children); | 1945 ComputeAriaOwnsChildren(owned_children); |
1945 for (AXObject* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) { | 1946 for (AXObjectImpl* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) { |
1946 if (!AxObjectCache().IsAriaOwned(obj)) | 1947 if (!AxObjectCache().IsAriaOwned(obj)) |
1947 children.push_back(obj); | 1948 children.push_back(obj); |
1948 } | 1949 } |
1949 for (const auto& owned_child : owned_children) | 1950 for (const auto& owned_child : owned_children) |
1950 children.push_back(owned_child); | 1951 children.push_back(owned_child); |
1951 | 1952 |
1952 for (AXObject* child : children) { | 1953 for (AXObjectImpl* child : children) { |
1953 // Don't recurse into children that are explicitly marked as aria-hidden. | 1954 // Don't recurse into children that are explicitly marked as aria-hidden. |
1954 // Note that we don't call isInertOrAriaHidden because that would return | 1955 // Note that we don't call isInertOrAriaHidden because that would return |
1955 // true if any ancestor is hidden, but we need to be able to compute the | 1956 // true if any ancestor is hidden, but we need to be able to compute the |
1956 // accessible name of object inside hidden subtrees (for example, if | 1957 // accessible name of object inside hidden subtrees (for example, if |
1957 // aria-labelledby points to an object that's hidden). | 1958 // aria-labelledby points to an object that's hidden). |
1958 if (EqualIgnoringASCIICase(child->GetAttribute(aria_hiddenAttr), "true")) | 1959 if (EqualIgnoringASCIICase(child->GetAttribute(aria_hiddenAttr), "true")) |
1959 continue; | 1960 continue; |
1960 | 1961 |
1961 // If we're going between two layoutObjects that are in separate | 1962 // If we're going between two layoutObjects that are in separate |
1962 // LayoutBoxes, add whitespace if it wasn't there already. Intuitively if | 1963 // LayoutBoxes, add whitespace if it wasn't there already. Intuitively if |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 ToLabelableElement(html_element)->labels()->length() > 0) | 2020 ToLabelableElement(html_element)->labels()->length() > 0) |
2020 return true; | 2021 return true; |
2021 } | 2022 } |
2022 | 2023 |
2023 return false; | 2024 return false; |
2024 } | 2025 } |
2025 | 2026 |
2026 bool AXNodeObject::NameFromContents() const { | 2027 bool AXNodeObject::NameFromContents() const { |
2027 Node* node = GetNode(); | 2028 Node* node = GetNode(); |
2028 if (!node || !node->IsElementNode()) | 2029 if (!node || !node->IsElementNode()) |
2029 return AXObject::NameFromContents(); | 2030 return AXObjectImpl::NameFromContents(); |
2030 // AXObject::nameFromContents determines whether an element should take its | 2031 // AXObjectImpl::nameFromContents determines whether an element should take |
2031 // name from its descendant contents based on role. However, <select> is a | 2032 // its name from its descendant contents based on role. However, <select> is a |
2032 // special case, as unlike a typical pop-up button it contains its own pop-up | 2033 // special case, as unlike a typical pop-up button it contains its own pop-up |
2033 // menu's contents, which should not be used as the name. | 2034 // menu's contents, which should not be used as the name. |
2034 if (isHTMLSelectElement(node)) | 2035 if (isHTMLSelectElement(node)) |
2035 return false; | 2036 return false; |
2036 return AXObject::NameFromContents(); | 2037 return AXObjectImpl::NameFromContents(); |
2037 } | 2038 } |
2038 | 2039 |
2039 void AXNodeObject::GetRelativeBounds( | 2040 void AXNodeObject::GetRelativeBounds( |
2040 AXObject** out_container, | 2041 AXObjectImpl** out_container, |
2041 FloatRect& out_bounds_in_container, | 2042 FloatRect& out_bounds_in_container, |
2042 SkMatrix44& out_container_transform) const { | 2043 SkMatrix44& out_container_transform) const { |
2043 if (LayoutObjectForRelativeBounds()) { | 2044 if (LayoutObjectForRelativeBounds()) { |
2044 AXObject::GetRelativeBounds(out_container, out_bounds_in_container, | 2045 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container, |
2045 out_container_transform); | 2046 out_container_transform); |
2046 return; | 2047 return; |
2047 } | 2048 } |
2048 | 2049 |
2049 *out_container = nullptr; | 2050 *out_container = nullptr; |
2050 out_bounds_in_container = FloatRect(); | 2051 out_bounds_in_container = FloatRect(); |
2051 out_container_transform.setIdentity(); | 2052 out_container_transform.setIdentity(); |
2052 | 2053 |
2053 // First check if it has explicit bounds, for example if this element is tied | 2054 // First check if it has explicit bounds, for example if this element is tied |
2054 // to a canvas path. When explicit coordinates are provided, the ID of the | 2055 // to a canvas path. When explicit coordinates are provided, the ID of the |
2055 // explicit container element that the coordinates are relative to must be | 2056 // explicit container element that the coordinates are relative to must be |
2056 // provided too. | 2057 // provided too. |
2057 if (!explicit_element_rect_.IsEmpty()) { | 2058 if (!explicit_element_rect_.IsEmpty()) { |
2058 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_); | 2059 *out_container = AxObjectCache().ObjectFromAXID(explicit_container_id_); |
2059 if (*out_container) { | 2060 if (*out_container) { |
2060 out_bounds_in_container = FloatRect(explicit_element_rect_); | 2061 out_bounds_in_container = FloatRect(explicit_element_rect_); |
2061 return; | 2062 return; |
2062 } | 2063 } |
2063 } | 2064 } |
2064 | 2065 |
2065 // If it's in a canvas but doesn't have an explicit rect, get the bounding | 2066 // If it's in a canvas but doesn't have an explicit rect, get the bounding |
2066 // rect of its children. | 2067 // rect of its children. |
2067 if (GetNode()->parentElement()->IsInCanvasSubtree()) { | 2068 if (GetNode()->parentElement()->IsInCanvasSubtree()) { |
2068 Vector<FloatRect> rects; | 2069 Vector<FloatRect> rects; |
2069 for (Node& child : NodeTraversal::ChildrenOf(*GetNode())) { | 2070 for (Node& child : NodeTraversal::ChildrenOf(*GetNode())) { |
2070 if (child.IsHTMLElement()) { | 2071 if (child.IsHTMLElement()) { |
2071 if (AXObject* obj = AxObjectCache().Get(&child)) { | 2072 if (AXObjectImpl* obj = AxObjectCache().Get(&child)) { |
2072 AXObject* container; | 2073 AXObjectImpl* container; |
2073 FloatRect bounds; | 2074 FloatRect bounds; |
2074 obj->GetRelativeBounds(&container, bounds, out_container_transform); | 2075 obj->GetRelativeBounds(&container, bounds, out_container_transform); |
2075 if (container) { | 2076 if (container) { |
2076 *out_container = container; | 2077 *out_container = container; |
2077 rects.push_back(bounds); | 2078 rects.push_back(bounds); |
2078 } | 2079 } |
2079 } | 2080 } |
2080 } | 2081 } |
2081 } | 2082 } |
2082 | 2083 |
2083 if (*out_container) { | 2084 if (*out_container) { |
2084 out_bounds_in_container = UnionRect(rects); | 2085 out_bounds_in_container = UnionRect(rects); |
2085 return; | 2086 return; |
2086 } | 2087 } |
2087 } | 2088 } |
2088 | 2089 |
2089 // If this object doesn't have an explicit element rect or computable from its | 2090 // If this object doesn't have an explicit element rect or computable from its |
2090 // children, for now, let's return the position of the ancestor that does have | 2091 // children, for now, let's return the position of the ancestor that does have |
2091 // a position, and make it the width of that parent, and about the height of a | 2092 // a position, and make it the width of that parent, and about the height of a |
2092 // line of text, so that it's clear the object is a child of the parent. | 2093 // line of text, so that it's clear the object is a child of the parent. |
2093 for (AXObject* position_provider = ParentObject(); position_provider; | 2094 for (AXObjectImpl* position_provider = ParentObject(); position_provider; |
2094 position_provider = position_provider->ParentObject()) { | 2095 position_provider = position_provider->ParentObject()) { |
2095 if (position_provider->IsAXLayoutObject()) { | 2096 if (position_provider->IsAXLayoutObject()) { |
2096 position_provider->GetRelativeBounds( | 2097 position_provider->GetRelativeBounds( |
2097 out_container, out_bounds_in_container, out_container_transform); | 2098 out_container, out_bounds_in_container, out_container_transform); |
2098 if (*out_container) | 2099 if (*out_container) |
2099 out_bounds_in_container.SetSize( | 2100 out_bounds_in_container.SetSize( |
2100 FloatSize(out_bounds_in_container.Width(), | 2101 FloatSize(out_bounds_in_container.Width(), |
2101 std::min(10.0f, out_bounds_in_container.Height()))); | 2102 std::min(10.0f, out_bounds_in_container.Height()))); |
2102 break; | 2103 break; |
2103 } | 2104 } |
(...skipping 10 matching lines...) Expand all Loading... |
2114 // <option>. | 2115 // <option>. |
2115 if (isHTMLOptionElement(node)) | 2116 if (isHTMLOptionElement(node)) |
2116 parent_node = toHTMLOptionElement(node)->OwnerSelectElement(); | 2117 parent_node = toHTMLOptionElement(node)->OwnerSelectElement(); |
2117 | 2118 |
2118 if (!parent_node) | 2119 if (!parent_node) |
2119 parent_node = node->parentNode(); | 2120 parent_node = node->parentNode(); |
2120 | 2121 |
2121 return parent_node; | 2122 return parent_node; |
2122 } | 2123 } |
2123 | 2124 |
2124 AXObject* AXNodeObject::ComputeParent() const { | 2125 AXObjectImpl* AXNodeObject::ComputeParent() const { |
2125 DCHECK(!IsDetached()); | 2126 DCHECK(!IsDetached()); |
2126 if (Node* parent_node = GetParentNodeForComputeParent(GetNode())) | 2127 if (Node* parent_node = GetParentNodeForComputeParent(GetNode())) |
2127 return AxObjectCache().GetOrCreate(parent_node); | 2128 return AxObjectCache().GetOrCreate(parent_node); |
2128 | 2129 |
2129 return nullptr; | 2130 return nullptr; |
2130 } | 2131 } |
2131 | 2132 |
2132 AXObject* AXNodeObject::ComputeParentIfExists() const { | 2133 AXObjectImpl* AXNodeObject::ComputeParentIfExists() const { |
2133 if (Node* parent_node = GetParentNodeForComputeParent(GetNode())) | 2134 if (Node* parent_node = GetParentNodeForComputeParent(GetNode())) |
2134 return AxObjectCache().Get(parent_node); | 2135 return AxObjectCache().Get(parent_node); |
2135 | 2136 |
2136 return nullptr; | 2137 return nullptr; |
2137 } | 2138 } |
2138 | 2139 |
2139 AXObject* AXNodeObject::RawFirstChild() const { | 2140 AXObjectImpl* AXNodeObject::RawFirstChild() const { |
2140 if (!GetNode()) | 2141 if (!GetNode()) |
2141 return 0; | 2142 return 0; |
2142 | 2143 |
2143 Node* first_child = GetNode()->firstChild(); | 2144 Node* first_child = GetNode()->firstChild(); |
2144 | 2145 |
2145 if (!first_child) | 2146 if (!first_child) |
2146 return 0; | 2147 return 0; |
2147 | 2148 |
2148 return AxObjectCache().GetOrCreate(first_child); | 2149 return AxObjectCache().GetOrCreate(first_child); |
2149 } | 2150 } |
2150 | 2151 |
2151 AXObject* AXNodeObject::RawNextSibling() const { | 2152 AXObjectImpl* AXNodeObject::RawNextSibling() const { |
2152 if (!GetNode()) | 2153 if (!GetNode()) |
2153 return 0; | 2154 return 0; |
2154 | 2155 |
2155 Node* next_sibling = GetNode()->nextSibling(); | 2156 Node* next_sibling = GetNode()->nextSibling(); |
2156 if (!next_sibling) | 2157 if (!next_sibling) |
2157 return 0; | 2158 return 0; |
2158 | 2159 |
2159 return AxObjectCache().GetOrCreate(next_sibling); | 2160 return AxObjectCache().GetOrCreate(next_sibling); |
2160 } | 2161 } |
2161 | 2162 |
2162 void AXNodeObject::AddChildren() { | 2163 void AXNodeObject::AddChildren() { |
2163 DCHECK(!IsDetached()); | 2164 DCHECK(!IsDetached()); |
2164 // If the need to add more children in addition to existing children arises, | 2165 // If the need to add more children in addition to existing children arises, |
2165 // childrenChanged should have been called, leaving the object with no | 2166 // childrenChanged should have been called, leaving the object with no |
2166 // children. | 2167 // children. |
2167 DCHECK(!have_children_); | 2168 DCHECK(!have_children_); |
2168 | 2169 |
2169 if (!node_) | 2170 if (!node_) |
2170 return; | 2171 return; |
2171 | 2172 |
2172 have_children_ = true; | 2173 have_children_ = true; |
2173 | 2174 |
2174 // The only time we add children from the DOM tree to a node with a | 2175 // The only time we add children from the DOM tree to a node with a |
2175 // layoutObject is when it's a canvas. | 2176 // layoutObject is when it's a canvas. |
2176 if (GetLayoutObject() && !isHTMLCanvasElement(*node_)) | 2177 if (GetLayoutObject() && !isHTMLCanvasElement(*node_)) |
2177 return; | 2178 return; |
2178 | 2179 |
2179 HeapVector<Member<AXObject>> owned_children; | 2180 HeapVector<Member<AXObjectImpl>> owned_children; |
2180 ComputeAriaOwnsChildren(owned_children); | 2181 ComputeAriaOwnsChildren(owned_children); |
2181 | 2182 |
2182 for (Node& child : NodeTraversal::ChildrenOf(*node_)) { | 2183 for (Node& child : NodeTraversal::ChildrenOf(*node_)) { |
2183 AXObject* child_obj = AxObjectCache().GetOrCreate(&child); | 2184 AXObjectImpl* child_obj = AxObjectCache().GetOrCreate(&child); |
2184 if (child_obj && !AxObjectCache().IsAriaOwned(child_obj)) | 2185 if (child_obj && !AxObjectCache().IsAriaOwned(child_obj)) |
2185 AddChild(child_obj); | 2186 AddChild(child_obj); |
2186 } | 2187 } |
2187 | 2188 |
2188 for (const auto& owned_child : owned_children) | 2189 for (const auto& owned_child : owned_children) |
2189 AddChild(owned_child); | 2190 AddChild(owned_child); |
2190 | 2191 |
2191 for (const auto& child : children_) | 2192 for (const auto& child : children_) |
2192 child->SetParent(this); | 2193 child->SetParent(this); |
2193 } | 2194 } |
2194 | 2195 |
2195 void AXNodeObject::AddChild(AXObject* child) { | 2196 void AXNodeObject::AddChild(AXObjectImpl* child) { |
2196 InsertChild(child, children_.size()); | 2197 InsertChild(child, children_.size()); |
2197 } | 2198 } |
2198 | 2199 |
2199 void AXNodeObject::InsertChild(AXObject* child, unsigned index) { | 2200 void AXNodeObject::InsertChild(AXObjectImpl* child, unsigned index) { |
2200 if (!child) | 2201 if (!child) |
2201 return; | 2202 return; |
2202 | 2203 |
2203 // If the parent is asking for this child's children, then either it's the | 2204 // If the parent is asking for this child's children, then either it's the |
2204 // first time (and clearing is a no-op), or its visibility has changed. In the | 2205 // first time (and clearing is a no-op), or its visibility has changed. In the |
2205 // latter case, this child may have a stale child cached. This can prevent | 2206 // latter case, this child may have a stale child cached. This can prevent |
2206 // aria-hidden changes from working correctly. Hence, whenever a parent is | 2207 // aria-hidden changes from working correctly. Hence, whenever a parent is |
2207 // getting children, ensure data is not stale. | 2208 // getting children, ensure data is not stale. |
2208 child->ClearChildren(); | 2209 child->ClearChildren(); |
2209 | 2210 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 if (isHTMLInputElement(*node)) { | 2266 if (isHTMLInputElement(*node)) { |
2266 HTMLInputElement& input = toHTMLInputElement(*node); | 2267 HTMLInputElement& input = toHTMLInputElement(*node); |
2267 if (!input.IsDisabledFormControl() && | 2268 if (!input.IsDisabledFormControl() && |
2268 (IsCheckboxOrRadio() || input.IsTextButton() || | 2269 (IsCheckboxOrRadio() || input.IsTextButton() || |
2269 input.type() == InputTypeNames::file)) | 2270 input.type() == InputTypeNames::file)) |
2270 return &input; | 2271 return &input; |
2271 } else if (isHTMLButtonElement(*node)) { | 2272 } else if (isHTMLButtonElement(*node)) { |
2272 return ToElement(node); | 2273 return ToElement(node); |
2273 } | 2274 } |
2274 | 2275 |
2275 if (AXObject::IsARIAInput(AriaRoleAttribute())) | 2276 if (AXObjectImpl::IsARIAInput(AriaRoleAttribute())) |
2276 return ToElement(node); | 2277 return ToElement(node); |
2277 | 2278 |
2278 if (IsImageButton()) | 2279 if (IsImageButton()) |
2279 return ToElement(node); | 2280 return ToElement(node); |
2280 | 2281 |
2281 if (isHTMLSelectElement(*node)) | 2282 if (isHTMLSelectElement(*node)) |
2282 return ToElement(node); | 2283 return ToElement(node); |
2283 | 2284 |
2284 switch (RoleValue()) { | 2285 switch (RoleValue()) { |
2285 case kButtonRole: | 2286 case kButtonRole: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 Document* AXNodeObject::GetDocument() const { | 2325 Document* AXNodeObject::GetDocument() const { |
2325 if (!GetNode()) | 2326 if (!GetNode()) |
2326 return 0; | 2327 return 0; |
2327 return &GetNode()->GetDocument(); | 2328 return &GetNode()->GetDocument(); |
2328 } | 2329 } |
2329 | 2330 |
2330 void AXNodeObject::SetNode(Node* node) { | 2331 void AXNodeObject::SetNode(Node* node) { |
2331 node_ = node; | 2332 node_ = node; |
2332 } | 2333 } |
2333 | 2334 |
2334 AXObject* AXNodeObject::CorrespondingControlForLabelElement() const { | 2335 AXObjectImpl* AXNodeObject::CorrespondingControlForLabelElement() const { |
2335 HTMLLabelElement* label_element = LabelElementContainer(); | 2336 HTMLLabelElement* label_element = LabelElementContainer(); |
2336 if (!label_element) | 2337 if (!label_element) |
2337 return 0; | 2338 return 0; |
2338 | 2339 |
2339 HTMLElement* corresponding_control = label_element->control(); | 2340 HTMLElement* corresponding_control = label_element->control(); |
2340 if (!corresponding_control) | 2341 if (!corresponding_control) |
2341 return 0; | 2342 return 0; |
2342 | 2343 |
2343 // Make sure the corresponding control isn't a descendant of this label | 2344 // Make sure the corresponding control isn't a descendant of this label |
2344 // that's in the middle of being destroyed. | 2345 // that's in the middle of being destroyed. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2423 return; | 2424 return; |
2424 } | 2425 } |
2425 | 2426 |
2426 AxObjectCache().PostNotification(this, AXObjectCacheImpl::kAXChildrenChanged); | 2427 AxObjectCache().PostNotification(this, AXObjectCacheImpl::kAXChildrenChanged); |
2427 | 2428 |
2428 // Go up the accessibility parent chain, but only if the element already | 2429 // Go up the accessibility parent chain, but only if the element already |
2429 // exists. This method is called during layout, minimal work should be done. | 2430 // exists. This method is called during layout, minimal work should be done. |
2430 // If AX elements are created now, they could interrogate the layout tree | 2431 // If AX elements are created now, they could interrogate the layout tree |
2431 // while it's in a funky state. At the same time, process ARIA live region | 2432 // while it's in a funky state. At the same time, process ARIA live region |
2432 // changes. | 2433 // changes. |
2433 for (AXObject* parent = this; parent; | 2434 for (AXObjectImpl* parent = this; parent; |
2434 parent = parent->ParentObjectIfExists()) { | 2435 parent = parent->ParentObjectIfExists()) { |
2435 parent->SetNeedsToUpdateChildren(); | 2436 parent->SetNeedsToUpdateChildren(); |
2436 | 2437 |
2437 // These notifications always need to be sent because screenreaders are | 2438 // These notifications always need to be sent because screenreaders are |
2438 // reliant on them to perform. In other words, they need to be sent even | 2439 // reliant on them to perform. In other words, they need to be sent even |
2439 // when the screen reader has not accessed this live region since the last | 2440 // when the screen reader has not accessed this live region since the last |
2440 // update. | 2441 // update. |
2441 | 2442 |
2442 // If this element supports ARIA live regions, then notify the AT of | 2443 // If this element supports ARIA live regions, then notify the AT of |
2443 // changes. | 2444 // changes. |
(...skipping 11 matching lines...) Expand all Loading... |
2455 } | 2456 } |
2456 | 2457 |
2457 void AXNodeObject::SelectionChanged() { | 2458 void AXNodeObject::SelectionChanged() { |
2458 // Post the selected text changed event on the first ancestor that's | 2459 // Post the selected text changed event on the first ancestor that's |
2459 // focused (to handle form controls, ARIA text boxes and contentEditable), | 2460 // focused (to handle form controls, ARIA text boxes and contentEditable), |
2460 // or the web area if the selection is just in the document somewhere. | 2461 // or the web area if the selection is just in the document somewhere. |
2461 if (IsFocused() || IsWebArea()) { | 2462 if (IsFocused() || IsWebArea()) { |
2462 AxObjectCache().PostNotification(this, | 2463 AxObjectCache().PostNotification(this, |
2463 AXObjectCacheImpl::kAXSelectedTextChanged); | 2464 AXObjectCacheImpl::kAXSelectedTextChanged); |
2464 if (GetDocument()) { | 2465 if (GetDocument()) { |
2465 AXObject* document_object = AxObjectCache().GetOrCreate(GetDocument()); | 2466 AXObjectImpl* document_object = |
| 2467 AxObjectCache().GetOrCreate(GetDocument()); |
2466 AxObjectCache().PostNotification( | 2468 AxObjectCache().PostNotification( |
2467 document_object, AXObjectCacheImpl::kAXDocumentSelectionChanged); | 2469 document_object, AXObjectCacheImpl::kAXDocumentSelectionChanged); |
2468 } | 2470 } |
2469 } else { | 2471 } else { |
2470 AXObject::SelectionChanged(); // Calls selectionChanged on parent. | 2472 AXObjectImpl::SelectionChanged(); // Calls selectionChanged on parent. |
2471 } | 2473 } |
2472 } | 2474 } |
2473 | 2475 |
2474 void AXNodeObject::TextChanged() { | 2476 void AXNodeObject::TextChanged() { |
2475 // If this element supports ARIA live regions, or is part of a region with an | 2477 // If this element supports ARIA live regions, or is part of a region with an |
2476 // ARIA editable role, then notify the AT of changes. | 2478 // ARIA editable role, then notify the AT of changes. |
2477 AXObjectCacheImpl& cache = AxObjectCache(); | 2479 AXObjectCacheImpl& cache = AxObjectCache(); |
2478 for (Node* parent_node = GetNode(); parent_node; | 2480 for (Node* parent_node = GetNode(); parent_node; |
2479 parent_node = parent_node->parentNode()) { | 2481 parent_node = parent_node->parentNode()) { |
2480 AXObject* parent = cache.Get(parent_node); | 2482 AXObjectImpl* parent = cache.Get(parent_node); |
2481 if (!parent) | 2483 if (!parent) |
2482 continue; | 2484 continue; |
2483 | 2485 |
2484 if (parent->IsLiveRegion()) | 2486 if (parent->IsLiveRegion()) |
2485 cache.PostNotification(parent_node, | 2487 cache.PostNotification(parent_node, |
2486 AXObjectCacheImpl::kAXLiveRegionChanged); | 2488 AXObjectCacheImpl::kAXLiveRegionChanged); |
2487 | 2489 |
2488 // If this element is an ARIA text box or content editable, post a "value | 2490 // If this element is an ARIA text box or content editable, post a "value |
2489 // changed" notification on it so that it behaves just like a native input | 2491 // changed" notification on it so that it behaves just like a native input |
2490 // element or textarea. | 2492 // element or textarea. |
2491 if (parent->IsNonNativeTextControl()) | 2493 if (parent->IsNonNativeTextControl()) |
2492 cache.PostNotification(parent_node, AXObjectCacheImpl::kAXValueChanged); | 2494 cache.PostNotification(parent_node, AXObjectCacheImpl::kAXValueChanged); |
2493 } | 2495 } |
2494 } | 2496 } |
2495 | 2497 |
2496 void AXNodeObject::UpdateAccessibilityRole() { | 2498 void AXNodeObject::UpdateAccessibilityRole() { |
2497 role_ = DetermineAccessibilityRole(); | 2499 role_ = DetermineAccessibilityRole(); |
2498 bool ignored_status = AccessibilityIsIgnored(); | 2500 bool ignored_status = AccessibilityIsIgnored(); |
2499 | 2501 |
2500 // The AX hierarchy only needs to be updated if the ignored status of an | 2502 // The AX hierarchy only needs to be updated if the ignored status of an |
2501 // element has changed. | 2503 // element has changed. |
2502 if (ignored_status != AccessibilityIsIgnored()) | 2504 if (ignored_status != AccessibilityIsIgnored()) |
2503 ChildrenChanged(); | 2505 ChildrenChanged(); |
2504 } | 2506 } |
2505 | 2507 |
2506 void AXNodeObject::ComputeAriaOwnsChildren( | 2508 void AXNodeObject::ComputeAriaOwnsChildren( |
2507 HeapVector<Member<AXObject>>& owned_children) const { | 2509 HeapVector<Member<AXObjectImpl>>& owned_children) const { |
2508 if (!HasAttribute(aria_ownsAttr)) | 2510 if (!HasAttribute(aria_ownsAttr)) |
2509 return; | 2511 return; |
2510 | 2512 |
2511 Vector<String> id_vector; | 2513 Vector<String> id_vector; |
2512 if (CanHaveChildren() && !IsNativeTextControl() && | 2514 if (CanHaveChildren() && !IsNativeTextControl() && |
2513 !HasContentEditableAttributeSet()) | 2515 !HasContentEditableAttributeSet()) |
2514 TokenVectorFromAttribute(id_vector, aria_ownsAttr); | 2516 TokenVectorFromAttribute(id_vector, aria_ownsAttr); |
2515 | 2517 |
2516 AxObjectCache().UpdateAriaOwns(this, id_vector, owned_children); | 2518 AxObjectCache().UpdateAriaOwns(this, id_vector, owned_children); |
2517 } | 2519 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 name_sources->back().native_source = kAXTextFromNativeHTMLFigcaption; | 2751 name_sources->back().native_source = kAXTextFromNativeHTMLFigcaption; |
2750 } | 2752 } |
2751 Element* figcaption = nullptr; | 2753 Element* figcaption = nullptr; |
2752 for (Element& element : ElementTraversal::DescendantsOf(*(GetNode()))) { | 2754 for (Element& element : ElementTraversal::DescendantsOf(*(GetNode()))) { |
2753 if (element.HasTagName(figcaptionTag)) { | 2755 if (element.HasTagName(figcaptionTag)) { |
2754 figcaption = &element; | 2756 figcaption = &element; |
2755 break; | 2757 break; |
2756 } | 2758 } |
2757 } | 2759 } |
2758 if (figcaption) { | 2760 if (figcaption) { |
2759 AXObject* figcaption_ax_object = AxObjectCache().GetOrCreate(figcaption); | 2761 AXObjectImpl* figcaption_ax_object = |
| 2762 AxObjectCache().GetOrCreate(figcaption); |
2760 if (figcaption_ax_object) { | 2763 if (figcaption_ax_object) { |
2761 text_alternative = | 2764 text_alternative = |
2762 RecursiveTextAlternative(*figcaption_ax_object, false, visited); | 2765 RecursiveTextAlternative(*figcaption_ax_object, false, visited); |
2763 | 2766 |
2764 if (related_objects) { | 2767 if (related_objects) { |
2765 local_related_objects.push_back(new NameSourceRelatedObject( | 2768 local_related_objects.push_back(new NameSourceRelatedObject( |
2766 figcaption_ax_object, text_alternative)); | 2769 figcaption_ax_object, text_alternative)); |
2767 *related_objects = local_related_objects; | 2770 *related_objects = local_related_objects; |
2768 local_related_objects.clear(); | 2771 local_related_objects.clear(); |
2769 } | 2772 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 | 2816 |
2814 // caption | 2817 // caption |
2815 name_from = kAXNameFromCaption; | 2818 name_from = kAXNameFromCaption; |
2816 if (name_sources) { | 2819 if (name_sources) { |
2817 name_sources->push_back(NameSource(*found_text_alternative)); | 2820 name_sources->push_back(NameSource(*found_text_alternative)); |
2818 name_sources->back().type = name_from; | 2821 name_sources->back().type = name_from; |
2819 name_sources->back().native_source = kAXTextFromNativeHTMLTableCaption; | 2822 name_sources->back().native_source = kAXTextFromNativeHTMLTableCaption; |
2820 } | 2823 } |
2821 HTMLTableCaptionElement* caption = table_element->caption(); | 2824 HTMLTableCaptionElement* caption = table_element->caption(); |
2822 if (caption) { | 2825 if (caption) { |
2823 AXObject* caption_ax_object = AxObjectCache().GetOrCreate(caption); | 2826 AXObjectImpl* caption_ax_object = AxObjectCache().GetOrCreate(caption); |
2824 if (caption_ax_object) { | 2827 if (caption_ax_object) { |
2825 text_alternative = | 2828 text_alternative = |
2826 RecursiveTextAlternative(*caption_ax_object, false, visited); | 2829 RecursiveTextAlternative(*caption_ax_object, false, visited); |
2827 if (related_objects) { | 2830 if (related_objects) { |
2828 local_related_objects.push_back( | 2831 local_related_objects.push_back( |
2829 new NameSourceRelatedObject(caption_ax_object, text_alternative)); | 2832 new NameSourceRelatedObject(caption_ax_object, text_alternative)); |
2830 *related_objects = local_related_objects; | 2833 *related_objects = local_related_objects; |
2831 local_related_objects.clear(); | 2834 local_related_objects.clear(); |
2832 } | 2835 } |
2833 | 2836 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 if (name_sources) { | 2873 if (name_sources) { |
2871 name_sources->push_back(NameSource(*found_text_alternative)); | 2874 name_sources->push_back(NameSource(*found_text_alternative)); |
2872 name_sources->back().type = name_from; | 2875 name_sources->back().type = name_from; |
2873 name_sources->back().native_source = kAXTextFromNativeHTMLTitleElement; | 2876 name_sources->back().native_source = kAXTextFromNativeHTMLTitleElement; |
2874 } | 2877 } |
2875 DCHECK(GetNode()->IsContainerNode()); | 2878 DCHECK(GetNode()->IsContainerNode()); |
2876 Element* title = ElementTraversal::FirstChild( | 2879 Element* title = ElementTraversal::FirstChild( |
2877 ToContainerNode(*(GetNode())), HasTagName(SVGNames::titleTag)); | 2880 ToContainerNode(*(GetNode())), HasTagName(SVGNames::titleTag)); |
2878 | 2881 |
2879 if (title) { | 2882 if (title) { |
2880 AXObject* title_ax_object = AxObjectCache().GetOrCreate(title); | 2883 AXObjectImpl* title_ax_object = AxObjectCache().GetOrCreate(title); |
2881 if (title_ax_object && !visited.Contains(title_ax_object)) { | 2884 if (title_ax_object && !visited.Contains(title_ax_object)) { |
2882 text_alternative = | 2885 text_alternative = |
2883 RecursiveTextAlternative(*title_ax_object, false, visited); | 2886 RecursiveTextAlternative(*title_ax_object, false, visited); |
2884 if (related_objects) { | 2887 if (related_objects) { |
2885 local_related_objects.push_back( | 2888 local_related_objects.push_back( |
2886 new NameSourceRelatedObject(title_ax_object, text_alternative)); | 2889 new NameSourceRelatedObject(title_ax_object, text_alternative)); |
2887 *related_objects = local_related_objects; | 2890 *related_objects = local_related_objects; |
2888 local_related_objects.clear(); | 2891 local_related_objects.clear(); |
2889 } | 2892 } |
2890 } | 2893 } |
(...skipping 11 matching lines...) Expand all Loading... |
2902 // Fieldset / legend. | 2905 // Fieldset / legend. |
2903 if (isHTMLFieldSetElement(GetNode())) { | 2906 if (isHTMLFieldSetElement(GetNode())) { |
2904 name_from = kAXNameFromRelatedElement; | 2907 name_from = kAXNameFromRelatedElement; |
2905 if (name_sources) { | 2908 if (name_sources) { |
2906 name_sources->push_back(NameSource(*found_text_alternative)); | 2909 name_sources->push_back(NameSource(*found_text_alternative)); |
2907 name_sources->back().type = name_from; | 2910 name_sources->back().type = name_from; |
2908 name_sources->back().native_source = kAXTextFromNativeHTMLLegend; | 2911 name_sources->back().native_source = kAXTextFromNativeHTMLLegend; |
2909 } | 2912 } |
2910 HTMLElement* legend = toHTMLFieldSetElement(GetNode())->Legend(); | 2913 HTMLElement* legend = toHTMLFieldSetElement(GetNode())->Legend(); |
2911 if (legend) { | 2914 if (legend) { |
2912 AXObject* legend_ax_object = AxObjectCache().GetOrCreate(legend); | 2915 AXObjectImpl* legend_ax_object = AxObjectCache().GetOrCreate(legend); |
2913 // Avoid an infinite loop | 2916 // Avoid an infinite loop |
2914 if (legend_ax_object && !visited.Contains(legend_ax_object)) { | 2917 if (legend_ax_object && !visited.Contains(legend_ax_object)) { |
2915 text_alternative = | 2918 text_alternative = |
2916 RecursiveTextAlternative(*legend_ax_object, false, visited); | 2919 RecursiveTextAlternative(*legend_ax_object, false, visited); |
2917 | 2920 |
2918 if (related_objects) { | 2921 if (related_objects) { |
2919 local_related_objects.push_back( | 2922 local_related_objects.push_back( |
2920 new NameSourceRelatedObject(legend_ax_object, text_alternative)); | 2923 new NameSourceRelatedObject(legend_ax_object, text_alternative)); |
2921 *related_objects = local_related_objects; | 2924 *related_objects = local_related_objects; |
2922 local_related_objects.clear(); | 2925 local_related_objects.clear(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 name_from = kAXNameFromRelatedElement; | 2967 name_from = kAXNameFromRelatedElement; |
2965 if (name_sources) { | 2968 if (name_sources) { |
2966 name_sources->push_back(NameSource(*found_text_alternative)); | 2969 name_sources->push_back(NameSource(*found_text_alternative)); |
2967 name_sources->back().type = name_from; | 2970 name_sources->back().type = name_from; |
2968 name_sources->back().native_source = kAXTextFromNativeHTMLTitleElement; | 2971 name_sources->back().native_source = kAXTextFromNativeHTMLTitleElement; |
2969 } | 2972 } |
2970 | 2973 |
2971 text_alternative = document->title(); | 2974 text_alternative = document->title(); |
2972 | 2975 |
2973 Element* title_element = document->TitleElement(); | 2976 Element* title_element = document->TitleElement(); |
2974 AXObject* title_ax_object = AxObjectCache().GetOrCreate(title_element); | 2977 AXObjectImpl* title_ax_object = |
| 2978 AxObjectCache().GetOrCreate(title_element); |
2975 if (title_ax_object) { | 2979 if (title_ax_object) { |
2976 if (related_objects) { | 2980 if (related_objects) { |
2977 local_related_objects.push_back( | 2981 local_related_objects.push_back( |
2978 new NameSourceRelatedObject(title_ax_object, text_alternative)); | 2982 new NameSourceRelatedObject(title_ax_object, text_alternative)); |
2979 *related_objects = local_related_objects; | 2983 *related_objects = local_related_objects; |
2980 local_related_objects.clear(); | 2984 local_related_objects.clear(); |
2981 } | 2985 } |
2982 | 2986 |
2983 if (name_sources) { | 2987 if (name_sources) { |
2984 NameSource& source = name_sources->back(); | 2988 NameSource& source = name_sources->back(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 | 3095 |
3092 description_from = kAXDescriptionFromRelatedElement; | 3096 description_from = kAXDescriptionFromRelatedElement; |
3093 if (description_sources) { | 3097 if (description_sources) { |
3094 description_sources->push_back(DescriptionSource(found_description)); | 3098 description_sources->push_back(DescriptionSource(found_description)); |
3095 description_sources->back().type = description_from; | 3099 description_sources->back().type = description_from; |
3096 description_sources->back().native_source = | 3100 description_sources->back().native_source = |
3097 kAXTextFromNativeHTMLTableCaption; | 3101 kAXTextFromNativeHTMLTableCaption; |
3098 } | 3102 } |
3099 HTMLTableCaptionElement* caption = table_element->caption(); | 3103 HTMLTableCaptionElement* caption = table_element->caption(); |
3100 if (caption) { | 3104 if (caption) { |
3101 AXObject* caption_ax_object = AxObjectCache().GetOrCreate(caption); | 3105 AXObjectImpl* caption_ax_object = AxObjectCache().GetOrCreate(caption); |
3102 if (caption_ax_object) { | 3106 if (caption_ax_object) { |
3103 AXObjectSet visited; | 3107 AXObjectSet visited; |
3104 description = | 3108 description = |
3105 RecursiveTextAlternative(*caption_ax_object, false, visited); | 3109 RecursiveTextAlternative(*caption_ax_object, false, visited); |
3106 if (related_objects) | 3110 if (related_objects) |
3107 related_objects->push_back( | 3111 related_objects->push_back( |
3108 new NameSourceRelatedObject(caption_ax_object, description)); | 3112 new NameSourceRelatedObject(caption_ax_object, description)); |
3109 | 3113 |
3110 if (description_sources) { | 3114 if (description_sources) { |
3111 DescriptionSource& source = description_sources->back(); | 3115 DescriptionSource& source = description_sources->back(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3222 | 3226 |
3223 String AXNodeObject::PlaceholderFromNativeAttribute() const { | 3227 String AXNodeObject::PlaceholderFromNativeAttribute() const { |
3224 Node* node = GetNode(); | 3228 Node* node = GetNode(); |
3225 if (!node || !IsTextControlElement(node)) | 3229 if (!node || !IsTextControlElement(node)) |
3226 return String(); | 3230 return String(); |
3227 return ToTextControlElement(node)->StrippedPlaceholder(); | 3231 return ToTextControlElement(node)->StrippedPlaceholder(); |
3228 } | 3232 } |
3229 | 3233 |
3230 DEFINE_TRACE(AXNodeObject) { | 3234 DEFINE_TRACE(AXNodeObject) { |
3231 visitor->Trace(node_); | 3235 visitor->Trace(node_); |
3232 AXObject::Trace(visitor); | 3236 AXObjectImpl::Trace(visitor); |
3233 } | 3237 } |
3234 | 3238 |
3235 } // namespace blink | 3239 } // namespace blink |
OLD | NEW |