[svn r21] bugs on isWhiteSpace and comment handling trunk
authordglazman
Fri, 12 Mar 2010 02:32:39 -0600
branchtrunk
changeset 17 a80d14633f23
parent 16 2de846b92978
child 18 4a3dc3774171
[svn r21] bugs on isWhiteSpace and comment handling
cssParser.js
demo.xhtml
--- a/cssParser.js	Fri Mar 12 02:23:19 2010 -0600
+++ b/cssParser.js	Fri Mar 12 02:32:39 2010 -0600
@@ -602,7 +602,7 @@
 
     this.mToken = this.mScanner.nextToken();
     while (this.mToken &&
-           ((aSkipWS && this.mToken.isWhitespace()) ||
+           ((aSkipWS && this.mToken.isWhiteSpace()) ||
             (aSkipComment && this.mToken.isComment())))
       this.mToken = this.mScanner.nextToken();
     return this.mToken;
@@ -776,7 +776,7 @@
                 s += ")";
                 break;
               }
-            } else if (token.isWhitespace()) {
+            } else if (token.isWhiteSpace()) {
               var nextToken = this.lookAhead(false, false);
               if (nextToken && nextToken.isSymbol(")")) {
                 s += ")";
@@ -1673,7 +1673,7 @@
           if (r)
             s += r;
         }
-        token = this.getToken(true, true);
+        token = this.getToken(true, false);
       }
     }
     if (valid) {
@@ -1771,7 +1771,7 @@
       }
       // now combinators and grouping...
       else if (!combinatorFound
-          && (token.isWhitespace()
+          && (token.isWhiteSpace()
               || token.isSymbol(">")
               || token.isSymbol("+")
               || token.isSymbol("~"))) {
@@ -1950,7 +1950,7 @@
     while (true) {
       if (!token.isNotNull())
         break;
-      if (token.isWhitespace())
+      if (token.isWhiteSpace())
       {
         if (aTryToPreserveWhitespaces)
           this.addWhitespace(sheet, token.value);
@@ -2047,7 +2047,7 @@
     return (this.type == aType && (!aValue || this.value.toLowerCase() == aValue));
   },
 
-  isWhitespace: function(w)
+  isWhiteSpace: function(w)
   {
     return this._isOfType(jscsspToken.WHITESPACE_TYPE, w);
   },
@@ -2198,7 +2198,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(false, false);
     if (token.isAtRule("@charset")) {
       if (parser.parseCharsetRule(token, sheet)) {
@@ -2240,7 +2240,7 @@
   },
 
   set cssText(val) {
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, false);
     if (token.isComment())
       this.parsedCssText = token.value;
@@ -2277,7 +2277,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (token.isAtRule("@import")) {
       if (parser.parseImportRule(token, sheet)) {
@@ -2311,7 +2311,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (token.isAtRule("@namespace")) {
       if (parser.parseNamespaceRule(token, sheet)) {
@@ -2347,7 +2347,7 @@
 
   set cssText(val) {
     var declarations = [];
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (parser.parseDeclaration(token, declarations, true)
         && declarations.length
@@ -2385,7 +2385,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (token.isAtRule("@font-face")) {
       if (parser.parseFontFaceRule(token, sheet)) {
@@ -2415,14 +2415,14 @@
     var preservedGTABS = gTABS;
     gTABS += "  ";
     for (var i = 0; i < this.cssRules.length; i++)
-      rv += this.cssRules[i].cssText + "\n";
+      rv += gTABS + this.cssRules[i].cssText + "\n";
     gTABS = preservedGTABS;
     return rv + gTABS + "}";
   },
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (token.isAtRule("@media")) {
       if (parser.parseMediaRule(token, sheet)) {
@@ -2444,12 +2444,12 @@
   this.type = kJscsspSTYLE_RULE;
   this.parsedCssText = null;
   this.declarations = []
-  this.mSelectorText = null;;
+  this.mSelectorText = null;
 }
 
 jscsspStyleRule.prototype = {
   get cssText() {
-    var rv = gTABS + this.mSelectorText + " {\n";
+    var rv = this.mSelectorText + " {\n";
     var preservedGTABS = gTABS;
     gTABS += "  ";
     for (var i = 0; i < this.declarations.length; i++)
@@ -2460,7 +2460,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (!token.isNotNull()) {
       if (parser.parseStyleRule(token, sheet)) {
@@ -2479,7 +2479,7 @@
   },
 
   set selectorText(val) {
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (!token.isNotNull()) {
       var s = parser.parseSelector(token, true);
@@ -2516,7 +2516,7 @@
 
   set cssText(val) {
     var sheet = {cssRules: []};
-    var parser = new CSSParser(val);;
+    var parser = new CSSParser(val);
     var token = parser.getToken(true, true);
     if (token.isAtRule("@page")) {
       if (parser.parsePageRule(token, sheet)) {
--- a/demo.xhtml	Fri Mar 12 02:23:19 2010 -0600
+++ b/demo.xhtml	Fri Mar 12 02:32:39 2010 -0600
@@ -7,12 +7,14 @@
   <script type="application/x-javascript">
     function onLoad() {
       var ss = "@charset 'iso-8859-1';\n\
-@media screen,projection,print {pre { background-color: #FFFFCC; border: 2px silver solid; padding: 1em; -moz-border-radius: 11px;\n\
--webkit-border-radius:11px}}\n\
+@media screen,projection,print {/* comment inside a media rule */pre { background-color: #FFFFCC;\n\
+/* comment between two declarations */<a ></a>border: 2px silver solid; padding: 1em; -moz-border-radius: 11px;\n\
+-webkit-border-radius:11px}\n\
 body { font-family: sans-serif; margin: 1em }\n\
+/* comment between two style rules */\n\
 h1 { background-color: silver }\n\
 h2 { background-color: lightgrey }\n\
-h1, h2 { margin: 0px; padding: 4px }";
+h1, h2 { margin: 0px; padding: 4px }}";
       var source = document.getElementById("source");
       source.textContent = ss;
       var style = document.createElement("style");