Changeset 185716 in webkit


Ignore:
Timestamp:
Jun 18, 2015, 12:21:22 PM (10 years ago)
Author:
Joseph Pecoraro
Message:

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

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r185709 r185716  
     12015-06-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Improve a few more node preview types
     4        https://bugs.webkit.org/show_bug.cgi?id=146048
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Views/FormattedValue.js:
     9        (WebInspector.FormattedValue.createElementForNodePreview):
     10
    1112015-06-18  Devin Rousso  <drousso@apple.com>
    212
  • trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js

    r185703 r185716  
    7070WebInspector.FormattedValue.createElementForNodePreview = function(preview)
    7171{
     72    var value = preview.value;
    7273    var span = document.createElement("span");
    7374    span.className = "formatted-node-preview syntax-highlighted";
    7475
    75     // A node preview has a very strict format, with at most a single attribute.
     76    // Comment node preview.
     77    if (value.startsWith("<!--")) {
     78        var comment = span.appendChild(document.createElement("span"));
     79        comment.className = "html-comment";
     80        comment.textContent = value;
     81        return span;
     82    }
     83
     84    // Doctype node preview.
     85    if (value.startsWith("<!DOCTYPE")) {
     86        var doctype = span.appendChild(document.createElement("span"));
     87        doctype.className = "html-doctype";
     88        doctype.textContent = value;
     89        return span;
     90    }
     91
     92    // Element node previews have a very strict format, with at most a single attribute.
    7693    // We can style it up like a DOMNode without interactivity.
    77     var matches = preview.value.match(/^<(\S+?)(?: (\S+?)="(.*?)")?>$/);
     94    var matches = value.match(/^<(\S+?)(?: (\S+?)="(.*?)")?>$/);
     95
     96    // Remaining node types are often #text, #document, etc, with attribute nodes potentially being any string.
    7897    if (!matches) {
    79         console.error("Node preview did not match format.", preview.value)
    80         span.textContent = preview.value;
     98        console.assert(!value.startsWith("<"), "Unexpected node preview format: " + value);
     99        span.textContent = value;
    81100        return span;
    82101    }
Note: See TracChangeset for help on using the changeset viewer.