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 AXSparseAttributeClient { | |
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 | |
346 void addStringAttribute(AXStringAttribute attribute, const String& value) {} | |
347 | |
348 void addObjectAttribute(AXObjectAttribute attribute, AXObject* object) { | |
349 switch (attribute) { | |
350 case AXObjectAttribute::AriaActiveDescendant: | |
351 m_properties.addItem( | |
352 createProperty(AXRelationshipAttributesEnum::Activedescendant, | |
353 createRelatedNodeListValue(*object))); | |
354 break; | |
355 } | |
356 } | |
357 | |
358 void addObjectVectorAttribute(AXObjectVectorAttribute attribute, | |
359 HeapVector<Member<AXObject>>& objects) { | |
360 switch (attribute) { | |
361 case AXObjectVectorAttribute::AriaControls: | |
362 m_properties.addItem(createRelatedNodeListProperty( | |
363 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, | |
364 *m_axObject)); | |
365 break; | |
366 case AXObjectVectorAttribute::AriaFlowTo: | |
367 m_properties.addItem(createRelatedNodeListProperty( | |
368 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, | |
369 *m_axObject)); | |
370 break; | |
371 } | |
372 } | |
373 }; | |
374 | |
330 void fillRelationships(AXObject& axObject, | 375 void fillRelationships(AXObject& axObject, |
331 protocol::Array<AXProperty>& properties) { | 376 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; | 377 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); | 378 axObject.ariaDescribedbyElements(results); |
354 if (!results.isEmpty()) | 379 if (!results.isEmpty()) |
355 properties.addItem( | 380 properties.addItem( |
356 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Describedby, | 381 createRelatedNodeListProperty(AXRelationshipAttributesEnum::Describedby, |
357 results, aria_describedbyAttr, axObject)); | 382 results, aria_describedbyAttr, axObject)); |
358 results.clear(); | 383 results.clear(); |
359 | 384 |
360 axObject.ariaOwnsElements(results); | 385 axObject.ariaOwnsElements(results); |
361 if (!results.isEmpty()) | 386 if (!results.isEmpty()) |
362 properties.addItem(createRelatedNodeListProperty( | 387 properties.addItem(createRelatedNodeListProperty( |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 nodeObject->setRole(createRoleNameValue(role)); | 563 nodeObject->setRole(createRoleNameValue(role)); |
539 | 564 |
540 std::unique_ptr<protocol::Array<AXProperty>> properties = | 565 std::unique_ptr<protocol::Array<AXProperty>> properties = |
541 protocol::Array<AXProperty>::create(); | 566 protocol::Array<AXProperty>::create(); |
542 fillLiveRegionProperties(axObject, *(properties.get())); | 567 fillLiveRegionProperties(axObject, *(properties.get())); |
543 fillGlobalStates(axObject, *(properties.get())); | 568 fillGlobalStates(axObject, *(properties.get())); |
544 fillWidgetProperties(axObject, *(properties.get())); | 569 fillWidgetProperties(axObject, *(properties.get())); |
545 fillWidgetStates(axObject, *(properties.get())); | 570 fillWidgetStates(axObject, *(properties.get())); |
546 fillRelationships(axObject, *(properties.get())); | 571 fillRelationships(axObject, *(properties.get())); |
547 | 572 |
573 Member<SparseAttributeAXPropertyAdapter> adapter = | |
574 new SparseAttributeAXPropertyAdapter(axObject, *(properties.get())); | |
dcheng
2017/01/19 23:02:45
Nit: just write *properties
dmazzoni
2017/01/21 00:16:35
Done.
| |
575 axObject.getSparseAXAttributes(*adapter.get()); | |
576 | |
548 AXObject::NameSources nameSources; | 577 AXObject::NameSources nameSources; |
549 String computedName = axObject.name(&nameSources); | 578 String computedName = axObject.name(&nameSources); |
550 if (!nameSources.isEmpty()) { | 579 if (!nameSources.isEmpty()) { |
551 std::unique_ptr<AXValue> name = | 580 std::unique_ptr<AXValue> name = |
552 createValue(computedName, AXValueTypeEnum::ComputedString); | 581 createValue(computedName, AXValueTypeEnum::ComputedString); |
553 if (!nameSources.isEmpty()) { | 582 if (!nameSources.isEmpty()) { |
554 std::unique_ptr<protocol::Array<AXValueSource>> nameSourceProperties = | 583 std::unique_ptr<protocol::Array<AXValueSource>> nameSourceProperties = |
555 protocol::Array<AXValueSource>::create(); | 584 protocol::Array<AXValueSource>::create(); |
556 for (size_t i = 0; i < nameSources.size(); ++i) { | 585 for (size_t i = 0; i < nameSources.size(); ++i) { |
557 NameSource& nameSource = nameSources[i]; | 586 NameSource& nameSource = nameSources[i]; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 } | 709 } |
681 } | 710 } |
682 | 711 |
683 DEFINE_TRACE(InspectorAccessibilityAgent) { | 712 DEFINE_TRACE(InspectorAccessibilityAgent) { |
684 visitor->trace(m_page); | 713 visitor->trace(m_page); |
685 visitor->trace(m_domAgent); | 714 visitor->trace(m_domAgent); |
686 InspectorBaseAgent::trace(visitor); | 715 InspectorBaseAgent::trace(visitor); |
687 } | 716 } |
688 | 717 |
689 } // namespace blink | 718 } // namespace blink |
OLD | NEW |