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

Parse rgb() like other color functions #40426

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Jun 7, 2023

Previously, rgb() and rgba() parsers were compressing all four color
channels and alpha to 8-bit integers. This is no longer necessary, as
blink::Color stores the parameters as floats.

As we move towards implementing relative color, the more unified the
color parsing is, the easier the eventual implementation will be.

After some discussion for Interop 2023, it was decided that non-finite
color parameters should round-trip and be resolved sanely:
http://github.com/w3c/csswg-drafts/issues/8629
This new requirement obviously puts us well out of 8-bit integer
territory.

Unfortunately, there are clearly still some code paths that are
independently compressing alpha to be an 8-bit integer and unless
we explicitly do this in the parser, many tests fail. A TODO has been
added to address this issue.

Here is the test change proposal: web-platform-tests/interop#369

Gradient tests with png expectations are pretty brittle, as evidenced
by the per-platform expectations. This change requires a rebaseline
because color channels are not squashed to [0,255] integer range at
the endpoints. So inputs like:
conic-gradient(rgb(0%, 75%, 25%), rgb(0%, 25%, 75%));
No longer become equivalent to:
conic-gradient(rgb(0, 191, 63), rgb(0, 63, 191));
25% of 255 is 63.75. 75% of 255 is 191.25.

Bug: 1452185
Change-Id: I1e89ad21d0e3007c1f51aa075728732c2856acc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4598329
Reviewed-by: Florin Malita <[email protected]>
Reviewed-by: Steinar H Gunderson <[email protected]>
Commit-Queue: Aaron Krajeski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1166616}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 2 times, most recently from ac9072c to 8cf2133 Compare June 8, 2023 15:47
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 3 times, most recently from c54a4d5 to b2fb50a Compare June 22, 2023 21:16
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 2 times, most recently from 4130e2d to f4b7add Compare June 22, 2023 22:39
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 2 times, most recently from da7ad6b to 3562728 Compare June 26, 2023 19:59
@chromium-wpt-export-bot chromium-wpt-export-bot changed the title Parse rgb() like everything else Parse rgb() like other color functions Jun 26, 2023
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 7 times, most recently from f12bf02 to b651ab9 Compare July 3, 2023 15:33
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-4598329 branch 4 times, most recently from f1d7a44 to 2c60737 Compare July 6, 2023 16:18
Previously, rgb() and rgba() parsers were compressing all four color
channels and alpha to 8-bit integers. This is no longer necessary, as
blink::Color stores the parameters as floats.

As we move towards implementing relative color, the more unified the
color parsing is, the easier the eventual implementation will be.

After some discussion for Interop 2023, it was decided that non-finite
color parameters should round-trip and be resolved sanely:
http://github.com/w3c/csswg-drafts/issues/8629
This new requirement obviously puts us well out of 8-bit integer
territory.

Unfortunately, there are clearly still some code paths that are
independently compressing alpha to be an 8-bit integer and unless
we explicitly do this in the parser, many tests fail. A TODO has been
added to address this issue.

Here is the test change proposal: web-platform-tests/interop#369

Gradient tests with png expectations are pretty brittle, as evidenced
by the per-platform expectations. This change requires a rebaseline
because color channels are not squashed to [0,255] integer range at
the endpoints. So inputs like:
  conic-gradient(rgb(0%, 75%, 25%), rgb(0%, 25%, 75%));
No longer become equivalent to:
  conic-gradient(rgb(0, 191, 63), rgb(0, 63, 191));
25% of 255 is 63.75. 75% of 255 is 191.25.

Bug: 1452185
Change-Id: I1e89ad21d0e3007c1f51aa075728732c2856acc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4598329
Reviewed-by: Florin Malita <[email protected]>
Reviewed-by: Steinar H Gunderson <[email protected]>
Commit-Queue: Aaron Krajeski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1166616}
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.

4 participants