Bug 234697 - [CSS Color 4] CSS color() function should not clamp channels to the 0-1 range
Summary: [CSS Color 4] CSS color() function should not clamp channels to the 0-1 range
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on: 234741
Blocks:
  Show dependency treegraph
 
Reported: 2021-12-26 15:45 PST by Sam Weinig
Modified: 2022-01-10 09:40 PST (History)
11 users (show)

See Also:


Attachments
Patch (120.08 KB, patch)
2022-01-10 06:39 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (147.12 KB, patch)
2022-01-10 07:48 PST, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2021-12-26 15:45:46 PST
The color() function in CSS Color 4 - https://drafts.csswg.org/css-color/#color-function - specifies that component values less than 0% or greater than 100% are not invalid:

"An out of gamut color has component values less than 0 or 0%, or greater than 1 or 100%. These are not invalid; instead, for display, they are gamut-mapped using a relative colorimetric intent which brings the values within the range 0/0% to 1/100% at computed-value time."


I have some questions about what this means in practice, and if computed value time is the right time to gamut map rather than at use, and I will raise these with the spec editors.
Comment 1 Radar WebKit Bug Importer 2022-01-02 15:46:19 PST
<rdar://problem/87054230>
Comment 2 Sam Weinig 2022-01-10 06:39:43 PST
Created attachment 448744 [details]
Patch
Comment 3 EWS Watchlist 2022-01-10 06:41:06 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 4 Sam Weinig 2022-01-10 07:48:31 PST
Created attachment 448751 [details]
Patch
Comment 5 Sam Weinig 2022-01-10 07:48:56 PST
We have a bunch of test duplication with the WPT tests, but I will fix that in another change.
Comment 6 Darin Adler 2022-01-10 08:58:19 PST
Comment on attachment 448751 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=448751&action=review

> Source/WebCore/ChangeLog:8
> +        Allow components outside the the 0-1 range for RGB color function types (e.g. color(srgb -2 15 100)).

Is this only for code paths that already store the components as floating point values? Does this affect performance in any cases that before would round down to [0,255] integers?
Comment 7 Sam Weinig 2022-01-10 09:20:51 PST
(In reply to Darin Adler from comment #6)
> Comment on attachment 448751 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=448751&action=review
> 
> > Source/WebCore/ChangeLog:8
> > +        Allow components outside the the 0-1 range for RGB color function types (e.g. color(srgb -2 15 100)).
> 
> Is this only for code paths that already store the components as floating
> point values? Does this affect performance in any cases that before would
> round down to [0,255] integers?

It's only for the code paths that we already store as float, no change to cases that before would round down to [0,255] integers.
Comment 8 EWS 2022-01-10 09:40:44 PST
Committed r287838 (245890@main): <https://commits.webkit.org/245890@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 448751 [details].