⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136144 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 11:59:14 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: Console: hovering node wrappers in object tree should highlight them on the page
​https://bugs.webkit.org/show_bug.cgi?id=101150

Reviewed by Vsevolod Vlasov.

  • Introduced a way to highlight nodes by object id in addition to node id.
  • Decorated nodes in the object tree outline and added on-hover highlighting.
  • inspector/Inspector.json:
  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::highlightNode):

  • inspector/InspectorDOMAgent.h:

(InspectorDOMAgent):

  • inspector/front-end/ConsoleMessage.js:

(WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreview):

  • inspector/front-end/DOMAgent.js:

(WebInspector.DOMAgent.prototype.highlightDOMNode):

  • inspector/front-end/DOMPresentationUtils.js:

(WebInspector.DOMPresentationUtils.createSpansForNodeTitle):

  • inspector/front-end/ObjectPropertiesSection.js:

(WebInspector.ObjectPropertyTreeElement.prototype.update):
(WebInspector.ObjectPropertyTreeElement.prototype._mouseMove):
(WebInspector.ObjectPropertyTreeElement.prototype._mouseOut):

  • inspector/front-end/RemoteObject.js:

(WebInspector.RemoteObject.prototype.highlightAsDOMNode):
(WebInspector.RemoteObject.prototype.hideDOMNodeHighlight):

  • inspector/front-end/TestController.js:
  • inspector/front-end/externs.js:
  • inspector/front-end/inspector.css:

