Changeset 107093 in webkit


Ignore:
Timestamp:
Feb 8, 2012 8:42:23 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: bind entire subtree upon childNodeInserted so that text node were accounted.
https://bugs.webkit.org/show_bug.cgi?id=78116

Reviewed by Yury Semikhatsky.

Source/WebCore:

  • inspector/front-end/DOMAgent.js:

(WebInspector.DOMNode):
(WebInspector.DOMDocument):
(WebInspector.DOMAgent.prototype._setDocument):
(WebInspector.DOMAgent.prototype._setDetachedRoot):
(WebInspector.DOMAgent.prototype._setChildNodes):
(WebInspector.DOMAgent.prototype._childNodeRemoved):
(WebInspector.DOMAgent.prototype._unbind):

LayoutTests:

  • inspector/elements/insert-node-expected.txt:
  • inspector/elements/insert-node.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107090 r107093  
     12012-02-08  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: bind entire subtree upon childNodeInserted so that text node were accounted.
     4        https://bugs.webkit.org/show_bug.cgi?id=78116
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/elements/insert-node-expected.txt:
     9        * inspector/elements/insert-node.html:
     10
    1112012-02-08  Michael Brüning  <michael.bruning@nokia.com>
    212
  • trunk/LayoutTests/inspector/elements/insert-node-expected.txt

    r79553 r107093  
    4040  </div>
    4141
     42Running: testAppendWithText
     43======== Appended with text=========
     44- <div id="container">
     45      <div id="child-before"></div>
     46      <div id="child1"></div>
     47      <div id="child-middle"></div>
     48      <div id="child2"></div>
     49      <div id="child3"></div>
     50      <div id="child-after"></div>
     51      <div style="display: none; " id="child-with-text">Text</div>
     52  </div>
     53Success: child text is bound
     54
  • trunk/LayoutTests/inspector/elements/insert-node.html

    r78576 r107093  
    2727    var child = document.createElement("div");
    2828    child.setAttribute("id", "child-after");
     29    container.appendChild(child);
     30}
     31
     32function appendChildWithText()
     33{
     34    var container = document.getElementById("container");
     35    var child = document.createElement("div");
     36    child.style.display = "none";
     37    child.innerText = "Text";
     38    child.setAttribute("id", "child-with-text");
    2939    container.appendChild(child);
    3040}
     
    7080        },
    7181
    72         function testAppend(next) {
     82        function testAppend(next)
     83        {
    7384            function callback()
    7485            {
     
    7889            }
    7990            InspectorTest.evaluateInPage("appendChild()", callback);
     91        },
     92
     93        function testAppendWithText(next)
     94        {
     95            function callback()
     96            {
     97                InspectorTest.addResult("======== Appended with text=========");
     98                InspectorTest.dumpElementsTree(containerNode);
     99                var newNode = InspectorTest.expandedNodeWithId("child-with-text");
     100                if (WebInspector.domAgent.nodeForId(newNode.firstChild.id))
     101                    InspectorTest.addResult("Success: child text is bound");
     102                else
     103                    InspectorTest.addResult("Failed: child text is not bound");
     104                next();
     105            }
     106            InspectorTest.evaluateInPage("appendChildWithText()", callback);
    80107        }
    81108    ]);
  • trunk/Source/WebCore/ChangeLog

    r107091 r107093  
     12012-02-08  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: bind entire subtree upon childNodeInserted so that text node were accounted.
     4        https://bugs.webkit.org/show_bug.cgi?id=78116
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/front-end/DOMAgent.js:
     9        (WebInspector.DOMNode):
     10        (WebInspector.DOMDocument):
     11        (WebInspector.DOMAgent.prototype._setDocument):
     12        (WebInspector.DOMAgent.prototype._setDetachedRoot):
     13        (WebInspector.DOMAgent.prototype._setChildNodes):
     14        (WebInspector.DOMAgent.prototype._childNodeRemoved):
     15        (WebInspector.DOMAgent.prototype._unbind):
     16
    1172012-02-08  Peter Rybin  <peter.rybin@gmail.com>
    218
  • trunk/Source/WebCore/inspector/front-end/DOMAgent.js

    r106811 r107093  
    4141
    4242    this.id = payload.nodeId;
     43    domAgent._idToDOMNode[this.id] = this;
    4344    this._nodeType = payload.nodeType;
    4445    this._nodeName = payload.nodeName;
     
    645646    this.documentURL = payload.documentURL || "";
    646647    this.xmlVersion = payload.xmlVersion;
    647     domAgent._idToDOMNode[this.id] = this;
    648648    this._listeners = {};
    649649}
     
    877877    {
    878878        this._idToDOMNode = {};
    879         if (payload && "nodeId" in payload) {
     879        if (payload && "nodeId" in payload)
    880880            this._document = new WebInspector.DOMDocument(this, payload);
    881             if (this._document.children)
    882                 this._bindNodes(this._document.children);
    883         } else
     881        else
    884882            this._document = null;
    885883        this.dispatchEventToListeners(WebInspector.DOMAgent.Events.DocumentUpdated, this._document);
     
    891889    _setDetachedRoot: function(payload)
    892890    {
    893         var root = new WebInspector.DOMNode(this, null, payload);
    894         this._idToDOMNode[payload.nodeId] = root;
     891        new WebInspector.DOMNode(this, null, payload);
    895892    },
    896893
     
    908905        var parent = this._idToDOMNode[parentId];
    909906        parent._setChildrenPayload(payloads);
    910         this._bindNodes(parent.children);
    911     },
    912 
    913     /**
    914      * @param {Array.<WebInspector.DOMNode>} children
    915      */
    916     _bindNodes: function(children)
    917     {
    918         for (var i = 0; i < children.length; ++i) {
    919             var child = children[i];
    920             this._idToDOMNode[child.id] = child;
    921             if (child.children)
    922                 this._bindNodes(child.children);
    923         }
    924907    },
    925908
     
    958941        var node = this._idToDOMNode[nodeId];
    959942        parent._removeChild(node);
     943        this._unbind(node);
    960944        this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved, {node:node, parent:parent});
    961         delete this._idToDOMNode[nodeId];
     945    },
     946
     947    /**
     948     * @param {DOMAgent.Node} node
     949     */
     950    _unbind: function(node)
     951    {
     952        delete this._idToDOMNode[node.id];
     953        for (var i = 0; node.children && i < node.children.length; ++i)
     954            this._unbind(node.children[i]);
    962955    },
    963956
Note: See TracChangeset for help on using the changeset viewer.