Changeset 54231 in webkit


Ignore:
Timestamp:
Feb 2, 2010 5:59:20 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-02-02 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: URLs are not syntax-higlighted as links in source view.

This change enables linkifier in the NativeTextViewer. It adds
"linkify" and "a_node" parse states into the highlighter in order
to detect links and distinguish between resource and external ones.
Contains drive-by fix for the webkit-html-* styles and moves them to the
common location.

https://bugs.webkit.org/show_bug.cgi?id=34364

  • inspector/front-end/NativeTextViewer.js: (WebInspector.NativeTextViewer): (WebInspector.NativeTextViewer.prototype._createSpan): (WebInspector.NativeTextViewer.prototype._createLink): (WebInspector.NativeTextViewer.prototype._rewriteHref):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype.setContent): (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
  • inspector/front-end/SourceHTMLTokenizer.js: (WebInspector.SourceHTMLTokenizer): (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttribute): (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttributeValue): (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttribute): (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttributeValue): (WebInspector.SourceHTMLTokenizer.prototype._stringToken): (WebInspector.SourceHTMLTokenizer.prototype._attrValueTokenType): (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
  • inspector/front-end/SourceHTMLTokenizer.re2js:
  • inspector/front-end/SourceView.js: (WebInspector.SourceView.prototype._contentLoaded):
  • inspector/front-end/TextEditorHighlighter.js: (WebInspector.TextEditorHighlighter):
  • inspector/front-end/inspector.css:
  • inspector/front-end/inspectorSyntaxHighlight.css:
Location:
trunk/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54229 r54231  
     12010-02-02  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: URLs are not syntax-higlighted as links in source view.
     6
     7        This change enables linkifier in the NativeTextViewer. It adds
     8        "linkify" and "a_node" parse states into the highlighter in order
     9        to detect links and distinguish between resource and external ones.
     10        Contains drive-by fix for the webkit-html-* styles and moves them to the
     11        common location.
     12
     13        https://bugs.webkit.org/show_bug.cgi?id=34364
     14
     15        * inspector/front-end/NativeTextViewer.js:
     16        (WebInspector.NativeTextViewer):
     17        (WebInspector.NativeTextViewer.prototype._createSpan):
     18        (WebInspector.NativeTextViewer.prototype._createLink):
     19        (WebInspector.NativeTextViewer.prototype._rewriteHref):
     20        * inspector/front-end/SourceFrame.js:
     21        (WebInspector.SourceFrame.prototype.setContent):
     22        (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
     23        * inspector/front-end/SourceHTMLTokenizer.js:
     24        (WebInspector.SourceHTMLTokenizer):
     25        (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttribute):
     26        (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttributeValue):
     27        (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttribute):
     28        (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttributeValue):
     29        (WebInspector.SourceHTMLTokenizer.prototype._stringToken):
     30        (WebInspector.SourceHTMLTokenizer.prototype._attrValueTokenType):
     31        (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
     32        * inspector/front-end/SourceHTMLTokenizer.re2js:
     33        * inspector/front-end/SourceView.js:
     34        (WebInspector.SourceView.prototype._contentLoaded):
     35        * inspector/front-end/TextEditorHighlighter.js:
     36        (WebInspector.TextEditorHighlighter):
     37        * inspector/front-end/inspector.css:
     38        * inspector/front-end/inspectorSyntaxHighlight.css:
     39
    1402010-02-02  Simon Hausmann  <simon.hausmann@nokia.com>
    241
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r54053 r54231  
    899899            return hrefValue;
    900900
    901         var match;
    902         var documentURL;
    903901        for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) {
    904902            if (frameOwnerCandidate.documentURL) {
    905                 documentURL = frameOwnerCandidate.documentURL;
     903                var result = WebInspector.completeURL(frameOwnerCandidate.documentURL, hrefValue);
     904                if (result)
     905                    return result;
    906906                break;
    907907            }
    908908        }
    909         if (documentURL) {
    910             match = documentURL.match(WebInspector.URLRegExp);
    911             if (match) {
    912                 var path = hrefValue;
    913                 if (path.charAt(0) !== "/") {
    914                     var documentPath = match[4] || "/";
    915                     path = documentPath.substring(0, documentPath.lastIndexOf("/")) + "/" + path;
    916                 }
    917                 return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path;
    918             }
    919         }
    920909
    921910        // documentURL not found or has bad value
    922911        for (var url in WebInspector.resourceURLMap) {
    923             match = url.match(WebInspector.URLRegExp);
     912            var match = url.match(WebInspector.URLRegExp);
    924913            if (match && match[4] === hrefValue)
    925914                return url;
  • trunk/WebCore/inspector/front-end/NativeTextViewer.js

    r54139 r54231  
    2929 */
    3030
    31 WebInspector.NativeTextViewer = function(textModel, platform)
     31WebInspector.NativeTextViewer = function(textModel, platform, url)
    3232{
    3333    WebInspector.TextEditor.call(this, textModel, platform);
     
    3535    this._canvas.style.zIndex = 0;
    3636    this._createLineDivs();
     37    this._url = url;
    3738    this._selectionColor = "rgb(241, 234, 0)";
    3839}
     
    191192    _createSpan: function(content, className)
    192193    {
     194        if (className === "html-resource-link" || className === "html-external-link")
     195            return this._createLink(content, className === "html-external-link");
     196
    193197        var span = document.createElement("span");
    194198        span.className = "webkit-" + className;
    195199        span.appendChild(document.createTextNode(content));
    196200        return span;
     201    },
     202
     203    _createLink: function(content, isExternal)
     204    {
     205        var quote = content.charAt(0);
     206        if (content.length > 1 && (quote === "\"" ||   quote === "'"))
     207            content = content.substring(1, content.length - 1);
     208        else
     209            quote = null;
     210
     211        var a = WebInspector.linkifyURLAsNode(this._rewriteHref(content), content, null, isExternal);
     212        var span = document.createElement("span");
     213        span.className = "webkit-html-attribute-value";
     214        if (quote)
     215            span.appendChild(document.createTextNode(quote));
     216        span.appendChild(a);
     217        if (quote)
     218            span.appendChild(document.createTextNode(quote));
     219        return span;
     220    },
     221
     222    _rewriteHref: function(hrefValue, isExternal)
     223    {
     224        if (!this._url || !hrefValue || hrefValue.indexOf("://") > 0)
     225            return hrefValue;
     226        return WebInspector.completeURL(this._url, hrefValue);
    197227    },
    198228
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r54139 r54231  
    124124    },
    125125
    126     setContent: function(mimeType, content)
     126    setContent: function(mimeType, content, url)
    127127    {
    128128        this._loaded = true;
    129129        this._textModel.setText(null, content);
    130130        this._mimeType = mimeType;
     131        this._url = url;
    131132        this._createEditorIfNeeded();
    132133    },
     
    138139
    139140        var editorConstructor = Preferences.useCanvasBasedEditor ? WebInspector.TextEditor : WebInspector.NativeTextViewer;
    140         this._editor = new editorConstructor(this._textModel, WebInspector.platform);
     141        this._editor = new editorConstructor(this._textModel, WebInspector.platform, this._url);
    141142        this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this, this._editor.textModel);
    142143        this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
  • trunk/WebCore/inspector/front-end/SourceHTMLTokenizer.js

    r54139 r54231  
    1 /* Generated by re2c 0.13.5 on Mon Feb  1 19:13:12 2010 */
     1/* Generated by re2c 0.13.5 on Tue Feb  2 00:44:38 2010 */
    22/*
    33 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    5050        INITIAL: 0,
    5151        COMMENT: 1,
    52         TAG: 2,
     52        DOCTYPE: 2,
     53        TAG: 3,
    5354        DSTRING: 4,
    5455        SSTRING: 5
     
    5657    this.case_INITIAL = 1000;
    5758    this.case_COMMENT = 1001;
    58     this.case_TAG = 1002;
     59    this.case_DOCTYPE = 1002;
     60    this.case_TAG = 1003;
    5961    this.case_DSTRING = 1004;
    6062    this.case_SSTRING = 1005;
     
    6466        ATTRIBUTE: 1,
    6567        ATTRIBUTE_VALUE: 2,
    66         SCRIPT: 3,
    67         SCRIPT_ATTRIBUTE: 4,
    68         SCRIPT_ATTRIBUTE_VALUE: 5,
    69         DOCTYPE: 6
     68        LINKIFY: 4,
     69        A_NODE: 8,
     70        SCRIPT: 16
    7071    };
    7172
     
    7475
    7576WebInspector.SourceHTMLTokenizer.prototype = {
    76     _isAttribute: function()
     77    _isExpectingAttribute: function()
    7778    {
    78         return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE;
     79        return this._parseCondition & this._parseConditions.ATTRIBUTE;
    7980    },
    8081
    81     _isAttributeValue: function()
     82    _isExpectingAttributeValue: function()
    8283    {
    83         return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE;
     84        return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
    8485    },
    8586
    86     _setAttributeValue: function()
     87    _setExpectingAttribute: function()
    8788    {
    88         if (this._parseCondition === this._parseConditions.ATTRIBUTE)
    89             this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE;
    90         else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE)
    91             this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE;
     89        if (this._isExpectingAttributeValue())
     90            this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
     91        this._parseCondition |= this._parseConditions.ATTRIBUTE;
    9292    },
    9393
    94     _setAttribute: function()
     94    _setExpectingAttributeValue: function()
    9595    {
    96         if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE)
    97             this._parseCondition = this._parseConditions.ATTRIBUTE;
    98         else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE)
    99             this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
     96        if (this._isExpectingAttribute())
     97            this._parseCondition ^= this._parseConditions.ATTRIBUTE;
     98        this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
    10099    },
    101100
    102101    _stringToken: function(cursor, stringEnds)
    103102    {
    104         if (this._isAttributeValue()) {
    105             this.tokenType = "html-attr-value";
    106             if (stringEnds)
    107                 this._setAttribute();
    108         } else if (this._parseCondition === this._parseConditions.DOCTYPE)
    109             this.tokenType = "html-doctype";
    110         else
     103        if (!this._isExpectingAttributeValue()) {
    111104            this.tokenType = null;
     105            return cursor;
     106        }
     107        this.tokenType = this._attrValueTokenType();
     108        if (stringEnds)
     109            this._setExpectingAttribute();
    112110        return cursor;
     111    },
     112
     113    _attrValueTokenType: function()
     114    {
     115        if (this._parseCondition & this._parseConditions.LINKIFY) {
     116            if (this._parseCondition & this._parseConditions.A_NODE)
     117                return "html-external-link";
     118            return "html-resource-link";
     119        }
     120        return "html-attribute-value";
    113121    },
    114122
     
    124132            case 1: var yych;
    125133            var yyaccept = 0;
    126             if (this.getLexCondition() < 2) {
     134            if (this.getLexCondition() < 3) {
    127135                if (this.getLexCondition() < 1) {
    128136                    { gotoCase = this.case_INITIAL; continue; };
    129137                } else {
    130                     { gotoCase = this.case_COMMENT; continue; };
    131                 }
    132             } else {
    133                 if (this.getLexCondition() < 3) {
     138                    if (this.getLexCondition() < 2) {
     139                        { gotoCase = this.case_COMMENT; continue; };
     140                    } else {
     141                        { gotoCase = this.case_DOCTYPE; continue; };
     142                    }
     143                }
     144            } else {
     145                if (this.getLexCondition() < 4) {
    134146                    { gotoCase = this.case_TAG; continue; };
    135147                } else {
    136                     if (this.getLexCondition() < 4) {
     148                    if (this.getLexCondition() < 5) {
    137149                        { gotoCase = this.case_DSTRING; continue; };
    138150                    } else {
     
    199211            }
    200212/* *********************************** */
    201 case this.case_DSTRING:
     213case this.case_DOCTYPE:
    202214            yych = this._charAt(cursor);
    203215            if (yych <= '\f') {
     
    206218            } else {
    207219                if (yych <= '\r') { gotoCase = 18; continue; };
    208                 if (yych == '"') { gotoCase = 20; continue; };
     220                if (yych == '>') { gotoCase = 20; continue; };
    209221                { gotoCase = 17; continue; };
    210222            }
    211223case 16:
    212             { return this._stringToken(cursor); }
     224            { this.tokenType = "html-doctype"; return cursor; }
    213225case 17:
    214226            yych = this._charAt(++cursor);
    215             { gotoCase = 24; continue; };
     227            { gotoCase = 23; continue; };
    216228case 18:
    217229            ++cursor;
     
    219231case 20:
    220232            ++cursor;
    221 case 21:
     233            this.setLexCondition(this._lexConditions.INITIAL);
     234            { this.tokenType = "html-doctype"; return cursor; }
     235case 22:
     236            ++cursor;
     237            yych = this._charAt(cursor);
     238case 23:
     239            if (yych <= '\f') {
     240                if (yych == '\n') { gotoCase = 16; continue; };
     241                { gotoCase = 22; continue; };
     242            } else {
     243                if (yych <= '\r') { gotoCase = 16; continue; };
     244                if (yych == '>') { gotoCase = 16; continue; };
     245                { gotoCase = 22; continue; };
     246            }
     247/* *********************************** */
     248case this.case_DSTRING:
     249            yych = this._charAt(cursor);
     250            if (yych <= '\f') {
     251                if (yych == '\n') { gotoCase = 28; continue; };
     252                { gotoCase = 27; continue; };
     253            } else {
     254                if (yych <= '\r') { gotoCase = 28; continue; };
     255                if (yych == '"') { gotoCase = 30; continue; };
     256                { gotoCase = 27; continue; };
     257            }
     258case 26:
     259            { return this._stringToken(cursor); }
     260case 27:
     261            yych = this._charAt(++cursor);
     262            { gotoCase = 34; continue; };
     263case 28:
     264            ++cursor;
     265            { this.tokenType = null; return cursor; }
     266case 30:
     267            ++cursor;
     268case 31:
    222269            this.setLexCondition(this._lexConditions.TAG);
    223270            { return this._stringToken(cursor, true); }
    224 case 22:
    225             yych = this._charAt(++cursor);
    226             { gotoCase = 21; continue; };
    227 case 23:
    228             ++cursor;
    229             yych = this._charAt(cursor);
    230 case 24:
    231             if (yych <= '\f') {
    232                 if (yych == '\n') { gotoCase = 16; continue; };
    233                 { gotoCase = 23; continue; };
    234             } else {
    235                 if (yych <= '\r') { gotoCase = 16; continue; };
    236                 if (yych == '"') { gotoCase = 22; continue; };
    237                 { gotoCase = 23; continue; };
     271case 32:
     272            yych = this._charAt(++cursor);
     273            { gotoCase = 31; continue; };
     274case 33:
     275            ++cursor;
     276            yych = this._charAt(cursor);
     277case 34:
     278            if (yych <= '\f') {
     279                if (yych == '\n') { gotoCase = 26; continue; };
     280                { gotoCase = 33; continue; };
     281            } else {
     282                if (yych <= '\r') { gotoCase = 26; continue; };
     283                if (yych == '"') { gotoCase = 32; continue; };
     284                { gotoCase = 33; continue; };
    238285            }
    239286/* *********************************** */
    240287case this.case_INITIAL:
    241288            yych = this._charAt(cursor);
    242             if (yych == '<') { gotoCase = 29; continue; };
     289            if (yych == '<') { gotoCase = 39; continue; };
    243290            ++cursor;
    244291            { this.tokenType = null; return cursor; }
    245 case 29:
     292case 39:
    246293            yyaccept = 0;
    247294            yych = this._charAt(YYMARKER = ++cursor);
    248295            if (yych <= '/') {
    249                 if (yych == '!') { gotoCase = 34; continue; };
    250                 if (yych >= '/') { gotoCase = 31; continue; };
     296                if (yych == '!') { gotoCase = 44; continue; };
     297                if (yych >= '/') { gotoCase = 41; continue; };
    251298            } else {
    252299                if (yych <= 'S') {
    253                     if (yych >= 'S') { gotoCase = 32; continue; };
     300                    if (yych >= 'S') { gotoCase = 42; continue; };
    254301                } else {
    255                     if (yych == 's') { gotoCase = 32; continue; };
    256                 }
    257             }
    258 case 30:
     302                    if (yych == 's') { gotoCase = 42; continue; };
     303                }
     304            }
     305case 40:
     306            this.setLexCondition(this._lexConditions.TAG);
    259307            {
    260                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     308                    if (this._parseCondition & this._parseConditions.SCRIPT) {
     309                        // Do not tokenize script tag contents, keep lexer state although processing "<".
     310                        this.setLexCondition(this._lexConditions.INITIAL);
    261311                        this.tokenType = null;
    262312                        return cursor;
    263313                    }
    264314
    265                     this.setLexCondition(this._lexConditions.TAG);
    266 
     315                    this._parseCondition = this._parseConditions.INITIAL;
    267316                    this.tokenType = "html-tag";
    268                     this._parseCondition = this._parseConditions.INITIAL;
    269317                    return cursor;
    270318                }
    271 case 31:
     319case 41:
    272320            yyaccept = 0;
    273321            yych = this._charAt(YYMARKER = ++cursor);
    274             if (yych == 'S') { gotoCase = 58; continue; };
    275             if (yych == 's') { gotoCase = 58; continue; };
    276             { gotoCase = 30; continue; };
    277 case 32:
    278             yych = this._charAt(++cursor);
    279             if (yych == 'C') { gotoCase = 52; continue; };
    280             if (yych == 'c') { gotoCase = 52; continue; };
    281 case 33:
     322            if (yych == 'S') { gotoCase = 68; continue; };
     323            if (yych == 's') { gotoCase = 68; continue; };
     324            { gotoCase = 40; continue; };
     325case 42:
     326            yych = this._charAt(++cursor);
     327            if (yych == 'C') { gotoCase = 62; continue; };
     328            if (yych == 'c') { gotoCase = 62; continue; };
     329case 43:
    282330            cursor = YYMARKER;
    283             { gotoCase = 30; continue; };
    284 case 34:
     331            { gotoCase = 40; continue; };
     332case 44:
    285333            yych = this._charAt(++cursor);
    286334            if (yych <= 'C') {
    287                 if (yych != '-') { gotoCase = 33; continue; };
    288             } else {
    289                 if (yych <= 'D') { gotoCase = 36; continue; };
    290                 if (yych == 'd') { gotoCase = 36; continue; };
    291                 { gotoCase = 33; continue; };
    292             }
    293             yych = this._charAt(++cursor);
    294             if (yych == '-') { gotoCase = 44; continue; };
    295             { gotoCase = 33; continue; };
    296 case 36:
    297             yych = this._charAt(++cursor);
    298             if (yych == 'O') { gotoCase = 37; continue; };
    299             if (yych != 'o') { gotoCase = 33; continue; };
    300 case 37:
    301             yych = this._charAt(++cursor);
    302             if (yych == 'C') { gotoCase = 38; continue; };
    303             if (yych != 'c') { gotoCase = 33; continue; };
    304 case 38:
    305             yych = this._charAt(++cursor);
    306             if (yych == 'T') { gotoCase = 39; continue; };
    307             if (yych != 't') { gotoCase = 33; continue; };
    308 case 39:
    309             yych = this._charAt(++cursor);
    310             if (yych == 'Y') { gotoCase = 40; continue; };
    311             if (yych != 'y') { gotoCase = 33; continue; };
    312 case 40:
    313             yych = this._charAt(++cursor);
    314             if (yych == 'P') { gotoCase = 41; continue; };
    315             if (yych != 'p') { gotoCase = 33; continue; };
    316 case 41:
    317             yych = this._charAt(++cursor);
    318             if (yych == 'E') { gotoCase = 42; continue; };
    319             if (yych != 'e') { gotoCase = 33; continue; };
    320 case 42:
    321             ++cursor;
    322             this.setLexCondition(this._lexConditions.TAG);
    323             {
    324                     this.tokenType = "html-doctype";
    325                     this._parseCondition = this._parseConditions.DOCTYPE;
    326                     return cursor;
    327                 }
    328 case 44:
    329             ++cursor;
    330             yych = this._charAt(cursor);
    331             if (yych <= '\f') {
    332                 if (yych == '\n') { gotoCase = 47; continue; };
    333                 { gotoCase = 44; continue; };
    334             } else {
    335                 if (yych <= '\r') { gotoCase = 47; continue; };
    336                 if (yych != '-') { gotoCase = 44; continue; };
    337             }
    338             ++cursor;
    339             yych = this._charAt(cursor);
    340             if (yych == '-') { gotoCase = 49; continue; };
    341             { gotoCase = 33; continue; };
     335                if (yych != '-') { gotoCase = 43; continue; };
     336            } else {
     337                if (yych <= 'D') { gotoCase = 46; continue; };
     338                if (yych == 'd') { gotoCase = 46; continue; };
     339                { gotoCase = 43; continue; };
     340            }
     341            yych = this._charAt(++cursor);
     342            if (yych == '-') { gotoCase = 54; continue; };
     343            { gotoCase = 43; continue; };
     344case 46:
     345            yych = this._charAt(++cursor);
     346            if (yych == 'O') { gotoCase = 47; continue; };
     347            if (yych != 'o') { gotoCase = 43; continue; };
    342348case 47:
     349            yych = this._charAt(++cursor);
     350            if (yych == 'C') { gotoCase = 48; continue; };
     351            if (yych != 'c') { gotoCase = 43; continue; };
     352case 48:
     353            yych = this._charAt(++cursor);
     354            if (yych == 'T') { gotoCase = 49; continue; };
     355            if (yych != 't') { gotoCase = 43; continue; };
     356case 49:
     357            yych = this._charAt(++cursor);
     358            if (yych == 'Y') { gotoCase = 50; continue; };
     359            if (yych != 'y') { gotoCase = 43; continue; };
     360case 50:
     361            yych = this._charAt(++cursor);
     362            if (yych == 'P') { gotoCase = 51; continue; };
     363            if (yych != 'p') { gotoCase = 43; continue; };
     364case 51:
     365            yych = this._charAt(++cursor);
     366            if (yych == 'E') { gotoCase = 52; continue; };
     367            if (yych != 'e') { gotoCase = 43; continue; };
     368case 52:
     369            ++cursor;
     370            this.setLexCondition(this._lexConditions.DOCTYPE);
     371            { this.tokenType = "html-doctype"; return cursor; }
     372case 54:
     373            ++cursor;
     374            yych = this._charAt(cursor);
     375            if (yych <= '\f') {
     376                if (yych == '\n') { gotoCase = 57; continue; };
     377                { gotoCase = 54; continue; };
     378            } else {
     379                if (yych <= '\r') { gotoCase = 57; continue; };
     380                if (yych != '-') { gotoCase = 54; continue; };
     381            }
     382            ++cursor;
     383            yych = this._charAt(cursor);
     384            if (yych == '-') { gotoCase = 59; continue; };
     385            { gotoCase = 43; continue; };
     386case 57:
    343387            ++cursor;
    344388            this.setLexCondition(this._lexConditions.COMMENT);
    345389            { this.tokenType = "html-comment"; return cursor; }
    346 case 49:
    347             ++cursor;
    348             yych = this._charAt(cursor);
    349             if (yych != '>') { gotoCase = 44; continue; };
     390case 59:
     391            ++cursor;
     392            yych = this._charAt(cursor);
     393            if (yych != '>') { gotoCase = 54; continue; };
    350394            ++cursor;
    351395            { this.tokenType = "html-comment"; return cursor; }
    352 case 52:
    353             yych = this._charAt(++cursor);
    354             if (yych == 'R') { gotoCase = 53; continue; };
    355             if (yych != 'r') { gotoCase = 33; continue; };
    356 case 53:
    357             yych = this._charAt(++cursor);
    358             if (yych == 'I') { gotoCase = 54; continue; };
    359             if (yych != 'i') { gotoCase = 33; continue; };
    360 case 54:
    361             yych = this._charAt(++cursor);
    362             if (yych == 'P') { gotoCase = 55; continue; };
    363             if (yych != 'p') { gotoCase = 33; continue; };
    364 case 55:
    365             yych = this._charAt(++cursor);
    366             if (yych == 'T') { gotoCase = 56; continue; };
    367             if (yych != 't') { gotoCase = 33; continue; };
    368 case 56:
     396case 62:
     397            yych = this._charAt(++cursor);
     398            if (yych == 'R') { gotoCase = 63; continue; };
     399            if (yych != 'r') { gotoCase = 43; continue; };
     400case 63:
     401            yych = this._charAt(++cursor);
     402            if (yych == 'I') { gotoCase = 64; continue; };
     403            if (yych != 'i') { gotoCase = 43; continue; };
     404case 64:
     405            yych = this._charAt(++cursor);
     406            if (yych == 'P') { gotoCase = 65; continue; };
     407            if (yych != 'p') { gotoCase = 43; continue; };
     408case 65:
     409            yych = this._charAt(++cursor);
     410            if (yych == 'T') { gotoCase = 66; continue; };
     411            if (yych != 't') { gotoCase = 43; continue; };
     412case 66:
    369413            ++cursor;
    370414            this.setLexCondition(this._lexConditions.TAG);
    371415            {
    372416                    this.tokenType = "html-tag";
    373                     this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
     417                    this._parseCondition = this._parseConditions.SCRIPT;
     418                    this._setExpectingAttribute();
    374419                    return cursor;
    375420                }
    376 case 58:
    377             yych = this._charAt(++cursor);
    378             if (yych == 'C') { gotoCase = 59; continue; };
    379             if (yych != 'c') { gotoCase = 33; continue; };
    380 case 59:
    381             yych = this._charAt(++cursor);
    382             if (yych == 'R') { gotoCase = 60; continue; };
    383             if (yych != 'r') { gotoCase = 33; continue; };
    384 case 60:
    385             yych = this._charAt(++cursor);
    386             if (yych == 'I') { gotoCase = 61; continue; };
    387             if (yych != 'i') { gotoCase = 33; continue; };
    388 case 61:
    389             yych = this._charAt(++cursor);
    390             if (yych == 'P') { gotoCase = 62; continue; };
    391             if (yych != 'p') { gotoCase = 33; continue; };
    392 case 62:
    393             yych = this._charAt(++cursor);
    394             if (yych == 'T') { gotoCase = 63; continue; };
    395             if (yych != 't') { gotoCase = 33; continue; };
    396 case 63:
     421case 68:
     422            yych = this._charAt(++cursor);
     423            if (yych == 'C') { gotoCase = 69; continue; };
     424            if (yych != 'c') { gotoCase = 43; continue; };
     425case 69:
     426            yych = this._charAt(++cursor);
     427            if (yych == 'R') { gotoCase = 70; continue; };
     428            if (yych != 'r') { gotoCase = 43; continue; };
     429case 70:
     430            yych = this._charAt(++cursor);
     431            if (yych == 'I') { gotoCase = 71; continue; };
     432            if (yych != 'i') { gotoCase = 43; continue; };
     433case 71:
     434            yych = this._charAt(++cursor);
     435            if (yych == 'P') { gotoCase = 72; continue; };
     436            if (yych != 'p') { gotoCase = 43; continue; };
     437case 72:
     438            yych = this._charAt(++cursor);
     439            if (yych == 'T') { gotoCase = 73; continue; };
     440            if (yych != 't') { gotoCase = 43; continue; };
     441case 73:
    397442            ++cursor;
    398443            this.setLexCondition(this._lexConditions.TAG);
     
    406451            yych = this._charAt(cursor);
    407452            if (yych <= '\f') {
    408                 if (yych == '\n') { gotoCase = 69; continue; };
    409                 { gotoCase = 68; continue; };
    410             } else {
    411                 if (yych <= '\r') { gotoCase = 69; continue; };
    412                 if (yych == '\'') { gotoCase = 71; continue; };
    413                 { gotoCase = 68; continue; };
    414             }
    415 case 67:
     453                if (yych == '\n') { gotoCase = 79; continue; };
     454                { gotoCase = 78; continue; };
     455            } else {
     456                if (yych <= '\r') { gotoCase = 79; continue; };
     457                if (yych == '\'') { gotoCase = 81; continue; };
     458                { gotoCase = 78; continue; };
     459            }
     460case 77:
    416461            { return this._stringToken(cursor); }
    417 case 68:
    418             yych = this._charAt(++cursor);
    419             { gotoCase = 75; continue; };
    420 case 69:
     462case 78:
     463            yych = this._charAt(++cursor);
     464            { gotoCase = 85; continue; };
     465case 79:
    421466            ++cursor;
    422467            { this.tokenType = null; return cursor; }
    423 case 71:
    424             ++cursor;
    425 case 72:
     468case 81:
     469            ++cursor;
     470case 82:
    426471            this.setLexCondition(this._lexConditions.TAG);
    427472            { return this._stringToken(cursor, true); }
    428 case 73:
    429             yych = this._charAt(++cursor);
    430             { gotoCase = 72; continue; };
    431 case 74:
    432             ++cursor;
    433             yych = this._charAt(cursor);
    434 case 75:
    435             if (yych <= '\f') {
    436                 if (yych == '\n') { gotoCase = 67; continue; };
    437                 { gotoCase = 74; continue; };
    438             } else {
    439                 if (yych <= '\r') { gotoCase = 67; continue; };
    440                 if (yych == '\'') { gotoCase = 73; continue; };
    441                 { gotoCase = 74; continue; };
     473case 83:
     474            yych = this._charAt(++cursor);
     475            { gotoCase = 82; continue; };
     476case 84:
     477            ++cursor;
     478            yych = this._charAt(cursor);
     479case 85:
     480            if (yych <= '\f') {
     481                if (yych == '\n') { gotoCase = 77; continue; };
     482                { gotoCase = 84; continue; };
     483            } else {
     484                if (yych <= '\r') { gotoCase = 77; continue; };
     485                if (yych == '\'') { gotoCase = 83; continue; };
     486                { gotoCase = 84; continue; };
    442487            }
    443488/* *********************************** */
    444489case this.case_TAG:
    445490            yych = this._charAt(cursor);
    446             if (yych <= '=') {
    447                 if (yych <= '\'') {
    448                     if (yych == '"') { gotoCase = 80; continue; };
    449                     if (yych >= '\'') { gotoCase = 81; continue; };
     491            if (yych <= '&') {
     492                if (yych <= '\r') {
     493                    if (yych == '\n') { gotoCase = 90; continue; };
     494                    if (yych >= '\r') { gotoCase = 90; continue; };
    450495                } else {
    451                     if (yych <= '/') { gotoCase = 78; continue; };
    452                     if (yych <= '9') { gotoCase = 82; continue; };
    453                     if (yych >= '=') { gotoCase = 84; continue; };
    454                 }
    455             } else {
    456                 if (yych <= '^') {
    457                     if (yych <= '>') { gotoCase = 86; continue; };
    458                     if (yych <= '@') { gotoCase = 78; continue; };
    459                     if (yych <= 'Z') { gotoCase = 82; continue; };
     496                    if (yych <= ' ') {
     497                        if (yych >= ' ') { gotoCase = 90; continue; };
     498                    } else {
     499                        if (yych == '"') { gotoCase = 92; continue; };
     500                    }
     501                }
     502            } else {
     503                if (yych <= '>') {
     504                    if (yych <= ';') {
     505                        if (yych <= '\'') { gotoCase = 93; continue; };
     506                    } else {
     507                        if (yych <= '<') { gotoCase = 90; continue; };
     508                        if (yych <= '=') { gotoCase = 94; continue; };
     509                        { gotoCase = 96; continue; };
     510                    }
    460511                } else {
    461                     if (yych <= '`') {
    462                         if (yych <= '_') { gotoCase = 82; continue; };
     512                    if (yych <= '[') {
     513                        if (yych >= '[') { gotoCase = 90; continue; };
    463514                    } else {
    464                         if (yych <= 'z') { gotoCase = 82; continue; };
    465                         if (yych >= 0x80) { gotoCase = 82; continue; };
    466                     }
    467                 }
    468             }
    469 case 78:
    470             ++cursor;
    471             { this.tokenType = null; return cursor; }
    472 case 80:
    473             yyaccept = 0;
    474             yych = this._charAt(YYMARKER = ++cursor);
    475             { gotoCase = 97; continue; };
    476 case 81:
    477             yyaccept = 0;
    478             yych = this._charAt(YYMARKER = ++cursor);
    479             { gotoCase = 91; continue; };
    480 case 82:
    481             ++cursor;
    482             yych = this._charAt(cursor);
    483             { gotoCase = 89; continue; };
    484 case 83:
     515                        if (yych == ']') { gotoCase = 90; continue; };
     516                    }
     517                }
     518            }
     519            ++cursor;
     520            yych = this._charAt(cursor);
     521            { gotoCase = 109; continue; };
     522case 89:
    485523            {
    486524                    if (this._parseCondition === this._parseConditions.SCRIPT) {
     525                        // Fall through if expecting attributes.
    487526                        this.tokenType = null;
    488527                        return cursor;
     
    491530                    if (this._parseCondition === this._parseConditions.INITIAL) {
    492531                        this.tokenType = "html-tag";
    493                         this._parseCondition = this._parseConditions.ATTRIBUTE;
    494                     } else if (this._isAttribute())
    495                         this.tokenType = "html-attr-name";
    496                     else if (this._isAttributeValue())
    497                         this.tokenType = "html-attr-value";
    498                     else if (this._parseCondition === this._parseConditions.DOCTYPE)
    499                         this.tokenType = "html-doctype";
     532                        this._setExpectingAttribute();
     533                        var token = this._line.substring(cursorOnEnter, cursor);
     534                        if (token === "a")
     535                            this._parseCondition |= this._parseConditions.A_NODE;
     536                        else if (this._parseCondition & this._parseConditions.A_NODE)
     537                            this._parseCondition ^= this._parseConditions.A_NODE;
     538                    } else if (this._isExpectingAttribute()) {
     539                        var token = this._line.substring(cursorOnEnter, cursor);
     540                        if (token === "href" || token === "src")
     541                            this._parseCondition |= this._parseConditions.LINKIFY;
     542                        else if (this._parseCondition |= this._parseConditions.LINKIFY)
     543                            this._parseCondition ^= this._parseConditions.LINKIFY;
     544                        this.tokenType = "html-attribute-name";
     545                    } else if (this._isExpectingAttributeValue())
     546                        this.tokenType = this._attrValueTokenType();
    500547                    else
    501548                        this.tokenType = null;
    502549                    return cursor;
    503550                }
    504 case 84:
     551case 90:
     552            ++cursor;
     553            { this.tokenType = null; return cursor; }
     554case 92:
     555            yyaccept = 0;
     556            yych = this._charAt(YYMARKER = ++cursor);
     557            { gotoCase = 105; continue; };
     558case 93:
     559            yyaccept = 0;
     560            yych = this._charAt(YYMARKER = ++cursor);
     561            { gotoCase = 99; continue; };
     562case 94:
    505563            ++cursor;
    506564            {
    507                     if (this._isAttribute()) {
    508                         this.tokenType = null;
    509                         this._setAttributeValue();
    510                     } else if (this._parseCondition === this._parseConditions.DOCTYPE)
    511                         this.tokenType = "html-doctype";
    512                     else
    513                         this.tokenType = null;
     565                    if (this._isExpectingAttribute())
     566                        this._setExpectingAttributeValue();
     567                    this.tokenType = null;
    514568                    return cursor;
    515569                }
    516 case 86:
     570case 96:
    517571            ++cursor;
    518572            this.setLexCondition(this._lexConditions.INITIAL);
    519573            {
    520                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     574                    if (this._parseCondition & this._parseConditions.SCRIPT) {
     575                        // Do not tokenize script tag contents.
    521576                        this.tokenType = null;
    522577                        return cursor;
    523578                    }
    524579
    525                     if (this._parseCondition === this._parseConditions.DOCTYPE)
    526                         this.tokenType = "html-doctype";
    527                     else
    528                         this.tokenType = "html-tag";
    529 
    530                     if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE)
    531                         this._parseCondition = this._parseConditions.SCRIPT;
    532                     else
    533                         this._parseCondition = this._parseConditions.INITIAL;
     580                    this._parseCondition = this._parseConditions.INITIAL;
     581                    this.tokenType = "html-tag";
    534582                    return cursor;
    535583                }
    536 case 88:
    537             ++cursor;
    538             yych = this._charAt(cursor);
    539 case 89:
    540             if (yych <= '^') {
    541                 if (yych <= '9') {
    542                     if (yych <= '/') { gotoCase = 83; continue; };
    543                     { gotoCase = 88; continue; };
    544                 } else {
    545                     if (yych <= '@') { gotoCase = 83; continue; };
    546                     if (yych <= 'Z') { gotoCase = 88; continue; };
    547                     { gotoCase = 83; continue; };
    548                 }
    549             } else {
    550                 if (yych <= '`') {
    551                     if (yych <= '_') { gotoCase = 88; continue; };
    552                     { gotoCase = 83; continue; };
    553                 } else {
    554                     if (yych <= 'z') { gotoCase = 88; continue; };
    555                     if (yych <= 0x7F) { gotoCase = 83; continue; };
    556                     { gotoCase = 88; continue; };
    557                 }
    558             }
    559 case 90:
    560             ++cursor;
    561             yych = this._charAt(cursor);
    562 case 91:
    563             if (yych <= '\f') {
    564                 if (yych != '\n') { gotoCase = 90; continue; };
    565             } else {
    566                 if (yych <= '\r') { gotoCase = 92; continue; };
    567                 if (yych == '\'') { gotoCase = 94; continue; };
    568                 { gotoCase = 90; continue; };
    569             }
    570 case 92:
     584case 98:
     585            ++cursor;
     586            yych = this._charAt(cursor);
     587case 99:
     588            if (yych <= '\f') {
     589                if (yych != '\n') { gotoCase = 98; continue; };
     590            } else {
     591                if (yych <= '\r') { gotoCase = 100; continue; };
     592                if (yych == '\'') { gotoCase = 102; continue; };
     593                { gotoCase = 98; continue; };
     594            }
     595case 100:
    571596            ++cursor;
    572597            this.setLexCondition(this._lexConditions.SSTRING);
    573598            { return this._stringToken(cursor); }
    574 case 94:
     599case 102:
    575600            ++cursor;
    576601            { return this._stringToken(cursor, true); }
    577 case 96:
    578             ++cursor;
    579             yych = this._charAt(cursor);
    580 case 97:
    581             if (yych <= '\f') {
    582                 if (yych != '\n') { gotoCase = 96; continue; };
    583             } else {
    584                 if (yych <= '\r') { gotoCase = 98; continue; };
    585                 if (yych == '"') { gotoCase = 94; continue; };
    586                 { gotoCase = 96; continue; };
    587             }
    588 case 98:
     602case 104:
     603            ++cursor;
     604            yych = this._charAt(cursor);
     605case 105:
     606            if (yych <= '\f') {
     607                if (yych != '\n') { gotoCase = 104; continue; };
     608            } else {
     609                if (yych <= '\r') { gotoCase = 106; continue; };
     610                if (yych == '"') { gotoCase = 102; continue; };
     611                { gotoCase = 104; continue; };
     612            }
     613case 106:
    589614            ++cursor;
    590615            this.setLexCondition(this._lexConditions.DSTRING);
    591616            { return this._stringToken(cursor); }
     617case 108:
     618            ++cursor;
     619            yych = this._charAt(cursor);
     620case 109:
     621            if (yych <= '"') {
     622                if (yych <= '\r') {
     623                    if (yych == '\n') { gotoCase = 89; continue; };
     624                    if (yych <= '\f') { gotoCase = 108; continue; };
     625                    { gotoCase = 89; continue; };
     626                } else {
     627                    if (yych == ' ') { gotoCase = 89; continue; };
     628                    if (yych <= '!') { gotoCase = 108; continue; };
     629                    { gotoCase = 89; continue; };
     630                }
     631            } else {
     632                if (yych <= '>') {
     633                    if (yych == '\'') { gotoCase = 89; continue; };
     634                    if (yych <= ';') { gotoCase = 108; continue; };
     635                    { gotoCase = 89; continue; };
     636                } else {
     637                    if (yych <= '[') {
     638                        if (yych <= 'Z') { gotoCase = 108; continue; };
     639                        { gotoCase = 89; continue; };
     640                    } else {
     641                        if (yych == ']') { gotoCase = 89; continue; };
     642                        { gotoCase = 108; continue; };
     643                    }
     644                }
     645            }
    592646        }
    593647
  • trunk/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js

    r54139 r54231  
    4949        INITIAL: 0,
    5050        COMMENT: 1,
    51         TAG: 2,
     51        DOCTYPE: 2,
     52        TAG: 3,
    5253        DSTRING: 4,
    5354        SSTRING: 5
     
    5556    this.case_INITIAL = 1000;
    5657    this.case_COMMENT = 1001;
    57     this.case_TAG = 1002;
     58    this.case_DOCTYPE = 1002;
     59    this.case_TAG = 1003;
    5860    this.case_DSTRING = 1004;
    5961    this.case_SSTRING = 1005;
     
    6365        ATTRIBUTE: 1,
    6466        ATTRIBUTE_VALUE: 2,
    65         SCRIPT: 3,
    66         SCRIPT_ATTRIBUTE: 4,
    67         SCRIPT_ATTRIBUTE_VALUE: 5,
    68         DOCTYPE: 6
     67        LINKIFY: 4,
     68        A_NODE: 8,
     69        SCRIPT: 16
    6970    };
    7071
     
    7374
    7475WebInspector.SourceHTMLTokenizer.prototype = {
    75     _isAttribute: function()
    76     {
    77         return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE;
    78     },
    79 
    80     _isAttributeValue: function()
    81     {
    82         return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE;
    83     },
    84 
    85     _setAttributeValue: function()
    86     {
    87         if (this._parseCondition === this._parseConditions.ATTRIBUTE)
    88             this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE;
    89         else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE)
    90             this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE;
    91     },
    92 
    93     _setAttribute: function()
    94     {
    95         if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE)
    96             this._parseCondition = this._parseConditions.ATTRIBUTE;
    97         else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE)
    98             this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
     76    _isExpectingAttribute: function()
     77    {
     78        return this._parseCondition & this._parseConditions.ATTRIBUTE;
     79    },
     80
     81    _isExpectingAttributeValue: function()
     82    {
     83        return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
     84    },
     85
     86    _setExpectingAttribute: function()
     87    {
     88        if (this._isExpectingAttributeValue())
     89            this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
     90        this._parseCondition |= this._parseConditions.ATTRIBUTE;
     91    },
     92
     93    _setExpectingAttributeValue: function()
     94    {
     95        if (this._isExpectingAttribute())
     96            this._parseCondition ^= this._parseConditions.ATTRIBUTE;
     97        this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
    9998    },
    10099
    101100    _stringToken: function(cursor, stringEnds)
    102101    {
    103         if (this._isAttributeValue()) {
    104             this.tokenType = "html-attr-value";
    105             if (stringEnds)
    106                 this._setAttribute();
    107         } else if (this._parseCondition === this._parseConditions.DOCTYPE)
    108             this.tokenType = "html-doctype";
    109         else
     102        if (!this._isExpectingAttributeValue()) {
    110103            this.tokenType = null;
     104            return cursor;
     105        }
     106        this.tokenType = this._attrValueTokenType();
     107        if (stringEnds)
     108            this._setExpectingAttribute();
    111109        return cursor;
     110    },
     111
     112    _attrValueTokenType: function()
     113    {
     114        if (this._parseCondition & this._parseConditions.LINKIFY) {
     115            if (this._parseCondition & this._parseConditions.A_NODE)
     116                return "html-external-link";
     117            return "html-resource-link";
     118        }
     119        return "html-attribute-value";
    112120    },
    113121
     
    136144                CommentEnd = CommentContent "-->";
    137145
    138                 DocTypeLT = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee];
     146                DocTypeStart = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee];
     147                DocTypeContent = [^\r\n>]*;
     148
    139149                ScriptStart = "<" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt];
    140150                ScriptEnd = "</" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt];
     
    152162                SingleStringEnd = SingleStringContent "'";
    153163
    154                 Identifier = [_a-zA-Z0-9\x80-\xFF]+;
     164                Identifier = [^ \r\n"'<>\[\]=]+;
    155165
    156166                <INITIAL> Comment { this.tokenType = "html-comment"; return cursor; }
     
    159169                <COMMENT> CommentEnd => INITIAL { this.tokenType = "html-comment"; return cursor; }
    160170
    161                 <INITIAL> DocTypeLT => TAG
    162                 {
    163                     this.tokenType = "html-doctype";
    164                     this._parseCondition = this._parseConditions.DOCTYPE;
    165                     return cursor;
    166                 }
     171                <INITIAL> DocTypeStart => DOCTYPE { this.tokenType = "html-doctype"; return cursor; }
     172                <DOCTYPE> DocTypeContent => DOCTYPE { this.tokenType = "html-doctype"; return cursor; }
     173                <DOCTYPE> GT => INITIAL { this.tokenType = "html-doctype"; return cursor; }
    167174
    168175                <INITIAL> ScriptStart => TAG
    169176                {
    170177                    this.tokenType = "html-tag";
    171                     this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
     178                    this._parseCondition = this._parseConditions.SCRIPT;
     179                    this._setExpectingAttribute();
    172180                    return cursor;
    173181                }
     
    180188                }
    181189
    182                 <INITIAL> LT
    183                 {
    184                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     190                <INITIAL> LT => TAG
     191                {
     192                    if (this._parseCondition & this._parseConditions.SCRIPT) {
     193                        // Do not tokenize script tag contents, keep lexer state although processing "<".
     194                        this.setLexCondition(this._lexConditions.INITIAL);
    185195                        this.tokenType = null;
    186196                        return cursor;
    187197                    }
    188198
    189                     // Only make lexer transition if not in script tag.
    190                     this.setLexCondition(this._lexConditions.TAG);
    191 
    192                     this.tokenType = "html-tag";
    193199                    this._parseCondition = this._parseConditions.INITIAL;
     200                    this.tokenType = "html-tag";
    194201                    return cursor;
    195202                }
     
    197204                <TAG> GT => INITIAL
    198205                {
    199                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     206                    if (this._parseCondition & this._parseConditions.SCRIPT) {
     207                        // Do not tokenize script tag contents.
    200208                        this.tokenType = null;
    201209                        return cursor;
    202210                    }
    203211
    204                     if (this._parseCondition === this._parseConditions.DOCTYPE)
    205                         this.tokenType = "html-doctype";
    206                     else
    207                         this.tokenType = "html-tag";
    208 
    209                     if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE)
    210                         this._parseCondition = this._parseConditions.SCRIPT;
    211                     else
    212                         this._parseCondition = this._parseConditions.INITIAL;
     212                    this._parseCondition = this._parseConditions.INITIAL;
     213                    this.tokenType = "html-tag";
    213214                    return cursor;
    214215                }
     
    224225                <TAG> EqualSign => TAG
    225226                {
    226                     if (this._isAttribute()) {
    227                         this.tokenType = null;
    228                         this._setAttributeValue();
    229                     } else if (this._parseCondition === this._parseConditions.DOCTYPE)
    230                         this.tokenType = "html-doctype";
    231                     else
    232                         this.tokenType = null;
     227                    if (this._isExpectingAttribute())
     228                        this._setExpectingAttributeValue();
     229                    this.tokenType = null;
    233230                    return cursor;
    234231                }
     
    237234                {
    238235                    if (this._parseCondition === this._parseConditions.SCRIPT) {
     236                        // Fall through if expecting attributes.
    239237                        this.tokenType = null;
    240238                        return cursor;
     
    243241                    if (this._parseCondition === this._parseConditions.INITIAL) {
    244242                        this.tokenType = "html-tag";
    245                         this._parseCondition = this._parseConditions.ATTRIBUTE;
    246                     } else if (this._isAttribute())
    247                         this.tokenType = "html-attr-name";
    248                     else if (this._isAttributeValue())
    249                         this.tokenType = "html-attr-value";
    250                     else if (this._parseCondition === this._parseConditions.DOCTYPE)
    251                         this.tokenType = "html-doctype";
     243                        this._setExpectingAttribute();
     244                        var token = this._line.substring(cursorOnEnter, cursor);
     245                        if (token === "a")
     246                            this._parseCondition |= this._parseConditions.A_NODE;
     247                        else if (this._parseCondition & this._parseConditions.A_NODE)
     248                            this._parseCondition ^= this._parseConditions.A_NODE;
     249                    } else if (this._isExpectingAttribute()) {
     250                        var token = this._line.substring(cursorOnEnter, cursor);
     251                        if (token === "href" || token === "src")
     252                            this._parseCondition |= this._parseConditions.LINKIFY;
     253                        else if (this._parseCondition |= this._parseConditions.LINKIFY)
     254                            this._parseCondition ^= this._parseConditions.LINKIFY;
     255                        this.tokenType = "html-attribute-name";
     256                    } else if (this._isExpectingAttributeValue())
     257                        this.tokenType = this._attrValueTokenType();
    252258                    else
    253259                        this.tokenType = null;
  • trunk/WebCore/inspector/front-end/SourceView.js

    r54148 r54231  
    8787    _contentLoaded: function(content)
    8888    {
    89         this.sourceFrame.setContent(this.resource.mimeType, content);
     89        this.sourceFrame.setContent(this.resource.mimeType, content, this.resource.url);
    9090        this._sourceFrameSetupFinished();
    9191    },
  • trunk/WebCore/inspector/front-end/TextEditorHighlighter.js

    r54110 r54231  
    4848    /* Keep this in sync with inspector.css and view-source.css */
    4949    this._styles["html-tag"] = "rgb(136, 18, 128)";
    50     this._styles["html-attr-name"] = "rgb(153, 69, 0)";
    51     this._styles["html-attr-value"] = "rgb(26, 26, 166)";
     50    this._styles["html-attribute-name"] = "rgb(153, 69, 0)";
     51    this._styles["html-attribute-value"] = "rgb(26, 26, 166)";
    5252    this._styles["html-comment"] = "rgb(35, 110, 37)";
    5353    this._styles["html-doctype"] = "rgb(192, 192, 192)";
     54    this._styles["html-external-link"] = "#00e";
     55    this._styles["html-resource-link"] = "#00e";
    5456
    5557    this._styles["javascript-comment"] = "rgb(0, 116, 0)";
  • trunk/WebCore/inspector/front-end/inspector.css

    r54133 r54231  
    11881188}
    11891189
    1190 .webkit-html-comment {
    1191     /* Keep this in sync with view-source.css (.webkit-html-comment) */
    1192     color: rgb(35, 110, 37);
    1193 }
    1194 
    1195 .webkit-html-tag {
    1196     /* Keep this in sync with view-source.css (.webkit-html-tag) */
    1197     color: rgb(136, 18, 128);
    1198 }
    1199 
    1200 .webkit-html-doctype {
    1201     /* Keep this in sync with view-source.css (.webkit-html-doctype) */
    1202     color: rgb(192, 192, 192);
    1203 }
    1204 
    1205 .webkit-html-attribute-name {
    1206     /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */
    1207     color: rgb(153, 69, 0);
    1208 }
    1209 
    1210 .webkit-html-attribute-value {
    1211     /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */
    1212     color: rgb(26, 26, 166);
    1213 }
    1214 
    1215 .webkit-html-external-link, .webkit-html-resource-link {
    1216     /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */
    1217     color: #00e;
    1218 }
    1219 
    1220 .webkit-html-external-link {
    1221     /* Keep this in sync with view-source.css (.webkit-html-external-link) */
    1222     text-decoration: none;
    1223 }
    1224 
    1225 .webkit-html-external-link:hover {
    1226     /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */
    1227     text-decoration: underline;
    1228 }
    1229 
    12301190.add-attribute {
    12311191    margin-left: 1px;
  • trunk/WebCore/inspector/front-end/inspector.js

    r54067 r54231  
    15271527    // FIXME:  Get rid of linkifyURL entirely.
    15281528    return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal, tooltipText).outerHTML;
     1529}
     1530
     1531WebInspector.completeURL = function(baseURL, href)
     1532{
     1533    var match = baseURL.match(WebInspector.URLRegExp);
     1534    if (match) {
     1535        var path = href;
     1536        if (path.charAt(0) !== "/") {
     1537            var basePath = match[4] || "/";
     1538            path = basePath.substring(0, basePath.lastIndexOf("/")) + "/" + path;
     1539        }
     1540        return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path;
     1541    }
     1542    return null;
    15291543}
    15301544
  • trunk/WebCore/inspector/front-end/inspectorSyntaxHighlight.css

    r54139 r54231  
    6767}
    6868
    69 /* Keep this in sync with view-source.css */
     69.webkit-html-comment {
     70    /* Keep this in sync with view-source.css (.webkit-html-comment) */
     71    color: rgb(35, 110, 37);
     72}
     73
    7074.webkit-html-tag {
     75    /* Keep this in sync with view-source.css (.webkit-html-tag) */
    7176    color: rgb(136, 18, 128);
    7277}
    7378
    74 .webkit-html-attr-name {
     79.webkit-html-doctype {
     80    /* Keep this in sync with view-source.css (.webkit-html-doctype) */
     81    color: rgb(192, 192, 192);
     82}
     83
     84.webkit-html-attribute-name {
     85    /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */
    7586    color: rgb(153, 69, 0);
    7687}
    7788
    78 .webkit-html-attr-value {
     89.webkit-html-attribute-value {
     90    /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */
    7991    color: rgb(26, 26, 166);
    8092}
    8193
    82 .webkit-html-comment {
    83     color: rgb(35, 110, 37);
     94.webkit-html-external-link, .webkit-html-resource-link {
     95    /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */
     96    color: #00e;
    8497}
    8598
    86 .webkit-html-doctype {
    87     color: rgb(192, 192, 192);
     99.webkit-html-external-link {
     100    /* Keep this in sync with view-source.css (.webkit-html-external-link) */
     101    text-decoration: none;
    88102}
     103
     104.webkit-html-external-link:hover {
     105    /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */
     106    text-decoration: underline;
     107}
Note: See TracChangeset for help on using the changeset viewer.