Skip to content

[css-color-5] Gamut mapping in HSL/HWB #7107

@devongovett

Description

@devongovett

I am implementing support for color-mix in 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:

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...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions