Bug 221881 - Prepare for adding relative color support
Summary: Prepare for adding relative color support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks: 221880
  Show dependency treegraph
 
Reported: 2021-02-14 15:38 PST by Sam Weinig
Modified: 2021-02-18 22:44 PST (History)
15 users (show)

See Also:


Attachments
Patch (70.25 KB, patch)
2021-02-14 15:52 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (70.69 KB, patch)
2021-02-14 16:03 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (71.36 KB, patch)
2021-02-14 16:15 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (71.75 KB, patch)
2021-02-14 16:27 PST, Sam Weinig
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (71.75 KB, patch)
2021-02-14 19:04 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (77.51 KB, patch)
2021-02-14 20:11 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (76.67 KB, patch)
2021-02-15 10:32 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch for landing (1.36 KB, patch)
2021-02-15 13:10 PST, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2021-02-14 15:38:16 PST
Prepare for adding relative color support
Comment 1 Sam Weinig 2021-02-14 15:52:53 PST Comment hidden (obsolete)
Comment 2 Sam Weinig 2021-02-14 16:03:30 PST Comment hidden (obsolete)
Comment 3 Sam Weinig 2021-02-14 16:15:14 PST Comment hidden (obsolete)
Comment 4 Sam Weinig 2021-02-14 16:27:24 PST Comment hidden (obsolete)
Comment 5 Sam Weinig 2021-02-14 19:04:01 PST Comment hidden (obsolete)
Comment 6 Sam Weinig 2021-02-14 20:11:54 PST
Created attachment 420267 [details]
Patch
Comment 7 Darin Adler 2021-02-15 08:41:10 PST
Comment on attachment 420267 [details]
Patch

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

> Source/WebCore/css/parser/CSSParser.cpp:120
> -    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, HTMLStandardMode);
> +    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, strictCSSParserContext());

Rationale for going from "standard mode" to "strict"?

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:699
> +        return clampTo<double>(*alphaParameter, 0.0, 1.0);

Should not need the <double> here.

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:712
> +    if (auto number = consumeNumberRaw(range))
> +        return *number;
> +
> +    return WTF::nullopt;

Doesn’t seem like we need an if here. Just a return.

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:723
> +enum class RGBComponentType {
> +    Number,
> +    Percentage
> +};

Looks better on a single line?

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:736
> +enum class RGBOrHSLSeparatorSyntax {
> +    Commas,
> +    WhitespaceSlash
> +};

Looks better on a single line?

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:760
> +    if (auto alphaParameter = consumeNumberOrPercentDividedBy100Raw(args))
> +        return *alphaParameter;
> +
> +    return WTF::nullopt;

Doesn’t seem like we need an if here. Just a return.

> Source/WebCore/editing/cocoa/DataDetection.mm:603
> +                        hsla.lightness = 50.0f;

How do you know you found all the places that depend on the old range?
Comment 8 EWS 2021-02-15 08:42:17 PST
ChangeLog entry in Tools/ChangeLog contains OOPS!.
Comment 9 Darin Adler 2021-02-15 09:21:18 PST
Comment on attachment 420267 [details]
Patch

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

>> Source/WebCore/css/parser/CSSParser.cpp:120
>> +    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, strictCSSParserContext());
> 
> Rationale for going from "standard mode" to "strict"?

Oh, wait, I guess those are two names for the same sort of thing. Somehow I thought "standard" was the non-strict.
Comment 10 Sam Weinig 2021-02-15 10:27:17 PST
(In reply to Darin Adler from comment #7)
> Comment on attachment 420267 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=420267&action=review
> 
> > Source/WebCore/css/parser/CSSParser.cpp:120
> > -    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, HTMLStandardMode);
> > +    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, strictCSSParserContext());
> 
> Rationale for going from "standard mode" to "strict"?

strictCSSParserContext() is just a CSSParserContext with HTMLStandardMode. 

const CSSParserContext& strictCSSParserContext()
{
    static MainThreadNeverDestroyed<CSSParserContext> strictContext(HTMLStandardMode);
    return strictContext;
}

So it should behave the same.

> 
> > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:699
> > +        return clampTo<double>(*alphaParameter, 0.0, 1.0);
> 
> Should not need the <double> here.

Fixed.

> 
> > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:712
> > +    if (auto number = consumeNumberRaw(range))
> > +        return *number;
> > +
> > +    return WTF::nullopt;
> 
> Doesn’t seem like we need an if here. Just a return.

Good point. Fixed.

> 
> > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:723
> > +enum class RGBComponentType {
> > +    Number,
> > +    Percentage
> > +};
> 
> Looks better on a single line?

Fixed.

> 
> > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:736
> > +enum class RGBOrHSLSeparatorSyntax {
> > +    Commas,
> > +    WhitespaceSlash
> > +};
> 
> Looks better on a single line?

Fixed.

> 
> > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:760
> > +    if (auto alphaParameter = consumeNumberOrPercentDividedBy100Raw(args))
> > +        return *alphaParameter;
> > +
> > +    return WTF::nullopt;
> 
> Doesn’t seem like we need an if here. Just a return.

Fixed.

> 
> > Source/WebCore/editing/cocoa/DataDetection.mm:603
> > +                        hsla.lightness = 50.0f;
> 
> How do you know you found all the places that depend on the old range?

Searched for all uses of HSLA in the code. Since you explicit conversion is needed it's pretty easy to find them all.

Thanks for the review.
Comment 11 Sam Weinig 2021-02-15 10:32:22 PST
Created attachment 420330 [details]
Patch
Comment 12 EWS 2021-02-15 11:24:18 PST
Committed r272870: <https://commits.webkit.org/r272870>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 420330 [details].
Comment 13 Radar WebKit Bug Importer 2021-02-15 11:25:16 PST
<rdar://problem/74358043>
Comment 14 Michael Catanzaro 2021-02-15 13:10:02 PST
Reopening to attach new patch.
Comment 15 Michael Catanzaro 2021-02-15 13:10:29 PST
Created attachment 420353 [details]
Patch for landing
Comment 16 EWS 2021-02-15 13:40:51 PST
Committed r272876: <https://commits.webkit.org/r272876>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 420353 [details].
Comment 17 Fujii Hironori 2021-02-18 22:44:11 PST
Comment on attachment 420330 [details]
Patch

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

> Source/WebCore/css/parser/CSSParser.cpp:120
> +    return CSSPropertyParserHelpers::consumeColorWorkerSafe(range, strictCSSParserContext());

You can't use strictCSSParserContext in parseColorWorkerSafe. See Bug 222156.