Bug 205675 - Support lab(), lch() and gray() colors
Summary: Support lab(), lch() and gray() colors
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks: 205725
  Show dependency treegraph
 
Reported: 2020-01-01 11:58 PST by Simon Fraser (smfr)
Modified: 2020-08-10 11:45 PDT (History)
23 users (show)

See Also:


Attachments
Patch (37.45 KB, patch)
2020-01-03 11:01 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (36.66 KB, patch)
2020-01-03 15:40 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (40.70 KB, patch)
2020-01-03 21:07 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (41.25 KB, patch)
2020-01-03 21:27 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (41.33 KB, patch)
2020-01-03 22:53 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (41.33 KB, patch)
2020-01-03 23:04 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (41.18 KB, patch)
2020-05-15 09:35 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2020-01-01 11:58:49 PST
Add support for lab(), lch() and gray() colors.
Comment 1 Radar WebKit Bug Importer 2020-01-01 15:27:23 PST
<rdar://problem/58264078>
Comment 2 Simon Fraser (smfr) 2020-01-02 12:11:28 PST
I have parsing and conversion done, but for computed style we need to store lab/lch colors without converting them to sRGB.

Also gradients/animations will need work.
Comment 3 Simon Fraser (smfr) 2020-01-03 11:01:55 PST
Created attachment 386699 [details]
Patch
Comment 4 Dean Jackson 2020-01-03 11:11:55 PST
Comment on attachment 386699 [details]
Patch

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

> Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:722
> +    float alpha = 1.0f;
> +    if (consumeSlashIncludingWhitespace(args)) {
> +        auto alphaParameter = consumePercent(args, ValueRangeAll);
> +        if (alphaParameter)
> +            alpha = clampTo<float>(alphaParameter->doubleValue() / 100.0, 0.0, 1.0);
> +        else {
> +            alphaParameter = consumeNumber(args, ValueRangeAll);
> +            if (!alphaParameter)
> +                return Color();
> +            alpha = clampTo<float>(alphaParameter->doubleValue(), 0.0, 1.0);
> +        }
> +    }

Seems like we do this often enough to separate into a function.

> Source/WebCore/platform/graphics/ExtendedColor.h:61
> +    const FloatComponents& value() const { return m_value; }

Maybe channels() or something?

> Source/WebCore/platform/graphics/cg/ColorCG.cpp:121
> +            // FIXME: This will give incorrect results on platforms that don't support CGColorSpaceCreateLab(). We should
> +            // convert to sRGB.

What platforms are they? This is already inside ColorCG.
Comment 5 Simon Fraser (smfr) 2020-01-03 15:40:45 PST
Created attachment 386722 [details]
Patch
Comment 6 Simon Fraser (smfr) 2020-01-03 21:07:32 PST
Created attachment 386752 [details]
Patch
Comment 7 Simon Fraser (smfr) 2020-01-03 21:27:11 PST
Created attachment 386754 [details]
Patch
Comment 8 Simon Fraser (smfr) 2020-01-03 22:53:37 PST
Created attachment 386758 [details]
Patch
Comment 9 Simon Fraser (smfr) 2020-01-03 23:04:36 PST
Created attachment 386759 [details]
Patch
Comment 10 Felipe Erias 2020-04-30 00:20:21 PDT
I would like to call your attention to the TAG discussion about this feature, specially when it comes to identifying which other pieces of the web platform would need to change in order to correctly support colors outside the sRGB gamut:

https://github.com/w3ctag/design-reviews/issues/488

I started looking into implementing lab() and lch() in Chromium, but it seems that WebKit is in a better position to lead the way here because it already has support for higher-precision colors.
Comment 11 Simon Fraser (smfr) 2020-04-30 09:37:12 PDT
Noted, although WebKit already supports P3 colors so adding lab() support isn't going to newly expose out-of-sRGB colors.
Comment 12 Simon Fraser (smfr) 2020-05-15 09:35:45 PDT
Created attachment 399486 [details]
Patch