| 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 <memory> | 7 #include <memory> |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/dom/AXObjectCache.h" | 9 #include "core/dom/AXObjectCache.h" |
| 10 #include "core/dom/DOMNodeIds.h" | 10 #include "core/dom/DOMNodeIds.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( | 323 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( |
| 324 const String& key, | 324 const String& key, |
| 325 AXRelatedObjectVector& nodes) { | 325 AXRelatedObjectVector& nodes) { |
| 326 std::unique_ptr<AXValue> node_list_value = | 326 std::unique_ptr<AXValue> node_list_value = |
| 327 CreateRelatedNodeListValue(nodes, AXValueTypeEnum::NodeList); | 327 CreateRelatedNodeListValue(nodes, AXValueTypeEnum::NodeList); |
| 328 return CreateProperty(key, std::move(node_list_value)); | 328 return CreateProperty(key, std::move(node_list_value)); |
| 329 } | 329 } |
| 330 | 330 |
| 331 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( | 331 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( |
| 332 const String& key, | 332 const String& key, |
| 333 AXObjectImpl::AXObjectVector& nodes, | 333 AXObjectImpl::AXObjectImplVector& nodes, |
| 334 const QualifiedName& attr, | 334 const QualifiedName& attr, |
| 335 AXObjectImpl& ax_object) { | 335 AXObjectImpl& ax_object) { |
| 336 std::unique_ptr<AXValue> node_list_value = CreateRelatedNodeListValue(nodes); | 336 std::unique_ptr<AXValue> node_list_value = CreateRelatedNodeListValue(nodes); |
| 337 const AtomicString& attr_value = ax_object.GetAttribute(attr); | 337 const AtomicString& attr_value = ax_object.GetAttribute(attr); |
| 338 node_list_value->setValue(protocol::StringValue::create(attr_value)); | 338 node_list_value->setValue(protocol::StringValue::create(attr_value)); |
| 339 return CreateProperty(key, std::move(node_list_value)); | 339 return CreateProperty(key, std::move(node_list_value)); |
| 340 } | 340 } |
| 341 | 341 |
| 342 class SparseAttributeAXPropertyAdapter | 342 class SparseAttributeAXPropertyAdapter |
| 343 : public GarbageCollected<SparseAttributeAXPropertyAdapter>, | 343 : public GarbageCollected<SparseAttributeAXPropertyAdapter>, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 properties_.addItem(CreateRelatedNodeListProperty( | 404 properties_.addItem(CreateRelatedNodeListProperty( |
| 405 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, | 405 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, |
| 406 *ax_object_)); | 406 *ax_object_)); |
| 407 break; | 407 break; |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 void FillRelationships(AXObjectImpl& ax_object, | 412 void FillRelationships(AXObjectImpl& ax_object, |
| 413 protocol::Array<AXProperty>& properties) { | 413 protocol::Array<AXProperty>& properties) { |
| 414 AXObjectImpl::AXObjectVector results; | 414 AXObjectImpl::AXObjectImplVector results; |
| 415 ax_object.AriaDescribedbyElements(results); | 415 ax_object.AriaDescribedbyElements(results); |
| 416 if (!results.IsEmpty()) | 416 if (!results.IsEmpty()) |
| 417 properties.addItem(CreateRelatedNodeListProperty( | 417 properties.addItem(CreateRelatedNodeListProperty( |
| 418 AXRelationshipAttributesEnum::Describedby, results, | 418 AXRelationshipAttributesEnum::Describedby, results, |
| 419 aria_describedbyAttr, ax_object)); | 419 aria_describedbyAttr, ax_object)); |
| 420 results.clear(); | 420 results.clear(); |
| 421 | 421 |
| 422 ax_object.AriaOwnsElements(results); | 422 ax_object.AriaOwnsElements(results); |
| 423 if (!results.IsEmpty()) | 423 if (!results.IsEmpty()) |
| 424 properties.addItem(CreateRelatedNodeListProperty( | 424 properties.addItem(CreateRelatedNodeListProperty( |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 } | 648 } |
| 649 | 649 |
| 650 void InspectorAccessibilityAgent::FillCoreProperties( | 650 void InspectorAccessibilityAgent::FillCoreProperties( |
| 651 AXObjectImpl& ax_object, | 651 AXObjectImpl& ax_object, |
| 652 AXObjectImpl* inspected_ax_object, | 652 AXObjectImpl* inspected_ax_object, |
| 653 bool fetch_relatives, | 653 bool fetch_relatives, |
| 654 AXNode& node_object, | 654 AXNode& node_object, |
| 655 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 655 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 656 AXObjectCacheImpl& cache) const { | 656 AXObjectCacheImpl& cache) const { |
| 657 AXNameFrom name_from; | 657 AXNameFrom name_from; |
| 658 AXObjectImpl::AXObjectVector name_objects; | 658 AXObjectImpl::AXObjectImplVector name_objects; |
| 659 ax_object.GetName(name_from, &name_objects); | 659 ax_object.GetName(name_from, &name_objects); |
| 660 | 660 |
| 661 AXDescriptionFrom description_from; | 661 AXDescriptionFrom description_from; |
| 662 AXObjectImpl::AXObjectVector description_objects; | 662 AXObjectImpl::AXObjectImplVector description_objects; |
| 663 String description = | 663 String description = |
| 664 ax_object.Description(name_from, description_from, &description_objects); | 664 ax_object.Description(name_from, description_from, &description_objects); |
| 665 if (!description.IsEmpty()) { | 665 if (!description.IsEmpty()) { |
| 666 node_object.setDescription( | 666 node_object.setDescription( |
| 667 CreateValue(description, AXValueTypeEnum::ComputedString)); | 667 CreateValue(description, AXValueTypeEnum::ComputedString)); |
| 668 } | 668 } |
| 669 // Value. | 669 // Value. |
| 670 if (ax_object.SupportsRangeValue()) { | 670 if (ax_object.SupportsRangeValue()) { |
| 671 node_object.setValue(CreateValue(ax_object.ValueForRange())); | 671 node_object.setValue(CreateValue(ax_object.ValueForRange())); |
| 672 } else { | 672 } else { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 AXObjectImpl* inspected_ax_object, | 711 AXObjectImpl* inspected_ax_object, |
| 712 std::unique_ptr<protocol::Array<AXNodeId>>& child_ids, | 712 std::unique_ptr<protocol::Array<AXNodeId>>& child_ids, |
| 713 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 713 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 714 AXObjectCacheImpl& cache) const { | 714 AXObjectCacheImpl& cache) const { |
| 715 if (inspected_ax_object && inspected_ax_object->AccessibilityIsIgnored() && | 715 if (inspected_ax_object && inspected_ax_object->AccessibilityIsIgnored() && |
| 716 &ax_object == inspected_ax_object->ParentObjectUnignored()) { | 716 &ax_object == inspected_ax_object->ParentObjectUnignored()) { |
| 717 child_ids->addItem(String::Number(inspected_ax_object->AxObjectID())); | 717 child_ids->addItem(String::Number(inspected_ax_object->AxObjectID())); |
| 718 return; | 718 return; |
| 719 } | 719 } |
| 720 | 720 |
| 721 const AXObjectImpl::AXObjectVector& children = ax_object.Children(); | 721 const AXObjectImpl::AXObjectImplVector& children = ax_object.Children(); |
| 722 for (unsigned i = 0; i < children.size(); i++) { | 722 for (unsigned i = 0; i < children.size(); i++) { |
| 723 AXObjectImpl& child_ax_object = *children[i].Get(); | 723 AXObjectImpl& child_ax_object = *children[i].Get(); |
| 724 child_ids->addItem(String::Number(child_ax_object.AxObjectID())); | 724 child_ids->addItem(String::Number(child_ax_object.AxObjectID())); |
| 725 if (&child_ax_object == inspected_ax_object) | 725 if (&child_ax_object == inspected_ax_object) |
| 726 continue; | 726 continue; |
| 727 if (&ax_object != inspected_ax_object) { | 727 if (&ax_object != inspected_ax_object) { |
| 728 if (!inspected_ax_object) | 728 if (!inspected_ax_object) |
| 729 continue; | 729 continue; |
| 730 if (&ax_object != inspected_ax_object->ParentObjectUnignored()) | 730 if (&ax_object != inspected_ax_object->ParentObjectUnignored()) |
| 731 continue; | 731 continue; |
| 732 } | 732 } |
| 733 | 733 |
| 734 // Only add children of inspected node (or un-inspectable children of | 734 // Only add children of inspected node (or un-inspectable children of |
| 735 // inspected node) to returned nodes. | 735 // inspected node) to returned nodes. |
| 736 std::unique_ptr<AXNode> child_node = BuildProtocolAXObjectImpl( | 736 std::unique_ptr<AXNode> child_node = BuildProtocolAXObjectImpl( |
| 737 child_ax_object, inspected_ax_object, true, nodes, cache); | 737 child_ax_object, inspected_ax_object, true, nodes, cache); |
| 738 nodes->addItem(std::move(child_node)); | 738 nodes->addItem(std::move(child_node)); |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 | 741 |
| 742 DEFINE_TRACE(InspectorAccessibilityAgent) { | 742 DEFINE_TRACE(InspectorAccessibilityAgent) { |
| 743 visitor->Trace(page_); | 743 visitor->Trace(page_); |
| 744 visitor->Trace(dom_agent_); | 744 visitor->Trace(dom_agent_); |
| 745 InspectorBaseAgent::Trace(visitor); | 745 InspectorBaseAgent::Trace(visitor); |
| 746 } | 746 } |
| 747 | 747 |
| 748 } // namespace blink | 748 } // namespace blink |
| OLD | NEW |