Title: [114261] trunk
- Revision
- 114261
- Author
- commit-qu...@webkit.org
- Date
- 2012-04-16 08:36:24 -0700 (Mon, 16 Apr 2012)
Log Message
CSS3 Selectors failures on css3test.com
https://bugs.webkit.org/show_bug.cgi?id=83885
Patch by Uday Kiran <udayki...@motorola.com> on 2012-04-16
Reviewed by Zoltan Herczeg.
Source/WebCore:
Parsing fix for CSS3 selectors :nth-child(), :nth-last-child() :nth-of-type() :nth-last-of-type()
with values -n-b and n-b as they are of valid form an+b where a and b are integers.
http://www.w3.org/TR/selectors/#structural-pseudos
Descriptors of form n-b or -n-b, where b is number, are valid CSS identifiers.
However, in NthChildMode we need to check whether this identifier is a valid nth child descriptor.
The original code only checked this if the string was n- or -n- but this is not enough.
We need to check everything which starts with an n- or -n- prefix.
Test: css3/parsing-css3-nthchild.html
* css/CSSParser.cpp:
(WebCore::CSSParser::lex):
LayoutTests:
* css3/parsing-css3-nthchild-expected.txt: Added.
* css3/parsing-css3-nthchild.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (114260 => 114261)
--- trunk/LayoutTests/ChangeLog 2012-04-16 15:35:30 UTC (rev 114260)
+++ trunk/LayoutTests/ChangeLog 2012-04-16 15:36:24 UTC (rev 114261)
@@ -1,3 +1,13 @@
+2012-04-16 Uday Kiran <udayki...@motorola.com>
+
+ CSS3 Selectors failures on css3test.com
+ https://bugs.webkit.org/show_bug.cgi?id=83885
+
+ Reviewed by Zoltan Herczeg.
+
+ * css3/parsing-css3-nthchild-expected.txt: Added.
+ * css3/parsing-css3-nthchild.html: Added.
+
2012-04-16 Philippe Normand <pnorm...@igalia.com>
Unreviewed, GTK test_expectations update.
Added: trunk/LayoutTests/css3/parsing-css3-nthchild-expected.txt (0 => 114261)
--- trunk/LayoutTests/css3/parsing-css3-nthchild-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/parsing-css3-nthchild-expected.txt 2012-04-16 15:36:24 UTC (rev 114261)
@@ -0,0 +1,23 @@
+SUCCESS
+
+Rules from the stylesheet:
+
+#a:nth-child(n-1) { color: green; }
+#b:nth-child(n- 10) { color: green; }
+#g:nth-child(-n-1) { color: green; }
+#h:nth-child(-n- 10) { color: green; }
+#n:nth-child(-n
+ - 1) { color: green; }
+#o:nth-child(-n
+ +13) { color: green; }
+Expected result:
+
+#a:nth-child(n-1) { color: green; }
+#b:nth-child(n- 10) { color: green; }
+#g:nth-child(-n-1) { color: green; }
+#h:nth-child(-n- 10) { color: green; }
+#n:nth-child(-n
+ - 1) { color: green; }
+#o:nth-child(-n
+ +13) { color: green; }
+
Added: trunk/LayoutTests/css3/parsing-css3-nthchild.html (0 => 114261)
--- trunk/LayoutTests/css3/parsing-css3-nthchild.html (rev 0)
+++ trunk/LayoutTests/css3/parsing-css3-nthchild.html 2012-04-16 15:36:24 UTC (rev 114261)
@@ -0,0 +1,64 @@
+<head>
+<style type="text/css">
+#a:nth-child(n-1) { color: green; }
+#b:nth-child(n- 10) { color: green; }
+#c:nth-child(n- 1 2) { color: green; }
+#d:nth-child(n-b1) { color: green; }
+#e:nth-child(n-+1) { color: green; }
+#f:nth-child(n-1n) { color: green; }
+#g:nth-child(-n-1) { color: green; }
+#h:nth-child(-n- 10) { color: green; }
+#i:nth-child(-n -b1) { color: green; }
+#j:nth-child(-1n- b1) { color: green; }
+#k:nth-child(-n-13b1) { color: green; }
+#l:nth-child(-n-+1) { color: green; }
+#m:nth-child(-n+n) { color: green; }
+#n:nth-child(-n
+ - 1) { color: green; }
+#o:nth-child(-n
+ +13) { 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 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(n-1) { color: green; }
+#b:nth-child(n- 10) { color: green; }
+#g:nth-child(-n-1) { color: green; }
+#h:nth-child(-n- 10) { color: green; }
+#n:nth-child(-n
+ - 1) { color: green; }
+#o:nth-child(-n
+ +13) { color: green; }
+</pre>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (114260 => 114261)
--- trunk/Source/WebCore/ChangeLog 2012-04-16 15:35:30 UTC (rev 114260)
+++ trunk/Source/WebCore/ChangeLog 2012-04-16 15:36:24 UTC (rev 114261)
@@ -1,3 +1,24 @@
+2012-04-16 Uday Kiran <udayki...@motorola.com>
+
+ CSS3 Selectors failures on css3test.com
+ https://bugs.webkit.org/show_bug.cgi?id=83885
+
+ Reviewed by Zoltan Herczeg.
+
+ Parsing fix for CSS3 selectors :nth-child(), :nth-last-child() :nth-of-type() :nth-last-of-type()
+ with values -n-b and n-b as they are of valid form an+b where a and b are integers.
+ http://www.w3.org/TR/selectors/#structural-pseudos
+
+ Descriptors of form n-b or -n-b, where b is number, are valid CSS identifiers.
+ However, in NthChildMode we need to check whether this identifier is a valid nth child descriptor.
+ The original code only checked this if the string was n- or -n- but this is not enough.
+ We need to check everything which starts with an n- or -n- prefix.
+
+ Test: css3/parsing-css3-nthchild.html
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::lex):
+
2012-04-16 Eric Carlson <eric.carl...@apple.com>
ASSERT in notifyChildInserted when HTMLMediaElement is removed from tree
Modified: trunk/Source/WebCore/css/CSSParser.cpp (114260 => 114261)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-04-16 15:35:30 UTC (rev 114260)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-04-16 15:36:24 UTC (rev 114261)
@@ -8557,16 +8557,17 @@
m_token = NTH;
yylval->string.length = m_currentCharacter - m_tokenStart;
}
- } else if (result - m_tokenStart == 2 && m_tokenStart[1] == '-') {
+ } else if (result - m_tokenStart >= 2 && m_tokenStart[1] == '-') {
// String "n-" is IDENT but "n-1" is NTH.
- // Speculatively decrease m_currentCharacter to detect an nth-child token.
- m_currentCharacter--;
+ // Set m_currentCharacter to '-' to continue parsing.
+ UChar* nextCharacter = result;
+ m_currentCharacter = m_tokenStart + 1;
if (parseNthChildExtra()) {
m_token = NTH;
yylval->string.length = m_currentCharacter - m_tokenStart;
} else {
// Revert the change to m_currentCharacter if unsuccessful.
- m_currentCharacter++;
+ m_currentCharacter = nextCharacter;
}
}
}
@@ -8656,16 +8657,17 @@
m_token = NTH;
result = m_currentCharacter;
}
- } else if (result - m_tokenStart == 3 && m_tokenStart[2] == '-') {
+ } else if (result - m_tokenStart >= 3 && m_tokenStart[2] == '-') {
// String "-n-" is IDENT but "-n-1" is NTH.
- // Speculatively decrease m_currentCharacter to detect an nth-child token.
- m_currentCharacter--;
+ // Set m_currentCharacter to second '-' of '-n-' to continue parsing.
+ UChar* nextCharacter = result;
+ m_currentCharacter = m_tokenStart + 2;
if (parseNthChildExtra()) {
m_token = NTH;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ result = m_currentCharacter;
} else {
// Revert the change to m_currentCharacter if unsuccessful.
- m_currentCharacter++;
+ m_currentCharacter = nextCharacter;
}
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes