Bug 232874 - Refactor consumeWillChange()
Summary: Refactor consumeWillChange()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Nguyen (:ntim)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-09 03:05 PST by Tim Nguyen (:ntim)
Modified: 2021-11-09 05:09 PST (History)
8 users (show)

See Also:


Attachments
Patch (3.47 KB, patch)
2021-11-09 03:14 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff
Patch (3.80 KB, patch)
2021-11-09 03:21 PST, Tim Nguyen (:ntim)
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Nguyen (:ntim) 2021-11-09 03:05:39 PST
See bug 232868 comment 9
Comment 1 Tim Nguyen (:ntim) 2021-11-09 03:14:53 PST
Created attachment 443671 [details]
Patch
Comment 2 Tim Nguyen (:ntim) 2021-11-09 03:21:38 PST
Created attachment 443672 [details]
Patch
Comment 3 Antti Koivisto 2021-11-09 04:06:09 PST
Comment on attachment 443672 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443672&action=review

> Source/WebCore/css/parser/CSSPropertyParser.cpp:-502
>      // 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 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)
> -                return nullptr;
> -            values->append(CSSValuePool::singleton().createIdentifierValue(propertyID));
> -            range.consumeIncludingWhitespace();
> -        } else {

It is not clear to me how this is better. The primary purpose of this loop is to consume property identifiers which the old code made clear.

After your change the loop looks like it is about CSSValues and property IDs are a buried special case.
Comment 4 Tim Nguyen (:ntim) 2021-11-09 04:51:47 PST
(In reply to Antti Koivisto from comment #3)
> Comment on attachment 443672 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=443672&action=review
> 
> > Source/WebCore/css/parser/CSSPropertyParser.cpp:-502
> >      // 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 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)
> > -                return nullptr;
> > -            values->append(CSSValuePool::singleton().createIdentifierValue(propertyID));
> > -            range.consumeIncludingWhitespace();
> > -        } else {
> 
> It is not clear to me how this is better. The primary purpose of this loop
> is to consume property identifiers which the old code made clear.
> 
> After your change the loop looks like it is about CSSValues and property IDs
> are a buried special case.

This is how the spec defines things, defines values first, and property IDs are just a special cases of <custom-ident>, so to me this is actually easier to read.
Comment 5 Antti Koivisto 2021-11-09 04:57:27 PST
Comment on attachment 443672 [details]
Patch

Ok then!
Comment 6 Tim Nguyen (:ntim) 2021-11-09 05:08:29 PST
Committed r285492 (244016@main): <https://commits.webkit.org/244016@main>
Comment 7 Radar WebKit Bug Importer 2021-11-09 05:09:21 PST
<rdar://problem/85198621>