Bug 211993 - Fix operator== and hash() for ExtendedColor
Summary: Fix operator== and hash() for ExtendedColor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-16 22:23 PDT by Simon Fraser (smfr)
Modified: 2020-05-18 15:32 PDT (History)
7 users (show)

See Also:


Attachments
Patch (11.48 KB, patch)
2020-05-16 22:25 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (11.28 KB, patch)
2020-05-17 09:32 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (11.28 KB, patch)
2020-05-17 10:14 PDT, Simon Fraser (smfr)
sam: review+
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-05-16 22:23:01 PDT
Fix operator== and hash() for ExtendedColor
Comment 1 Simon Fraser (smfr) 2020-05-16 22:25:46 PDT
Created attachment 399584 [details]
Patch
Comment 2 Simon Fraser (smfr) 2020-05-17 09:32:39 PDT
Created attachment 399593 [details]
Patch
Comment 3 Simon Fraser (smfr) 2020-05-17 10:14:49 PDT
Created attachment 399595 [details]
Patch
Comment 4 Sam Weinig 2020-05-17 10:40:50 PDT
Comment on attachment 399595 [details]
Patch

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

> Source/WebCore/platform/graphics/Color.h:320
> +// One or both may be extended.

s/may/must/
Comment 5 Simon Fraser (smfr) 2020-05-17 12:28:37 PDT
https://trac.webkit.org/changeset/261794/webkit
Comment 6 Radar WebKit Bug Importer 2020-05-17 12:29:14 PDT
<rdar://problem/63319983>
Comment 7 Darin Adler 2020-05-18 13:02:28 PDT
Comment on attachment 399595 [details]
Patch

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

> Source/WebCore/platform/graphics/ExtendedColor.h:78
> +    return a.colorSpace() == b.colorSpace() && areEssentiallyEqual(a.channels(), b.channels());

How did you settle on "essentially equal" as the definition of ==, rather than something closer to floating point "=="?
Comment 8 Simon Fraser (smfr) 2020-05-18 13:20:13 PDT
It seemed like the right thing to do? I didn't have any strong evidence to support either choice.
Comment 9 Darin Adler 2020-05-18 13:33:43 PDT
I would suggest that "==" should be built on top of "==", with no shift to "essentially" done beneath the covers.

In fact, reflecting on this I know it’s a problem for hashing! It‘s critical for hash functions that if two values compute as "==", then they have the same hash. That seems to not be true.
Comment 10 Simon Fraser (smfr) 2020-05-18 15:32:43 PDT
Done in https://trac.webkit.org/changeset/261835/webkit