Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 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 double 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 Loading... | |
| 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 std::unique_ptr<protocol::Array<AXNode>>* nodes) { |
| 387 std::unique_ptr<protocol::Array<protocol::Accessibility::AXNode>>* nodes) { | |
| 388 if (!m_domAgent->enabled()) { | 402 if (!m_domAgent->enabled()) { |
| 389 *errorString = "DOM agent must be enabled"; | 403 *errorString = "DOM agent must be enabled"; |
| 390 return; | 404 return; |
| 391 } | 405 } |
| 392 Node* domNode = m_domAgent->assertNode(errorString, domNodeId); | 406 Node* domNode = m_domAgent->assertNode(errorString, domNodeId); |
| 393 if (!domNode) | 407 if (!domNode) |
| 394 return; | 408 return; |
| 395 | 409 |
| 396 Document& document = domNode->document(); | 410 Document& document = domNode->document(); |
| 397 document.updateStyleAndLayoutIgnorePendingStylesheets(); | 411 document.updateStyleAndLayoutIgnorePendingStylesheets(); |
| 398 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 412 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
| 399 document.lifecycle()); | 413 document.lifecycle()); |
| 400 LocalFrame* localFrame = document.frame(); | 414 LocalFrame* localFrame = document.frame(); |
| 401 if (!localFrame) { | 415 if (!localFrame) { |
| 402 *errorString = "Frame is detached."; | 416 *errorString = "Frame is detached."; |
| 403 return; | 417 return; |
| 404 } | 418 } |
| 405 std::unique_ptr<ScopedAXObjectCache> scopedCache = | 419 std::unique_ptr<ScopedAXObjectCache> scopedCache = |
| 406 ScopedAXObjectCache::create(document); | 420 ScopedAXObjectCache::create(document); |
| 407 AXObjectCacheImpl* cache = toAXObjectCacheImpl(scopedCache->get()); | 421 AXObjectCacheImpl* cache = toAXObjectCacheImpl(scopedCache->get()); |
| 408 | 422 |
| 409 AXObject* inspectedAXObject = cache->getOrCreate(domNode); | 423 AXObject* inspectedAXObject = cache->getOrCreate(domNode); |
| 410 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); | 424 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); |
| 411 if (!inspectedAXObject || inspectedAXObject->accessibilityIsIgnored()) { | 425 if (!inspectedAXObject || inspectedAXObject->accessibilityIsIgnored()) { |
| 412 (*nodes)->addItem(buildObjectForIgnoredNode(domNode, inspectedAXObject)); | 426 (*nodes)->addItem( |
| 427 buildObjectForIgnoredNode(domNode, inspectedAXObject, *nodes, *cache)); | |
| 413 } else { | 428 } else { |
| 414 (*nodes)->addItem(buildProtocolAXObject(*inspectedAXObject)); | 429 (*nodes)->addItem(buildProtocolAXObject(*inspectedAXObject, |
| 430 inspectedAXObject, *nodes, *cache)); | |
| 415 } | 431 } |
| 416 | 432 |
| 417 if (fetchAncestors && inspectedAXObject) { | 433 if (!inspectedAXObject) |
| 418 AXObject* parent = inspectedAXObject->parentObjectUnignored(); | 434 return; |
| 419 while (parent) { | 435 |
| 420 (*nodes)->addItem(buildProtocolAXObject(*parent)); | 436 AXObject* parent = inspectedAXObject->parentObjectUnignored(); |
| 421 parent = parent->parentObjectUnignored(); | 437 if (!parent) |
| 422 } | 438 return; |
| 439 | |
| 440 addAncestors(*parent, inspectedAXObject, *nodes, *cache); | |
| 441 } | |
| 442 | |
| 443 void InspectorAccessibilityAgent::addAncestors( | |
| 444 AXObject& firstAncestor, | |
| 445 AXObject* inspectedAXObject, | |
| 446 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 447 AXObjectCacheImpl& cache) const { | |
| 448 AXObject* ancestor = &firstAncestor; | |
| 449 while (ancestor) { | |
| 450 nodes->addItem( | |
| 451 buildProtocolAXObject(*ancestor, inspectedAXObject, nodes, cache)); | |
| 452 ancestor = ancestor->parentObjectUnignored(); | |
| 423 } | 453 } |
| 424 } | 454 } |
| 425 | 455 |
| 426 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildObjectForIgnoredNode( | 456 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildObjectForIgnoredNode( |
| 427 Node* domNode, | 457 Node* domNode, |
| 428 AXObject* axObject) const { | 458 AXObject* axObject, |
| 459 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 460 AXObjectCacheImpl& cache) const { | |
| 429 AXObject::IgnoredReasons ignoredReasons; | 461 AXObject::IgnoredReasons ignoredReasons; |
| 430 | 462 |
| 431 AXID axID = 0; | 463 AXID axID = kIDForInspectedNodeWithNoAXNode; |
| 432 if (axObject) | 464 if (axObject) |
| 433 axID = axObject->axObjectID(); | 465 axID = axObject->axObjectID(); |
| 434 std::unique_ptr<AXNode> ignoredNodeObject = | 466 std::unique_ptr<AXNode> ignoredNodeObject = |
| 435 AXNode::create().setNodeId(String::number(axID)).setIgnored(true).build(); | 467 AXNode::create().setNodeId(String::number(axID)).setIgnored(true).build(); |
| 436 if (axObject) { | 468 if (axObject) { |
| 437 axObject->computeAccessibilityIsIgnored(&ignoredReasons); | 469 axObject->computeAccessibilityIsIgnored(&ignoredReasons); |
| 438 axID = axObject->axObjectID(); | 470 AccessibilityRole role = AccessibilityRole::IgnoredRole; |
| 439 AccessibilityRole role = axObject->roleValue(); | |
| 440 ignoredNodeObject->setRole(createRoleNameValue(role)); | 471 ignoredNodeObject->setRole(createRoleNameValue(role)); |
| 472 | |
| 473 populateRelatives(*axObject, axObject, *(ignoredNodeObject.get()), nodes, | |
| 474 cache); | |
| 441 } else if (domNode && !domNode->layoutObject()) { | 475 } else if (domNode && !domNode->layoutObject()) { |
| 476 populateDOMNodeRelatives(*domNode, *(ignoredNodeObject.get()), nodes, | |
| 477 cache); | |
| 442 ignoredReasons.append(IgnoredReason(AXNotRendered)); | 478 ignoredReasons.append(IgnoredReason(AXNotRendered)); |
| 443 } | 479 } |
| 444 | 480 |
| 481 if (domNode) | |
| 482 ignoredNodeObject->setDomNodeId(DOMNodeIds::idForNode(domNode)); | |
| 483 | |
| 445 std::unique_ptr<protocol::Array<AXProperty>> ignoredReasonProperties = | 484 std::unique_ptr<protocol::Array<AXProperty>> ignoredReasonProperties = |
| 446 protocol::Array<AXProperty>::create(); | 485 protocol::Array<AXProperty>::create(); |
| 447 for (size_t i = 0; i < ignoredReasons.size(); i++) | 486 for (size_t i = 0; i < ignoredReasons.size(); i++) |
| 448 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i])); | 487 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i])); |
| 449 ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties)); | 488 ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties)); |
| 450 | 489 |
| 451 return ignoredNodeObject; | 490 return ignoredNodeObject; |
| 452 } | 491 } |
| 453 | 492 |
| 493 void InspectorAccessibilityAgent::populateDOMNodeRelatives( | |
| 494 Node& inspectedDOMNode, | |
| 495 AXNode& nodeObject, | |
| 496 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 497 AXObjectCacheImpl& cache) const { | |
| 498 // Walk up parents until an AXObject can be found. | |
| 499 Node* parentNode = FlatTreeTraversal::parent(inspectedDOMNode); | |
| 500 AXObject* parentAXObject = cache.getOrCreate(parentNode); | |
| 501 while (!parentAXObject) { | |
| 502 parentNode = FlatTreeTraversal::parent(inspectedDOMNode); | |
| 503 parentAXObject = cache.getOrCreate(parentNode); | |
| 504 }; | |
| 505 if (parentAXObject) { | |
| 506 if (parentAXObject->accessibilityIsIgnored()) | |
| 507 parentAXObject = parentAXObject->parentObjectUnignored(); | |
| 508 // Populate parent, ancestors and siblings. | |
| 509 nodeObject.setParentId(String::number(parentAXObject->axObjectID())); | |
| 510 std::unique_ptr<AXNode> parentNodeObject = | |
| 511 buildProtocolAXObject(*parentAXObject, nullptr, nodes, cache); | |
| 512 std::unique_ptr<protocol::Array<AXNodeId>> siblingIds = | |
| 513 protocol::Array<AXNodeId>::create(); | |
| 514 findDOMNodeChildren(siblingIds, *parentNode, inspectedDOMNode, nodes, | |
| 515 cache); | |
| 516 parentNodeObject->setChildIds(std::move(siblingIds)); | |
| 517 nodes->addItem(std::move(parentNodeObject)); | |
| 518 | |
| 519 AXObject* grandparentAXObject = parentAXObject->parentObjectUnignored(); | |
| 520 if (grandparentAXObject) | |
| 521 addAncestors(*grandparentAXObject, nullptr, nodes, cache); | |
| 522 } | |
| 523 | |
| 524 // Then populate children. | |
| 525 std::unique_ptr<protocol::Array<AXNodeId>> childIds = | |
| 526 protocol::Array<AXNodeId>::create(); | |
| 527 findDOMNodeChildren(childIds, inspectedDOMNode, inspectedDOMNode, nodes, | |
| 528 cache); | |
| 529 } | |
| 530 | |
| 531 void InspectorAccessibilityAgent::findDOMNodeChildren( | |
| 532 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, | |
| 533 Node& parentNode, | |
| 534 Node& inspectedDOMNode, | |
| 535 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 536 AXObjectCacheImpl& cache) const { | |
| 537 NodeList* childNodes = parentNode.childNodes(); | |
| 538 for (size_t i = 0; i < childNodes->length(); ++i) { | |
| 539 Node* childNode = childNodes->item(i); | |
| 540 if (childNode == &inspectedDOMNode) { | |
| 541 childIds->addItem(String::number(kIDForInspectedNodeWithNoAXNode)); | |
| 542 continue; | |
| 543 } | |
| 544 AXObject* childAXObject = cache.getOrCreate(childNode); | |
| 545 if (childAXObject && !childAXObject->accessibilityIsIgnored()) { | |
| 546 addChild(childIds, *childAXObject, nullptr, nodes, cache); | |
| 547 continue; | |
| 548 } | |
| 549 | |
| 550 if (!childAXObject || | |
| 551 childNode->isShadowIncludingInclusiveAncestorOf(&inspectedDOMNode)) { | |
| 552 // If the inspected node may be a descendant of this node, keep walking | |
| 553 // recursively until we find its actual siblings. | |
| 554 findDOMNodeChildren(childIds, *childNode, inspectedDOMNode, nodes, cache); | |
| 555 continue; | |
| 556 } | |
| 557 | |
| 558 // Otherwise, just add the un-ignored children. | |
| 559 const AXObject::AXObjectVector& indirectChildren = | |
| 560 childAXObject->children(); | |
| 561 for (unsigned i = 0; i < indirectChildren.size(); ++i) | |
| 562 addChild(childIds, *(indirectChildren[i]), nullptr, nodes, cache); | |
| 563 } | |
| 564 } | |
| 565 | |
| 454 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject( | 566 std::unique_ptr<AXNode> InspectorAccessibilityAgent::buildProtocolAXObject( |
| 455 AXObject& axObject) const { | 567 AXObject& axObject, |
| 568 AXObject* inspectedAXObject, | |
| 569 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 570 AXObjectCacheImpl& cache) const { | |
| 456 AccessibilityRole role = axObject.roleValue(); | 571 AccessibilityRole role = axObject.roleValue(); |
| 457 std::unique_ptr<AXNode> nodeObject = | 572 std::unique_ptr<AXNode> nodeObject = |
| 458 AXNode::create() | 573 AXNode::create() |
| 459 .setNodeId(String::number(axObject.axObjectID())) | 574 .setNodeId(String::number(axObject.axObjectID())) |
| 460 .setIgnored(false) | 575 .setIgnored(false) |
| 461 .build(); | 576 .build(); |
| 462 nodeObject->setRole(createRoleNameValue(role)); | 577 nodeObject->setRole(createRoleNameValue(role)); |
| 463 | 578 |
| 464 std::unique_ptr<protocol::Array<AXProperty>> properties = | 579 std::unique_ptr<protocol::Array<AXProperty>> properties = |
| 465 protocol::Array<AXProperty>::create(); | 580 protocol::Array<AXProperty>::create(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 489 } | 604 } |
| 490 } | 605 } |
| 491 name->setSources(std::move(nameSourceProperties)); | 606 name->setSources(std::move(nameSourceProperties)); |
| 492 } | 607 } |
| 493 nodeObject->setProperties(std::move(properties)); | 608 nodeObject->setProperties(std::move(properties)); |
| 494 nodeObject->setName(std::move(name)); | 609 nodeObject->setName(std::move(name)); |
| 495 } else { | 610 } else { |
| 496 nodeObject->setProperties(std::move(properties)); | 611 nodeObject->setProperties(std::move(properties)); |
| 497 } | 612 } |
| 498 | 613 |
| 499 fillCoreProperties(axObject, *(nodeObject.get())); | 614 fillCoreProperties(axObject, inspectedAXObject, *(nodeObject.get()), nodes, |
| 615 cache); | |
| 500 return nodeObject; | 616 return nodeObject; |
| 501 } | 617 } |
| 502 | 618 |
| 503 void InspectorAccessibilityAgent::fillCoreProperties(AXObject& axObject, | 619 void InspectorAccessibilityAgent::fillCoreProperties( |
| 504 AXNode& nodeObject) const { | 620 AXObject& axObject, |
| 621 AXObject* inspectedAXObject, | |
| 622 AXNode& nodeObject, | |
| 623 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 624 AXObjectCacheImpl& cache) const { | |
| 505 AXNameFrom nameFrom; | 625 AXNameFrom nameFrom; |
| 506 AXObject::AXObjectVector nameObjects; | 626 AXObject::AXObjectVector nameObjects; |
| 507 axObject.name(nameFrom, &nameObjects); | 627 axObject.name(nameFrom, &nameObjects); |
| 508 | 628 |
| 509 AXDescriptionFrom descriptionFrom; | 629 AXDescriptionFrom descriptionFrom; |
| 510 AXObject::AXObjectVector descriptionObjects; | 630 AXObject::AXObjectVector descriptionObjects; |
| 511 String description = | 631 String description = |
| 512 axObject.description(nameFrom, descriptionFrom, &descriptionObjects); | 632 axObject.description(nameFrom, descriptionFrom, &descriptionObjects); |
| 513 if (!description.isEmpty()) { | 633 if (!description.isEmpty()) { |
| 514 nodeObject.setDescription( | 634 nodeObject.setDescription( |
| 515 createValue(description, AXValueTypeEnum::ComputedString)); | 635 createValue(description, AXValueTypeEnum::ComputedString)); |
| 516 } | 636 } |
| 517 // Value. | 637 // Value. |
| 518 if (axObject.supportsRangeValue()) { | 638 if (axObject.supportsRangeValue()) { |
| 519 nodeObject.setValue(createValue(axObject.valueForRange())); | 639 nodeObject.setValue(createValue(axObject.valueForRange())); |
| 520 } else { | 640 } else { |
| 521 String stringValue = axObject.stringValue(); | 641 String stringValue = axObject.stringValue(); |
| 522 if (!stringValue.isEmpty()) | 642 if (!stringValue.isEmpty()) |
| 523 nodeObject.setValue(createValue(stringValue)); | 643 nodeObject.setValue(createValue(stringValue)); |
| 524 } | 644 } |
| 645 | |
| 646 populateRelatives(axObject, inspectedAXObject, nodeObject, nodes, cache); | |
| 647 | |
| 648 Node* node = axObject.getNode(); | |
| 649 if (node) | |
| 650 nodeObject.setDomNodeId(DOMNodeIds::idForNode(node)); | |
| 651 } | |
| 652 | |
| 653 void InspectorAccessibilityAgent::populateRelatives( | |
| 654 AXObject& axObject, | |
| 655 AXObject* inspectedAXObject, | |
| 656 AXNode& nodeObject, | |
| 657 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 658 AXObjectCacheImpl& cache) const { | |
| 659 AXObject* parentObject = axObject.parentObject(); | |
| 660 if (parentObject && parentObject != inspectedAXObject) { | |
| 661 // Use unignored parent unless parent is inspected ignored object. | |
| 662 parentObject = axObject.parentObjectUnignored(); | |
| 663 } | |
| 664 if (parentObject) | |
| 665 nodeObject.setParentId(String::number(parentObject->axObjectID())); | |
| 666 | |
| 667 std::unique_ptr<protocol::Array<AXNodeId>> childIds = | |
| 668 protocol::Array<AXNodeId>::create(); | |
| 669 if (!inspectedAXObject) { | |
| 670 // If there is no AXObject for the inspected node, the caller will populate | |
| 671 // its relatives. | |
| 672 return; | |
| 673 } | |
| 674 | |
| 675 if (&axObject == inspectedAXObject->parentObjectUnignored() && | |
| 676 inspectedAXObject->accessibilityIsIgnored()) { | |
| 677 // This is the parent of an ignored object, so search for its siblings. | |
| 678 addSiblingsOfIgnored(childIds, axObject, inspectedAXObject, nodes, cache); | |
| 679 } else { | |
| 680 addChildren(axObject, *inspectedAXObject, childIds, nodes, cache); | |
| 681 } | |
| 682 nodeObject.setChildIds(std::move(childIds)); | |
| 683 } | |
| 684 | |
| 685 void InspectorAccessibilityAgent::addSiblingsOfIgnored( | |
| 686 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, | |
| 687 AXObject& parentAXObject, | |
| 688 AXObject* inspectedAXObject, | |
| 689 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 690 AXObjectCacheImpl& cache) const { | |
| 691 for (AXObject* childAXObject = parentAXObject.rawFirstChild(); childAXObject; | |
|
dmazzoni
2016/10/21 20:09:42
rawFirstChild skips over some important corner cas
aboxhall
2016/10/31 19:33:25
I added a test for <canvas> fallback content.
I'm
| |
| 692 childAXObject = childAXObject->rawNextSibling()) { | |
| 693 if (childAXObject != inspectedAXObject && | |
| 694 childAXObject->accessibilityIsIgnored()) { | |
| 695 if (isAncestorOf(childAXObject, inspectedAXObject)) { | |
| 696 addSiblingsOfIgnored(childIds, *childAXObject, inspectedAXObject, nodes, | |
| 697 cache); | |
| 698 continue; | |
| 699 } | |
| 700 const AXObject::AXObjectVector& indirectChildren = | |
| 701 childAXObject->children(); | |
| 702 for (unsigned i = 0; i < indirectChildren.size(); ++i) { | |
| 703 addChild(childIds, *(indirectChildren[i]), inspectedAXObject, nodes, | |
| 704 cache); | |
| 705 } | |
| 706 continue; | |
| 707 } | |
| 708 addChild(childIds, *childAXObject, inspectedAXObject, nodes, cache); | |
| 709 } | |
| 710 } | |
| 711 | |
| 712 void InspectorAccessibilityAgent::addChild( | |
| 713 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, | |
| 714 AXObject& childAXObject, | |
| 715 AXObject* inspectedAXObject, | |
| 716 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 717 AXObjectCacheImpl& cache) const { | |
| 718 childIds->addItem(String::number(childAXObject.axObjectID())); | |
| 719 if (&childAXObject == inspectedAXObject) | |
| 720 return; | |
| 721 nodes->addItem( | |
| 722 buildProtocolAXObject(childAXObject, inspectedAXObject, nodes, cache)); | |
| 723 } | |
| 724 | |
| 725 void InspectorAccessibilityAgent::addChildren( | |
| 726 AXObject& axObject, | |
| 727 AXObject& inspectedAXObject, | |
| 728 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, | |
| 729 std::unique_ptr<protocol::Array<AXNode>>& nodes, | |
| 730 AXObjectCacheImpl& cache) const { | |
| 731 const AXObject::AXObjectVector& children = axObject.children(); | |
| 732 for (unsigned i = 0; i < children.size(); i++) { | |
| 733 AXObject& childAXObject = *children[i].get(); | |
| 734 childIds->addItem(String::number(childAXObject.axObjectID())); | |
| 735 if (&axObject == &inspectedAXObject || | |
| 736 &axObject == inspectedAXObject.parentObjectUnignored()) { | |
| 737 // Only add children/siblings of inspected node to returned nodes. | |
| 738 nodes->addItem(buildProtocolAXObject(childAXObject, &inspectedAXObject, | |
| 739 nodes, cache)); | |
| 740 } | |
| 741 } | |
| 525 } | 742 } |
| 526 | 743 |
| 527 DEFINE_TRACE(InspectorAccessibilityAgent) { | 744 DEFINE_TRACE(InspectorAccessibilityAgent) { |
| 528 visitor->trace(m_page); | 745 visitor->trace(m_page); |
| 529 visitor->trace(m_domAgent); | 746 visitor->trace(m_domAgent); |
| 530 InspectorBaseAgent::trace(visitor); | 747 InspectorBaseAgent::trace(visitor); |
| 531 } | 748 } |
| 532 | 749 |
| 533 } // namespace blink | 750 } // namespace blink |
| OLD | NEW |