OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/accessibility/InspectorAccessibilityAgent.h" | 5 #include "modules/accessibility/InspectorAccessibilityAgent.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/AXObjectCache.h" | 8 #include "core/dom/AXObjectCache.h" |
9 #include "core/dom/DOMNodeIds.h" | 9 #include "core/dom/DOMNodeIds.h" |
10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 const String& key, | 320 const String& key, |
321 AXObject::AXObjectVector& nodes, | 321 AXObject::AXObjectVector& nodes, |
322 const QualifiedName& attr, | 322 const QualifiedName& attr, |
323 AXObject& axObject) { | 323 AXObject& axObject) { |
324 std::unique_ptr<AXValue> nodeListValue = createRelatedNodeListValue(nodes); | 324 std::unique_ptr<AXValue> nodeListValue = createRelatedNodeListValue(nodes); |
325 const AtomicString& attrValue = axObject.getAttribute(attr); | 325 const AtomicString& attrValue = axObject.getAttribute(attr); |
326 nodeListValue->setValue(protocol::StringValue::create(attrValue)); | 326 nodeListValue->setValue(protocol::StringValue::create(attrValue)); |
327 return createProperty(key, std::move(nodeListValue)); | 327 return createProperty(key, std::move(nodeListValue)); |
328 } | 328 } |
329 | 329 |
| 330 class SparseAttributeAXPropertyAdapter |
| 331 : public GarbageCollected<SparseAttributeAXPropertyAdapter>, |
| 332 public AXSparseAttributeMap { |
| 333 public: |
| 334 SparseAttributeAXPropertyAdapter(AXObject& axObject, |
| 335 protocol::Array<AXProperty>& properties) |
| 336 : m_axObject(&axObject), m_properties(properties) {} |
| 337 |
| 338 DEFINE_INLINE_TRACE() { visitor->trace(m_axObject); } |
| 339 |
| 340 private: |
| 341 Member<AXObject> m_axObject; |
| 342 protocol::Array<AXProperty>& m_properties; |
| 343 |
| 344 void addBoolAttribute(AXBoolAttribute attribute, bool value) { |
| 345 switch (attribute) { |
| 346 case AXBoolAttribute::AriaModal: |
| 347 // TODO |
| 348 break; |
| 349 } |
| 350 } |
| 351 |
| 352 void addStringAttribute(AXStringAttribute attribute, const String& value) { |
| 353 switch (attribute) { |
| 354 case AXStringAttribute::AriaKeyShortcuts: |
| 355 // TODO |
| 356 break; |
| 357 case AXStringAttribute::AriaRoleDescription: |
| 358 // TODO |
| 359 break; |
| 360 } |
| 361 } |
| 362 |
| 363 void addObjectAttribute(AXObjectAttribute attribute, AXObject* object) { |
| 364 switch (attribute) { |
| 365 case AXObjectAttribute::AriaActiveDescendant: |
| 366 m_properties.addItem( |
| 367 createProperty(AXRelationshipAttributesEnum::Activedescendant, |
| 368 createRelatedNodeListValue(*object))); |
| 369 break; |
| 370 case AXObjectAttribute::AriaErrorMessage: |
| 371 // TODO |
| 372 break; |
| 373 } |
| 374 } |
| 375 |
| 376 void addObjectVectorAttribute(AXObjectVectorAttribute attribute, |
| 377 HeapVector<Member<AXObject>>& objects) { |
| 378 switch (attribute) { |
| 379 case AXObjectVectorAttribute::AriaControls: |
| 380 m_properties.addItem(createRelatedNodeListProperty( |
| 381 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, |
| 382 *m_axObject)); |
| 383 break; |
| 384 case AXObjectVectorAttribute::AriaDetails: |
| 385 // TODO |
| 386 break; |
| 387 case AXObjectVectorAttribute::AriaFlowTo: |
| 388 m_properties.addItem(createRelatedNodeListProperty( |
| 389 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, |
| 390 *m_axObject)); |
| 391 break; |
| 392 } |
| 393 } |
| 394 }; |
| 395 |
330 void fillRelationships(AXObject& axObject, | 396 void fillRelationships(AXObject& axObject, |
331 protocol::Array<AXProperty>& properties) { | 397 protocol::Array<AXProperty>& properties) { |
332 if (AXObject* activeDescendant = axObject.activeDescendant()) { | |
333 properties.addItem( | |
334 createProperty(AXRelationshipAttributesEnum::Activedescendant, | |
335 createRelatedNodeListValue(*activeDescendant))); | |
336 } | |
337 | |
338 AXObject::AXObjectVector results; | 398 AXObject::AXObjectVector results; |
339 axObject.ariaFlowToElements(results); | |
340 if (!results.isEmpty()) | |
341 properties.addItem( | |
342 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Flowto, | |
343 results, aria_flowtoAttr, axObject)); | |
344 results.clear(); | |
345 | |
346 axObject.ariaControlsElements(results); | |
347 if (!results.isEmpty()) | |
348 properties.addItem( | |
349 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Controls, | |
350 results, aria_controlsAttr, axObject)); | |
351 results.clear(); | |
352 | |
353 axObject.ariaDescribedbyElements(results); | 399 axObject.ariaDescribedbyElements(results); |
354 if (!results.isEmpty()) | 400 if (!results.isEmpty()) |
355 properties.addItem( | 401 properties.addItem( |
356 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Describedby, | 402 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Describedby, |
357 results, aria_describedbyAttr, axObject)); | 403 results, aria_describedbyAttr, axObject)); |
358 results.clear(); | 404 results.clear(); |
359 | 405 |
360 axObject.ariaOwnsElements(results); | 406 axObject.ariaOwnsElements(results); |
361 if (!results.isEmpty()) | 407 if (!results.isEmpty()) |
362 properties.addItem(createRelatedNodeListProperty( | 408 properties.addItem(createRelatedNodeListProperty( |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 nodeObject->setRole(createRoleNameValue(role)); | 661 nodeObject->setRole(createRoleNameValue(role)); |
616 | 662 |
617 std::unique_ptr<protocol::Array<AXProperty>> properties = | 663 std::unique_ptr<protocol::Array<AXProperty>> properties = |
618 protocol::Array<AXProperty>::create(); | 664 protocol::Array<AXProperty>::create(); |
619 fillLiveRegionProperties(axObject, *(properties.get())); | 665 fillLiveRegionProperties(axObject, *(properties.get())); |
620 fillGlobalStates(axObject, *(properties.get())); | 666 fillGlobalStates(axObject, *(properties.get())); |
621 fillWidgetProperties(axObject, *(properties.get())); | 667 fillWidgetProperties(axObject, *(properties.get())); |
622 fillWidgetStates(axObject, *(properties.get())); | 668 fillWidgetStates(axObject, *(properties.get())); |
623 fillRelationships(axObject, *(properties.get())); | 669 fillRelationships(axObject, *(properties.get())); |
624 | 670 |
| 671 Member<SparseAttributeAXPropertyAdapter> adapter = |
| 672 new SparseAttributeAXPropertyAdapter(axObject, *(properties.get())); |
| 673 axObject.getSparseAXAttributes(*adapter.get()); |
| 674 |
625 AXObject::NameSources nameSources; | 675 AXObject::NameSources nameSources; |
626 String computedName = axObject.name(&nameSources); | 676 String computedName = axObject.name(&nameSources); |
627 if (!nameSources.isEmpty()) { | 677 if (!nameSources.isEmpty()) { |
628 std::unique_ptr<AXValue> name = | 678 std::unique_ptr<AXValue> name = |
629 createValue(computedName, AXValueTypeEnum::ComputedString); | 679 createValue(computedName, AXValueTypeEnum::ComputedString); |
630 if (!nameSources.isEmpty()) { | 680 if (!nameSources.isEmpty()) { |
631 std::unique_ptr<protocol::Array<AXValueSource>> nameSourceProperties = | 681 std::unique_ptr<protocol::Array<AXValueSource>> nameSourceProperties = |
632 protocol::Array<AXValueSource>::create(); | 682 protocol::Array<AXValueSource>::create(); |
633 for (size_t i = 0; i < nameSources.size(); ++i) { | 683 for (size_t i = 0; i < nameSources.size(); ++i) { |
634 NameSource& nameSource = nameSources[i]; | 684 NameSource& nameSource = nameSources[i]; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 834 } |
785 } | 835 } |
786 | 836 |
787 DEFINE_TRACE(InspectorAccessibilityAgent) { | 837 DEFINE_TRACE(InspectorAccessibilityAgent) { |
788 visitor->trace(m_page); | 838 visitor->trace(m_page); |
789 visitor->trace(m_domAgent); | 839 visitor->trace(m_domAgent); |
790 InspectorBaseAgent::trace(visitor); | 840 InspectorBaseAgent::trace(visitor); |
791 } | 841 } |
792 | 842 |
793 } // namespace blink | 843 } // namespace blink |
OLD | NEW |