Bug 211993

Summary: Fix operator== and hash() for ExtendedColor
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: Layout and RenderingAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, darin, dino, sam, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch sam: review+

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