Title: [208133] trunk/Source/WebCore
Revision
208133
Author
[email protected]
Date
2016-10-30 15:33:02 -0700 (Sun, 30 Oct 2016)

Log Message

[CSS Parser] Fix nth-child serialization
https://bugs.webkit.org/show_bug.cgi?id=164210

Reviewed by Darin Adler.

Our nth-child serialization preserves what the author originally
typed. Even though this is not spec-compliant (the latest CSS Syntax
spec has a dumbed down serialization process that doesn't preserve what
the author originally typed), I think it's better behavior to preserve
this text.

* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize):
Fix a bug in the serialization of number tokens that started with
a plus sign. Make sure the plus sign is preserved.

* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumePseudo):
Grab the range of tokens from after the ( and up to the ) or the "of"
and then serialize them. Strip whitepsace from the ends and set that
as the selector argument.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208132 => 208133)


--- trunk/Source/WebCore/ChangeLog	2016-10-30 20:48:22 UTC (rev 208132)
+++ trunk/Source/WebCore/ChangeLog	2016-10-30 22:33:02 UTC (rev 208133)
@@ -1,3 +1,27 @@
+2016-10-30  Dave Hyatt  <[email protected]>
+
+        [CSS Parser] Fix nth-child serialization
+        https://bugs.webkit.org/show_bug.cgi?id=164210
+
+        Reviewed by Darin Adler.
+
+        Our nth-child serialization preserves what the author originally
+        typed. Even though this is not spec-compliant (the latest CSS Syntax
+        spec has a dumbed down serialization process that doesn't preserve what
+        the author originally typed), I think it's better behavior to preserve
+        this text.
+
+        * css/parser/CSSParserToken.cpp:
+        (WebCore::CSSParserToken::serialize):
+        Fix a bug in the serialization of number tokens that started with
+        a plus sign. Make sure the plus sign is preserved.
+
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::CSSSelectorParser::consumePseudo):
+        Grab the range of tokens from after the ( and up to the ) or the "of"
+        and then serialize them. Strip whitepsace from the ends and set that
+        as the selector argument.
+
 2016-10-28  Brent Fulgham  <[email protected]>
 
         [Win][Direct2D] Correct bookkeeping for begin/end draw pairs

Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (208132 => 208133)


--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2016-10-30 20:48:22 UTC (rev 208132)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2016-10-30 22:33:02 UTC (rev 208133)
@@ -412,6 +412,8 @@
         return builder.append(delimiter());
     case NumberToken:
         // These won't properly preserve the NumericValueType flag
+        if (m_numericSign == PlusSign)
+            builder.append('+');
         return builder.appendNumber(numericValue());
     case PercentageToken:
         builder.appendNumber(numericValue());

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (208132 => 208133)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-10-30 20:48:22 UTC (rev 208132)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-10-30 22:33:02 UTC (rev 208133)
@@ -540,7 +540,9 @@
     block.consumeWhitespace();
     if (token.type() != FunctionToken)
         return nullptr;
-
+    
+    const auto& argumentStart = block.peek();
+    
     if (selector->match() == CSSSelector::PseudoClass) {
         switch (selector->pseudoClassType()) {
         case CSSSelector::PseudoClassNot: {
@@ -560,6 +562,10 @@
             if (!consumeANPlusB(block, ab))
                 return nullptr;
             block.consumeWhitespace();
+            const auto& argumentEnd = block.peek();
+            auto rangeOfANPlusB = block.makeSubRange(&argumentStart, &argumentEnd);
+            auto argument = rangeOfANPlusB.serialize();
+            selector->setArgument(argument.stripWhiteSpace());
             if (!block.atEnd()) {
                 if (block.peek().type() != IdentToken)
                     return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to