Bug 232874

Summary: Refactor consumeWillChange()
Product: WebKit Reporter: Tim Nguyen (:ntim) <ntim>
Component: CSSAssignee: Tim Nguyen (:ntim) <ntim>
Status: RESOLVED FIXED    
Severity: Normal CC: esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, koivisto, macpherson, menard, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch koivisto: review+

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>