RESOLVED FIXED 226513
Add support for "relative color syntax" for color()
https://bugs.webkit.org/show_bug.cgi?id=226513
Summary Add support for "relative color syntax" for color()
Sam Weinig
Reported 2021-06-01 13:37:59 PDT
Add support for "relative color syntax" for color()
Attachments
Patch (29.94 KB, patch)
2021-06-01 15:01 PDT, Sam Weinig
no flags
Patch (78.91 KB, patch)
2021-06-01 18:16 PDT, Sam Weinig
no flags
Patch (79.38 KB, patch)
2021-06-02 08:17 PDT, Sam Weinig
ews-feeder: commit-queue-
Patch (79.38 KB, patch)
2021-06-02 08:40 PDT, Sam Weinig
ews-feeder: commit-queue-
Patch (79.38 KB, patch)
2021-06-02 08:43 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2021-06-01 15:01:06 PDT Comment hidden (obsolete)
Sam Weinig
Comment 2 2021-06-01 18:16:05 PDT
Darin Adler
Comment 3 2021-06-01 18:31:14 PDT
Comment on attachment 430312 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=430312&action=review > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1566 > + ASSERT(range.peek().functionId() == CSSValueRgb || range.peek().functionId() == CSSValueRgba); Wouldn’t we want the more precise assertion? ASSERT(range.peek().functionId() == (Mode == RGBFunctionMode::RGB ? CSSValueRgb : CSSValueRgba)); Or is my assertion wrong? > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1583 > + return convertColor<SRGBA<uint8_t>>(HSLA<float> { static_cast<float>(normalizedHue), static_cast<float>(normalizedSaturation), static_cast<float>(normalizedLightness), static_cast<float>(normalizedAlpha) }); This explicit conversion to SRGBA really does need a comment. I know it’s not new. The fact that we do not create an extended color, but instead round and clamp to SRGBA intentionally really does not go without saying! > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1659 > + ASSERT(range.peek().functionId() == CSSValueHsl || range.peek().functionId() == CSSValueHsla); Same thought about the assertion. > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1720 > + return convertColor<SRGBA<uint8_t>>(HWBA<float> { static_cast<float>(normalizedHue), static_cast<float>(normalizedWhitness), static_cast<float>(normalizedBlackness), static_cast<float>(*alpha) }); Same thought about the comment. > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1929 > + for (int i = 0; i < 3; ++i) { for (auto& channel : channels) { > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1932 > + if (!value) > + break; All unspecified channels are set to 0? Peculiar syntax!
Sam Weinig
Comment 4 2021-06-02 08:17:22 PDT Comment hidden (obsolete)
Sam Weinig
Comment 5 2021-06-02 08:40:08 PDT Comment hidden (obsolete)
Sam Weinig
Comment 6 2021-06-02 08:42:49 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 430312 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=430312&action=review > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1566 > > + ASSERT(range.peek().functionId() == CSSValueRgb || range.peek().functionId() == CSSValueRgba); > > Wouldn’t we want the more precise assertion? > > ASSERT(range.peek().functionId() == (Mode == RGBFunctionMode::RGB ? > CSSValueRgb : CSSValueRgba)); > > Or is my assertion wrong? Nope. Great idea. The template parameter and the assertion were added at different times and I didn't put them together. Done. > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1583 > > + return convertColor<SRGBA<uint8_t>>(HSLA<float> { static_cast<float>(normalizedHue), static_cast<float>(normalizedSaturation), static_cast<float>(normalizedLightness), static_cast<float>(normalizedAlpha) }); > > This explicit conversion to SRGBA really does need a comment. I know it’s > not new. The fact that we do not create an extended color, but instead round > and clamp to SRGBA intentionally really does not go without saying! Totally agree. Added. > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1659 > > + ASSERT(range.peek().functionId() == CSSValueHsl || range.peek().functionId() == CSSValueHsla); > > Same thought about the assertion. Done. > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1720 > > + return convertColor<SRGBA<uint8_t>>(HWBA<float> { static_cast<float>(normalizedHue), static_cast<float>(normalizedWhitness), static_cast<float>(normalizedBlackness), static_cast<float>(*alpha) }); > > Same thought about the comment. Done. > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1929 > > + for (int i = 0; i < 3; ++i) { > > for (auto& channel : channels) { Done. > > > Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:1932 > > + if (!value) > > + break; > > All unspecified channels are set to 0? Peculiar syntax! So odd. It has to do with the fact that a custom profile can have any number of components, so it just defaults everything to 0, but I think they should just special case the predefined ones to require the right number of components, but I think I lost that argument.
Sam Weinig
Comment 7 2021-06-02 08:43:29 PDT
EWS
Comment 8 2021-06-02 10:39:05 PDT
Committed r278364 (238394@main): <https://commits.webkit.org/238394@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 430363 [details].
Radar WebKit Bug Importer
Comment 9 2021-06-02 10:40:21 PDT
Note You need to log in before you can comment on or make changes to this bug.