Bug 251152 - color() function parsing incorrectly parses missing components
Summary: color() function parsing incorrectly parses missing components
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Nguyen (:ntim)
URL: https://wpt.fyi/results/css/css-color...
Keywords: BrowserCompat, GoodFirstBug, InRadar
Depends on:
Blocks:
 
Reported: 2023-01-25 08:15 PST by Emilio Cobos Álvarez (:emilio)
Modified: 2023-03-24 14:34 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Cobos Álvarez (:emilio) 2023-01-25 08:15:00 PST
color(srgb / 0.5) seems to parse on safari with the components zeroed out, but that seems wrong per spec. https://w3c.github.io/csswg-drafts/css-color-4/#funcdef-color only says the alpha is optional.
Comment 1 Emilio Cobos Álvarez (:emilio) 2023-01-25 17:19:22 PST
https://bugs.chromium.org/p/chromium/issues/detail?id=1410200 is the relevant chromium bug, for reference. I found this while reviewing patches to implement this in Firefox.
Comment 2 Karl Dubost 2023-01-25 18:19:49 PST
After:

    document.body.style.color = color(srgb / 0.5)
    document.body.style.color


WebKit 'color(srgb 0 0 0 / 0.5)'
Gecko  ''
Blink  'color(srgb 0 0 0 / 0.5)'
Comment 3 Radar WebKit Bug Importer 2023-01-25 20:43:59 PST
<rdar://problem/104679823>
Comment 4 Chris Lilley 2023-01-26 07:58:31 PST
This used to be correct per spec, long ago when color() also did custom color spaces and it was reasonable to omit some components and have them auto-filled with zero.

Now custom color spaces are in CSS Color 5, and clearly distinguished with a dashed-ident; while predefined color spaces are in CSS Color 4 and are wither an RGB space or an XYZ space. Both take 3 components, as the grammar makes clear.

There was some leftover prose about variable number of components, not up to date with the grammar change, which I just corrected.
Comment 5 Tim Nguyen (:ntim) 2023-03-24 11:51:31 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11940
Comment 6 EWS 2023-03-24 14:34:49 PDT
Committed 262098@main (77b199a5f044): <https://commits.webkit.org/262098@main>

Reviewed commits have been landed. Closing PR #11940 and removing active labels.