Changeset 53846 in webkit


Ignore:
Timestamp:
Jan 26, 2010 2:18:50 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-01-26 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: Implement HTML and CSS highlighters.

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

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/front-end/JavaScriptTokenizer.js: Removed.
  • inspector/front-end/JavaScriptTokenizer.re2js: Removed.
  • inspector/front-end/SourceCSSTokenizer.js: Added. (WebInspector.SourceCSSTokenizer): (WebInspector.SourceCSSTokenizer.prototype._stringToken): (WebInspector.SourceCSSTokenizer.prototype._isPropertyValue): (WebInspector.SourceCSSTokenizer.prototype.nextToken):
  • inspector/front-end/SourceCSSTokenizer.re2js: Added.
  • inspector/front-end/SourceHTMLTokenizer.js: Added. (WebInspector.SourceHTMLTokenizer): (WebInspector.SourceHTMLTokenizer.prototype._stringToken): (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
  • inspector/front-end/SourceHTMLTokenizer.re2js: Added.
  • inspector/front-end/SourceJavaScriptTokenizer.js: Added. (WebInspector.SourceJavaScriptTokenizer): (WebInspector.SourceJavaScriptTokenizer.prototype.nextToken):
  • inspector/front-end/SourceJavaScriptTokenizer.re2js: Added.
  • inspector/front-end/TextEditorHighlighter.js: (WebInspector.TextEditorHighlighter): (WebInspector.TextEditorHighlighter.prototype._highlightLines): (WebInspector.TextEditorHighlighter.Tokenizer): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.set line): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.set condition): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.get condition): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.hasCondition): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.getLexCondition): (WebInspector.TextEditorHighlighter.Tokenizer.prototype.setLexCondition): (WebInspector.TextEditorHighlighter.Tokenizer.prototype._charAt):
  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
Location:
trunk/WebCore
Files:
4 added
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53845 r53846  
     12010-01-26  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: Implement HTML and CSS highlighters.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=34144
     8
     9        * WebCore.gypi:
     10        * WebCore.vcproj/WebCore.vcproj:
     11        * inspector/front-end/JavaScriptTokenizer.js: Removed.
     12        * inspector/front-end/JavaScriptTokenizer.re2js: Removed.
     13        * inspector/front-end/SourceCSSTokenizer.js: Added.
     14        (WebInspector.SourceCSSTokenizer):
     15        (WebInspector.SourceCSSTokenizer.prototype._stringToken):
     16        (WebInspector.SourceCSSTokenizer.prototype._isPropertyValue):
     17        (WebInspector.SourceCSSTokenizer.prototype.nextToken):
     18        * inspector/front-end/SourceCSSTokenizer.re2js: Added.
     19        * inspector/front-end/SourceHTMLTokenizer.js: Added.
     20        (WebInspector.SourceHTMLTokenizer):
     21        (WebInspector.SourceHTMLTokenizer.prototype._stringToken):
     22        (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
     23        * inspector/front-end/SourceHTMLTokenizer.re2js: Added.
     24        * inspector/front-end/SourceJavaScriptTokenizer.js: Added.
     25        (WebInspector.SourceJavaScriptTokenizer):
     26        (WebInspector.SourceJavaScriptTokenizer.prototype.nextToken):
     27        * inspector/front-end/SourceJavaScriptTokenizer.re2js: Added.
     28        * inspector/front-end/TextEditorHighlighter.js:
     29        (WebInspector.TextEditorHighlighter):
     30        (WebInspector.TextEditorHighlighter.prototype._highlightLines):
     31        (WebInspector.TextEditorHighlighter.Tokenizer):
     32        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.set line):
     33        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.set condition):
     34        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.get condition):
     35        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.hasCondition):
     36        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.getLexCondition):
     37        (WebInspector.TextEditorHighlighter.Tokenizer.prototype.setLexCondition):
     38        (WebInspector.TextEditorHighlighter.Tokenizer.prototype._charAt):
     39        * inspector/front-end/WebKit.qrc:
     40        * inspector/front-end/inspector.html:
     41
    1422010-01-26  Simon Hausmann  <simon.hausmann@nokia.com>
    243
  • trunk/WebCore/WebCore.gypi

    r53795 r53846  
    37083708            'inspector/front-end/inspector.js',
    37093709            'inspector/front-end/JavaScriptSourceSyntaxHighlighter.js',
    3710             'inspector/front-end/JavaScriptTokenizer.js',
    37113710            'inspector/front-end/KeyboardShortcut.js',
    37123711            'inspector/front-end/MetricsSidebarPane.js',
     
    37353734            'inspector/front-end/SidebarPane.js',
    37363735            'inspector/front-end/SidebarTreeElement.js',
     3736            'inspector/front-end/SourceCSSTokenizer.js',
    37373737            'inspector/front-end/SourceFrame.js',
    37383738            'inspector/front-end/SourceFrame2.js',
     3739            'inspector/front-end/SourceHTMLTokenizer.js',
     3740            'inspector/front-end/SourceJavaScriptTokenizer.js',
    37393741            'inspector/front-end/SourceSyntaxHighlighter.js',
    37403742            'inspector/front-end/SourceView.js',
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r53795 r53846  
    4292542925                                </File>
    4292642926                                <File
    42927                                         RelativePath="..\inspector\front-end\JavaScriptTokenizer.js"
    42928                                         >
    42929                                 </File>
    42930                                 <File
    4293142927                                        RelativePath="..\inspector\front-end\MetricsSidebarPane.js"
    4293242928                                        >
     
    4302943025                                </File>
    4303043026                                <File
     43027                                        RelativePath="..\inspector\front-end\SourceCSSTokenizer.js"
     43028                                        >
     43029                                </File>
     43030                                <File
    4303143031                                        RelativePath="..\inspector\front-end\SourceFrame.js"
    4303243032                                        >
     
    4303443034                                <File
    4303543035                                        RelativePath="..\inspector\front-end\SourceFrame2.js"
     43036                                        >
     43037                                </File>
     43038                                <File
     43039                                        RelativePath="..\inspector\front-end\SourceHTMLTokenizer.js"
     43040                                        >
     43041                                </File>
     43042                                <File
     43043                                        RelativePath="..\inspector\front-end\SourceJavaScriptTokenizer.js"
    4303643044                                        >
    4303743045                                </File>
  • trunk/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js

    r53845 r53846  
    1 /* Generated by re2c 0.13.5 on Fri Jan  8 14:49:18 2010 */
     1/* Generated by re2c 0.13.5 on Tue Jan 26 01:16:33 2010 */
    22/*
    33 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    3232// Generate js file as follows:
    3333//
    34 // re2c -isc WebCore/inspector/front-end/JavaScriptTokenizer.re2js \
     34// re2c -isc WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
    3535// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
    3636// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
     
    4242// | sed 's|var\ yych|case 1: case 1: var yych|'
    4343
    44 WebInspector.JavaScriptTokenizer = function()
     44WebInspector.SourceJavaScriptTokenizer = function()
    4545{
    46     this._tokens = [];
     46    WebInspector.TextEditorHighlighter.Tokenizer.call(this);
     47
    4748    this._keywords = [
    4849        "null", "true", "false", "break", "case", "catch", "const", "default", "finally", "for",
     
    5253    ].keySet();
    5354
    54     this._conditions = {
     55    this._lexConditions = {
    5556        DIV: 0,
    5657        NODIV: 1,
     
    6869    this.case_REGEX = 1005;
    6970
    70     this.initialCondition = this._conditions.NODIV;
    71     this.condition = this.initialCondition;
     71    this.initialCondition = { lexCondition: this._lexConditions.NODIV }
    7272}
    7373
    74 WebInspector.JavaScriptTokenizer.prototype = {
    75 
    76     set line(line) {
    77         this._line = line;
    78     },
    79 
    80     getCondition: function()
    81     {
    82         return this.condition;
    83     },
    84 
    85     setCondition: function(condition)
    86     {
    87         this.condition = condition;
    88     },
    89 
    90     _charAt: function(cursor)
    91     {
    92         return cursor < this._line.length ? this._line.charAt(cursor) : "\n";
    93     },
    94 
     74WebInspector.SourceJavaScriptTokenizer.prototype = {
    9575    nextToken: function(cursor)
    9676    {
     
    10484            case 1: var yych;
    10585            var yyaccept = 0;
    106             if (this.getCondition() < 3) {
    107                 if (this.getCondition() < 1) {
     86            if (this.getLexCondition() < 3) {
     87                if (this.getLexCondition() < 1) {
    10888                    { gotoCase = this.case_DIV; continue; };
    10989                } else {
    110                     if (this.getCondition() < 2) {
     90                    if (this.getLexCondition() < 2) {
    11191                        { gotoCase = this.case_NODIV; continue; };
    11292                    } else {
     
    11595                }
    11696            } else {
    117                 if (this.getCondition() < 4) {
     97                if (this.getLexCondition() < 4) {
    11898                    { gotoCase = this.case_DSTRING; continue; };
    11999                } else {
    120                     if (this.getCondition() < 5) {
     100                    if (this.getLexCondition() < 5) {
    121101                        { gotoCase = this.case_SSTRING; continue; };
    122102                    } else {
     
    138118            }
    139119case 2:
    140             { this.tokenType = "comment"; return cursor; }
     120            { this.tokenType = "js-comment"; return cursor; }
    141121case 3:
    142122            yyaccept = 0;
     
    153133case 7:
    154134            ++cursor;
    155             this.setCondition(this._conditions.NODIV);
    156             { this.tokenType = "comment"; return cursor; }
     135            this.setLexCondition(this._lexConditions.NODIV);
     136            { this.tokenType = "js-comment"; return cursor; }
    157137case 9:
    158138            ++cursor;
     
    252232            if ((yych = this._charAt(cursor)) == '=') { gotoCase = 115; continue; };
    253233case 18:
    254             this.setCondition(this._conditions.NODIV);
     234            this.setLexCondition(this._lexConditions.NODIV);
    255235            { this.tokenType = null; return cursor; }
    256236case 19:
     
    268248                    var token = this._line.substring(cursorOnEnter, cursor);
    269249                    if (token in this._keywords)
    270                         this.tokenType = "keyword";
     250                        this.tokenType = "js-keyword";
    271251                    else
    272252                        this.tokenType = null;
     
    323303            }
    324304case 33:
    325             this.setCondition(this._conditions.NODIV);
     305            this.setLexCondition(this._lexConditions.NODIV);
    326306            { this.tokenType = null; return cursor; }
    327307case 34:
     
    344324            }
    345325case 35:
    346             { this.tokenType = "number"; return cursor; }
     326            { this.tokenType = "js-number"; return cursor; }
    347327case 36:
    348328            yyaccept = 3;
     
    657637            if (yych != '\r') { gotoCase = 80; continue; };
    658638case 82:
    659             { this.tokenType = "comment"; return cursor; }
     639            { this.tokenType = "js-comment"; return cursor; }
    660640case 83:
    661641            ++cursor;
     
    666646case 85:
    667647            ++cursor;
    668             this.setCondition(this._conditions.COMMENT);
    669             { this.tokenType = "comment"; return cursor; }
     648            this.setLexCondition(this._lexConditions.COMMENT);
     649            { this.tokenType = "js-comment"; return cursor; }
    670650case 87:
    671651            ++cursor;
    672             { this.tokenType = "comment"; return cursor; }
     652            { this.tokenType = "js-comment"; return cursor; }
    673653case 89:
    674654            yyaccept = 3;
     
    763743case 98:
    764744            ++cursor;
    765             { this.tokenType = "string"; return cursor; }
     745            { this.tokenType = "js-string"; return cursor; }
    766746case 100:
    767747            ++cursor;
     
    779759case 101:
    780760            ++cursor;
    781             this.setCondition(this._conditions.SSTRING);
    782             { this.tokenType = "string"; return cursor; }
     761            this.setLexCondition(this._lexConditions.SSTRING);
     762            { this.tokenType = "js-string"; return cursor; }
    783763case 103:
    784764            ++cursor;
     
    889869case 110:
    890870            ++cursor;
    891             this.setCondition(this._conditions.DSTRING);
    892             { this.tokenType = "string"; return cursor; }
     871            this.setLexCondition(this._lexConditions.DSTRING);
     872            { this.tokenType = "js-string"; return cursor; }
    893873case 112:
    894874            ++cursor;
     
    947927            }
    948928case 118:
    949             { this.tokenType = "string"; return cursor; }
     929            { this.tokenType = "js-string"; return cursor; }
    950930case 119:
    951931            yyaccept = 0;
     
    959939            ++cursor;
    960940case 123:
    961             this.setCondition(this._conditions.NODIV);
    962             { this.tokenType = "string"; return cursor; }
     941            this.setLexCondition(this._lexConditions.NODIV);
     942            { this.tokenType = "js-string"; return cursor; }
    963943case 124:
    964944            yyaccept = 1;
     
    11961176            { gotoCase = 170; continue; };
    11971177case 142:
    1198             this.setCondition(this._conditions.DIV);
     1178            this.setLexCondition(this._lexConditions.DIV);
    11991179            {
    12001180                    var token = this._line.substring(cursorOnEnter, cursor);
    12011181                    if (token in this._keywords)
    1202                         this.tokenType = "keyword";
     1182                        this.tokenType = "js-keyword";
    12031183                    else
    12041184                        this.tokenType = null;
     
    12251205case 147:
    12261206            ++cursor;
    1227             this.setCondition(this._conditions.DIV);
     1207            this.setLexCondition(this._lexConditions.DIV);
    12281208            { this.tokenType = null; return cursor; }
    12291209case 149:
     
    12881268            }
    12891269case 155:
    1290             this.setCondition(this._conditions.DIV);
    1291             { this.tokenType = "number"; return cursor; }
     1270            this.setLexCondition(this._lexConditions.DIV);
     1271            { this.tokenType = "js-number"; return cursor; }
    12921272case 156:
    12931273            yyaccept = 2;
     
    16481628            if (yych != '\r') { gotoCase = 204; continue; };
    16491629case 206:
    1650             { this.tokenType = "comment"; return cursor; }
     1630            { this.tokenType = "js-comment"; return cursor; }
    16511631case 207:
    16521632            ++cursor;
     
    16571637case 209:
    16581638            ++cursor;
    1659             this.setCondition(this._conditions.COMMENT);
    1660             { this.tokenType = "comment"; return cursor; }
     1639            this.setLexCondition(this._lexConditions.COMMENT);
     1640            { this.tokenType = "js-comment"; return cursor; }
    16611641case 211:
    16621642            ++cursor;
    1663             { this.tokenType = "comment"; return cursor; }
     1643            { this.tokenType = "js-comment"; return cursor; }
    16641644case 213:
    16651645            ++cursor;
     
    16971677            if (yych != '\r') { gotoCase = 213; continue; };
    16981678case 217:
    1699             this.setCondition(this._conditions.REGEX);
    1700             { this.tokenType = "regex"; return cursor; }
     1679            this.setLexCondition(this._lexConditions.REGEX);
     1680            { this.tokenType = "js-regex"; return cursor; }
    17011681case 218:
    17021682            ++cursor;
     
    17301710                if (yych == 'm') { gotoCase = 220; continue; };
    17311711            }
    1732             { this.tokenType = "regex"; return cursor; }
     1712            { this.tokenType = "js-regex"; return cursor; }
    17331713case 223:
    17341714            ++cursor;
     
    19211901case 243:
    19221902            ++cursor;
    1923             { this.tokenType = "string"; return cursor; }
     1903            { this.tokenType = "js-string"; return cursor; }
    19241904case 245:
    19251905            ++cursor;
     
    19371917case 246:
    19381918            ++cursor;
    1939             this.setCondition(this._conditions.SSTRING);
    1940             { this.tokenType = "string"; return cursor; }
     1919            this.setLexCondition(this._lexConditions.SSTRING);
     1920            { this.tokenType = "js-string"; return cursor; }
    19411921case 248:
    19421922            ++cursor;
     
    20472027case 255:
    20482028            ++cursor;
    2049             this.setCondition(this._conditions.DSTRING);
    2050             { this.tokenType = "string"; return cursor; }
     2029            this.setLexCondition(this._lexConditions.DSTRING);
     2030            { this.tokenType = "js-string"; return cursor; }
    20512031case 257:
    20522032            ++cursor;
     
    21112091            }
    21122092case 263:
    2113             { this.tokenType = "regex"; return cursor; }
     2093            { this.tokenType = "js-regex"; return cursor; }
    21142094case 264:
    21152095            yyaccept = 0;
     
    21252105            { gotoCase = 278; continue; };
    21262106case 268:
    2127             this.setCondition(this._conditions.NODIV);
    2128             { this.tokenType = "regex"; return cursor; }
     2107            this.setLexCondition(this._lexConditions.NODIV);
     2108            { this.tokenType = "js-regex"; return cursor; }
    21292109case 269:
    21302110            yyaccept = 1;
     
    22702250            }
    22712251case 285:
    2272             { this.tokenType = "string"; return cursor; }
     2252            { this.tokenType = "js-string"; return cursor; }
    22732253case 286:
    22742254            yyaccept = 0;
     
    22822262            ++cursor;
    22832263case 290:
    2284             this.setCondition(this._conditions.NODIV);
    2285             { this.tokenType = "string"; return cursor; }
     2264            this.setLexCondition(this._lexConditions.NODIV);
     2265            { this.tokenType = "js-string"; return cursor; }
    22862266case 291:
    22872267            yyaccept = 1;
     
    24332413    }
    24342414}
     2415
     2416WebInspector.SourceJavaScriptTokenizer.prototype.__proto__ = WebInspector.TextEditorHighlighter.Tokenizer.prototype;
  • trunk/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js

    r53845 r53846  
    3131// Generate js file as follows:
    3232//
    33 // re2c -isc WebCore/inspector/front-end/JavaScriptTokenizer.re2js \
     33// re2c -isc WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
    3434// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
    3535// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
     
    4141// | sed 's|var\ yych|case 1: var yych|'
    4242
    43 WebInspector.JavaScriptTokenizer = function()
     43WebInspector.SourceJavaScriptTokenizer = function()
    4444{
    45     this._tokens = [];
     45    WebInspector.TextEditorHighlighter.Tokenizer.call(this);
     46
    4647    this._keywords = [
    4748        "null", "true", "false", "break", "case", "catch", "const", "default", "finally", "for",
     
    5152    ].keySet();
    5253
    53     this._conditions = {
     54    this._lexConditions = {
    5455        DIV: 0,
    5556        NODIV: 1,
     
    6768    this.case_REGEX = 1005;
    6869
    69     this.initialCondition = this._conditions.NODIV;
    70     this.condition = this.initialCondition;
     70    this.initialCondition = { lexCondition: this._lexConditions.NODIV }
    7171}
    7272
    73 WebInspector.JavaScriptTokenizer.prototype = {
    74 
    75     set line(line) {
    76         this._line = line;
    77     },
    78 
    79     getCondition: function()
    80     {
    81         return this.condition;
    82     },
    83 
    84     setCondition: function(condition)
    85     {
    86         this.condition = condition;
    87     },
    88 
    89     _charAt: function(cursor)
    90     {
    91         return cursor < this._line.length ? this._line.charAt(cursor) : "\n";
    92     },
    93 
     73WebInspector.SourceJavaScriptTokenizer.prototype = {
    9474    nextToken: function(cursor)
    9575    {
     
    10282                re2c:define:YYCTYPE  = "var";
    10383                re2c:define:YYCURSOR = cursor;
    104                 re2c:define:YYGETCONDITION = "this.getCondition";
    105                 re2c:define:YYSETCONDITION = "this.setCondition";
     84                re2c:define:YYGETCONDITION = "this.getLexCondition";
     85                re2c:define:YYSETCONDITION = "this.setLexCondition";
    10686                re2c:condprefix = "case this.case_";
    107                 re2c:condenumprefix = "this._conditions.";
     87                re2c:condenumprefix = "this._lexConditions.";
    10888                re2c:yyfill:enable = 0;
    10989                re2c:labelprefix = "case ";
     
    145125                DoubleStringStart = "\"" DoubleStringContent "\\" [\r\n];
    146126                DoubleStringEnd = DoubleStringContent "\"";
    147                 SingleStringStart = "\'" SingleStringContent "\\" [\r\n];
    148                 SingleStringEnd = SingleStringContent "\'";
     127                SingleStringStart = "'" SingleStringContent "\\" [\r\n];
     128                SingleStringEnd = SingleStringContent "'";
    149129
    150130                BackslashSequence = "\\" [^\r\n];
     
    157137                RegexEnd = RegexContent "/" [igm]*;
    158138
    159                 <DIV,NODIV> LineComment { this.tokenType = "comment"; return cursor; }
    160                 <DIV,NODIV> Comment { this.tokenType = "comment"; return cursor; }
    161                 <DIV,NODIV> CommentStart => COMMENT { this.tokenType = "comment"; return cursor; }
    162                 <COMMENT> CommentContent => COMMENT { this.tokenType = "comment"; return cursor; }
    163                 <COMMENT> CommentEnd => NODIV { this.tokenType = "comment"; return cursor; }
     139                <DIV,NODIV> LineComment { this.tokenType = "js-comment"; return cursor; }
     140                <DIV,NODIV> Comment { this.tokenType = "js-comment"; return cursor; }
     141                <DIV,NODIV> CommentStart => COMMENT { this.tokenType = "js-comment"; return cursor; }
     142                <COMMENT> CommentContent => COMMENT { this.tokenType = "js-comment"; return cursor; }
     143                <COMMENT> CommentEnd => NODIV { this.tokenType = "js-comment"; return cursor; }
    164144
    165                 <DIV,NODIV> StringLiteral { this.tokenType = "string"; return cursor; }
    166                 <DIV,NODIV> DoubleStringStart => DSTRING { this.tokenType = "string"; return cursor; }
    167                 <DSTRING> DoubleStringContent => DSTRING { this.tokenType = "string"; return cursor; }
    168                 <DSTRING> DoubleStringEnd => NODIV { this.tokenType = "string"; return cursor; }
    169                 <DIV,NODIV> SingleStringStart => SSTRING { this.tokenType = "string"; return cursor; }
    170                 <SSTRING> SingleStringContent => SSTRING { this.tokenType = "string"; return cursor; }
    171                 <SSTRING> SingleStringEnd => NODIV { this.tokenType = "string"; return cursor; }
     145                <DIV,NODIV> StringLiteral { this.tokenType = "js-string"; return cursor; }
     146                <DIV,NODIV> DoubleStringStart => DSTRING { this.tokenType = "js-string"; return cursor; }
     147                <DSTRING> DoubleStringContent => DSTRING { this.tokenType = "js-string"; return cursor; }
     148                <DSTRING> DoubleStringEnd => NODIV { this.tokenType = "js-string"; return cursor; }
     149                <DIV,NODIV> SingleStringStart => SSTRING { this.tokenType = "js-string"; return cursor; }
     150                <SSTRING> SingleStringContent => SSTRING { this.tokenType = "js-string"; return cursor; }
     151                <SSTRING> SingleStringEnd => NODIV { this.tokenType = "js-string"; return cursor; }
    172152
    173                 <NODIV> Regex { this.tokenType = "regex"; return cursor; }
    174                 <NODIV> RegexStart => REGEX { this.tokenType = "regex"; return cursor; }
    175                 <REGEX> RegexContent => REGEX { this.tokenType = "regex"; return cursor; }
    176                 <REGEX> RegexEnd => NODIV { this.tokenType = "regex"; return cursor; }
     153                <NODIV> Regex { this.tokenType = "js-regex"; return cursor; }
     154                <NODIV> RegexStart => REGEX { this.tokenType = "js-regex"; return cursor; }
     155                <REGEX> RegexContent => REGEX { this.tokenType = "js-regex"; return cursor; }
     156                <REGEX> RegexEnd => NODIV { this.tokenType = "js-regex"; return cursor; }
    177157
    178                 <DIV,NODIV> NumericLiteral => DIV { this.tokenType = "number"; return cursor; }
     158                <DIV,NODIV> NumericLiteral => DIV { this.tokenType = "js-number"; return cursor; }
    179159                <DIV,NODIV> Identifier => DIV
    180160                {
    181161                    var token = this._line.substring(cursorOnEnter, cursor);
    182162                    if (token in this._keywords)
    183                         this.tokenType = "keyword";
     163                        this.tokenType = "js-keyword";
    184164                    else
    185165                        this.tokenType = null;
     
    194174    }
    195175}
     176
     177WebInspector.SourceJavaScriptTokenizer.prototype.__proto__ = WebInspector.TextEditorHighlighter.Tokenizer.prototype;
  • trunk/WebCore/inspector/front-end/TextEditorHighlighter.js

    r53795 r53846  
    3333{
    3434    this._textModel = textModel;
    35     this._tokenizer = new WebInspector.JavaScriptTokenizer();
     35    this._tokenizer = new WebInspector.SourceCSSTokenizer();
    3636
    3737    this._styles = [];
    38     this._styles["comment"] = "rgb(0, 116, 0)";
    39     this._styles["string"] = "rgb(196, 26, 22)";
    40     this._styles["regex"] = "rgb(196, 26, 22)";
    41     this._styles["keyword"] = "rgb(170, 13, 145)";
    42     this._styles["number"] = "rgb(28, 0, 207)";
     38
     39    this._styles["css-comment"] = "rgb(0, 116, 0)";
     40    this._styles["css-params"] = "rgb(7, 144, 154)";
     41    this._styles["css-string"] = "rgb(7, 144, 154)";
     42    this._styles["css-keyword"] = "rgb(7, 144, 154)";
     43    this._styles["css-number"] = "rgb(50, 0, 255)";
     44    this._styles["css-property"] = "rgb(200, 0, 0)";
     45    this._styles["css-at-rule"] = "rgb(200, 0, 0)";
     46    this._styles["css-selector"] = "rgb(0, 0, 0)";
     47    this._styles["css-important"] = "rgb(200, 0, 180)";
     48
     49    /* Keep this in sync with inspector.css and view-source.css */
     50    this._styles["html-tag"] = "rgb(136, 18, 128)";
     51    this._styles["html-attr-name"] = "rgb(153, 69, 0)";
     52    this._styles["html-attr-value"] = "rgb(26, 26, 166)";
     53    this._styles["html-comment"] = "rgb(35, 110, 37)";
     54    this._styles["html-doctype"] = "rgb(192, 192, 192)";
     55
     56    this._styles["js-comment"] = "rgb(0, 116, 0)";
     57    this._styles["js-string"] = "rgb(196, 26, 22)";
     58    this._styles["js-regex"] = "rgb(196, 26, 22)";
     59    this._styles["js-keyword"] = "rgb(170, 13, 145)";
     60    this._styles["js-number"] = "rgb(28, 0, 207)";
    4361
    4462    this._damageCallback = damageCallback;   
     
    147165
    148166            var nextLineState = this._textModel.getAttribute(i + 1, "highlighter-state");
    149             if (nextLineState && nextLineState.preCondition === state.postCondition) {
     167            if (nextLineState && this._tokenizer.hasCondition(nextLineState.preCondition)) {
    150168                // Following lines are up to date, no need re-highlight.
    151169                this._damageCallback(startLine, i + 1);
     
    169187    }
    170188}
     189
     190WebInspector.TextEditorHighlighter.Tokenizer = function()
     191{
     192}
     193
     194WebInspector.TextEditorHighlighter.Tokenizer.prototype = {
     195    set line(line) {
     196        this._line = line;
     197    },
     198
     199    set condition(condition)
     200    {
     201        this._lexCondition = condition.lexCondition;
     202        this._parseCondition = condition.parseCondition;
     203    },
     204
     205    get condition()
     206    {
     207        return { lexCondition: this._lexCondition, parseCondition: this._parseCondition };
     208    },
     209
     210    hasCondition: function(condition)
     211    {
     212        return this._lexCondition === condition.lexCondition && this._parseCondition === condition.parseCondition;
     213    },
     214
     215    getLexCondition: function()
     216    {
     217        return this._lexCondition;
     218    },
     219
     220    setLexCondition: function(lexCondition)
     221    {
     222        this._lexCondition = lexCondition;
     223    },
     224
     225    _charAt: function(cursor)
     226    {
     227        return cursor < this._line.length ? this._line.charAt(cursor) : "\n";
     228    }
     229}
  • trunk/WebCore/inspector/front-end/WebKit.qrc

    r53795 r53846  
    3737    <file>InspectorFrontendHostStub.js</file>
    3838    <file>JavaScriptSourceSyntaxHighlighter.js</file>
    39     <file>JavaScriptTokenizer.js</file>
    4039    <file>KeyboardShortcut.js</file>
    4140    <file>MetricsSidebarPane.js</file>
     
    6463    <file>SidebarPane.js</file>
    6564    <file>SidebarTreeElement.js</file>
     65    <file>SourceCSSTokenizer.js</file>
    6666    <file>SourceFrame.js</file>
    6767    <file>SourceFrame2.js</file>
     68    <file>SourceHTMLTokenizer.js</file>
     69    <file>SourceJavaScriptTokenizer.js</file>
    6870    <file>SourceSyntaxHighlighter.js</file>
    6971    <file>SourceView.js</file>
  • trunk/WebCore/inspector/front-end/inspector.html

    r53795 r53846  
    101101    <script type="text/javascript" src="TextEditor.js"></script>
    102102    <script type="text/javascript" src="TextEditorHighlighter.js"></script>
    103     <script type="text/javascript" src="JavaScriptTokenizer.js"></script>
     103    <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
     104    <script type="text/javascript" src="SourceHTMLTokenizer.js"></script>
     105    <script type="text/javascript" src="SourceJavaScriptTokenizer.js"></script>
    104106    <script type="text/javascript" src="SourceView.js"></script>
    105107    <script type="text/javascript" src="FontView.js"></script>
Note: See TracChangeset for help on using the changeset viewer.