这是indexloc提供的服务,不要输入任何密码

Changeset 49081 in webkit


Ignore:
Timestamp:
Oct 4, 2009, 9:16:40 PM (16 years ago)
Author:
bweinstein@apple.com
Message:

2009-10-04 Brian Weinstein <bweinstein@apple.com>

Reviewed by Timothy Hatcher.


Fixes <https://bugs.webkit.org/show_bug.cgi?id=30062>
Inspector should syntax highlight JS/CSS in elements view.

Add syntax highlighting of CSS and JavaScript tags to the elements panel.
Copied CSS rules from SourceFrame.js to inspector.css, and have the text nodes
in utilities.js call the CSS or JS Syntax highlighters if their parent is a script
or style tag.

  • inspector/front-end/inspector.css:
  • inspector/front-end/utilities.js:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49080 r49081  
     12009-10-04  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Timothy Hatcher.
     4       
     5        Fixes <https://bugs.webkit.org/show_bug.cgi?id=30062>
     6        Inspector should syntax highlight JS/CSS in elements view.
     7
     8        Add syntax highlighting of CSS and JavaScript tags to the elements panel.
     9        Copied CSS rules from SourceFrame.js to inspector.css, and have the text nodes
     10        in utilities.js call the CSS or JS Syntax highlighters if their parent is a script
     11        or style tag.
     12
     13        * inspector/front-end/inspector.css:
     14        * inspector/front-end/utilities.js:
     15
    1162009-10-04  Fumitoshi Ukai  <ukai@chromium.org>
    217
  • trunk/WebCore/inspector/front-end/inspector.css

    r49036 r49081  
    34233423    color: rgb(15%, 15%, 15%);
    34243424}
     3425
     3426.webkit-html-js-node, .webkit-html-css-node {
     3427    white-space: pre;
     3428}
     3429
     3430.webkit-css-comment {
     3431    color: rgb(0, 116, 0);
     3432}
     3433
     3434.webkit-css-string, .webkit-css-keyword, .webkit-css-unit {
     3435    color: rgb(7, 144, 154);
     3436}
     3437
     3438.webkit-css-number {
     3439    color: rgb(50, 0, 255);
     3440}
     3441
     3442.webkit-css-property, .webkit-css-at-rule {
     3443    color: rgb(200, 0, 0);
     3444}
     3445
     3446.webkit-css-url {
     3447    color: rgb(0, 0, 0);
     3448}
     3449
     3450.webkit-css-selector {
     3451    color: rgb(0, 0, 0);
     3452}
     3453
     3454.webkit-css-pseudo-class {
     3455    color: rgb(128, 128, 128);
     3456}
     3457
     3458.webkit-javascript-comment {
     3459    color: rgb(0, 116, 0);
     3460}
     3461
     3462.webkit-javascript-keyword {
     3463    color: rgb(170, 13, 145);
     3464}
     3465
     3466.webkit-javascript-number {
     3467    color: rgb(28, 0, 207);
     3468}
     3469
     3470.webkit-javascript-string, .webkit-javascript-regexp {
     3471    color: rgb(196, 26, 22);
     3472}
  • trunk/WebCore/inspector/front-end/utilities.js

    r48809 r49081  
    595595            if (isNodeWhitespace.call(this))
    596596                info.title = "(whitespace)";
    597             else
    598                 info.title = "\"<span class=\"webkit-html-text-node\">" + this.nodeValue.escapeHTML() + "</span>\"";
    599             break
     597            else {
     598                if (this.parentNode && this.parentNode.nodeName.toLowerCase() == "script") {
     599                    var newNode = document.createElement("span");
     600                    newNode.textContent = this.textContent;
     601                   
     602                    var javascriptSyntaxHighlighter = new WebInspector.JavaScriptSourceSyntaxHighlighter(null, null);
     603                    javascriptSyntaxHighlighter.syntaxHighlightLine(newNode, null);
     604                   
     605                    info.title = "<span class=\"webkit-html-text-node webkit-html-js-node\">" + newNode.innerHTML.replace(/^[\n\r]*/, "").replace(/\s*$/, "") + "</span>";
     606                } else if (this.parentNode && this.parentNode.nodeName.toLowerCase() == "style") {
     607                    var newNode = document.createElement("span");
     608                    newNode.textContent = this.textContent;
     609                   
     610                    var cssSyntaxHighlighter = new WebInspector.CSSSourceSyntaxHighligher(null, null);
     611                    cssSyntaxHighlighter.syntaxHighlightLine(newNode, null);
     612                   
     613                    info.title = "<span class=\"webkit-html-text-node webkit-html-css-node\">" + newNode.innerHTML.replace(/^[\n\r]*/, "").replace(/\s*$/, "") + "</span>";
     614                } else {
     615                    info.title = "\"<span class=\"webkit-html-text-node\">" + this.nodeValue.escapeHTML() + "</span>\"";
     616                }
     617            }
     618            break;
    600619
    601620        case Node.COMMENT_NODE:
Note: See TracChangeset for help on using the changeset viewer.