Title: [102560] trunk
Revision
102560
Author
zherc...@webkit.org
Date
2011-12-11 23:44:02 -0800 (Sun, 11 Dec 2011)

Log Message

Add new CSS nth-children parsing tests
https://bugs.webkit.org/show_bug.cgi?id=74178

Source/WebCore: 

Reviewed by Darin Adler.

Test: fast/css/parsing-css-nth-child.html

* css/CSSParser.cpp:
(WebCore::isValidNthToken): Add "-n" to the possible identifiers.

LayoutTests: 

The test covers several valid and invalid nth-child tokens.

Reviewed by Darin Adler.

* fast/css/parsing-css-nth-child-expected.txt: Added.
* fast/css/parsing-css-nth-child.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102559 => 102560)


--- trunk/LayoutTests/ChangeLog	2011-12-12 07:07:56 UTC (rev 102559)
+++ trunk/LayoutTests/ChangeLog	2011-12-12 07:44:02 UTC (rev 102560)
@@ -1,3 +1,15 @@
+2011-12-11  Zoltan Herczeg  <zherc...@webkit.org>
+
+        Add new CSS nth-children parsing tests
+        https://bugs.webkit.org/show_bug.cgi?id=74178
+
+        The test covers several valid and invalid nth-child tokens.
+
+        Reviewed by Darin Adler.
+
+        * fast/css/parsing-css-nth-child-expected.txt: Added.
+        * fast/css/parsing-css-nth-child.html: Added.
+
 2011-12-11  Andreas Kling  <kl...@webkit.org>
 
         WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.

Added: trunk/LayoutTests/fast/css/parsing-css-nth-child-expected.txt (0 => 102560)


--- trunk/LayoutTests/fast/css/parsing-css-nth-child-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-css-nth-child-expected.txt	2011-12-12 07:44:02 UTC (rev 102560)
@@ -0,0 +1,51 @@
+Test parsing of CSS nth-child tokens.
+
+SUCCESS
+
+Rules from the stylesheet:
+
+#a:nth-child(1n+0) { color: green; }
+#b:nth-child(n+0) { color: green; }
+#c:nth-child(n) { color: green; }
+#d:nth-child(-n+0) { color: green; }
+#e:nth-child(-n) { color: green; }
+#f:nth-child(1N+0) { color: green; }
+#g:nth-child(N+0) { color: green; }
+#h:nth-child(N) { color: green; }
+#i:nth-child(-N+0) { color: green; }
+#j:nth-child(-N) { color: green; }
+#l:nth-child(-1N
+  -
+  123) { color: green; }
+#m:nth-child(N- 123) { color: green; }
+#o:nth-child(23n
+
+ +
+
+123) { color: green; }
+#t:nth-child(+n+3) { color: green; }
+#u:nth-child(+n + 7) { color: green; }
+Expected result:
+
+#a:nth-child(1n+0) { color: green; }
+#b:nth-child(n+0) { color: green; }
+#c:nth-child(n) { color: green; }
+#d:nth-child(-n+0) { color: green; }
+#e:nth-child(-n) { color: green; }
+#f:nth-child(1N+0) { color: green; }
+#g:nth-child(N+0) { color: green; }
+#h:nth-child(N) { color: green; }
+#i:nth-child(-N+0) { color: green; }
+#j:nth-child(-N) { color: green; }
+#l:nth-child(-1N
+  -
+  123) { color: green; }
+#m:nth-child(N- 123) { color: green; }
+#o:nth-child(23n
+
+ +
+
+123) { color: green; }
+#t:nth-child(+n+3) { color: green; }
+#u:nth-child(+n + 7) { color: green; }
+

Added: trunk/LayoutTests/fast/css/parsing-css-nth-child.html (0 => 102560)


