Title: [285492] trunk/Source/WebCore
Revision
285492
Author
[email protected]
Date
2021-11-09 05:08:17 -0800 (Tue, 09 Nov 2021)

Log Message

Refactor consumeWillChange() to make better use of consumeCustomIdent()
https://bugs.webkit.org/show_bug.cgi?id=232874

Reviewed by Antti Koivisto.

consumeCustomIdent() already rejects for non-ident types and reserved keywords.
Make use of that to make the function more readable.

* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeWillChange):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285491 => 285492)


--- trunk/Source/WebCore/ChangeLog	2021-11-09 12:15:23 UTC (rev 285491)
+++ trunk/Source/WebCore/ChangeLog	2021-11-09 13:08:17 UTC (rev 285492)
@@ -1,5 +1,18 @@
 2021-11-09  Tim Nguyen  <[email protected]>
 
+        Refactor consumeWillChange() to make better use of consumeCustomIdent()
+        https://bugs.webkit.org/show_bug.cgi?id=232874
+
+        Reviewed by Antti Koivisto.
+
+        consumeCustomIdent() already rejects for non-ident types and reserved keywords.
+        Make use of that to make the function more readable.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeWillChange):
+
+2021-11-09  Tim Nguyen  <[email protected]>
+
         Use isValidCustomIdentifier in consumeWillChange
         https://bugs.webkit.org/show_bug.cgi?id=232868
 

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (285491 => 285492)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-11-09 12:15:23 UTC (rev 285491)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-11-09 13:08:17 UTC (rev 285492)
@@ -488,40 +488,35 @@
     RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
     // Every comma-separated list of identifiers is a valid will-change value,
     // unless the list includes an explicitly disallowed identifier.
-    while (true) {
-        if (range.peek().type() != IdentToken)
+    while (!range.atEnd()) {
+        switch (range.peek().id()) {
+        case CSSValueContents:
+        case CSSValueScrollPosition:
+            values->append(consumeIdent(range).releaseNonNull());
+            break;
+        case CSSValueNone:
+        case CSSValueAll:
+        case CSSValueAuto:
             return nullptr;
-        CSSPropertyID propertyID = cssPropertyID(range.peek().value());
-        if (propertyID != CSSPropertyInvalid) {
-            // Now "all" is used by both CSSValue and CSSPropertyValue.
-            // Need to return nullptr when currentValue is CSSPropertyAll.
-            if (propertyID == CSSPropertyWillChange || propertyID == CSSPropertyAll)
+        default:
+            CSSPropertyID propertyID = cssPropertyID(range.peek().value());
+            if (propertyID == CSSPropertyWillChange)
                 return nullptr;
-            values->append(CSSValuePool::singleton().createIdentifierValue(propertyID));
-            range.consumeIncludingWhitespace();
-        } else {
-            auto id = range.peek().id();
-            switch (id) {
-            case CSSValueNone:
-            case CSSValueAll:
-            case CSSValueAuto:
-                return nullptr;
-            case CSSValueContents:
-            case CSSValueScrollPosition:
-                values->append(consumeIdent(range).releaseNonNull());
+            if (propertyID != CSSPropertyInvalid) {
+                values->append(CSSValuePool::singleton().createIdentifierValue(propertyID));
+                range.consumeIncludingWhitespace();
                 break;
-            default:
-                if (!isValidCustomIdentifier(id))
-                    return nullptr;
+            }
+            if (auto customIdent = consumeCustomIdent(range)) {
                 // Append properties we don't recognize, but that are legal, as strings.
-                values->append(consumeCustomIdent(range).releaseNonNull());
+                values->append(customIdent.releaseNonNull());
                 break;
             }
+            return nullptr;
         }
 
-        if (range.atEnd())
-            break;
-        if (!consumeCommaIncludingWhitespace(range))
+        // This is a comma separated list
+        if (!range.atEnd() && !consumeCommaIncludingWhitespace(range))
             return nullptr;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to