Bug 212143 - Replace Color::getHSL() with sRGBToHSL to ensure it at least gives somewhat sensible results for ExtendedColors and reduce code duplication
Summary: Replace Color::getHSL() with sRGBToHSL to ensure it at least gives somewhat s...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-20 09:02 PDT by Sam Weinig
Modified: 2020-05-20 15:55 PDT (History)
4 users (show)

See Also:


Attachments
Patch (17.83 KB, patch)
2020-05-20 09:25 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (17.76 KB, patch)
2020-05-20 09:45 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (23.15 KB, patch)
2020-05-20 15:09 PDT, 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 2020-05-20 09:02:34 PDT
Replace Color::getHSL() with sRGBToHSL to ensure it at least gives somewhat sensible results for ExtendedColors and reduce code duplication
Comment 1 Sam Weinig 2020-05-20 09:25:59 PDT
Created attachment 399845 [details]
Patch
Comment 2 Sam Weinig 2020-05-20 09:45:54 PDT
Created attachment 399847 [details]
Patch
Comment 3 Simon Fraser (smfr) 2020-05-20 10:25:31 PDT
Comment on attachment 399847 [details]
Patch

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

> Source/WebCore/editing/ReplaceSelectionCommand.cpp:550
> +        return lightness(color.value().toSRGBAComponentsLossy());

Ideally we'd be able to compute lightness for any colorspace without converting to sRGB. Which makes me think that lightness() should stay as a function on Color. This will be especially true when we have LAB color where lightness is just one of the components.

> Source/WebCore/editing/cocoa/DataDetection.mm:628
> +                        auto underlineColor = Color(makeRGBAFromHSLA(hue, saturation, overrideLightness, overrideAlphaMultiplier * alpha));

Make sure the hue is correctly round-tripped here.

> Source/WebCore/page/FrameView.cpp:368
> +        if (lightness(backgroundColor.toSRGBAComponentsLossy()) <= .5f && backgroundColor.isVisible())

Yeah, this would be much better with backgroundColor.getHSL.lightness().
Comment 4 Sam Weinig 2020-05-20 10:35:52 PDT
(In reply to Simon Fraser (smfr) from comment #3)
> Comment on attachment 399847 [details]
> Patch

> > Source/WebCore/page/FrameView.cpp:368
> > +        if (lightness(backgroundColor.toSRGBAComponentsLossy()) <= .5f && backgroundColor.isVisible())
> 
> Yeah, this would be much better with backgroundColor.getHSL.lightness().

Would you be ok with backgroundColor.lightness()?
Comment 5 Simon Fraser (smfr) 2020-05-20 13:52:46 PDT
(In reply to Sam Weinig from comment #4)
> (In reply to Simon Fraser (smfr) from comment #3)
> > Comment on attachment 399847 [details]
> > Patch
> 
> > > Source/WebCore/page/FrameView.cpp:368
> > > +        if (lightness(backgroundColor.toSRGBAComponentsLossy()) <= .5f && backgroundColor.isVisible())
> > 
> > Yeah, this would be much better with backgroundColor.getHSL.lightness().
> 
> Would you be ok with backgroundColor.lightness()?

That's actually what I mean to write!
Comment 6 Sam Weinig 2020-05-20 14:00:12 PDT
Comment on attachment 399847 [details]
Patch

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

>> Source/WebCore/editing/cocoa/DataDetection.mm:628
>> +                        auto underlineColor = Color(makeRGBAFromHSLA(hue, saturation, overrideLightness, overrideAlphaMultiplier * alpha));
> 
> Make sure the hue is correctly round-tripped here.

I think this is wrong now. Going to make an API test with round-tripping to see.
Comment 7 Sam Weinig 2020-05-20 15:09:52 PDT
Created attachment 399897 [details]
Patch
Comment 8 EWS 2020-05-20 15:54:16 PDT
Committed r261967: <https://trac.webkit.org/changeset/261967>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 399897 [details].
Comment 9 Radar WebKit Bug Importer 2020-05-20 15:55:17 PDT
<rdar://problem/63467460>