--- trunk/LayoutTests/fast/css/parsing-css-nth-child.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-css-nth-child.html	2011-12-12 07:44:02 UTC (rev 102560)
@@ -0,0 +1,100 @@
+<head>
+<style>
+#a:nth-child(1n+0) { color: green; }
+#b:nth-child(n+0)  { color: green; }
+#c:nth-child(n)    { color: green; }
+#d:nth-child(-n+0) { color: green; }
+#e:nth-child(-n)   { color: green; }
+
+#f:nth-child(1N+0) { color: green; }
+#g:nth-child(N+0)  { color: green; }
+#h:nth-child(N)    { color: green; }
+#i:nth-child(-N+0) { color: green; }
+#j:nth-child(-N)   { color: green; }
+
+#k:nth-child(+ 1n) { color: green; }
+#l:nth-child(-1N
+  -
+  123  ) { color: green; }
+#m:nth-child(  N- 123) { color: green; }
+#n:nth-child(  n +12 3) { color: green; }
+#o:nth-child( 23n
+
+ +
+
+123  ) { color: green; }
+#p:nth-child(  12 n ) { color: green; }
+#q:nth-child(+12n-0+1) { color: green; }
+#r:nth-child(+12N -- 1) { color: green; }
+#s:nth-child(+12 N ) { color: green; }
+#t:nth-child(+n+3) { color: green; }
+#u:nth-child( +n + 7 ) { color: green; }
+#v:nth-child(+ n + 7) { color: green; }
+</style>
+
+<script>
+
+/** Changes the result text font size. */
+function runTest()
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var rules = document.styleSheets[0].cssRules;
+    var text = "";
+    for (var i = 0; i < rules.length; i++) {
+        text += rules.item(i).cssText;
+        text += "\n";
+    }
+
+    document.getElementById("result").appendChild(document.createTextNode(text));
+
+    if (document.getElementById("result").firstChild.data ="" document.getElementById("expected").firstChild.data)
+        document.getElementById("message").firstChild.data = ""
+    else
+        document.getElementById("message").firstChild.data = ""
+}
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+
+<p>Test parsing of CSS nth-child tokens.</p>
+
+<p id="message">TEST DID NOT COMPLETE</p>
+
+<p>Rules from the stylesheet:</p>
+
+<pre id="result"></pre>
+
+<p>Expected result:</p>
+
+<pre id="expected">#a:nth-child(1n+0) { color: green; }
+#b:nth-child(n+0) { color: green; }
+#c:nth-child(n) { color: green; }
+#d:nth-child(-n+0) { color: green; }
+#e:nth-child(-n) { color: green; }
+#f:nth-child(1N+0) { color: green; }
+#g:nth-child(N+0) { color: green; }
+#h:nth-child(N) { color: green; }
+#i:nth-child(-N+0) { color: green; }
+#j:nth-child(-N) { color: green; }
+#l:nth-child(-1N
+  -
+  123) { color: green; }
+#m:nth-child(N- 123) { color: green; }
+#o:nth-child(23n
+
+ +
+
+123) { color: green; }
+#t:nth-child(+n+3) { color: green; }
+#u:nth-child(+n + 7) { color: green; }
+</pre>
+
+<script>
+
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (102559 => 102560)


--- trunk/Source/WebCore/ChangeLog	2011-12-12 07:07:56 UTC (rev 102559)
+++ trunk/Source/WebCore/ChangeLog	2011-12-12 07:44:02 UTC (rev 102560)
@@ -1,3 +1,15 @@
+2011-12-11  Zoltan Herczeg  <zherc...@webkit.org>
+
+        Add new CSS nth-children parsing tests
+        https://bugs.webkit.org/show_bug.cgi?id=74178
+
+        Reviewed by Darin Adler.
+
+        Test: fast/css/parsing-css-nth-child.html
+
+        * css/CSSParser.cpp:
+        (WebCore::isValidNthToken): Add "-n" to the possible identifiers.
+
 2011-12-11  Kentaro Hara  <hara...@chromium.org>
 
         Use [Supplemental] IDL in WebSocket

Modified: trunk/Source/WebCore/css/CSSParser.cpp (102559 => 102560)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-12-12 07:07:56 UTC (rev 102559)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-12-12 07:44:02 UTC (rev 102560)
@@ -8102,8 +8102,11 @@
 bool isValidNthToken(const CSSParserString& token)
 {
     // The tokenizer checks for the construct of an+b.
-    // nth can also accept "n", "odd" or "even" but should not accept any other token.
-    return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") || equalIgnoringCase(token, "n");
+    // However, since the {ident} rule precedes the {nth} rule, some of those
+    // tokens are identified as string literal. Furthermore we need to accept
+    // "odd" and "even" which does not match to an+b.
+    return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
+        || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
 }
 
 #define YY_DECL int CSSParser::lex()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to