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" |
| 11 #include "core/dom/Node.h" | 11 #include "core/dom/Node.h" |
| 12 #include "core/dom/NodeList.h" | 12 #include "core/dom/NodeList.h" |
| 13 #include "core/dom/shadow/ElementShadow.h" | |
| 13 #include "core/inspector/IdentifiersFactory.h" | 14 #include "core/inspector/IdentifiersFactory.h" |
| 14 #include "core/inspector/InspectorDOMAgent.h" | 15 #include "core/inspector/InspectorDOMAgent.h" |
| 15 #include "core/inspector/InspectorStyleSheet.h" | 16 #include "core/inspector/InspectorStyleSheet.h" |
| 16 #include "core/page/Page.h" | 17 #include "core/page/Page.h" |
| 17 #include "modules/accessibility/AXObject.h" | 18 #include "modules/accessibility/AXObject.h" |
| 18 #include "modules/accessibility/AXObjectCacheImpl.h" | 19 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 19 #include "modules/accessibility/InspectorTypeBuilderHelper.h" | 20 #include "modules/accessibility/InspectorTypeBuilderHelper.h" |
| 20 #include <memory> | 21 #include <memory> |
| 21 | 22 |
| 22 namespace blink { | 23 namespace blink { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 504 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 504 AXObjectCacheImpl& cache) const { | 505 AXObjectCacheImpl& cache) const { |
| 505 // Populate children. | 506 // Populate children. |
| 506 std::unique_ptr<protocol::Array<AXNodeId>> childIds = | 507 std::unique_ptr<protocol::Array<AXNodeId>> childIds = |
| 507 protocol::Array<AXNodeId>::create(); | 508 protocol::Array<AXNodeId>::create(); |
| 508 findDOMNodeChildren(childIds, inspectedDOMNode, inspectedDOMNode, nodes, | 509 findDOMNodeChildren(childIds, inspectedDOMNode, inspectedDOMNode, nodes, |
| 509 cache); | 510 cache); |
| 510 nodeObject.setChildIds(std::move(childIds)); | 511 nodeObject.setChildIds(std::move(childIds)); |
| 511 | 512 |
| 512 // Walk up parents until an AXObject can be found. | 513 // Walk up parents until an AXObject can be found. |
| 513 Node* parentNode = FlatTreeTraversal::parent(inspectedDOMNode); | 514 Node* parentNode = inspectedDOMNode.isShadowRoot() |
|
aboxhall
2016/12/02 00:30:14
The crash was here: FlatTreeTraversal explicitly d
| |
| 515 ? &toShadowRoot(inspectedDOMNode).host() | |
| 516 : FlatTreeTraversal::parent(inspectedDOMNode); | |
| 514 AXObject* parentAXObject = cache.getOrCreate(parentNode); | 517 AXObject* parentAXObject = cache.getOrCreate(parentNode); |
| 515 while (parentNode && !parentAXObject) { | 518 while (parentNode && !parentAXObject) { |
| 516 parentNode = FlatTreeTraversal::parent(inspectedDOMNode); | 519 parentNode = parentNode->isShadowRoot() |
| 517 parentAXObject = cache.getOrCreate(parentNode); | 520 ? &toShadowRoot(parentNode)->host() |
|
dgozman
2016/12/02 18:04:16
Where did this line go?
aboxhall
2016/12/02 22:25:11
Yikes. Replaced.
| |
| 521 : FlatTreeTraversal::parent(*parentNode); | |
| 518 }; | 522 }; |
| 519 | 523 |
| 520 if (!parentAXObject) | 524 if (!parentAXObject) |
| 521 return; | 525 return; |
| 522 | 526 |
| 523 if (parentAXObject->accessibilityIsIgnored()) | 527 if (parentAXObject->accessibilityIsIgnored()) |
| 524 parentAXObject = parentAXObject->parentObjectUnignored(); | 528 parentAXObject = parentAXObject->parentObjectUnignored(); |
| 525 if (!parentAXObject) | 529 if (!parentAXObject) |
| 526 return; | 530 return; |
| 527 | 531 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 538 if (grandparentAXObject) | 542 if (grandparentAXObject) |
| 539 addAncestors(*grandparentAXObject, nullptr, nodes, cache); | 543 addAncestors(*grandparentAXObject, nullptr, nodes, cache); |
| 540 } | 544 } |
| 541 | 545 |
| 542 void InspectorAccessibilityAgent::findDOMNodeChildren( | 546 void InspectorAccessibilityAgent::findDOMNodeChildren( |
| 543 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, | 547 std::unique_ptr<protocol::Array<AXNodeId>>& childIds, |
| 544 Node& parentNode, | 548 Node& parentNode, |
| 545 Node& inspectedDOMNode, | 549 Node& inspectedDOMNode, |
| 546 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 550 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 547 AXObjectCacheImpl& cache) const { | 551 AXObjectCacheImpl& cache) const { |
| 552 if (inspectedDOMNode.isShadowRoot() && | |
| 553 &parentNode == toShadowRoot(inspectedDOMNode).host()) { | |
| 554 childIds->addItem(String::number(kIDForInspectedNodeWithNoAXNode)); | |
| 555 return; | |
| 556 } | |
| 548 NodeList* childNodes = parentNode.childNodes(); | 557 NodeList* childNodes = parentNode.childNodes(); |
| 558 if (!childNodes->length() && parentNode.isElementNode()) { | |
| 559 Element& parentElement = toElement(parentNode); | |
| 560 ElementShadow* elementShadow = parentElement.shadow(); | |
| 561 if (elementShadow) { | |
| 562 ShadowRoot& shadowRoot = elementShadow->youngestShadowRoot(); | |
| 563 childNodes = shadowRoot.childNodes(); | |
| 564 } | |
| 565 } | |
| 549 for (size_t i = 0; i < childNodes->length(); ++i) { | 566 for (size_t i = 0; i < childNodes->length(); ++i) { |
| 550 Node* childNode = childNodes->item(i); | 567 Node* childNode = childNodes->item(i); |
| 551 if (childNode == &inspectedDOMNode) { | 568 if (childNode == &inspectedDOMNode) { |
| 552 childIds->addItem(String::number(kIDForInspectedNodeWithNoAXNode)); | 569 childIds->addItem(String::number(kIDForInspectedNodeWithNoAXNode)); |
| 553 continue; | 570 continue; |
| 554 } | 571 } |
| 555 | 572 |
| 556 AXObject* childAXObject = cache.getOrCreate(childNode); | 573 AXObject* childAXObject = cache.getOrCreate(childNode); |
| 557 if (childAXObject) { | 574 if (childAXObject) { |
| 558 if (childAXObject->accessibilityIsIgnored()) { | 575 if (childAXObject->accessibilityIsIgnored()) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 } | 783 } |
| 767 } | 784 } |
| 768 | 785 |
| 769 DEFINE_TRACE(InspectorAccessibilityAgent) { | 786 DEFINE_TRACE(InspectorAccessibilityAgent) { |
| 770 visitor->trace(m_page); | 787 visitor->trace(m_page); |
| 771 visitor->trace(m_domAgent); | 788 visitor->trace(m_domAgent); |
| 772 InspectorBaseAgent::trace(visitor); | 789 InspectorBaseAgent::trace(visitor); |
| 773 } | 790 } |
| 774 | 791 |
| 775 } // namespace blink | 792 } // namespace blink |
| OLD | NEW |