[csswg-drafts] [css-color-5] Gamut mapping in HSL/HSB (#7107)

devongovett has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-5] Gamut mapping in HSL/HSB ==
I am implementing support for `color-mix` in [Parcel CSS](https://github.com/parcel-bundler/parcel-css), and following the tests in WPT. A few tests related to gamut mapping failed in my implementation and I am wondering whether the test is wrong or my understanding of the spec is wrong.

[Example test](https://github.com/web-platform-tests/wpt/blob/f8c76b11cff66a7adc87264a18e39353cb5a60c9/css/css-color/parsing/color-mix-computed.html#L100):

```js
test_computed_value(`color`, `color-mix(in hsl, color(display-p3 0 1 0) 100%, rgb(0, 0, 0) 0%)`, `rgb(0, 249, 66)`); // Naive clip based mapping would give rgb(0, 255, 0).
```

The test expects `rgb(0, 249, 66)` as the result, but I am getting `rgb(0, 247, 78)`. This seems to be the result of gamut mapping occurring in the sRGB space rather than the HSL space. However, the `color-mix` in the test states that the color mixing should occur in the HSL space. If I convert the HSL color to sRGB before gamut mapping, and then back to HSL afterward for interpolation the test passes. However, I don't see where in the spec that is required. It says:

> For intermediate color calculations, these out of gamut values are preserved.

In this case, we're converting from OKLCH to HSL, and then comparing the clipped result via deltaE, so I would consider sRGB to be an intermediate space.

So my question: does gamut mapping happen in the sRGB space for HSL and HWB colors, or in the HSL/HWB space?

Hopefully that made sense...

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7107 using your GitHub account


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

Received on Sunday, 6 March 2022 19:30:14 UTC