Bug 202662 - Copying white text from dark mode WebKit apps and pasting in a light mode app results in white (invisible) text
Summary: Copying white text from dark mode WebKit apps and pasting in a light mode app...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Timothy Hatcher
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-07 17:33 PDT by Timothy Hatcher
Modified: 2019-10-08 14:56 PDT (History)
8 users (show)

See Also:


Attachments
Patch (12.77 KB, patch)
2019-10-07 17:36 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff
Patch (12.86 KB, patch)
2019-10-07 18:34 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff
Patch (12.90 KB, patch)
2019-10-08 09:49 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.