Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 #include "core/html/imports/HTMLImportChild.h" | 59 #include "core/html/imports/HTMLImportChild.h" |
| 60 #include "core/html/imports/HTMLImportLoader.h" | 60 #include "core/html/imports/HTMLImportLoader.h" |
| 61 #include "core/inspector/DOMEditor.h" | 61 #include "core/inspector/DOMEditor.h" |
| 62 #include "core/inspector/DOMPatchSupport.h" | 62 #include "core/inspector/DOMPatchSupport.h" |
| 63 #include "core/inspector/IdentifiersFactory.h" | 63 #include "core/inspector/IdentifiersFactory.h" |
| 64 #include "core/inspector/InspectedFrames.h" | 64 #include "core/inspector/InspectedFrames.h" |
| 65 #include "core/inspector/InspectorHighlight.h" | 65 #include "core/inspector/InspectorHighlight.h" |
| 66 #include "core/inspector/InspectorHistory.h" | 66 #include "core/inspector/InspectorHistory.h" |
| 67 #include "core/inspector/V8InspectorString.h" | 67 #include "core/inspector/V8InspectorString.h" |
| 68 #include "core/layout/HitTestResult.h" | 68 #include "core/layout/HitTestResult.h" |
| 69 #include "core/layout/LayoutInline.h" | |
| 69 #include "core/layout/api/LayoutViewItem.h" | 70 #include "core/layout/api/LayoutViewItem.h" |
| 71 #include "core/layout/line/InlineTextBox.h" | |
| 70 #include "core/loader/DocumentLoader.h" | 72 #include "core/loader/DocumentLoader.h" |
| 71 #include "core/page/FrameTree.h" | 73 #include "core/page/FrameTree.h" |
| 72 #include "core/page/Page.h" | 74 #include "core/page/Page.h" |
| 73 #include "core/xml/DocumentXPathEvaluator.h" | 75 #include "core/xml/DocumentXPathEvaluator.h" |
| 74 #include "core/xml/XPathResult.h" | 76 #include "core/xml/XPathResult.h" |
| 75 #include "platform/PlatformGestureEvent.h" | 77 #include "platform/PlatformGestureEvent.h" |
| 76 #include "platform/PlatformMouseEvent.h" | 78 #include "platform/PlatformMouseEvent.h" |
| 77 #include "platform/PlatformTouchEvent.h" | 79 #include "platform/PlatformTouchEvent.h" |
| 78 #include "wtf/ListHashSet.h" | 80 #include "wtf/ListHashSet.h" |
| 79 #include "wtf/PtrUtil.h" | 81 #include "wtf/PtrUtil.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 if (!m_document) { | 523 if (!m_document) { |
| 522 *errorString = "Document is not available"; | 524 *errorString = "Document is not available"; |
| 523 return; | 525 return; |
| 524 } | 526 } |
| 525 | 527 |
| 526 discardFrontendBindings(); | 528 discardFrontendBindings(); |
| 527 | 529 |
| 528 *root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get()) ; | 530 *root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get()) ; |
| 529 } | 531 } |
| 530 | 532 |
| 533 namespace { | |
| 534 std::unique_ptr<protocol::DOM::Rect> getRectForFloatRect(const FloatRect& rect) | |
|
pfeldman
2016/09/16 00:59:35
We call these build*. Also, either move those to t
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Done.
| |
| 535 { | |
| 536 return protocol::DOM::Rect::create() | |
| 537 .setX(rect.x()) | |
| 538 .setY(rect.y()) | |
| 539 .setWidth(rect.width()) | |
| 540 .setHeight(rect.height()) | |
| 541 .build(); | |
| 542 } | |
| 543 | |
| 544 FloatRect getAbsoluteBoundingBox(LayoutObject* layoutObject) | |
|
pfeldman
2016/09/16 00:59:35
Blink does not (yet) use get prefixes.
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Done.
| |
| 545 { | |
| 546 if (layoutObject->isText()) { | |
| 547 FloatRect localRect(toLayoutText(layoutObject)->linesBoundingBox()); | |
| 548 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); | |
|
pfeldman
2016/09/16 00:59:35
I am not sure this matches your expectations wrt c
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Acknowledged.
| |
| 549 } | |
| 550 if (layoutObject->isLayoutInline()) { | |
| 551 FloatRect localRect(toLayoutInline(layoutObject)->linesBoundingBox()); | |
| 552 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); | |
| 553 } | |
| 554 if (layoutObject->isBox()) { | |
| 555 FloatRect localRect(toLayoutBox(layoutObject)->borderBoxRect()); | |
| 556 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); | |
| 557 } | |
| 558 return layoutObject->absoluteBoundingBoxRect(); | |
| 559 } | |
| 560 | |
| 561 } // namespace | |
| 562 | |
| 563 void InspectorDOMAgent::getRenderTreeNodes(ErrorString* errorString, std::unique _ptr<protocol::Array<protocol::DOM::RenderTreeNode>>* renderTreeNodes) | |
| 564 { | |
| 565 renderTreeNodes->reset(new protocol::Array<protocol::DOM::RenderTreeNode>); | |
| 566 | |
| 567 std::vector<Node*> unvisited; // Neither WTF::Vector or HeapVector allow Nod e* :( | |
| 568 unvisited.push_back(m_document.get()); | |
| 569 | |
| 570 while (!unvisited.empty()) { | |
| 571 Node* node = unvisited.back(); | |
| 572 unvisited.pop_back(); | |
| 573 LayoutObject* layoutObject = node->layoutObject(); | |
| 574 if (!layoutObject) | |
|
pfeldman
2016/09/16 00:59:35
You still might want to go over the dom hierarchy.
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Good point!
| |
| 575 continue; | |
| 576 | |
| 577 int backendNodeId = DOMNodeIds::idForNode(node); | |
| 578 DCHECK(backendNodeId); | |
|
pfeldman
2016/09/16 00:59:35
It is always there
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Done.
| |
| 579 std::unique_ptr<protocol::DOM::RenderTreeNode> renderTreeNode = | |
| 580 protocol::DOM::RenderTreeNode::create() | |
| 581 .setBackendNodeId(backendNodeId) | |
| 582 .setBoundingBox(getRectForFloatRect(getAbsoluteBoundingBox(layou tObject))) | |
| 583 .build(); | |
| 584 | |
| 585 if (layoutObject->isText()) { | |
| 586 LayoutText* layoutText = toLayoutText(layoutObject); | |
| 587 renderTreeNode->setLayoutText(layoutText->text()); | |
| 588 if (layoutText->hasTextBoxes()) { | |
| 589 std::unique_ptr<protocol::Array<protocol::DOM::InlineTextBox>> i nlineTextNodes(new protocol::Array<protocol::DOM::InlineTextBox>()); | |
| 590 for (const InlineTextBox* itb = layoutText->firstTextBox(); itb; itb = itb->nextTextBox()) { | |
| 591 FloatRect localItbRect(itb->calculateBoundaries()); | |
| 592 FloatRect absoluteItbRect = layoutObject->localToAbsoluteQua d(localItbRect).boundingBox(); | |
| 593 inlineTextNodes->addItem( | |
| 594 protocol::DOM::InlineTextBox::create() | |
| 595 .setText(layoutText->text().substring(itb->start(), itb->len()).utf8().data()) | |
| 596 .setBoundingBox(getRectForFloatRect(absoluteItbRect) ) | |
| 597 .build()); | |
| 598 } | |
| 599 renderTreeNode->setInlineTextNodes(std::move(inlineTextNodes)); | |
| 600 } | |
| 601 } | |
| 602 | |
| 603 (*renderTreeNodes)->addItem(std::move(renderTreeNode)); | |
| 604 | |
| 605 for (node = innerFirstChild(node); node; node = innerNextSibling(node)) | |
|
pfeldman
2016/09/16 00:59:35
I don't see where you account for the shadow dom.
alex clarke (OOO till 29th)
2016/09/16 10:23:36
Hopefully I've done that now.
| |
| 606 unvisited.push_back(node); | |
| 607 } | |
| 608 } | |
| 609 | |
| 531 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) | 610 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) |
| 532 { | 611 { |
| 533 Node* node = nodeForId(nodeId); | 612 Node* node = nodeForId(nodeId); |
| 534 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is DocumentFragment())) | 613 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is DocumentFragment())) |
| 535 return; | 614 return; |
| 536 | 615 |
| 537 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); | 616 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); |
| 538 | 617 |
| 539 if (m_childrenRequested.contains(nodeId)) { | 618 if (m_childrenRequested.contains(nodeId)) { |
| 540 if (depth <= 1) | 619 if (depth <= 1) |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2101 visitor->trace(m_idToNodesMap); | 2180 visitor->trace(m_idToNodesMap); |
| 2102 visitor->trace(m_document); | 2181 visitor->trace(m_document); |
| 2103 visitor->trace(m_revalidateTask); | 2182 visitor->trace(m_revalidateTask); |
| 2104 visitor->trace(m_searchResults); | 2183 visitor->trace(m_searchResults); |
| 2105 visitor->trace(m_history); | 2184 visitor->trace(m_history); |
| 2106 visitor->trace(m_domEditor); | 2185 visitor->trace(m_domEditor); |
| 2107 InspectorBaseAgent::trace(visitor); | 2186 InspectorBaseAgent::trace(visitor); |
| 2108 } | 2187 } |
| 2109 | 2188 |
| 2110 } // namespace blink | 2189 } // namespace blink |
| OLD | NEW |