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

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

Issue 2390783006: [DevTools] Accessibility: Show siblings and children of selected node (Closed)
Patch Set: Handle indirect children better Created 4 years, 1 month 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 "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 20 matching lines...) Expand all
31 using protocol::Accessibility::AXRelatedNode; 31 using protocol::Accessibility::AXRelatedNode;
32 using protocol::Accessibility::AXRelationshipAttributes; 32 using protocol::Accessibility::AXRelationshipAttributes;
33 using protocol::Accessibility::AXValue; 33 using protocol::Accessibility::AXValue;
34 using protocol::Accessibility::AXWidgetAttributes; 34 using protocol::Accessibility::AXWidgetAttributes;
35 using protocol::Accessibility::AXWidgetStates; 35 using protocol::Accessibility::AXWidgetStates;
36 36
37 using namespace HTMLNames; 37 using namespace HTMLNames;
38 38
39 namespace { 39 namespace {
40 40
41 static const AXID kIDForInspectedNodeWithNoAXNode = 0;
42
41 void fillLiveRegionProperties(AXObject& axObject, 43 void fillLiveRegionProperties(AXObject& axObject,
42 protocol::Array<AXProperty>& properties) { 44 protocol::Array<AXProperty>& properties) {
43 if (!axObject.liveRegionRoot()) 45 if (!axObject.liveRegionRoot())
44 return; 46 return;
45 47
46 properties.addItem( 48 properties.addItem(
47 createProperty(AXLiveRegionAttributesEnum::Live, 49 createProperty(AXLiveRegionAttributesEnum::Live,
48 createValue(axObject.containerLiveRegionStatus(), 50 createValue(axObject.containerLiveRegionStatus(),
49 AXValueTypeEnum::Token))); 51 AXValueTypeEnum::Token)));
50 properties.addItem( 52 properties.addItem(
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 std::unique_ptr<AXValue> roleNameValue; 368 std::unique_ptr<AXValue> roleNameValue;
367 if (!roleName.isNull()) { 369 if (!roleName.isNull()) {
368 roleNameValue = createValue(roleName, AXValueTypeEnum::Role); 370 roleNameValue = createValue(roleName, AXValueTypeEnum::Role);
369 } else { 371 } else {
370 roleNameValue = createValue(AXObject::internalRoleName(role), 372 roleNameValue = createValue(AXObject::internalRoleName(role),
371 AXValueTypeEnum::InternalRole); 373 AXValueTypeEnum::InternalRole);
372 } 374 }
373 return roleNameValue; 375 return roleNameValue;
374 } 376 }
375 377
378 bool isAncestorOf(AXObject* possibleAncestor, AXObject* descendant) {
379 if (!possibleAncestor || !descendant)
380 return false;
381
382 AXObject* ancestor = descendant;
383 while (ancestor) {
384 if (ancestor == possibleAncestor)
385 return true;
386 ancestor = ancestor->parentObject();
387 }
388 return false;
389 }
390
376 } // namespace 391 } // namespace
377 392
378 InspectorAccessibilityAgent::InspectorAccessibilityAgent( 393 InspectorAccessibilityAgent::InspectorAccessibilityAgent(
379 Page* page, 394 Page* page,
380 InspectorDOMAgent* domAgent) 395 InspectorDOMAgent* domAgent)
381 : m_page(page), m_domAgent(domAgent) {} 396 : m_page(page), m_domAgent(domAgent) {}
382 397
383 void InspectorAccessibilityAgent::getAXNodeChain( 398 void InspectorAccessibilityAgent::getPartialAXTree(
384 ErrorString* errorString, 399 ErrorString* errorString,
385 int domNodeId, 400 int domNodeId,
386 bool fetchAncestors, 401 const Maybe<bool>& fetchRelatives,
387 std::unique_ptr<protocol::Array<protocol::Accessibility::AXNode>>* nodes) { 402 std::unique_ptr<protocol::Array<AXNode>>* nodes) {
388 if (!m_domAgent->enabled()) { 403 if (!m_domAgent->enabled()) {
389 *errorString = "DOM agent must be enabled"; 404 *errorString = "DOM agent must be enabled";
390 return; 405 return;
391 } 406 }
392 Node* domNode = m_domAgent->assertNode(errorString, domNodeId); 407 Node* domNode = m_domAgent->assertNode(errorString, domNodeId);
393 if (!domNode) 408 if (!domNode)
394 return; 409 return;
395 410
396 Document& document = domNode->document(); 411 Document& document = domNode->document();
397 document.updateStyleAndLayoutIgnorePendingStylesheets(); 412 document.updateStyleAndLayoutIgnorePendingStylesheets();
398 DocumentLifecycle::DisallowTransitionScope disallowTransition( 413 DocumentLifecycle::DisallowTransitionScope disallowTransition(
399 document.lifecycle()); 414 document.lifecycle());
400 LocalFrame* localFrame = document.frame(); 415 LocalFrame* localFrame = document.frame();
401 if (!localFrame) { 416 if (!localFrame) {
402 *errorString = "Frame is detached."; 417 *errorString = "Frame is detached.";
403 return; 418 return;
404 } 419 }
405 std::unique_ptr<ScopedAXObjectCache> scopedCache = 420 std::unique_ptr<ScopedAXObjectCache> scopedCache =
406 ScopedAXObjectCache::create(document); 421 ScopedAXObjectCache::create(document);
407 AXObjectCacheImpl* cache = toAXObjectCacheImpl(scopedCache->get()); 422 AXObjectCacheImpl* cache = toAXObjectCacheImpl(scopedCache->get());
408 423
409 AXObject* inspectedAXObject = cache->getOrCreate(domNode); 424 AXObject* inspectedAXObject = cache->getOrCreate(domNode);
410 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); 425 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create();
426 bool justFetchRelatives = true;
427 if (fetchRelatives.isJust())
428 justFetchRelatives = fetchRelatives.fromJust();
411 if (!inspectedAXObject || inspectedAXObject->accessibilityIsIgnored()) { 429 if (!inspectedAXObject || inspectedAXObject->accessibilityIsIgnored()) {
412 (*nodes)->addItem(buildObjectForIgnoredNode(domNode, inspectedAXObject)); 430 (*nodes)->addItem(buildObjectForIgnoredNode(
431 domNode, inspectedAXObject, justFetchRelatives, *nodes, *cache));
dgozman 2016/10/31 21:36:31 fetchRelatives.fromMaybe(true) would be easier.
aboxhall 2016/10/31 22:45:15 Thanks, done!
413 } else { 432 } else {
414 (*nodes)->addItem(buildProtocolAXObject(*inspectedAXObject)); 433 (*nodes)->addItem(
434 buildProtocolAXObject(*inspectedAXObject, inspectedAXObject,
435 justFetchRelatives, *nodes, *cache));
415 } 436 }
416 437
417 if (fetchAncestors && inspectedAXObject) { 438 if (!inspectedAXObject || !inspectedAXObject->isAXLayoutObject())
418 AXObject* parent = inspectedAXObject->parentObjectUnignored(); 439 return;
419 while (parent) { 440
420 (*nodes)->addItem(buildProtocolAXObject(*parent)); 441 AXObject* parent = inspectedAXObject->parentObjectUnignored();
421 parent = parent->parentObjectUnignored(); 442 if (!parent)
422 } 443 return;
444
445 if (justFetchRelatives)
446 addAncestors(*parent, inspectedAXObject, *nodes, *cache);
447 }
448
449 void InspectorAccessibilityAgent::addAncestors(
450 AXObject& firstAncestor,
451 AXObject* inspectedAXObject,
452 std::unique_ptr<protocol::Array<AXNode>>& nodes,
453 AXObjectCacheImpl& cache) const {
454 AXObject* ancestor = &firstAncestor;
455 while (ancestor) {
456 nodes->addItem(buildProtocolAXObject(*ancestor, inspectedAXObject, true,
457 nodes, cache));
458 ancestor = ancestor->parentObjectUnignored();
423 } 459 }
424 } 460 }
425 461
426 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildObjectForIgnoredNode( 462 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildObjectForIgnoredNode(
427 Node* domNode, 463 Node* domNode,
428 AXObject* axObject) const { 464 AXObject* axObject,
465 bool fetchRelatives,
466 std::unique_ptr<protocol::Array<AXNode>>& nodes,
467 AXObjectCacheImpl& cache) const {
429 AXObject::IgnoredReasons ignoredReasons; 468 AXObject::IgnoredReasons ignoredReasons;
430 469
431 AXID axID = 0; 470 AXID axID = kIDForInspectedNodeWithNoAXNode;
432 if (axObject) 471 if (axObject && axObject->isAXLayoutObject())
433 axID = axObject->axObjectID(); 472 axID = axObject->axObjectID();
434 std::unique_ptr<AXNode> ignoredNodeObject = 473 std::unique_ptr<AXNode> ignoredNodeObject =
435 AXNode::create().setNodeId(String::number(axID)).setIgnored(true).build(); 474 AXNode::create().setNodeId(String::number(axID)).setIgnored(true).build();
436 if (axObject) { 475 AccessibilityRole role = AccessibilityRole::IgnoredRole;
476 ignoredNodeObject->setRole(createRoleNameValue(role));
477
478 if (axObject && axObject->isAXLayoutObject()) {
437 axObject->computeAccessibilityIsIgnored(&ignoredReasons); 479 axObject->computeAccessibilityIsIgnored(&ignoredReasons);
438 axID = axObject->axObjectID(); 480
439 AccessibilityRole role = axObject->roleValue(); 481 if (fetchRelatives) {
440 ignoredNodeObject->setRole(createRoleNameValue(role)); 482 populateRelatives(*axObject, axObject, *(ignoredNodeObject.get()), nodes,
483 cache);
484 }
441 } else if (domNode && !domNode->layoutObject()) { 485 } else if (domNode && !domNode->layoutObject()) {
486 if (fetchRelatives) {
487 populateDOMNodeRelatives(*domNode, *(ignoredNodeObject.get()), nodes,
488 cache);
489 }
442 ignoredReasons.append(IgnoredReason(AXNotRendered)); 490 ignoredReasons.append(IgnoredReason(AXNotRendered));
443 } 491 }
444 492
493 if (domNode)
494 ignoredNodeObject->setBackendDomNodeId(DOMNodeIds::idForNode(domNode));
495
445 std::unique_ptr<protocol::Array<AXProperty>> ignoredReasonProperties = 496 std::unique_ptr<protocol::Array<AXProperty>> ignoredReasonProperties =
446 protocol::Array<AXProperty>::create(); 497 protocol::Array<AXProperty>::create();
447 for (size_t i = 0; i < ignoredReasons.size(); i++) 498 for (size_t i = 0; i < ignoredReasons.size(); i++)
448 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i])); 499 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i]));
449 ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties)); 500 ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties));
450 501
451 return ignoredNodeObject; 502 return ignoredNodeObject;
452 } 503 }
453 504
505 void InspectorAccessibilityAgent::populateDOMNodeRelatives(
506 Node& inspectedDOMNode,
507 AXNode& nodeObject,
508 std::unique_ptr<protocol::Array<AXNode>>& nodes,
509 AXObjectCacheImpl& cache) const {
510 // Walk up parents until an AXObject can be found.
511 Node* parentNode = FlatTreeTraversal::parent(inspectedDOMNode);
512 AXObject* parentAXObject = cache.getOrCreate(parentNode);
513 while (!parentAXObject) {
dgozman 2016/10/31 21:36:31 while (parentNode && !parentAXObject)
aboxhall 2016/10/31 22:45:15 Done.
514 parentNode = FlatTreeTraversal::parent(inspectedDOMNode);
515 parentAXObject = cache.getOrCreate(parentNode);
516 };
517 if (parentAXObject) {
518 if (parentAXObject->accessibilityIsIgnored())
519 parentAXObject = parentAXObject->parentObjectUnignored();
520 // Populate parent, ancestors and siblings.
521 nodeObject.setParentId(String::number(parentAXObject->axObjectID()));
522 std::unique_ptr<AXNode> parentNodeObject =
523 buildProtocolAXObject(*parentAXObject, nullptr, true, nodes, cache);
524 std::unique_ptr<protocol::Array<AXNodeId>> siblingIds =
525 protocol::Array<AXNodeId>::create();
526 findDOMNodeChildren(siblingIds, *parentNode, *parentNode, inspectedDOMNode,
527 nodes, cache);
528 parentNodeObject->setChildIds(std::move(siblingIds));
529 nodes->addItem(std::move(parentNodeObject));
530
531 AXObject* grandparentAXObject = parentAXObject->parentObjectUnignored();
532 if (grandparentAXObject)
533 addAncestors(*grandparentAXObject, nullptr, nodes, cache);
534 }
535
536 // Then populate children.
537 std::unique_ptr<protocol::Array<AXNodeId>> childIds =
538 protocol::Array<AXNodeId>::create();
539 findDOMNodeChildren(childIds, inspectedDOMNode, inspectedDOMNode,
540 inspectedDOMNode, nodes, cache);
541 nodeObject.setChildIds(std::move(childIds));
542 }
543
544 void InspectorAccessibilityAgent::findDOMNodeChildren(
545 std::unique_ptr<protocol::Array<AXNodeId>>& childIds,
546 Node& parentNode,
547 Node& treeParentNode,
548 Node& inspectedDOMNode,
549 std::unique_ptr<protocol::Array<AXNode>>& nodes,
550 AXObjectCacheImpl& cache) const {
551 NodeList* childNodes = parentNode.childNodes();
552 for (size_t i = 0; i < childNodes->length(); ++i) {
553 Node* childNode = childNodes->item(i);
554 if (childNode == &inspectedDOMNode) {
555 childIds->addItem(String::number(kIDForInspectedNodeWithNoAXNode));
556 continue;
557 }
558
559 AXObject* childAXObject = cache.getOrCreate(childNode);
560 if (childAXObject) {
561 if (childAXObject->accessibilityIsIgnored()) {
562 // search for un-ignored descendants
563 findDOMNodeChildren(childIds, *childNode, parentNode, inspectedDOMNode,
564 nodes, cache);
565 } else {
566 if (&treeParentNode == &inspectedDOMNode) {
567 childIds->addItem(String::number(childAXObject->axObjectID()));
568 std::unique_ptr<AXNode> childNode = buildProtocolAXObject(
569 *childAXObject, nullptr, true, nodes, cache);
570 childNode->setParentId(
571 String::number(kIDForInspectedNodeWithNoAXNode));
572 nodes->addItem(std::move(childNode));
573 } else {
574 addChild(childIds, *childAXObject, nullptr, nodes, cache);
575 }
576 }
577
578 continue;
579 }
580
581 if (!childAXObject ||
582 childNode->isShadowIncludingInclusiveAncestorOf(&inspectedDOMNode)) {
583 // If the inspected node may be a descendant of this node, keep walking
584 // recursively until we find its actual siblings.
585 findDOMNodeChildren(childIds, *childNode, parentNode, inspectedDOMNode,
586 nodes, cache);
587 continue;
588 }
589
590 // Otherwise, just add the un-ignored children.
591 const AXObject::AXObjectVector& indirectChildren =
592 childAXObject->children();
593 for (unsigned i = 0; i < indirectChildren.size(); ++i)
594 addChild(childIds, *(indirectChildren[i]), nullptr, nodes, cache);
595 }
596 }
597
454 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject( 598 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject(
455 AXObject& axObject) const { 599 AXObject& axObject,
600 AXObject* inspectedAXObject,
601 bool fetchRelatives,
602 std::unique_ptr<protocol::Array<AXNode>>& nodes,
603 AXObjectCacheImpl& cache) const {
456 AccessibilityRole role = axObject.roleValue(); 604 AccessibilityRole role = axObject.roleValue();
457 std::unique_ptr<AXNode> nodeObject = 605 std::unique_ptr<AXNode> nodeObject =
458 AXNode::create() 606 AXNode::create()
459 .setNodeId(String::number(axObject.axObjectID())) 607 .setNodeId(String::number(axObject.axObjectID()))
460 .setIgnored(false) 608 .setIgnored(false)
461 .build(); 609 .build();
462 nodeObject->setRole(createRoleNameValue(role)); 610 nodeObject->setRole(createRoleNameValue(role));
463 611
464 std::unique_ptr<protocol::Array<AXProperty>> properties = 612 std::unique_ptr<protocol::Array<AXProperty>> properties =
465 protocol::Array<AXProperty>::create(); 613 protocol::Array<AXProperty>::create();
(...skipping 23 matching lines...) Expand all
489 } 637 }
490 } 638 }
491 name->setSources(std::move(nameSourceProperties)); 639 name->setSources(std::move(nameSourceProperties));
492 } 640 }
493 nodeObject->setProperties(std::move(properties)); 641 nodeObject->setProperties(std::move(properties));
494 nodeObject->setName(std::move(name)); 642 nodeObject->setName(std::move(name));
495 } else { 643 } else {
496 nodeObject->setProperties(std::move(properties)); 644 nodeObject->setProperties(std::move(properties));
497 } 645 }
498 646
499 fillCoreProperties(axObject, *(nodeObject.get())); 647 fillCoreProperties(axObject, inspectedAXObject, fetchRelatives,
648 *(nodeObject.get()), nodes, cache);
500 return nodeObject; 649 return nodeObject;
501 } 650 }
502 651
503 void InspectorAccessibilityAgent::fillCoreProperties(AXObject& axObject, 652 void InspectorAccessibilityAgent::fillCoreProperties(
504 AXNode& nodeObject) const { 653 AXObject& axObject,
654 AXObject* inspectedAXObject,
655 bool fetchRelatives,
656 AXNode& nodeObject,
657 std::unique_ptr<protocol::Array<AXNode>>& nodes,
658 AXObjectCacheImpl& cache) const {
505 AXNameFrom nameFrom; 659 AXNameFrom nameFrom;
506 AXObject::AXObjectVector nameObjects; 660 AXObject::AXObjectVector nameObjects;
507 axObject.name(nameFrom, &nameObjects); 661 axObject.name(nameFrom, &nameObjects);
508 662
509 AXDescriptionFrom descriptionFrom; 663 AXDescriptionFrom descriptionFrom;
510 AXObject::AXObjectVector descriptionObjects; 664 AXObject::AXObjectVector descriptionObjects;
511 String description = 665 String description =
512 axObject.description(nameFrom, descriptionFrom, &descriptionObjects); 666 axObject.description(nameFrom, descriptionFrom, &descriptionObjects);
513 if (!description.isEmpty()) { 667 if (!description.isEmpty()) {
514 nodeObject.setDescription( 668 nodeObject.setDescription(
515 createValue(description, AXValueTypeEnum::ComputedString)); 669 createValue(description, AXValueTypeEnum::ComputedString));
516 } 670 }
517 // Value. 671 // Value.
518 if (axObject.supportsRangeValue()) { 672 if (axObject.supportsRangeValue()) {
519 nodeObject.setValue(createValue(axObject.valueForRange())); 673 nodeObject.setValue(createValue(axObject.valueForRange()));
520 } else { 674 } else {
521 String stringValue = axObject.stringValue(); 675 String stringValue = axObject.stringValue();
522 if (!stringValue.isEmpty()) 676 if (!stringValue.isEmpty())
523 nodeObject.setValue(createValue(stringValue)); 677 nodeObject.setValue(createValue(stringValue));
524 } 678 }
679
680 if (fetchRelatives)
681 populateRelatives(axObject, inspectedAXObject, nodeObject, nodes, cache);
682
683 Node* node = axObject.getNode();
684 if (node)
685 nodeObject.setBackendDomNodeId(DOMNodeIds::idForNode(node));
686 }
687
688 void InspectorAccessibilityAgent::populateRelatives(
689 AXObject& axObject,
690 AXObject* inspectedAXObject,
691 AXNode& nodeObject,
692 std::unique_ptr<protocol::Array<AXNode>>& nodes,
693 AXObjectCacheImpl& cache) const {
694 AXObject* parentObject = axObject.parentObject();
695 if (parentObject && parentObject != inspectedAXObject) {
696 // Use unignored parent unless parent is inspected ignored object.
697 parentObject = axObject.parentObjectUnignored();
698 }
699 if (parentObject)
700 nodeObject.setParentId(String::number(parentObject->axObjectID()));
701
702 std::unique_ptr<protocol::Array<AXNodeId>> childIds =
703 protocol::Array<AXNodeId>::create();
704 if (!inspectedAXObject) {
705 // If there is no AXObject for the inspected node, the caller will populate
706 // its relatives.
707 return;
708 }
709
710 if (&axObject == inspectedAXObject->parentObjectUnignored() &&
711 inspectedAXObject->accessibilityIsIgnored()) {
712 // This is the parent of an ignored object, so search for its siblings.
713 addSiblingsOfIgnored(childIds, axObject, inspectedAXObject, nodes, cache);
714 } else {
715 addChildren(axObject, *inspectedAXObject, childIds, nodes, cache);
716 }
717 nodeObject.setChildIds(std::move(childIds));
718 }
719
720 void InspectorAccessibilityAgent::addSiblingsOfIgnored(
721 std::unique_ptr<protocol::Array<AXNodeId>>& childIds,
722 AXObject& parentAXObject,
723 AXObject* inspectedAXObject,
724 std::unique_ptr<protocol::Array<AXNode>>& nodes,
725 AXObjectCacheImpl& cache) const {
726 for (AXObject* childAXObject = parentAXObject.rawFirstChild(); childAXObject;
727 childAXObject = childAXObject->rawNextSibling()) {
728 if (!childAXObject->accessibilityIsIgnored() ||
729 childAXObject == inspectedAXObject) {
730 addChild(childIds, *childAXObject, inspectedAXObject, nodes, cache);
731 continue;
732 }
733
734 if (isAncestorOf(childAXObject, inspectedAXObject)) {
735 addSiblingsOfIgnored(childIds, *childAXObject, inspectedAXObject, nodes,
736 cache);
737 continue;
738 }
739
740 const AXObject::AXObjectVector& indirectChildren =
741 childAXObject->children();
742 for (unsigned i = 0; i < indirectChildren.size(); ++i) {
743 addChild(childIds, *(indirectChildren[i]), inspectedAXObject, nodes,
744 cache);
745 }
746 }
747 }
748
749 void InspectorAccessibilityAgent::addChild(
750 std::unique_ptr<protocol::Array<AXNodeId>>& childIds,
751 AXObject& childAXObject,
752 AXObject* inspectedAXObject,
753 std::unique_ptr<protocol::Array<AXNode>>& nodes,
754 AXObjectCacheImpl& cache) const {
755 childIds->addItem(String::number(childAXObject.axObjectID()));
756 if (&childAXObject == inspectedAXObject)
757 return;
758 nodes->addItem(buildProtocolAXObject(childAXObject, inspectedAXObject, true,
759 nodes, cache));
760 }
761
762 void InspectorAccessibilityAgent::addChildren(
763 AXObject& axObject,
764 AXObject& inspectedAXObject,
765 std::unique_ptr<protocol::Array<AXNodeId>>& childIds,
766 std::unique_ptr<protocol::Array<AXNode>>& nodes,
767 AXObjectCacheImpl& cache) const {
768 const AXObject::AXObjectVector& children = axObject.children();
769 for (unsigned i = 0; i < children.size(); i++) {
770 AXObject& childAXObject = *children[i].get();
771 childIds->addItem(String::number(childAXObject.axObjectID()));
772 if (&childAXObject != &inspectedAXObject &&
773 (&axObject == &inspectedAXObject ||
774 &axObject == inspectedAXObject.parentObjectUnignored())) {
775 // Only add children/siblings of inspected node to returned nodes.
776 std::unique_ptr<AXNode> childNode = buildProtocolAXObject(
777 childAXObject, &inspectedAXObject, true, nodes, cache);
778 // If the inspected node is ignored, the default parent ID will be the
779 // unignored parent.
780 if (axObject.accessibilityIsIgnored())
781 childNode->setParentId(String::number(axObject.axObjectID()));
782 nodes->addItem(std::move(childNode));
783 }
784 }
525 } 785 }
526 786
527 DEFINE_TRACE(InspectorAccessibilityAgent) { 787 DEFINE_TRACE(InspectorAccessibilityAgent) {
528 visitor->trace(m_page); 788 visitor->trace(m_page);
529 visitor->trace(m_domAgent); 789 visitor->trace(m_domAgent);
530 InspectorBaseAgent::trace(visitor); 790 InspectorBaseAgent::trace(visitor);
531 } 791 }
532 792
533 } // namespace blink 793 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698