Title: [185671] trunk/Source/WebInspectorUI
Revision
185671
Author
[email protected]
Date
2015-06-17 14:34:22 -0700 (Wed, 17 Jun 2015)

Log Message

Web Inspector: Improve a few more node preview types
https://bugs.webkit.org/show_bug.cgi?id=146048

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

* UserInterface/Views/FormattedValue.js:
(WebInspector.FormattedValue.createElementForNodePreview):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (185670 => 185671)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-06-17 21:34:06 UTC (rev 185670)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-06-17 21:34:22 UTC (rev 185671)
@@ -1,3 +1,13 @@
+2015-06-17  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Improve a few more node preview types
+        https://bugs.webkit.org/show_bug.cgi?id=146048
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/FormattedValue.js:
+        (WebInspector.FormattedValue.createElementForNodePreview):
+
 2015-06-17  Diego Pino Garcia  <[email protected]>
 
         Web Inspector: Show/Hide sidebar buttons have inconsistent highlighted state

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (185670 => 185671)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-06-17 21:34:06 UTC (rev 185670)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-06-17 21:34:22 UTC (rev 185671)
@@ -69,15 +69,34 @@
 
 WebInspector.FormattedValue.createElementForNodePreview = function(preview)
 {
+    var value = preview.value;
     var span = document.createElement("span");
     span.className = "formatted-node-preview syntax-highlighted";
 
-    // A node preview has a very strict format, with at most a single attribute.
+    // Comment node preview.
+    if (value.startsWith("<!--")) {
+        var comment = span.appendChild(document.createElement("span"));
+        comment.className = "html-comment";
+        comment.textContent = value;
+        return span;
+    }
+
+    // Doctype node preview.
+    if (value.startsWith("<!DOCTYPE")) {
+        var doctype = span.appendChild(document.createElement("span"));
+        doctype.className = "html-doctype";
+        doctype.textContent = value;
+        return span;
+    }
+
+    // Element node previews have a very strict format, with at most a single attribute.
     // We can style it up like a DOMNode without interactivity.
-    var matches = preview.value.match(/^<(\S+?)(?: (\S+?)="(.*?)")?>$/);
+    var matches = value.match(/^<(\S+?)(?: (\S+?)="(.*?)")?>$/);
+
+    // Remaining node types are often #text, #document, etc, with attribute nodes potentially being any string.
     if (!matches) {
-        console.error("Node preview did not match format.", preview.value)
-        span.textContent = preview.value;
+        console.assert(!value.startsWith("<"), "Unexpected node preview format: " + value);
+        span.textContent = value;
         return span;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to