Title: [187507] trunk
Revision
187507
Author
[email protected]
Date
2015-07-28 13:37:16 -0700 (Tue, 28 Jul 2015)

Log Message

Web Inspector: Include <template> node content in DOM Tree
https://bugs.webkit.org/show_bug.cgi?id=147335

Patch by Joseph Pecoraro <[email protected]> on 2015-07-28
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Controllers/DOMTreeManager.js:
(WebInspector.DOMTreeManager.prototype._unbind):
Cleanup templateContent when DOMNodes get removed.

* UserInterface/Models/DOMNode.js:
(WebInspector.DOMNode.prototype.templateContent):
Create a DOMNode from the payload's templateContent.

* UserInterface/Views/DOMTreeElement.js:
(WebInspector.DOMTreeElement.prototype._singleTextChild):
(WebInspector.DOMTreeElement.prototype._hasVisibleChildren):
(WebInspector.DOMTreeElement.prototype._visibleChildren):
A DOMTreeElement has children if the DOMNode has template content.

LayoutTests:

* inspector/dom/template-content-expected.txt: Added.
* inspector/dom/template-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187506 => 187507)


--- trunk/LayoutTests/ChangeLog	2015-07-28 20:20:40 UTC (rev 187506)
+++ trunk/LayoutTests/ChangeLog	2015-07-28 20:37:16 UTC (rev 187507)
@@ -1,3 +1,13 @@
+2015-07-28  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Include <template> node content in DOM Tree
+        https://bugs.webkit.org/show_bug.cgi?id=147335
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/dom/template-content-expected.txt: Added.
+        * inspector/dom/template-content.html: Added.
+
 2015-07-28  Basile Clement  <[email protected]>
 
         Misleading error message: "At least one digit must occur after a decimal point"

Added: trunk/LayoutTests/inspector/dom/template-content-expected.txt (0 => 187507)


--- trunk/LayoutTests/inspector/dom/template-content-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/template-content-expected.txt	2015-07-28 20:37:16 UTC (rev 187507)
@@ -0,0 +1,8 @@
+Test that we include template content in DOM Nodes for <template> elements.
+
+PASS: Got DOMNode for div element
+PASS: DOMNode does not have template content
+
+PASS: Got DOMNode for template element
+PASS: DOMNode has template content
+

Added: trunk/LayoutTests/inspector/dom/template-content.html (0 => 187507)


--- trunk/LayoutTests/inspector/dom/template-content.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/template-content.html	2015-07-28 20:37:16 UTC (rev 187507)
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script src=""
+<script>
+function test() {
+    WebInspector.domTreeManager.requestDocument(function(documentNode) {
+        WebInspector.domTreeManager.querySelector(documentNode.id, "#div", function(nodeId) {
+            var domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+            InspectorTest.expectThat(domNode, "Got DOMNode for div element");
+            InspectorTest.expectThat(!domNode.templateContent(), "DOMNode does not have template content");
+        });
+
+        WebInspector.domTreeManager.querySelector(documentNode.id, "#template", function(nodeId) {
+            var domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+            InspectorTest.log("");
+            InspectorTest.expectThat(domNode, "Got DOMNode for template element");
+            InspectorTest.expectThat(domNode.templateContent(), "DOMNode has template content");
+            InspectorTest.completeTest();
+        });
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Test that we include template content in DOM Nodes for &lt;template&gt; elements.</p>
+
+    <div id="div"></div>
+    <template id="template">
+        <h1>Header</h1>
+        <p>Paragraph</p>
+    </template>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (187506 => 187507)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-07-28 20:20:40 UTC (rev 187506)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-07-28 20:37:16 UTC (rev 187507)
@@ -1,3 +1,24 @@
+2015-07-28  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Include <template> node content in DOM Tree
+        https://bugs.webkit.org/show_bug.cgi?id=147335
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/DOMTreeManager.js:
+        (WebInspector.DOMTreeManager.prototype._unbind):
+        Cleanup templateContent when DOMNodes get removed.
+
+        * UserInterface/Models/DOMNode.js:
+        (WebInspector.DOMNode.prototype.templateContent):
+        Create a DOMNode from the payload's templateContent.
+
+        * UserInterface/Views/DOMTreeElement.js:
+        (WebInspector.DOMTreeElement.prototype._singleTextChild):
+        (WebInspector.DOMTreeElement.prototype._hasVisibleChildren):
+        (WebInspector.DOMTreeElement.prototype._visibleChildren):
+        A DOMTreeElement has children if the DOMNode has template content.
+
 2015-07-28  Devin Rousso  <[email protected]>
 
         Web Inspector: Invalid selectors can be applied to the stylesheet

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js (187506 => 187507)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js	2015-07-28 20:20:40 UTC (rev 187506)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js	2015-07-28 20:37:16 UTC (rev 187507)
@@ -289,12 +289,14 @@
         for (var i = 0; node.children && i < node.children.length; ++i)
             this._unbind(node.children[i]);
 
+        if (node.templateContent())
+            this._unbind(node.templateContent());
+
         var pseudoElements = node.pseudoElements();
         for (var pseudoElement of pseudoElements)
             this._unbind(pseudoElement);
 
         // FIXME: Handle shadow roots.
-        // FIXME: Handle template content.
     }
 
     get restoreSelectedNodeIsAllowed()

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (187506 => 187507)


--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2015-07-28 20:20:40 UTC (rev 187506)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js	2015-07-28 20:37:16 UTC (rev 187507)
@@ -79,7 +79,10 @@
             }
         }
 
-        // FIXME: Handle templateContent.
+        if (payload.templateContent) {
+            this._templateContent = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, true, payload.templateContent);
+            this._templateContent.parentNode = this;
+        }
 
         if (payload.children)
             this._setChildrenPayload(payload.children);
@@ -263,6 +266,11 @@
         return this._localName;
     }
 
+    templateContent()
+    {
+        return this._templateContent || null;
+    }
+
     pseudoType()
     {
         return this._pseudoType;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (187506 => 187507)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2015-07-28 20:20:40 UTC (rev 187506)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2015-07-28 20:37:16 UTC (rev 187507)
@@ -1260,6 +1260,8 @@
 
         if (node.hasShadowRoots())
             return null;
+        if (node.templateContent())
+            return null;
         if (node.hasPseudoElements())
             return null;
 
@@ -1286,6 +1288,8 @@
 
         if (node.hasChildNodes())
             return true;
+        if (node.templateContent())
+            return true;
         if (node.hasPseudoElements())
             return true;
 
@@ -1298,6 +1302,10 @@
 
         var visibleChildren = [];
 
+        var templateContent = node.templateContent();
+        if (templateContent)
+            visibleChildren.push(templateContent);
+
         var beforePseudoElement = node.beforePseudoElement();
         if (beforePseudoElement)
             visibleChildren.push(beforePseudoElement);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to