Skip to content

[css-color-4] Expected behavior around lightness 0 or 100% in Oklab/Oklch/Lab/LCH? #10109

@foolip

Description

@foolip

When adjusting lightness in Oklab/Oklch/Lab/LCH, what is expected behavior?

This is related to handling out-of-gamut colors, because:

  • As lightness decreases we reach imaginary colors with no physical meaning.
  • As lightness increases we reach real colors that cannot be shown on most displays.

I'm filing a new issue, because since Chrome 120, lightness exactly equalling 0 or 100% are mapped to black and white respectively. This led to a discontinuity and browsers now handle these cases differently:

https://wpt.live/css/css-color/oklab-l-almost-0.html (subtle difference)
https://wpt.live/css/css-color/oklab-l-almost-1.html (very apparent difference)

See also results on wpt.fyi

In web-platform-tests/wpt#45073 (comment), @svgeesus explained that the spec previously "effectively mandated a discontinuity", but that's no longer the case, so Chrome appropriate fails these tests now.

Oklab gradients with endpoints close to 0/100% are also affected. Demo at https://codepen.io/foolip/pen/zYXZPYr, with Chrome rendering inlined here:

Lightness 0-100%:
zero-to-hundred

Lightness 0-99.9%:
zero-to-almost

Lightness 0.1-100%:
almost-to-hundred

Lightness 0.1-99.9%:
almost-to-almost

In Firefox and Safari, all gradients look like the last case.

The fastest way to get back to an interoperable state would be to revert the Chrome change, so that all browsers do channel clipping, but ideally the behavior would only change once. I'm filing this issue as background reading for the breakout session planned on March 27.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.css-color-4Current Work

    Type

    No type

    Projects

    Status

    Wednesday morning

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions