Bug 202662

Summary: Copying white text from dark mode WebKit apps and pasting in a light mode app results in white (invisible) text
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: WebKit Misc.Assignee: Timothy Hatcher <timothy>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, commit-queue, ews-watchlist, megan_gardner, mifenton, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Timothy Hatcher 2019-10-07 17:33:28 PDT
HTMLConverter needs to strip white colors when the document is in dark mode, like it does for black in light mode.

<rdar://problem/48677354>
Comment 1 Timothy Hatcher 2019-10-07 17:36:33 PDT Comment hidden (obsolete)
Comment 2 Timothy Hatcher 2019-10-07 18:34:00 PDT Comment hidden (obsolete)
Comment 3 Timothy Hatcher 2019-10-08 09:49:58 PDT
Created attachment 380438 [details]
Patch
Comment 4 Timothy Hatcher 2019-10-08 13:54:22 PDT
Web Inspector layout test failure on WK1 is unrelated. Ready to review.
Comment 5 Megan Gardner 2019-10-08 14:05:30 PDT
Comment on attachment 380438 [details]
Patch

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

> Source/WebCore/editing/cocoa/HTMLConverter.mm:-864
> -    if (red < ColorEpsilon && green < ColorEpsilon && blue < ColorEpsilon && (ignoreBlack || alpha < ColorEpsilon))

I'm guessing this was basically looking for 'black'. I don't know what the trade off for looking for 'probably almost black' and 'true black' is, but I'm trusting this is equal or better than Color::isBlackColor.

> Source/WebCore/editing/cocoa/HTMLConverter.mm:882
> +

nit whitespace?
Comment 6 Timothy Hatcher 2019-10-08 14:14:49 PDT
Comment on attachment 380438 [details]
Patch

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

>> Source/WebCore/editing/cocoa/HTMLConverter.mm:-864
>> -    if (red < ColorEpsilon && green < ColorEpsilon && blue < ColorEpsilon && (ignoreBlack || alpha < ColorEpsilon))
> 
> I'm guessing this was basically looking for 'black'. I don't know what the trade off for looking for 'probably almost black' and 'true black' is, but I'm trusting this is equal or better than Color::isBlackColor.

Yes, this was looking for black. However, since getRGBA does a division by 255 to convert the hex to a float, so there was this logic to avoid floating point issues. Using Color::isBlackColor is better because it looks at the internal hex, and supports extended color too.
Comment 7 WebKit Commit Bot 2019-10-08 14:56:36 PDT
Comment on attachment 380438 [details]
Patch

Clearing flags on attachment: 380438

Committed r250863: <https://trac.webkit.org/changeset/250863>
Comment 8 WebKit Commit Bot 2019-10-08 14:56:37 PDT
All reviewed patches have been landed.  Closing bug.