Re: [csswg-drafts] [css-color-4] Allow out-of-gamut HSL/HWB colors (previously "Move gamut mapping to a future spec") (#8444)

I realize that there is another color syntax which can't represent out of sRGB gamut colors. CSS Color 4 is mostly silent on that case.

We used to say:

> If dest cannot represent [out of gamut](https://www.w3.org/TR/css-color-4/#out-of-gamut) colors, for example [hsl](https://www.w3.org/TR/css-color-4/#valdef-hsl-hsl) or [hwb](https://www.w3.org/TR/css-color-4/#valdef-hwb-hwb), then col2 must be [css gamut mapped](https://www.w3.org/TR/css-color-4/#css-gamut-mapped).

That was removed when we allowed out of gamut HSL and HWB values. But the _for example_  hides another syntax that can't represent out-of-gamut colors: `rgb()`.

RCS [says](https://drafts.csswg.org/css-color-5/#relative-RGB)

> r, g, and b are all [`<number>`](https://w3c.github.io/csswg-drafts/css-values-4/#number-value)s that correspond to the [origin color’s](https://drafts.csswg.org/css-color-5/#origin-color) red, green, and blue channels after [conversion, if required](https://drafts.csswg.org/css-color-5/#required-conversion) to sRGB. 255.0 is equivalent to 100%.

and CSS Color 4 [says](https://drafts.csswg.org/css-color-4/#rgb-functions)

> 0% represents the minimum value for that color channel in the sRGB gamut, and 100% represents the maximum value. A [<number>](https://w3c.github.io/csswg-drafts/css-values-4/#number-value) is equivalent to a [<percentage>](https://w3c.github.io/csswg-drafts/css-values-4/#percentage-value), but with a different range: 0 again represents the minimum value for the color channel, but 255 represents the maximum.

and

> Values outside these ranges are not invalid, but are clamped to the ranges defined here at parsed-value time.

It doesn't look web-compatible to start allowing things like `rgb(-131, 259.4, -79.3)` and WPT has [tests that assume CSS gamut mapping is applied](https://github.com/web-platform-tests/wpt/blob/390d91561e2d01c14b10d0986618d98c4d968e30/css/css-color/parsing/color-computed-relative-color.html#L37-L46).

Options:

1. Use gamut mapping as tested in WPT
2. Use clip (the wording "are clamped" comes from at least CSS Color 3, probably earlier
3. See if unbounded `rgb()` would be acceptable (we already went from integer to number on `rgb()`)
4. Disallow RCS with `rgb()` and have people use `color(srgb)` instead which has no gamut limitation, being defined on the full range

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8444#issuecomment-1487282557 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 28 March 2023 16:55:23 UTC