Closed Bug 1352757 Opened 7 years ago Closed 1 year ago

Implement lab(), lch(), oklab() and oklch() from CSS Color Module Level 4

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: sebo, Assigned: tlouw)

References

(Blocks 5 open bugs, )

Details

(Keywords: dev-doc-complete, Whiteboard: [layout:backlog])

Attachments

(1 file, 2 obsolete files)

CSS Color Module Level 4 defines lab() and lch() functions allowing to specify colors in Lab and LCH.

This bug is meant to implement these two functions.

Sebastian
Blocks: 1352758
Assignee: nobody → boris.chiou
Status: NEW → ASSIGNED
Blocks: css3test
Priority: -- → P3
Assignee: boris.chiou → nobody
Status: ASSIGNED → NEW
Assignee: nobody → boris.chiou
Whiteboard: [layout:backlog]
Assignee: boris.chiou → nobody
Flags: needinfo?(emilio)
No longer blocks: 1703356
Depends on: 1703356
Blocks: 1759772
Blocks: interop2022
Assignee: nobody → tlouw

Some initial comments after first investigation:

  • In the rust-cssparser library (that does the parsing only) assumes that all color spaces will be converted back to rgb. According to some comments from webkit bug and also looking at the styles and animation code it looks like we should rather just pass the values back to the consumer of the lib in the formats that is being parsed. So in stead of RGB we return {r, g, b}, {l, a, b}, {l, c, h}, {h, s, l}, etc.
  • The second problem is that the conversion functions used in css-color-5 is mostly implemented in gecko already and we don't have access to those from rust-cssparser. Having to convert to RGB would require a duplication of the code or extracting the conversion functions to separate lib. (Which is not a bad idea in general I think. Really handy functions)

Choosing whether to convert to sRGB or to store the parsed values is an implementation detail provided that extended-range sRGB is being converted to/from (ie values <0 and >1.0 are preserved). Modulo some round-trip error of course.

Since the original bug was filed, CSS Color 4 has added oklab() and oklch() which are significantly better than Lab/LCH in terms of perceptual uniformity, are used for gradient interpolation and gamut mapping, and also don't require chromatic adaptation between D65 and D50 white points which is another source of cumulative round-off error.

Severity: normal → S3
Attachment #9306204 - Attachment description: WIP: Bug 1352757 - Part 1 - Add lab() and lch() color spaces. r=#layout-reviewers → WIP: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers
Attachment #9305997 - Attachment is obsolete: true
Attachment #9306204 - Attachment description: WIP: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers → Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers
Attachment #9306204 - Attachment description: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers → WIP: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers
Attachment #9306204 - Attachment description: WIP: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers → Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers
Attachment #9306204 - Attachment description: Bug 1352757 - Part 1 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers → Bug 1352757 - Add lab(), lch(), oklab(), oklch() to specified colors. r=#layout-reviewers
Attachment #9305998 - Attachment is obsolete: true

Similar to guidance on :has in https://bugzilla.mozilla.org/show_bug.cgi?id=418039#c62, may we know roughly when Firefox intends to ship this?

Pushed by tlouw@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/218b12b92ccb
Add lab(), lch(), oklab(), oklch() to specified colors. r=supply-chain-reviewers,emilio

(In reply to Alexandre Dieulot from comment #9)

Similar to guidance on :has in https://bugzilla.mozilla.org/show_bug.cgi?id=418039#c62, may we know roughly when Firefox intends to ship this?

We are actively working on some color-4 improvements and you can expect a release in the coming months.

Pushed by tlouw@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3fa8d29c7c44
Add lab(), lch(), oklab(), oklch() to specified colors. r=supply-chain-reviewers,emilio

Fixed issue and landed again.

Flags: needinfo?(tlouw)
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
Blocks: 1632548

These changes are currently under the layout.css.more_color_4.enabled preference.

Documentation changes for this are being tracked in the following issue on GitHub: https://github.com/mdn/content/issues/24395

[Updating bug title to reflect the fact that we implemented oklab() and oklch() here as well. Also, closing stale needinfo for emilio from back before this bug had an assignee.]

Flags: needinfo?(emilio)
Summary: Implement lab() and lch() from CSS Color Module Level 4 → Implement lab(), lch(), oklab() and oklch() from CSS Color Module Level 4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: