Web Inspector: only the first @rule is highlighted in CSS
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Dec 2011 13:35:23 +0000 (13:35 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Dec 2011 13:35:23 +0000 (13:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=74568

Patch by Pavel Feldman <pavel.feldman@gmail.com> on 2011-12-19
Reviewed by Timothy Hatcher.

* inspector/front-end/SourceCSSTokenizer.js:
(WebInspector.SourceCSSTokenizer.prototype.nextToken):
* inspector/front-end/SourceCSSTokenizer.re2js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103231 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/inspector/syntax-highlight-css-expected.txt
LayoutTests/inspector/syntax-highlight-css.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js

index dab0edb..82f0b87 100644 (file)
@@ -4,8 +4,9 @@ a[href='/']: webkit-css-selector
 #content > a:hover: *,webkit-css-selector,*,webkit-css-selector,*,webkit-css-selector
 @import url(style.css);: webkit-css-at-rule,*,webkit-css-keyword,*
 @import url("style.css") projection, tv;: webkit-css-at-rule,*,webkit-css-keyword,*,webkit-css-string,*,webkit-css-keyword,*,webkit-css-keyword,*
+@import "/css/fireball_unicode.css"; html {}: webkit-css-at-rule,*,webkit-css-string,*,webkit-css-selector,*
 @media screen { body { color: red; } }: webkit-css-at-rule,*,webkit-css-keyword,*,webkit-css-selector,*,webkit-css-property,*,webkit-css-color,*
-@font-face { font-family: MyHelvetica; }: webkit-css-at-rule,*,webkit-css-property,*
+@font-face { font-family: "MyHelvetica"; }: webkit-css-at-rule,*,webkit-css-property,*,webkit-css-string,*
 p { color: color; red: red; color: #000; color: #FFF; color: #123AbC; color: #faebfe; color:papayawhip; }: webkit-css-selector,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*
 p { margin: -10px !important; }: webkit-css-selector,*,webkit-css-property,*,webkit-css-number,*,webkit-css-important,*
 
index 50f1a08..7194832 100644 (file)
@@ -15,8 +15,9 @@ function test()
     dumpSyntaxHighlightCSS("#content > a:hover");
     dumpSyntaxHighlightCSS("@import url(style.css);");
     dumpSyntaxHighlightCSS("@import url(\"style.css\") projection, tv;");
+    dumpSyntaxHighlightCSS("@import \"/css/fireball_unicode.css\"; html {}");
     dumpSyntaxHighlightCSS("@media screen { body { color: red; } }");
-    dumpSyntaxHighlightCSS("@font-face { font-family: MyHelvetica; }");
+    dumpSyntaxHighlightCSS("@font-face { font-family: \"MyHelvetica\"; }");
     dumpSyntaxHighlightCSS("p { color: color; red: red; color: #000; color: #FFF; color: #123AbC; color: #faebfe; color:papayawhip; }");
     dumpSyntaxHighlightCSS("p { margin: -10px !important; }");
 
index 0bf1ced..406245c 100644 (file)
@@ -1,3 +1,14 @@
+2011-12-19  Pavel Feldman  <pavel.feldman@gmail.com>
+
+        Web Inspector: only the first @rule is highlighted in CSS
+        https://bugs.webkit.org/show_bug.cgi?id=74568
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/front-end/SourceCSSTokenizer.js:
+        (WebInspector.SourceCSSTokenizer.prototype.nextToken):
+        * inspector/front-end/SourceCSSTokenizer.re2js:
+
 2011-12-19  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: Feature Request: Able to remove all breakpoints.
index f2aa420..0f4cedd 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Thu Dec 15 20:24:52 2011 */
+/* Generated by re2c 0.13.5 on Mon Dec 19 17:28:29 2011 */
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
  *
  */
 
 // Generate js file as follows:
-//
-// re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
-// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
-// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
-// | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
-// | sed 's|[*]cursor|this._charAt(cursor)|' \
-// | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
-// | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
-// | sed 's|unsigned\ int|var|' \
-// | sed 's|var\ yych|case 1: case 1: var yych|'
+
+/*
+re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
+*/
 
 /**
  * @constructor
@@ -115,7 +117,8 @@ WebInspector.SourceCSSTokenizer = function()
         INITIAL: 0,
         PROPERTY: 1,
         PROPERTY_VALUE: 2,
-        AT_RULE: 3
+        AT_RULE: 3,
+        AT_MEDIA_RULE: 4
     };
 
     this.case_INITIAL = 1000;
@@ -389,15 +392,15 @@ case 32:
             {
                     var token = this._line.substring(cursorOnEnter, cursor);
                     if (this._condition.parseCondition === this._parseConditions.INITIAL) {
-                        if (token === "@import" || token === "@media") {
+                        if (token === "@media") {
                             this.tokenType = "css-at-rule";
-                            this._condition.parseCondition = this._parseConditions.AT_RULE;
-                        } else if (token.indexOf("@") === 0)
+                            this._condition.parseCondition = this._parseConditions.AT_MEDIA_RULE;
+                        } else if (token.indexOf("@") === 0) {
                             this.tokenType = "css-at-rule";
-                        else
+                            this._condition.parseCondition = this._parseConditions.AT_RULE;
+                        } else
                             this.tokenType = "css-selector";
-                    }
-                    else if (this._condition.parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
+                    } else if ((this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE || this._condition.parseCondition === this._parseConditions.AT_RULE) && token in this._mediaTypes)
                         this.tokenType = "css-keyword";
                     else if (this._condition.parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
                         this.tokenType = "css-property";
@@ -646,7 +649,7 @@ case 45:
             ++cursor;
             {
                     this.tokenType = null;
-                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
+                    if (this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE)
                         this._condition.parseCondition = this._parseConditions.INITIAL;
                     else
                         this._condition.parseCondition = this._parseConditions.PROPERTY;
index bfc8358..dd93c4a 100644 (file)
  */
 
 // Generate js file as follows:
-//
-// re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
-// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
-// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
-// | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
-// | sed 's|[*]cursor|this._charAt(cursor)|' \
-// | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
-// | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
-// | sed 's|unsigned\ int|var|' \
-// | sed 's|var\ yych|case 1: var yych|'
+
+/*
+re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
+*/
 
 /**
  * @constructor
@@ -114,7 +116,8 @@ WebInspector.SourceCSSTokenizer = function()
         INITIAL: 0,
         PROPERTY: 1,
         PROPERTY_VALUE: 2,
-        AT_RULE: 3
+        AT_RULE: 3,
+        AT_MEDIA_RULE: 4
     };
 
     this.case_INITIAL = 1000;
@@ -209,7 +212,7 @@ WebInspector.SourceCSSTokenizer.prototype = {
                 <INITIAL> OpenCurlyBracket
                 {
                     this.tokenType = null;
-                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
+                    if (this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE)
                         this._condition.parseCondition = this._parseConditions.INITIAL;
                     else
                         this._condition.parseCondition = this._parseConditions.PROPERTY;
@@ -263,15 +266,15 @@ WebInspector.SourceCSSTokenizer.prototype = {
                 {
                     var token = this._line.substring(cursorOnEnter, cursor);
                     if (this._condition.parseCondition === this._parseConditions.INITIAL) {
-                        if (token === "@import" || token === "@media") {
+                        if (token === "@media") {
                             this.tokenType = "css-at-rule";
-                            this._condition.parseCondition = this._parseConditions.AT_RULE;
-                        } else if (token.indexOf("@") === 0)
+                            this._condition.parseCondition = this._parseConditions.AT_MEDIA_RULE;
+                        } else if (token.indexOf("@") === 0) {
                             this.tokenType = "css-at-rule";
-                        else
+                            this._condition.parseCondition = this._parseConditions.AT_RULE;
+                        } else
                             this.tokenType = "css-selector";
-                    }
-                    else if (this._condition.parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
+                    } else if ((this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE || this._condition.parseCondition === this._parseConditions.AT_RULE) && token in this._mediaTypes)
                         this.tokenType = "css-keyword";
                     else if (this._condition.parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
                         this.tokenType = "css-property";