Changeset 185784 in webkit
- Timestamp:
- Jun 19, 2015, 5:48:28 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 15 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/dom/highlightSelector-expected.txt (added)
-
LayoutTests/inspector/dom/highlightSelector-iframe.html (added)
-
LayoutTests/inspector/dom/highlightSelector.html (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/inspector/protocol/DOM.json (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/InspectorController.cpp (modified) (1 diff)
-
Source/WebCore/inspector/InspectorController.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorDOMAgent.cpp (modified) (2 diffs)
-
Source/WebCore/inspector/InspectorDOMAgent.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorOverlay.cpp (modified) (7 diffs)
-
Source/WebCore/inspector/InspectorOverlay.h (modified) (5 diffs)
-
Source/WebCore/inspector/InspectorOverlayPage.js (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/DOMNode.js (modified) (2 diffs)
-
Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r185779 r185784 1 2015-06-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Highlight currently edited CSS selector 4 https://bugs.webkit.org/show_bug.cgi?id=145658 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/dom/highlightSelector-expected.txt: Added. 9 * inspector/dom/highlightSelector-iframe.html: Added. 10 * inspector/dom/highlightSelector.html: Added. 11 1 12 2015-06-19 Dean Jackson <dino@apple.com> 2 13 -
trunk/Source/JavaScriptCore/ChangeLog
r185773 r185784 1 2015-06-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Highlight currently edited CSS selector 4 https://bugs.webkit.org/show_bug.cgi?id=145658 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/protocol/DOM.json: Added highlightSelector to show highlight over multiple nodes. 9 1 10 2015-06-19 Mark Lam <mark.lam@apple.com> 2 11 -
trunk/Source/JavaScriptCore/inspector/protocol/DOM.json
r174906 r185784 332 332 }, 333 333 { 334 "name": "highlightSelector", 335 "parameters": [ 336 { "name": "highlightConfig", "$ref": "HighlightConfig", "description": "A descriptor for the highlight appearance." }, 337 { "name": "selectorString", "type": "string", "description": "A CSS selector for finding matching nodes to highlight." }, 338 { "name": "frameId", "type": "string", "optional": true, "description": "Identifier of the frame which will be searched using the selector. If not provided, the main frame will be used." } 339 ], 340 "description": "Highlights all DOM nodes that match a given selector. A string containing a CSS selector must be specified." 341 }, 342 { 334 343 "name": "highlightNode", 335 344 "parameters": [ -
trunk/Source/WebCore/ChangeLog
r185781 r185784 1 2015-06-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Highlight currently edited CSS selector 4 https://bugs.webkit.org/show_bug.cgi?id=145658 5 6 Reviewed by Joseph Pecoraro. 7 8 Test: inspector/dom/highlight-multiple-shapes.html 9 10 * inspector/InspectorController.cpp: 11 (WebCore::InspectorController::buildObjectForHighlightedNode): 12 * inspector/InspectorController.h: 13 * inspector/InspectorDOMAgent.cpp: 14 (WebCore::InspectorDOMAgent::highlightSelector): Gets a list of all nodes matching a given selector string and highlights each of them. 15 * inspector/InspectorDOMAgent.h: 16 * inspector/InspectorOverlay.cpp: 17 (WebCore::InspectorOverlay::hideHighlight): 18 (WebCore::InspectorOverlay::highlightNodeList): Loops through a given NodeList to create highlightObjects for each of them. 19 (WebCore::InspectorOverlay::shouldShowOverlay): 20 (WebCore::buildObjectForElementData): Don't show flow fragments when highlighting multiple nodes. 21 (WebCore::InspectorOverlay::buildHighlightObjectForNode): 22 (WebCore::InspectorOverlay::buildObjectForHighlightedNode): Now returns an array containing the highlightObject for each highligthed node. 23 (WebCore::InspectorOverlay::drawNodeHighlight): Now sends an array to the InspectorOverlayPage.js to provide support for highlighting multiple nodes. 24 * inspector/InspectorOverlay.h: 25 * inspector/InspectorOverlayPage.js: Now expects an array as its parameter and loops through it to highlight each node given. 26 If the parameter array contains more than one element, do not draw the textbox containing info on that node. 27 (drawNodeHighlight): 28 1 29 2015-06-19 Joseph Pecoraro <pecoraro@apple.com> 2 30 -
trunk/Source/WebCore/inspector/InspectorController.cpp
r182193 r185784 325 325 } 326 326 327 Ref Ptr<Inspector::Protocol::OverlayTypes::NodeHighlightData> InspectorController::buildObjectForHighlightedNode() const328 { 329 return m_overlay->buildObjectForHighlightedNode ();327 Ref<Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>> InspectorController::buildObjectForHighlightedNodes() const 328 { 329 return m_overlay->buildObjectForHighlightedNodes(); 330 330 } 331 331 -
trunk/Source/WebCore/inspector/InspectorController.h
r180116 r185784 115 115 void setIndicating(bool); 116 116 117 WEBCORE_EXPORT Ref Ptr<Inspector::Protocol::OverlayTypes::NodeHighlightData> buildObjectForHighlightedNode() const;117 WEBCORE_EXPORT Ref<Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>> buildObjectForHighlightedNodes() const; 118 118 119 119 bool isUnderTest() const { return m_isUnderTest; } -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r185722 r185784 1076 1076 } 1077 1077 1078 void InspectorDOMAgent::highlightSelector(ErrorString& errorString, const InspectorObject& highlightInspectorObject, const String& selectorString, const String* frameId) 1079 { 1080 RefPtr<Document> document; 1081 1082 if (frameId) { 1083 Frame* frame = m_pageAgent->frameForId(*frameId); 1084 if (!frame) { 1085 errorString = ASCIILiteral("No frame for given id found"); 1086 return; 1087 } 1088 1089 document = frame->document(); 1090 } else 1091 document = m_document; 1092 1093 if (!document) { 1094 errorString = ASCIILiteral("Document could not be found"); 1095 return; 1096 } 1097 1098 ExceptionCode ec = 0; 1099 RefPtr<NodeList> nodes = document->querySelectorAll(selectorString, ec); 1100 // FIXME: <https://webkit.org/b/146161> Web Inspector: DOM.highlightSelector should work for "a:visited" 1101 if (ec) { 1102 errorString = ASCIILiteral("DOM Error while querying"); 1103 return; 1104 } 1105 1106 std::unique_ptr<HighlightConfig> highlightConfig = highlightConfigFromInspectorObject(errorString, &highlightInspectorObject); 1107 if (!highlightConfig) 1108 return; 1109 1110 m_overlay->highlightNodeList(nodes, *highlightConfig); 1111 } 1112 1078 1113 void InspectorDOMAgent::highlightNode(ErrorString& errorString, const InspectorObject& highlightInspectorObject, const int* nodeId, const String* objectId) 1079 1114 { … … 1295 1330 } else if (is<Document>(*node)) { 1296 1331 Document& document = downcast<Document>(*node); 1332 value->setFrameId(m_pageAgent->frameId(document.frame())); 1297 1333 value->setDocumentURL(documentURLString(&document)); 1298 1334 value->setBaseURL(documentBaseURLString(&document)); -
trunk/Source/WebCore/inspector/InspectorDOMAgent.h
r185722 r185784 144 144 virtual void highlightRect(ErrorString&, int x, int y, int width, int height, const Inspector::InspectorObject* color, const Inspector::InspectorObject* outlineColor, const bool* usePageCoordinates) override; 145 145 virtual void highlightQuad(ErrorString&, const Inspector::InspectorArray& quad, const Inspector::InspectorObject* color, const Inspector::InspectorObject* outlineColor, const bool* usePageCoordinates) override; 146 virtual void highlightSelector(ErrorString&, const Inspector::InspectorObject& highlightConfig, const String& selectorString, const String* frameId) override; 146 147 virtual void highlightNode(ErrorString&, const Inspector::InspectorObject& highlightConfig, const int* nodeId, const String* objectId) override; 147 148 virtual void highlightFrame(ErrorString&, const String& frameId, const Inspector::InspectorObject* color, const Inspector::InspectorObject* outlineColor) override; -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r184895 r185784 245 245 { 246 246 m_highlightNode.clear(); 247 m_highlightNodeList.clear(); 247 248 m_highlightQuad.reset(); 248 249 update(); 249 250 } 250 251 252 void InspectorOverlay::highlightNodeList(PassRefPtr<NodeList> nodes, const HighlightConfig& highlightConfig) 253 { 254 m_nodeHighlightConfig = highlightConfig; 255 m_highlightNodeList = nodes; 256 m_highlightNode.clear(); 257 update(); 258 } 259 251 260 void InspectorOverlay::highlightNode(Node* node, const HighlightConfig& highlightConfig) 252 261 { 253 262 m_nodeHighlightConfig = highlightConfig; 254 263 m_highlightNode = node; 264 m_highlightNodeList.clear(); 255 265 update(); 256 266 } … … 290 300 bool InspectorOverlay::shouldShowOverlay() const 291 301 { 292 return m_highlightNode || m_highlight Quad || m_indicating || m_showingPaintRects || !m_pausedInDebuggerMessage.isNull();302 return m_highlightNode || m_highlightNodeList || m_highlightQuad || m_indicating || m_showingPaintRects || !m_pausedInDebuggerMessage.isNull(); 293 303 } 294 304 … … 674 684 #endif 675 685 676 static RefPtr<Inspector::Protocol::OverlayTypes::ElementData> buildObjectForElementData(Node* node )686 static RefPtr<Inspector::Protocol::OverlayTypes::ElementData> buildObjectForElementData(Node* node, HighlightType type) 677 687 { 678 688 if (!is<Element>(node) || !node->document().frame()) … … 717 727 elementData->setSize(WTF::move(sizeObject)); 718 728 719 if ( renderer->isRenderNamedFlowFragmentContainer()) {729 if (type != HighlightType::NodeList && renderer->isRenderNamedFlowFragmentContainer()) { 720 730 RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(*renderer).renderNamedFlowFragment(); 721 731 if (region.isValid()) { … … 758 768 } 759 769 760 RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> InspectorOverlay::build ObjectForHighlightedNode() const761 { 762 if (! m_highlightNode)770 RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> InspectorOverlay::buildHighlightObjectForNode(Node* node, HighlightType type) const 771 { 772 if (!node) 763 773 return nullptr; 764 774 765 Node* node = m_highlightNode.get();766 775 RenderObject* renderer = node->renderer(); 767 776 if (!renderer) … … 781 790 782 791 if (m_nodeHighlightConfig.showInfo) { 783 if (RefPtr<Inspector::Protocol::OverlayTypes::ElementData> elementData = buildObjectForElementData(node ))792 if (RefPtr<Inspector::Protocol::OverlayTypes::ElementData> elementData = buildObjectForElementData(node, type)) 784 793 nodeHighlightObject->setElementData(WTF::move(elementData)); 785 794 } … … 788 797 } 789 798 799 Ref<Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>> InspectorOverlay::buildObjectForHighlightedNodes() const 800 { 801 auto highlights = Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>::create(); 802 803 if (m_highlightNode) { 804 if (RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> nodeHighlightData = buildHighlightObjectForNode(m_highlightNode.get(), HighlightType::Node)) 805 highlights->addItem(WTF::move(nodeHighlightData)); 806 } else if (m_highlightNodeList) { 807 for (unsigned i = 0; i < m_highlightNodeList->length(); ++i) { 808 if (RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> nodeHighlightData = buildHighlightObjectForNode(m_highlightNodeList->item(i), HighlightType::NodeList)) 809 highlights->addItem(WTF::move(nodeHighlightData)); 810 } 811 } 812 813 return WTF::move(highlights); 814 } 815 790 816 void InspectorOverlay::drawNodeHighlight() 791 817 { 792 if ( RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> highlightObject = buildObjectForHighlightedNode())793 evaluateInOverlay("drawNodeHighlight", WTF::move(highlightObject));818 if (m_highlightNode || m_highlightNodeList) 819 evaluateInOverlay("drawNodeHighlight", buildObjectForHighlightedNodes()); 794 820 } 795 821 -
trunk/Source/WebCore/inspector/InspectorOverlay.h
r178631 r185784 33 33 #include "FloatQuad.h" 34 34 #include "LayoutRect.h" 35 #include "NodeList.h" 35 36 #include "Timer.h" 37 #include <inspector/InspectorProtocolObjects.h> 36 38 #include <wtf/Deque.h> 37 39 #include <wtf/RefPtr.h> … … 73 75 enum class HighlightType { 74 76 Node, // Provides 4 quads: margin, border, padding, content. 77 NodeList, // Provides a list of nodes. 75 78 Rects, // Provides a list of quads. 76 79 }; … … 118 121 119 122 void hideHighlight(); 123 void highlightNodeList(PassRefPtr<NodeList>, const HighlightConfig&); 120 124 void highlightNode(Node*, const HighlightConfig&); 121 125 void highlightQuad(std::unique_ptr<FloatQuad>, const HighlightConfig&); … … 130 134 void setIndicating(bool indicating); 131 135 132 RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> buildObjectForHighlightedNode() const; 136 RefPtr<Inspector::Protocol::OverlayTypes::NodeHighlightData> buildHighlightObjectForNode(Node*, HighlightType) const; 137 Ref<Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::NodeHighlightData>> buildObjectForHighlightedNodes() const; 133 138 134 139 void freePage(); … … 154 159 String m_pausedInDebuggerMessage; 155 160 RefPtr<Node> m_highlightNode; 161 RefPtr<NodeList> m_highlightNodeList; 156 162 HighlightConfig m_nodeHighlightConfig; 157 163 std::unique_ptr<FloatQuad> m_highlightQuad; -
trunk/Source/WebCore/inspector/InspectorOverlayPage.js
r178631 r185784 488 488 } 489 489 490 function drawNodeHighlight(highlight) 491 { 492 context.save(); 493 context.translate(-highlight.scrollOffset.x, -highlight.scrollOffset.y); 494 495 for (var i = 0; i < highlight.fragments.length; ++i) 496 _drawFragmentHighlight(highlight.fragments[i]); 497 498 if (highlight.elementData && highlight.elementData.regionFlowData) 499 _drawRegionsHighlight(highlight.elementData.regionFlowData.regions); 500 501 if (highlight.elementData && highlight.elementData.shapeOutsideData) 502 _drawShapeHighlight(highlight.elementData.shapeOutsideData); 503 504 context.restore(); 505 490 function drawNodeHighlight(allHighlights) 491 { 506 492 var elementTitleContainer = document.getElementById("element-title-container"); 507 elementTitleContainer.innerHTML = ""; 508 for (var i = 0; i < highlight.fragments.length; ++i) 509 _drawElementTitle(highlight.elementData, highlight.fragments[i], highlight.scrollOffset); 493 while (elementTitleContainer.hasChildNodes()) 494 elementTitleContainer.removeChild(elementTitleContainer.lastChild); 495 496 for (var highlight of allHighlights) { 497 context.save(); 498 context.translate(-highlight.scrollOffset.x, -highlight.scrollOffset.y); 499 500 for (var fragment of highlight.fragments) 501 _drawFragmentHighlight(fragment); 502 503 if (highlight.elementData && highlight.elementData.regionFlowData) 504 _drawRegionsHighlight(highlight.elementData.regionFlowData.regions); 505 506 if (highlight.elementData && highlight.elementData.shapeOutsideData) 507 _drawShapeHighlight(highlight.elementData.shapeOutsideData); 508 509 context.restore(); 510 511 if (allHighlights.length === 1) { 512 for (var fragment of highlight.fragments) 513 _drawElementTitle(highlight.elementData, fragment, highlight.scrollOffset); 514 } 515 } 510 516 } 511 517 -
trunk/Source/WebCore/testing/Internals.cpp
r185310 r185784 927 927 return String(); 928 928 } 929 auto object = document->page()->inspectorController().buildObjectForHighlightedNode(); 930 return object ? object->toJSONString() :String();929 930 return document->page()->inspectorController().buildObjectForHighlightedNodes()->toJSONString(); 931 931 } 932 932 -
trunk/Source/WebInspectorUI/ChangeLog
r185759 r185784 1 2015-06-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Highlight currently edited CSS selector 4 https://bugs.webkit.org/show_bug.cgi?id=145658 5 6 Reviewed by Joseph Pecoraro. 7 8 * UserInterface/Views/CSSStyleDeclarationSection.js: 9 (WebInspector.CSSStyleDeclarationSection): Added event listeners on the selector text for mouseover and mouseout. 10 (WebInspector.CSSStyleDeclarationSection.prototype._highlightNodesWithSelector): Selector text mouseover action that highlights all nodes that match the selector string in the corresponding frame. 11 (WebInspector.CSSStyleDeclarationSection.prototype._hideHighlightOnNodesWithSelector): Selector text mouseout action that clears all highlights on matching nodes. 12 * UserInterface/Views/DOMNode.js: 13 (WebInspector.DOMNode): If the payload contains a frameId, then save it. 14 (WebInspector.DOMNode.frameIdentifier): 15 1 16 2015-06-19 Joseph Pecoraro <pecoraro@apple.com> 2 17 -
trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js
r182113 r185784 87 87 this._renumber(); 88 88 } 89 90 if (payload.frameId) 91 this._frameIdentifier = payload.frameId; 89 92 90 93 if (this._nodeType === Node.ELEMENT_NODE) { … … 583 586 }; 584 587 } 588 589 get frameIdentifier() 590 { 591 return this._frameIdentifier; 592 } 585 593 }; 586 594 -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js
r185757 r185784 49 49 this._selectorElement.className = "selector"; 50 50 this._selectorElement.setAttribute("spellcheck", "false"); 51 this._selectorElement.addEventListener("mouseover", this._highlightNodesWithSelector.bind(this)); 52 this._selectorElement.addEventListener("mouseout", this._hideHighlightOnNodesWithSelector.bind(this)); 51 53 this._headerElement.appendChild(this._selectorElement); 52 54 … … 392 394 }, 393 395 396 _highlightNodesWithSelector: function() 397 { 398 var highlightConfig = { 399 borderColor: {r: 255, g: 229, b: 153, a: 0.66}, 400 contentColor: {r: 111, g: 168, b: 220, a: 0.66}, 401 marginColor: {r: 246, g: 178, b: 107, a: 0.66}, 402 paddingColor: {r: 147, g: 196, b: 125, a: 0.66}, 403 showInfo: true 404 }; 405 406 if (!this._style.ownerRule) { 407 // COMPATIBILITY (iOS 6): Order of parameters changed in iOS 7. 408 DOMAgent.highlightNode.invoke({nodeId: this._style.node.id, highlightConfig}); 409 return; 410 } 411 412 if (DOMAgent.highlightSelector) 413 DOMAgent.highlightSelector(highlightConfig, this._style.ownerRule.selectorText, this._style.node.ownerDocument.frameIdentifier); 414 }, 415 416 _hideHighlightOnNodesWithSelector: function() 417 { 418 DOMAgent.hideHighlight(); 419 }, 420 394 421 _commitSelector: function(mutations) 395 422 {
Note:
See TracChangeset
for help on using the changeset viewer.