Title: [292781] trunk/Source/WebInspectorUI
Revision
292781
Author
[email protected]
Date
2022-04-12 12:26:56 -0700 (Tue, 12 Apr 2022)

Log Message

Web Inspector: Add engineering-build-only ability to dump the current known bound nodes tree in Inspector^2 or layout tests
https://bugs.webkit.org/show_bug.cgi?id=239086

Reviewed by Devin Rousso.

* UserInterface/Debug/DOMManager.js: Added.
(appendLine):
(appendChildren):
(get let):
- To assist with debugging layout tests and patches to the DOMManager, add a utility getter to dump the current
node tree.

* UserInterface/Main.html:
* UserInterface/Test.html:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (292780 => 292781)


--- trunk/Source/WebInspectorUI/ChangeLog	2022-04-12 18:52:27 UTC (rev 292780)
+++ trunk/Source/WebInspectorUI/ChangeLog	2022-04-12 19:26:56 UTC (rev 292781)
@@ -1,3 +1,20 @@
+2022-04-12  Patrick Angle  <[email protected]>
+
+        Web Inspector: Add engineering-build-only ability to dump the current known bound nodes tree in Inspector^2 or layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=239086
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Debug/DOMManager.js: Added.
+        (appendLine):
+        (appendChildren):
+        (get let):
+        - To assist with debugging layout tests and patches to the DOMManager, add a utility getter to dump the current
+        node tree.
+        
+        * UserInterface/Main.html:
+        * UserInterface/Test.html:
+
 2022-04-11  Patrick Angle  <[email protected]>
 
         Web Inspector: preserve DOM.NodeId if a node is removed and re-added

Added: trunk/Source/WebInspectorUI/UserInterface/Debug/DOMManager.js (0 => 292781)


--- trunk/Source/WebInspectorUI/UserInterface/Debug/DOMManager.js	                        (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/DOMManager.js	2022-04-12 19:26:56 UTC (rev 292781)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+Object.defineProperty(WI.DOMManager.prototype, "boundNodesDebugDescription", {
+    get() {
+        let debugDescription = "";
+        function appendLine(line) {
+            debugDescription += line + "\n";
+        }
+
+        const singleLevelSpacePrefix = "    ";
+        function appendChildren(parent, level) {
+            let spacePrefix = singleLevelSpacePrefix.repeat(level + 1);
+
+            for (let child of parent.children) {
+                appendLine(`${spacePrefix}id(${child.id}) displayName(${child.displayName})`);
+
+                for (let pseudoElement of child.pseudoElements().values())
+                    appendLine(`${spacePrefix}${singleLevelSpacePrefix}id(${pseudoElement.id}) displayName(${pseudoElement.displayName})`);
+
+                if (child.children)
+                    appendChildren(child, level + 1);
+            }
+        }
+
+        let rootNodes = Object.values(this._idToDOMNode).filter((value) => !value.parentNode);
+        for (let rootNode of rootNodes) {
+            appendLine(`<${rootNode === this._document ? "Document" : "Detached"} Root> id(${rootNode.id}) displayName(${rootNode.displayName})`);
+            if (rootNode.children)
+                appendChildren(rootNode, 0);
+        }
+
+        return debugDescription;
+    }
+});
\ No newline at end of file

Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (292780 => 292781)


--- trunk/Source/WebInspectorUI/UserInterface/Main.html	2022-04-12 18:52:27 UTC (rev 292780)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html	2022-04-12 19:26:56 UTC (rev 292781)
@@ -963,6 +963,7 @@
     <script src=""
     <script src=""
     <script src=""
+    <script src=""
 
     <script src=""
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (292780 => 292781)


--- trunk/Source/WebInspectorUI/UserInterface/Test.html	2022-04-12 18:52:27 UTC (rev 292780)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html	2022-04-12 19:26:56 UTC (rev 292781)
@@ -293,6 +293,8 @@
     <script src=""
     <script src=""
 
+    <script src=""
+
     <script src=""
 
     <script type="text/_javascript_">
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to