| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 130 } |
| 129 | 131 |
| 130 v8::Local<v8::Value> nodeV8Value(v8::Local<v8::Context> context, Node* node) | 132 v8::Local<v8::Value> nodeV8Value(v8::Local<v8::Context> context, Node* node) |
| 131 { | 133 { |
| 132 v8::Isolate* isolate = context->GetIsolate(); | 134 v8::Isolate* isolate = context->GetIsolate(); |
| 133 if (!node || !BindingSecurity::shouldAllowAccessTo(currentDOMWindow(isolate)
, node, BindingSecurity::ErrorReportOption::DoNotReport)) | 135 if (!node || !BindingSecurity::shouldAllowAccessTo(currentDOMWindow(isolate)
, node, BindingSecurity::ErrorReportOption::DoNotReport)) |
| 134 return v8::Null(isolate); | 136 return v8::Null(isolate); |
| 135 return toV8(node, context->Global(), isolate); | 137 return toV8(node, context->Global(), isolate); |
| 136 } | 138 } |
| 137 | 139 |
| 140 std::unique_ptr<protocol::DOM::Rect> buildRectForFloatRect(const FloatRect& rect
) |
| 141 { |
| 142 return protocol::DOM::Rect::create() |
| 143 .setX(rect.x()) |
| 144 .setY(rect.y()) |
| 145 .setWidth(rect.width()) |
| 146 .setHeight(rect.height()) |
| 147 .build(); |
| 148 } |
| 149 |
| 150 FloatRect buildAbsoluteBoundingBox(LayoutObject* layoutObject) |
| 151 { |
| 152 if (layoutObject->isText()) { |
| 153 FloatRect localRect(toLayoutText(layoutObject)->linesBoundingBox()); |
| 154 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); |
| 155 } |
| 156 if (layoutObject->isLayoutInline()) { |
| 157 FloatRect localRect(toLayoutInline(layoutObject)->linesBoundingBox()); |
| 158 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); |
| 159 } |
| 160 if (layoutObject->isBox()) { |
| 161 FloatRect localRect(toLayoutBox(layoutObject)->borderBoxRect()); |
| 162 return layoutObject->localToAbsoluteQuad(localRect).boundingBox(); |
| 163 } |
| 164 return layoutObject->absoluteBoundingBoxRect(); |
| 165 } |
| 166 |
| 138 } // namespace | 167 } // namespace |
| 139 | 168 |
| 169 |
| 140 class InspectorRevalidateDOMTask final : public GarbageCollectedFinalized<Inspec
torRevalidateDOMTask> { | 170 class InspectorRevalidateDOMTask final : public GarbageCollectedFinalized<Inspec
torRevalidateDOMTask> { |
| 141 public: | 171 public: |
| 142 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); | 172 explicit InspectorRevalidateDOMTask(InspectorDOMAgent*); |
| 143 void scheduleStyleAttrRevalidationFor(Element*); | 173 void scheduleStyleAttrRevalidationFor(Element*); |
| 144 void reset() { m_timer.stop(); } | 174 void reset() { m_timer.stop(); } |
| 145 void onTimer(TimerBase*); | 175 void onTimer(TimerBase*); |
| 146 DECLARE_TRACE(); | 176 DECLARE_TRACE(); |
| 147 | 177 |
| 148 private: | 178 private: |
| 149 Member<InspectorDOMAgent> m_domAgent; | 179 Member<InspectorDOMAgent> m_domAgent; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 if (!m_document) { | 551 if (!m_document) { |
| 522 *errorString = "Document is not available"; | 552 *errorString = "Document is not available"; |
| 523 return; | 553 return; |
| 524 } | 554 } |
| 525 | 555 |
| 526 discardFrontendBindings(); | 556 discardFrontendBindings(); |
| 527 | 557 |
| 528 *root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get())
; | 558 *root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get())
; |
| 529 } | 559 } |
| 530 | 560 |
| 561 void InspectorDOMAgent::getRenderTreeNodes(ErrorString* errorString, std::unique
_ptr<protocol::Array<protocol::DOM::RenderTreeNode>>* renderTreeNodes) |
| 562 { |
| 563 renderTreeNodes->reset(new protocol::Array<protocol::DOM::RenderTreeNode>); |
| 564 |
| 565 std::vector<Node*> unvisited; // Neither WTF::Vector or HeapVector allow Nod
e* :( |
| 566 unvisited.push_back(m_document.get()); |
| 567 |
| 568 while (!unvisited.empty()) { |
| 569 Node* node = unvisited.back(); |
| 570 unvisited.pop_back(); |
| 571 |
| 572 if (node->isElementNode()) { |
| 573 const Element* element = toElement(node); |
| 574 ElementShadow* elementShadow = element->shadow(); |
| 575 if (elementShadow) |
| 576 unvisited.push_back(&elementShadow->youngestShadowRoot()); |
| 577 } |
| 578 for (Node* child = innerFirstChild(node); child; child = innerNextSiblin
g(child)) { |
| 579 unvisited.push_back(child); |
| 580 } |
| 581 |
| 582 LayoutObject* layoutObject = node->layoutObject(); |
| 583 if (!layoutObject) |
| 584 continue; |
| 585 |
| 586 int backendNodeId = DOMNodeIds::idForNode(node); |
| 587 std::unique_ptr<protocol::DOM::RenderTreeNode> renderTreeNode = |
| 588 protocol::DOM::RenderTreeNode::create() |
| 589 .setBackendNodeId(backendNodeId) |
| 590 .setBoundingBox(buildRectForFloatRect(buildAbsoluteBoundingBox(l
ayoutObject))) |
| 591 .build(); |
| 592 |
| 593 if (layoutObject->isText()) { |
| 594 LayoutText* layoutText = toLayoutText(layoutObject); |
| 595 renderTreeNode->setLayoutText(layoutText->text()); |
| 596 if (layoutText->hasTextBoxes()) { |
| 597 std::unique_ptr<protocol::Array<protocol::DOM::InlineTextBox>> i
nlineTextNodes(new protocol::Array<protocol::DOM::InlineTextBox>()); |
| 598 for (const InlineTextBox* itb = layoutText->firstTextBox(); itb;
itb = itb->nextTextBox()) { |
| 599 FloatRect localItbRect(itb->calculateBoundaries()); |
| 600 FloatRect absoluteItbRect = layoutObject->localToAbsoluteQua
d(localItbRect).boundingBox(); |
| 601 inlineTextNodes->addItem( |
| 602 protocol::DOM::InlineTextBox::create() |
| 603 .setText(layoutText->text().substring(itb->start(),
itb->len()).utf8().data()) |
| 604 .setBoundingBox(buildRectForFloatRect(absoluteItbRec
t)) |
| 605 .build()); |
| 606 } |
| 607 renderTreeNode->setInlineTextNodes(std::move(inlineTextNodes)); |
| 608 } |
| 609 } |
| 610 |
| 611 (*renderTreeNodes)->addItem(std::move(renderTreeNode)); |
| 612 } |
| 613 } |
| 614 |
| 531 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) | 615 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) |
| 532 { | 616 { |
| 533 Node* node = nodeForId(nodeId); | 617 Node* node = nodeForId(nodeId); |
| 534 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is
DocumentFragment())) | 618 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is
DocumentFragment())) |
| 535 return; | 619 return; |
| 536 | 620 |
| 537 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); | 621 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); |
| 538 | 622 |
| 539 if (m_childrenRequested.contains(nodeId)) { | 623 if (m_childrenRequested.contains(nodeId)) { |
| 540 if (depth <= 1) | 624 if (depth <= 1) |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 visitor->trace(m_idToNodesMap); | 2185 visitor->trace(m_idToNodesMap); |
| 2102 visitor->trace(m_document); | 2186 visitor->trace(m_document); |
| 2103 visitor->trace(m_revalidateTask); | 2187 visitor->trace(m_revalidateTask); |
| 2104 visitor->trace(m_searchResults); | 2188 visitor->trace(m_searchResults); |
| 2105 visitor->trace(m_history); | 2189 visitor->trace(m_history); |
| 2106 visitor->trace(m_domEditor); | 2190 visitor->trace(m_domEditor); |
| 2107 InspectorBaseAgent::trace(visitor); | 2191 InspectorBaseAgent::trace(visitor); |
| 2108 } | 2192 } |
| 2109 | 2193 |
| 2110 } // namespace blink | 2194 } // namespace blink |
| OLD | NEW |