Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test oklab()/oklch() with lightness close to 0/1 #45073

Merged
merged 1 commit into from Mar 16, 2024

Conversation

foolip
Copy link
Member

@foolip foolip commented Mar 12, 2024

This is an interop issue where Chrome's behavior is different from
Firefox and Safari's: https://crbug.com/329106317

These tests don't care what the color is, as long as it is the same.

@foolip
Copy link
Member Author

foolip commented Mar 12, 2024

I am adding these tests so that implementing the same behavior as Chrome would fail these tests, to make the discontinuity that results from special-casing lightness 100% very obvious.

@foolip
Copy link
Member Author

foolip commented Mar 13, 2024

@foolip foolip changed the title Add tests of Oklab and Oklch with lightness 99.9999% Test oklab()/oklch() with with lightness close to 0/1 Mar 13, 2024
@foolip
Copy link
Member Author

foolip commented Mar 13, 2024

I've updated this PR to also test a color with lightness close to 0.

@foolip
Copy link
Member Author

foolip commented Mar 13, 2024

https://wpt.fyi/results/css/css-color?label=pr_head&max-count=1&pr=45073 is updated now and what I expected. The ones close to 0 aren't very interesting to look at, the problem is that the channel values aren't quite zero, but you need to know it to see it.

Here is Chrome, Firefox and Safari for oklab-l-almost-1.html, since there aren't screenshots for passing tests.

Chrome:

image

Firefox and Safari both look like this:

image

That's it. Please review :)

@mdubet
Copy link
Contributor

mdubet commented Mar 13, 2024

The tests look very convincing to me that this discontinuity is very unfortunate 👍 But are they following the spec ?

The wording of the spec "displayed as black ..due to gamut mapping to the display" seems to indicate that the discontinuity should not happen because a proper gamut mapping should prevent it ? Which mapping ?

cc @svgeesus

@foolip
Copy link
Member Author

foolip commented Mar 13, 2024

AFAIK, the spec doesn't say anything normative to the effect of "no large discontinuities" so the tests are written from a place of "something this close must round to the same thing".

I deliberately avoiding depending on what the color(s) actually are, to shine a light on the interoperability issue here. Other tests could test the colors of 0 / 0.0001% / 99.9999% / 1, it's just not what I was trying to isolate out here.

Copy link
Member

@dbaron dbaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping @svgeesus can look at the substance here, but I have one wording comment:

css/css-color/oklab-l-almost-0.html Outdated Show resolved Hide resolved
@foolip foolip changed the title Test oklab()/oklch() with with lightness close to 0/1 Test oklab()/oklch() with lightness close to 0/1 Mar 13, 2024
@foolip
Copy link
Member Author

foolip commented Mar 13, 2024

I've sent #45092 to update the tests I took inspiration from. If that lands, I can make these tests match that style.

This is an interop issue where Chrome's behavior is different from
Firefox and Safari's: https://crbug.com/329106317

These tests don't care what the color is, as long as it is the same.
@foolip
Copy link
Member Author

foolip commented Mar 14, 2024

I was impatient, so I've updated to match #45092 before it lands. It's easy to change the class names or wording if a reviewer asks for that.

@svgeesus
Copy link
Contributor

svgeesus commented Mar 16, 2024

The wording of the spec "displayed as black ..due to gamut mapping to the display" seems to indicate that the discontinuity should not happen because a proper gamut mapping should prevent it ? Which mapping ?

The spec used to say that L <=0 (black) and L>= 100% (white) got clamped, which effectively mandated a discontinuity between, say, 99.98% and 100.02%.

It was changed to say that this was caused by gamut mapping to the display, which has two benefits:

  • no sudden discontinuity as you approach the white or black point, regardless of the chroma
  • saying that un-displayable colors have to get mapped to a displayable color seems clear and obvious.

Copy link
Contributor

@svgeesus svgeesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the special casing is no longer in the spec so this undesirable discontinuity used to be spec compliant but no longer is.

@svgeesus svgeesus merged commit 298d159 into web-platform-tests:master Mar 16, 2024
19 checks passed
@foolip foolip deleted the lightness-almost-100 branch March 16, 2024 19:57
@foolip
Copy link
Member Author

foolip commented Mar 16, 2024

Thanks for review and the spec background @svgeesus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants