Changeset 219316 in webkit


Ignore:
Timestamp:
Jul 10, 2017 5:01:55 PM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Highlight matching CSS canvas clients when hovering contexts in the Resources tab
https://bugs.webkit.org/show_bug.cgi?id=174279

Reviewed by Matt Baker.

Source/JavaScriptCore:

  • inspector/protocol/DOM.json:

Add highlightNodeList command that will highlight each node in the given list.

Source/WebCore:

Test: inspector/dom/highlightNodeList.html

  • inspector/InspectorDOMAgent.h:
  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::highlightNodeList):

Source/WebInspectorUI:

  • UserInterface/Controllers/DOMTreeManager.js:

(WebInspector.DOMTreeManager.prototype.highlightDOMNodeList):
(WebInspector.DOMTreeManager.prototype.highlightSelector):

  • UserInterface/Views/CanvasTreeElement.js:

(WebInspector.CanvasTreeElement.prototype._handleMouseOver):

LayoutTests:

  • inspector/dom/highlightNodeList-expected.html: Added.
  • inspector/dom/highlightNodeList.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219315 r219316  
     12017-07-10  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Highlight matching CSS canvas clients when hovering contexts in the Resources tab
     4        https://bugs.webkit.org/show_bug.cgi?id=174279
     5
     6        Reviewed by Matt Baker.
     7
     8        * inspector/dom/highlightNodeList-expected.html: Added.
     9        * inspector/dom/highlightNodeList.html: Added.
     10
    1112017-07-10  Javier Fernandez  <jfernandez@igalia.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r219301 r219316  
     12017-07-10  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Highlight matching CSS canvas clients when hovering contexts in the Resources tab
     4        https://bugs.webkit.org/show_bug.cgi?id=174279
     5
     6        Reviewed by Matt Baker.
     7
     8        * inspector/protocol/DOM.json:
     9        Add `highlightNodeList` command that will highlight each node in the given list.
     10
    1112017-07-03  Brian Burg  <bburg@apple.com>
    212
  • trunk/Source/JavaScriptCore/inspector/protocol/DOM.json

    r218898 r219316  
    378378        },
    379379        {
     380            "name": "highlightNodeList",
     381            "description": "Highlights each DOM node in the given list.",
     382            "parameters": [
     383                { "name": "nodeIds", "type": "array", "items": { "$ref": "NodeId" } },
     384                { "name": "highlightConfig", "$ref": "HighlightConfig" }
     385            ]
     386        },
     387        {
    380388            "name": "hideHighlight",
    381389            "description": "Hides DOM node highlight."
  • trunk/Source/WebCore/ChangeLog

    r219315 r219316  
     12017-07-10  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Highlight matching CSS canvas clients when hovering contexts in the Resources tab
     4        https://bugs.webkit.org/show_bug.cgi?id=174279
     5
     6        Reviewed by Matt Baker.
     7
     8        Test: inspector/dom/highlightNodeList.html
     9
     10        * inspector/InspectorDOMAgent.h:
     11        * inspector/InspectorDOMAgent.cpp:
     12        (WebCore::InspectorDOMAgent::highlightNodeList):
     13
    1142017-07-10  Javier Fernandez  <jfernandez@igalia.com>
    215
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r215160 r219316  
    8686#include "ScriptState.h"
    8787#include "ShadowRoot.h"
     88#include "StaticNodeList.h"
    8889#include "StyleProperties.h"
    8990#include "StyleResolver.h"
     
    11451146
    11461147    m_overlay->highlightNode(node, *highlightConfig);
     1148}
     1149
     1150void InspectorDOMAgent::highlightNodeList(ErrorString& errorString, const InspectorArray& nodeIds, const InspectorObject& highlightInspectorObject)
     1151{
     1152    Vector<Ref<Node>> nodes;
     1153    for (auto& nodeValue : nodeIds) {
     1154        if (!nodeValue) {
     1155            errorString = ASCIILiteral("Invalid nodeIds item.");
     1156            return;
     1157        }
     1158
     1159        int nodeId = 0;
     1160        if (!nodeValue->asInteger(nodeId)) {
     1161            errorString = ASCIILiteral("Invalid nodeIds item type. Expecting integer types.");
     1162            return;
     1163        }
     1164
     1165        // In the case that a node is removed in the time between when highlightNodeList is invoked
     1166        // by the frontend and it is executed by the backend, we should still attempt to highlight
     1167        // as many nodes as possible. As such, we should ignore any errors generated when attempting
     1168        // to get a Node from a given nodeId.
     1169        ErrorString ignored;
     1170        Node* node = assertNode(ignored, nodeId);
     1171        if (!node)
     1172            continue;
     1173
     1174        nodes.append(*node);
     1175    }
     1176
     1177    std::unique_ptr<HighlightConfig> highlightConfig = highlightConfigFromInspectorObject(errorString, &highlightInspectorObject);
     1178    if (!highlightConfig)
     1179        return;
     1180
     1181    m_overlay->highlightNodeList(StaticNodeList::create(WTFMove(nodes)), *highlightConfig);
    11471182}
    11481183
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r213626 r219316  
    140140    void highlightSelector(ErrorString&, const Inspector::InspectorObject& highlightConfig, const String& selectorString, const String* const frameId) override;
    141141    void highlightNode(ErrorString&, const Inspector::InspectorObject& highlightConfig, const int* const nodeId, const String* const objectId) override;
     142    void highlightNodeList(ErrorString&, const Inspector::InspectorArray& nodeIds, const Inspector::InspectorObject& highlightConfig) override;
    142143    void highlightFrame(ErrorString&, const String& frameId, const Inspector::InspectorObject* color, const Inspector::InspectorObject* outlineColor) override;
    143144
  • trunk/Source/WebInspectorUI/ChangeLog

    r219301 r219316  
     12017-07-10  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Highlight matching CSS canvas clients when hovering contexts in the Resources tab
     4        https://bugs.webkit.org/show_bug.cgi?id=174279
     5
     6        Reviewed by Matt Baker.
     7
     8        * UserInterface/Controllers/DOMTreeManager.js:
     9        (WebInspector.DOMTreeManager.prototype.highlightDOMNodeList):
     10        (WebInspector.DOMTreeManager.prototype.highlightSelector):
     11        * UserInterface/Views/CanvasTreeElement.js:
     12        (WebInspector.CanvasTreeElement.prototype._handleMouseOver):
     13
    1142017-07-03  Brian Burg  <bburg@apple.com>
    215
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js

    r219268 r219316  
    427427    }
    428428
     429    highlightDOMNodeList(nodeIds, mode)
     430    {
     431        // COMPATIBILITY (iOS 11): DOM.highlightNodeList did not exist.
     432        if (!DOMAgent.highlightNodeList)
     433            return;
     434
     435        if (this._hideDOMNodeHighlightTimeout) {
     436            clearTimeout(this._hideDOMNodeHighlightTimeout);
     437            this._hideDOMNodeHighlightTimeout = undefined;
     438        }
     439
     440        DOMAgent.highlightNodeList(nodeIds, this._buildHighlightConfig(mode));
     441    }
     442
    429443    highlightSelector(selectorText, frameId, mode)
    430444    {
     
    432446        if (!DOMAgent.highlightSelector)
    433447            return;
     448
     449        if (this._hideDOMNodeHighlightTimeout) {
     450            clearTimeout(this._hideDOMNodeHighlightTimeout);
     451            this._hideDOMNodeHighlightTimeout = undefined;
     452        }
    434453
    435454        DOMAgent.highlightSelector(this._buildHighlightConfig(mode), selectorText, frameId);
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js

    r219214 r219316  
    6666    _handleMouseOver(event)
    6767    {
    68         this.representedObject.requestNode((node) => {
    69             if (!node || !node.ownerDocument)
    70                 return;
     68        if (this.representedObject.cssCanvasName) {
     69            this.representedObject.requestCSSCanvasClientNodes((cssCanvasClientNodes) => {
     70                WebInspector.domTreeManager.highlightDOMNodeList(cssCanvasClientNodes.map((node) => node.id), "all");
     71            });
     72        } else {
     73            this.representedObject.requestNode((node) => {
     74                if (!node || !node.ownerDocument)
     75                    return;
    7176
    72             WebInspector.domTreeManager.highlightDOMNode(node.id, "all");
    73         });
     77                WebInspector.domTreeManager.highlightDOMNode(node.id, "all");
     78            });
     79        }
    7480    }
    7581
Note: See TracChangeset for help on using the changeset viewer.