(.console-formatted-node:hover):

  • inspector/front-end/utilities.js:
Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136142 r136144  
     12012-11-29  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: Console: hovering node wrappers in object tree should highlight them on the page
     4        https://bugs.webkit.org/show_bug.cgi?id=101150
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        - Introduced a way to highlight nodes by object id in addition to node id.
     9        - Decorated nodes in the object tree outline and added on-hover highlighting.
     10
     11        * inspector/Inspector.json:
     12        * inspector/InspectorDOMAgent.cpp:
     13        (WebCore::InspectorDOMAgent::highlightNode):
     14        * inspector/InspectorDOMAgent.h:
     15        (InspectorDOMAgent):
     16        * inspector/front-end/ConsoleMessage.js:
     17        (WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreview):
     18        * inspector/front-end/DOMAgent.js:
     19        (WebInspector.DOMAgent.prototype.highlightDOMNode):
     20        * inspector/front-end/DOMPresentationUtils.js:
     21        (WebInspector.DOMPresentationUtils.createSpansForNodeTitle):
     22        * inspector/front-end/ObjectPropertiesSection.js:
     23        (WebInspector.ObjectPropertyTreeElement.prototype.update):
     24        (WebInspector.ObjectPropertyTreeElement.prototype._mouseMove):
     25        (WebInspector.ObjectPropertyTreeElement.prototype._mouseOut):
     26        * inspector/front-end/RemoteObject.js:
     27        (WebInspector.RemoteObject.prototype.highlightAsDOMNode):
     28        (WebInspector.RemoteObject.prototype.hideDOMNodeHighlight):
     29        * inspector/front-end/TestController.js:
     30        * inspector/front-end/externs.js:
     31        * inspector/front-end/inspector.css:
     32        (.console-formatted-node:hover):
     33        * inspector/front-end/utilities.js:
     34
    1352012-11-29  Dan Bernstein  <mitz@apple.com>
    236
  • trunk/Source/WebCore/inspector/Inspector.json

    r135591 r136144  
    18591859                "name": "highlightNode",
    18601860                "parameters": [
    1861                     { "name": "nodeId", "$ref": "NodeId", "description": "Identifier of the node to highlight." },
     1861                    { "name": "nodeId", "$ref": "NodeId", "optional": true, "description": "Identifier of the node to highlight." },
     1862                    { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "optional": true, "description": "JavaScript object id of the node to be highlighted." },
    18621863                    { "name": "highlightConfig", "$ref": "HighlightConfig", "description": "A descriptor for the highlight appearance." }
    18631864                ],
    1864                 "description": "Highlights DOM node with given id."
     1865                "description": "Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified."
    18651866            },
    18661867            {
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r133885 r136144  
    10671067}
    10681068
    1069 void InspectorDOMAgent::highlightNode(
    1070     ErrorString* errorString,
    1071     int nodeId,
    1072     const RefPtr<InspectorObject>& highlightInspectorObject)
    1073 {
    1074     Node* node = nodeForId(nodeId);
     1069void InspectorDOMAgent::highlightNode(ErrorString* errorString, const int* nodeId, const String* objectId, const RefPtr<InspectorObject>& highlightInspectorObject)
     1070{
     1071    Node* node = 0;
     1072    if (nodeId) {
     1073        node = assertNode(errorString, *nodeId);
     1074    } else if (objectId) {
     1075        InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*objectId);
     1076        node = injectedScript.nodeForObjectId(*objectId);
     1077        if (!node)
     1078            *errorString = "Node for given objectId not found";
     1079    } else
     1080        *errorString = "Either nodeId or objectId must be specified";
     1081
    10751082    if (!node)
    10761083        return;
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r131083 r136144  
    142142    virtual void hideHighlight(ErrorString*);
    143143    virtual void highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
    144     virtual void highlightNode(ErrorString*, int nodeId, const RefPtr<InspectorObject>& highlightConfig);
     144    virtual void highlightNode(ErrorString*, const int* nodeId, const String* objectId, const RefPtr<InspectorObject>& highlightConfig);
    145145    virtual void highlightFrame(ErrorString*, const String& frameId, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
    146146    virtual void moveTo(ErrorString*, int nodeId, int targetNodeId, const int* anchorNodeId, int* newNodeId);
  • trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js

    r135720 r136144  
    352352        if (property.type === "object" && property.subtype === "node") {
    353353            span.addStyleClass("console-formatted-preview-node");
    354             var match = property.value.match(/([^#.]+)(#[^.]+)?(\..*)?/);
    355             span.createChild("span", "webkit-html-tag-name").textContent = match[1];
    356             if (match[2])
    357                 span.createChild("span", "webkit-html-attribute-value").textContent = match[2];
    358             if (match[3])
    359                 span.createChild("span", "webkit-html-attribute-name").textContent = match[3];
     354            WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, property.value);
    360355            return;
    361356        }
  • trunk/Source/WebCore/inspector/front-end/DOMAgent.js

    r134751 r136144  
    11991199     * @param {?number} nodeId
    12001200     * @param {string=} mode
    1201      */
    1202     highlightDOMNode: function(nodeId, mode)
     1201     * @param {RuntimeAgent.RemoteObjectId=} objectId
     1202     */
     1203    highlightDOMNode: function(nodeId, mode, objectId)
    12031204    {
    12041205        if (this._hideDOMNodeHighlightTimeout) {
    … …  
    12071208        }
    12081209
    1209         this._highlightedDOMNodeId = nodeId;
    1210         if (nodeId)
    1211             DOMAgent.highlightNode(nodeId, this._buildHighlightConfig(mode));
     1210        if (objectId || nodeId)
     1211            DOMAgent.highlightNode(objectId ? undefined : nodeId, objectId, this._buildHighlightConfig(mode));
    12121212        else
    12131213            DOMAgent.hideHighlight();
  • trunk/Source/WebCore/inspector/front-end/DOMPresentationUtils.js

    r126579 r136144  
    7777}
    7878
     79/**
     80 * @param {Element} container
     81 * @param {string} nodeTitle
     82 */
     83WebInspector.DOMPresentationUtils.createSpansForNodeTitle = function(container, nodeTitle)
     84{
     85    var match = nodeTitle.match(/([^#.]+)(#[^.]+)?(\..*)?/);
     86    container.createChild("span", "webkit-html-tag-name").textContent = match[1];
     87    if (match[2])
     88        container.createChild("span", "webkit-html-attribute-value").textContent = match[2];
     89    if (match[3])
     90        container.createChild("span", "webkit-html-attribute-name").textContent = match[3];
     91}
     92
    7993WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node)
    8094{
  • trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js

    r135122 r136144  
    235235            this.valueElement.textContent = /.*/.exec(description)[0].replace(/ +$/g, "");
    236236            this.valueElement._originalTextContent = description;
    237         } else
     237        } else if (this.property.value.type !== "object" || this.property.value.subtype !== "node")
    238238            this.valueElement.textContent = description;
    239239
    … …  
    246246
    247247        this.valueElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property.value), false);
    248         this.valueElement.title = description || "";
     248        if (this.property.value.type === "object" && this.property.value.subtype === "node") {
     249            WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.valueElement, this.property.value.description);
     250            this.valueElement.addEventListener("mousemove", this._mouseMove.bind(this, this.property.value), false);
     251            this.valueElement.addEventListener("mouseout", this._mouseOut.bind(this, this.property.value), false);
     252        } else
     253            this.valueElement.title = description || "";
    249254
    250255        this.listItemElement.removeChildren();
    … …  
    269274    populateContextMenu: function(contextMenu)
    270275    {
     276    },
     277
     278    _mouseMove: function(event)
     279    {
     280        this.property.value.highlightAsDOMNode();
     281    },
     282
     283    _mouseOut: function(event)
     284    {
     285        this.property.value.hideDOMNodeHighlight();
    271286    },
    272287
  • trunk/Source/WebCore/inspector/front-end/RemoteObject.js

    r134914 r136144  
    289289    },
    290290
     291    highlightAsDOMNode: function()
     292    {
     293        WebInspector.domAgent.highlightDOMNode(undefined, undefined, this._objectId);
     294    },
     295
     296    hideDOMNodeHighlight: function()
     297    {
     298        WebInspector.domAgent.hideDOMNodeHighlight();
     299    },
     300
    291301    /**
    292302     * @param {function(this:Object)} functionDeclaration
  • trunk/Source/WebCore/inspector/front-end/TestController.js

    r134745 r136144  
    4646WebInspector.evaluateForTestInFrontend = function(callId, script)
    4747{
    48     WebInspector.isUnderTest = true;
     48    window.isUnderTest = true;
    4949    function invokeMethod()
    5050    {
  • trunk/Source/WebCore/inspector/front-end/externs.js

    r135588 r136144  
    6565/** @type {*} */
    6666window.testRunner = null;
     67
     68window.isUnderTest = false;
    6769
    6870/**
  • trunk/Source/WebCore/inspector/front-end/inspector.css

    r136104 r136144  
    11421142}
    11431143
     1144.console-formatted-node:hover {
     1145    background-color: rgba(56, 121, 217, 0.1);
     1146}
     1147
    11441148.console-formatted-object .section, .console-formatted-node .section, .console-formatted-array .section {
    11451149    position: static;
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r135681 r136144  
    862862}
    863863
     864window.isUnderTest = false;
    864865
    865866/**
    … …  
    873874    this._observer = new WebKitMutationObserver(handler);
    874875    NonLeakingMutationObserver._instances.push(this);
    875     if (!window.testRunner && !WebInspector.isUnderTest && !NonLeakingMutationObserver._unloadListener) {
     876    if (!window.testRunner && !window.isUnderTest && !NonLeakingMutationObserver._unloadListener) {
    876877        NonLeakingMutationObserver._unloadListener = function() {
    877878            while (NonLeakingMutationObserver._instances.length)
Note: See TracChangeset for help on using the changeset viewer.