Title: [107093] trunk
Revision
107093
Author
[email protected]
Date
2012-02-08 08:42:23 -0800 (Wed, 08 Feb 2012)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107092 => 107093)


--- trunk/LayoutTests/ChangeLog	2012-02-08 16:31:14 UTC (rev 107092)
+++ trunk/LayoutTests/ChangeLog	2012-02-08 16:42:23 UTC (rev 107093)
@@ -1,3 +1,13 @@
+2012-02-08  Pavel Feldman  <[email protected]>
+
+        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.
+
+        * inspector/elements/insert-node-expected.txt:
+        * inspector/elements/insert-node.html:
+
 2012-02-08  Michael BrĂ¼ning  <[email protected]>
 
         [Qt][WK2] Compute and set cache capacities using the current CacheModel

Modified: trunk/LayoutTests/inspector/elements/insert-node-expected.txt (107092 => 107093)


--- trunk/LayoutTests/inspector/elements/insert-node-expected.txt	2012-02-08 16:31:14 UTC (rev 107092)
+++ trunk/LayoutTests/inspector/elements/insert-node-expected.txt	2012-02-08 16:42:23 UTC (rev 107093)
@@ -39,3 +39,16 @@
       <div id="child-after"></div>
   </div>
 
+Running: testAppendWithText
+======== Appended with text=========
+- <div id="container">
+      <div id="child-before"></div>
+      <div id="child1"></div>
+      <div id="child-middle"></div>
+      <div id="child2"></div>
+      <div id="child3"></div>
+      <div id="child-after"></div>
+      <div style="display: none; " id="child-with-text">Text</div>
+  </div>
+Success: child text is bound
+

Modified: trunk/LayoutTests/inspector/elements/insert-node.html (107092 => 107093)


--- trunk/LayoutTests/inspector/elements/insert-node.html	2012-02-08 16:31:14 UTC (rev 107092)
+++ trunk/LayoutTests/inspector/elements/insert-node.html	2012-02-08 16:42:23 UTC (rev 107093)
@@ -29,6 +29,16 @@
     container.appendChild(child);
 }
 
+function appendChildWithText()
+{
+    var container = document.getElementById("container");
+    var child = document.createElement("div");
+    child.style.display = "none";
+    child.innerText = "Text";
+    child.setAttribute("id", "child-with-text");
+    container.appendChild(child);
+}
+
 function test()
 {
     var containerNode;
@@ -69,7 +79,8 @@
             InspectorTest.evaluateInPage("insertNode()", callback);
         },
 
-        function testAppend(next) {
+        function testAppend(next)
+        {
             function callback()
             {
                 InspectorTest.addResult("======== Appended =========");
@@ -77,6 +88,22 @@
                 next();
             }
             InspectorTest.evaluateInPage("appendChild()", callback);
+        },
+
+        function testAppendWithText(next)
+        {
+            function callback()
+            {
+                InspectorTest.addResult("======== Appended with text=========");
+                InspectorTest.dumpElementsTree(containerNode);
+                var newNode = InspectorTest.expandedNodeWithId("child-with-text");
+                if (WebInspector.domAgent.nodeForId(newNode.firstChild.id))
+                    InspectorTest.addResult("Success: child text is bound");
+                else
+                    InspectorTest.addResult("Failed: child text is not bound");
+                next();
+            }
+            InspectorTest.evaluateInPage("appendChildWithText()", callback);
         }
     ]);
 }

Modified: trunk/Source/WebCore/ChangeLog (107092 => 107093)


--- trunk/Source/WebCore/ChangeLog	2012-02-08 16:31:14 UTC (rev 107092)
+++ trunk/Source/WebCore/ChangeLog	2012-02-08 16:42:23 UTC (rev 107093)
@@ -1,3 +1,19 @@
+2012-02-08  Pavel Feldman  <[email protected]>
+
+        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.
+
+        * 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):
+
 2012-02-08  Peter Rybin  <[email protected]>
 
         Web Inspector: Optional out arguments are not supported in the Web Inspector protocol, which breaks the implementation

Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (107092 => 107093)


--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-08 16:31:14 UTC (rev 107092)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-08 16:42:23 UTC (rev 107093)
@@ -40,6 +40,7 @@
     this.ownerDocument = doc;
 
     this.id = payload.nodeId;
+    domAgent._idToDOMNode[this.id] = this;
     this._nodeType = payload.nodeType;
     this._nodeName = payload.nodeName;
     this._localName = payload.localName;
@@ -644,7 +645,6 @@
     WebInspector.DOMNode.call(this, domAgent, this, payload);
     this.documentURL = payload.documentURL || "";
     this.xmlVersion = payload.xmlVersion;
-    domAgent._idToDOMNode[this.id] = this;
     this._listeners = {};
 }
 
@@ -876,11 +876,9 @@
     _setDocument: function(payload)
     {
         this._idToDOMNode = {};
-        if (payload && "nodeId" in payload) {
+        if (payload && "nodeId" in payload)
             this._document = new WebInspector.DOMDocument(this, payload);
-            if (this._document.children)
-                this._bindNodes(this._document.children);
-        } else
+        else
             this._document = null;
         this.dispatchEventToListeners(WebInspector.DOMAgent.Events.DocumentUpdated, this._document);
     },
@@ -890,8 +888,7 @@
      */
     _setDetachedRoot: function(payload)
     {
-        var root = new WebInspector.DOMNode(this, null, payload);
-        this._idToDOMNode[payload.nodeId] = root;
+        new WebInspector.DOMNode(this, null, payload);
     },
 
     /**
@@ -907,23 +904,9 @@
 
         var parent = this._idToDOMNode[parentId];
         parent._setChildrenPayload(payloads);
-        this._bindNodes(parent.children);
     },
 
     /**
-     * @param {Array.<WebInspector.DOMNode>} children
-     */
-    _bindNodes: function(children)
-    {
-        for (var i = 0; i < children.length; ++i) {
-            var child = children[i];
-            this._idToDOMNode[child.id] = child;
-            if (child.children)
-                this._bindNodes(child.children);
-        }
-    },
-
-    /**
      * @param {DOMAgent.NodeId} nodeId
      * @param {number} newValue
      */
@@ -957,11 +940,21 @@
         var parent = this._idToDOMNode[parentId];
         var node = this._idToDOMNode[nodeId];
         parent._removeChild(node);
+        this._unbind(node);
         this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved, {node:node, parent:parent});
-        delete this._idToDOMNode[nodeId];
     },
 
     /**
+     * @param {DOMAgent.Node} node
+     */
+    _unbind: function(node)
+    {
+        delete this._idToDOMNode[node.id];
+        for (var i = 0; node.children && i < node.children.length; ++i)
+            this._unbind(node.children[i]);
+    },
+
+    /**
      * @param {number} nodeId
      */
     inspectElement: function(nodeId)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to