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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert histograms.xml Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(scoped_cache->Get()); 468 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(scoped_cache->Get());
469 469
470 AXObjectImpl* inspected_ax_object = cache->GetOrCreate(dom_node); 470 AXObjectImpl* inspected_ax_object = cache->GetOrCreate(dom_node);
471 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); 471 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create();
472 if (!inspected_ax_object || inspected_ax_object->AccessibilityIsIgnored()) { 472 if (!inspected_ax_object || inspected_ax_object->AccessibilityIsIgnored()) {
473 (*nodes)->addItem(BuildObjectForIgnoredNode(dom_node, inspected_ax_object, 473 (*nodes)->addItem(BuildObjectForIgnoredNode(dom_node, inspected_ax_object,
474 fetch_relatives.fromMaybe(true), 474 fetch_relatives.fromMaybe(true),
475 *nodes, *cache)); 475 *nodes, *cache));
476 return Response::OK(); 476 return Response::OK();
477 } else { 477 } else {
478 (*nodes)->addItem( 478 (*nodes)->addItem(BuildProtocolAXObjectImpl(
479 BuildProtocolAXObject(*inspected_ax_object, inspected_ax_object, 479 *inspected_ax_object, inspected_ax_object,
480 fetch_relatives.fromMaybe(true), *nodes, *cache)); 480 fetch_relatives.fromMaybe(true), *nodes, *cache));
481 } 481 }
482 482
483 if (!inspected_ax_object) 483 if (!inspected_ax_object)
484 return Response::OK(); 484 return Response::OK();
485 485
486 AXObjectImpl* parent = inspected_ax_object->ParentObjectUnignored(); 486 AXObjectImpl* parent = inspected_ax_object->ParentObjectUnignored();
487 if (!parent) 487 if (!parent)
488 return Response::OK(); 488 return Response::OK();
489 489
490 if (fetch_relatives.fromMaybe(true)) 490 if (fetch_relatives.fromMaybe(true))
491 AddAncestors(*parent, inspected_ax_object, *nodes, *cache); 491 AddAncestors(*parent, inspected_ax_object, *nodes, *cache);
492 492
493 return Response::OK(); 493 return Response::OK();
494 } 494 }
495 495
496 void InspectorAccessibilityAgent::AddAncestors( 496 void InspectorAccessibilityAgent::AddAncestors(
497 AXObjectImpl& first_ancestor, 497 AXObjectImpl& first_ancestor,
498 AXObjectImpl* inspected_ax_object, 498 AXObjectImpl* inspected_ax_object,
499 std::unique_ptr<protocol::Array<AXNode>>& nodes, 499 std::unique_ptr<protocol::Array<AXNode>>& nodes,
500 AXObjectCacheImpl& cache) const { 500 AXObjectCacheImpl& cache) const {
501 AXObjectImpl* ancestor = &first_ancestor; 501 AXObjectImpl* ancestor = &first_ancestor;
502 while (ancestor) { 502 while (ancestor) {
503 nodes->addItem(BuildProtocolAXObject(*ancestor, inspected_ax_object, true, 503 nodes->addItem(BuildProtocolAXObjectImpl(*ancestor, inspected_ax_object,
504 nodes, cache)); 504 true, nodes, cache));
505 ancestor = ancestor->ParentObjectUnignored(); 505 ancestor = ancestor->ParentObjectUnignored();
506 } 506 }
507 } 507 }
508 508
509 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildObjectForIgnoredNode( 509 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildObjectForIgnoredNode(
510 Node* dom_node, 510 Node* dom_node,
511 AXObjectImpl* ax_object, 511 AXObjectImpl* ax_object,
512 bool fetch_relatives, 512 bool fetch_relatives,
513 std::unique_ptr<protocol::Array<AXNode>>& nodes, 513 std::unique_ptr<protocol::Array<AXNode>>& nodes,
514 AXObjectCacheImpl& cache) const { 514 AXObjectCacheImpl& cache) const {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 if (!parent_ax_object) 570 if (!parent_ax_object)
571 return; 571 return;
572 572
573 if (parent_ax_object->AccessibilityIsIgnored()) 573 if (parent_ax_object->AccessibilityIsIgnored())
574 parent_ax_object = parent_ax_object->ParentObjectUnignored(); 574 parent_ax_object = parent_ax_object->ParentObjectUnignored();
575 if (!parent_ax_object) 575 if (!parent_ax_object)
576 return; 576 return;
577 577
578 // Populate parent and ancestors. 578 // Populate parent and ancestors.
579 std::unique_ptr<AXNode> parent_node_object = 579 std::unique_ptr<AXNode> parent_node_object =
580 BuildProtocolAXObject(*parent_ax_object, nullptr, true, nodes, cache); 580 BuildProtocolAXObjectImpl(*parent_ax_object, nullptr, true, nodes, cache);
581 std::unique_ptr<protocol::Array<AXNodeId>> child_ids = 581 std::unique_ptr<protocol::Array<AXNodeId>> child_ids =
582 protocol::Array<AXNodeId>::create(); 582 protocol::Array<AXNodeId>::create();
583 child_ids->addItem(String::Number(kIDForInspectedNodeWithNoAXNode)); 583 child_ids->addItem(String::Number(kIDForInspectedNodeWithNoAXNode));
584 parent_node_object->setChildIds(std::move(child_ids)); 584 parent_node_object->setChildIds(std::move(child_ids));
585 nodes->addItem(std::move(parent_node_object)); 585 nodes->addItem(std::move(parent_node_object));
586 586
587 AXObjectImpl* grandparent_ax_object = 587 AXObjectImpl* grandparent_ax_object =
588 parent_ax_object->ParentObjectUnignored(); 588 parent_ax_object->ParentObjectUnignored();
589 if (grandparent_ax_object) 589 if (grandparent_ax_object)
590 AddAncestors(*grandparent_ax_object, nullptr, nodes, cache); 590 AddAncestors(*grandparent_ax_object, nullptr, nodes, cache);
591 } 591 }
592 592
593 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildProtocolAXObject( 593 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildProtocolAXObjectImpl(
594 AXObjectImpl& ax_object, 594 AXObjectImpl& ax_object,
595 AXObjectImpl* inspected_ax_object, 595 AXObjectImpl* inspected_ax_object,
596 bool fetch_relatives, 596 bool fetch_relatives,
597 std::unique_ptr<protocol::Array<AXNode>>& nodes, 597 std::unique_ptr<protocol::Array<AXNode>>& nodes,
598 AXObjectCacheImpl& cache) const { 598 AXObjectCacheImpl& cache) const {
599 AccessibilityRole role = ax_object.RoleValue(); 599 AccessibilityRole role = ax_object.RoleValue();
600 std::unique_ptr<AXNode> node_object = 600 std::unique_ptr<AXNode> node_object =
601 AXNode::create() 601 AXNode::create()
602 .setNodeId(String::Number(ax_object.AxObjectID())) 602 .setNodeId(String::Number(ax_object.AxObjectID()))
603 .setIgnored(false) 603 .setIgnored(false)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::AXObjectVector& 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 (ax_object.GetNode() || 728 if (!inspected_ax_object)
729 ax_object.ParentObjectUnignored() != inspected_ax_object)) { 729 continue;
730 continue; 730 if (&ax_object != inspected_ax_object->ParentObjectUnignored())
731 continue;
731 } 732 }
732 733
733 // Only add children of inspected node (or un-inspectable children of 734 // Only add children of inspected node (or un-inspectable children of
734 // inspected node) to returned nodes. 735 // inspected node) to returned nodes.
735 std::unique_ptr<AXNode> child_node = BuildProtocolAXObject( 736 std::unique_ptr<AXNode> child_node = BuildProtocolAXObjectImpl(
736 child_ax_object, inspected_ax_object, true, nodes, cache); 737 child_ax_object, inspected_ax_object, true, nodes, cache);
737 nodes->addItem(std::move(child_node)); 738 nodes->addItem(std::move(child_node));
738 } 739 }
739 } 740 }
740 741
741 DEFINE_TRACE(InspectorAccessibilityAgent) { 742 DEFINE_TRACE(InspectorAccessibilityAgent) {
742 visitor->Trace(page_); 743 visitor->Trace(page_);
743 visitor->Trace(dom_agent_); 744 visitor->Trace(dom_agent_);
744 InspectorBaseAgent::Trace(visitor); 745 InspectorBaseAgent::Trace(visitor);
745 } 746 }
746 747
747 } // namespace blink 748 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698