Bug 1370353 - Stop accepting `-/**/n` in nth-child ; r?dbaron
MozReview-Commit-ID: AhFYJrqynfw
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -6346,20 +6346,20 @@ CSSParserImpl::ParsePseudoClassWithNthPa
// A helper function that checks if the token starts with literal string
// |aStr| using a case-insensitive match.
auto TokenBeginsWith = [this] (const nsLiteralString& aStr) {
return StringBeginsWith(mToken.mIdent, aStr,
nsASCIICaseInsensitiveStringComparator());
};
- if (mToken.IsSymbol('+') || mToken.IsSymbol('-')) {
- // This can only be +n or -n, since +an, -an, +a, -a will all
- // parse a number as the first token.
- numbers[0] = mToken.IsSymbol('+') ? 1 : -1;
+ if (mToken.IsSymbol('+')) {
+ // This can only be +n, since +an, -an, +a, -a will all
+ // parse a number as the first token, and -n is an ident token.
+ numbers[0] = 1;
onlyN = true;
// consume the `n`
// We do not allow whitespace here
// https://drafts.csswg.org/css-syntax-3/#the-anb-type
if (! GetToken(false)) {
REPORT_UNEXPECTED_EOF(PEPseudoClassArgEOF);
return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')')
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -135,15 +135,14 @@ to mochitest command.
* test_property_syntax_errors.html `-webkit-gradient` [20]
* test_specified_value_serialization.html `-webkit-radial-gradient`: bug 1367299 [1]
* test_variables.html `var(--var6)`: irrelevant test for stylo bug 1367306 [1]
## Unknown / Unsure
* test_selectors_on_anonymous_content.html: xbl and :nth-child [1]
* test_parse_rule.html `rgb(0, 128, 0)`: color properties not getting computed [5]
-* test_selectors.html `:nth-child`: https://github.com/servo/rust-cssparser/issues/153 [4]
## Ignore
* Ignore for now since should be mostly identical to test_value_storage.html
* test_value_cloning.html [*]
* test_value_computation.html [*]
--- a/layout/style/test/test_selectors.html
+++ b/layout/style/test/test_selectors.html
@@ -647,17 +647,17 @@ function run() {
test_parseable(":nth-child(+n/**/+2)");
test_parseable(":nth-child(+n+/**/2)");
test_parseable(":nth-child(+n+2/**/)");
test_balanced_unparseable(":nth-child(+1/**/n+2)");
test_parseable(":nth-child(+1n/**/+2)");
test_parseable(":nth-child(+1n/**/+2)");
test_parseable(":nth-child(+1n+/**/2)");
test_parseable(":nth-child(+1n+2/**/)");
- test_parseable(":nth-child(-/**/n+2)");
+ test_balanced_unparseable(":nth-child(-/**/n+2)");
test_parseable(":nth-child(-n/**/+2)");
test_parseable(":nth-child(-n/**/+2)");
test_parseable(":nth-child(-n+/**/2)");
test_parseable(":nth-child(-n+2/**/)");
test_balanced_unparseable(":nth-child(-1/**/n+2)");
test_parseable(":nth-child(-1n/**/+2)");
test_parseable(":nth-child(-1n/**/+2)");
test_parseable(":nth-child(-1n+/**/2)");
@@ -671,17 +671,17 @@ function run() {
test_parseable(":nth-child(+n/**/-2)");
test_parseable(":nth-child(+n-/**/2)");
test_parseable(":nth-child(+n-2/**/)");
test_balanced_unparseable(":nth-child(+1/**/n-2)");
test_parseable(":nth-child(+1n/**/-2)");
test_parseable(":nth-child(+1n/**/-2)");
test_parseable(":nth-child(+1n-/**/2)");
test_parseable(":nth-child(+1n-2/**/)");
- test_parseable(":nth-child(-/**/n-2)");
+ test_balanced_unparseable(":nth-child(-/**/n-2)");
test_parseable(":nth-child(-n/**/-2)");
test_parseable(":nth-child(-n/**/-2)");
test_parseable(":nth-child(-n-/**/2)");
test_parseable(":nth-child(-n-2/**/)");
test_balanced_unparseable(":nth-child(-1/**/n-2)");
test_parseable(":nth-child(-1n/**/-2)");
test_parseable(":nth-child(-1n/**/-2)");
test_parseable(":nth-child(-1n-/**/2)");
@@ -695,17 +695,17 @@ function run() {
test_parseable(":nth-child(+N/**/-2)");
test_parseable(":nth-child(+N-/**/2)");
test_parseable(":nth-child(+N-2/**/)");
test_balanced_unparseable(":nth-child(+1/**/N-2)");
test_parseable(":nth-child(+1N/**/-2)");
test_parseable(":nth-child(+1N/**/-2)");
test_parseable(":nth-child(+1N-/**/2)");
test_parseable(":nth-child(+1N-2/**/)");
- test_parseable(":nth-child(-/**/N-2)");
+ test_balanced_unparseable(":nth-child(-/**/N-2)");
test_parseable(":nth-child(-N/**/-2)");
test_parseable(":nth-child(-N/**/-2)");
test_parseable(":nth-child(-N-/**/2)");
test_parseable(":nth-child(-N-2/**/)");
test_balanced_unparseable(":nth-child(-1/**/N-2)");
test_parseable(":nth-child(-1N/**/-2)");
test_parseable(":nth-child(-1N/**/-2)");
test_parseable(":nth-child(-1N-/**/2)");
@@ -715,17 +715,17 @@ function run() {
test_balanced_unparseable(":nth-child(+/**/ N-2)");
test_balanced_unparseable(":nth-child(+ /**/N-2)");
test_parseable(":nth-child( +n + 1 )");
test_parseable(":nth-child( +/**/n + 1 )");
test_balanced_unparseable(":nth-child( -/**/2/**/n/**/+/**/4 )");
test_parseable(":nth-child( -2n/**/ + /**/4 )");
test_parseable(":nth-child( -2n/**/+/**/4 )");
test_parseable(":nth-child( -2n /**/+/**/4 )");
- test_parseable(":nth-child( -/**/n /**/+ /**/ 4 )");
+ test_balanced_unparseable(":nth-child( -/**/n /**/+ /**/ 4 )");
test_parseable(":nth-child( +/**/n /**/+ /**/ 4 )");
test_balanced_unparseable(":nth-child(+1/**/n-1)");
test_balanced_unparseable(":nth-child(1/**/n-1)");
// bug 876570
test_balanced_unparseable(":nth-child(+2n-)");
test_balanced_unparseable(":nth-child(+n-)");
test_balanced_unparseable(":nth-child(-2n-)");
test_balanced_unparseable(":nth-child(-n-)");