RESOLVED FIXED 189382
[macOS] [WK2] Support changing foreground colors via color panel
https://bugs.webkit.org/show_bug.cgi?id=189382
Summary [macOS] [WK2] Support changing foreground colors via color panel
Wenson Hsieh
Reported 2018-09-06 16:29:14 PDT
Currently, attempting to choose a font color using the color picker (accessible through NSFontPanel) does nothing in WKWebView. However, this works in legacy WebKit.
Attachments
Patch (16.40 KB, patch)
2018-09-10 21:28 PDT, Wenson Hsieh
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (3.33 MB, application/zip)
2018-09-10 22:25 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews102 for mac-sierra (2.32 MB, application/zip)
2018-09-10 22:33 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews202 for win-future (12.90 MB, application/zip)
2018-09-10 23:05 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews115 for mac-sierra (3.02 MB, application/zip)
2018-09-10 23:07 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (2.30 MB, application/zip)
2018-09-10 23:22 PDT, EWS Watchlist
no flags
Patch for EWS (21.45 KB, patch)
2018-09-11 08:41 PDT, Wenson Hsieh
no flags
Another patch for EWS (21.07 KB, patch)
2018-09-11 09:41 PDT, Wenson Hsieh
no flags
Patch (1.99 KB, patch)
2018-09-11 16:46 PDT, Wenson Hsieh
no flags
Radar WebKit Bug Importer
Comment 1 2018-09-07 09:54:52 PDT
Wenson Hsieh
Comment 2 2018-09-10 21:28:05 PDT
Ryosuke Niwa
Comment 3 2018-09-10 21:35:12 PDT
Comment on attachment 349376 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349376&action=review > Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm:276 > + checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)"); Let's also add an assertion to make sure we're inserting a font element instead of a span in this case. > Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm:287 > + checkFontColorAtStartAndEndWithInputEvents("rgb(204, 179, 51)"); Ditto.
EWS Watchlist
Comment 4 2018-09-10 22:25:43 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 5 2018-09-10 22:25:44 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 6 2018-09-10 22:33:14 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 7 2018-09-10 22:33:15 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 8 2018-09-10 23:05:00 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 9 2018-09-10 23:05:12 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 10 2018-09-10 23:07:42 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 11 2018-09-10 23:07:44 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 12 2018-09-10 23:22:45 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 13 2018-09-10 23:22:46 PDT Comment hidden (obsolete)
Wenson Hsieh
Comment 14 2018-09-11 07:20:50 PDT
Comment on attachment 349376 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349376&action=review >> Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm:276 >> + checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)"); > > Let's also add an assertion to make sure we're inserting a font element instead of a span in this case. Sounds good!
Wenson Hsieh
Comment 15 2018-09-11 07:31:10 PDT
(In reply to Build Bot from comment #13) > Created attachment 349384 [details] > Archive of layout-test-results from ews121 for ios-simulator-wk2 > > The attached test failures were seen while running run-webkit-tests on the > ios-sim-ews. > Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4 The test expectation here doesn't seem right to me: > -PASS foreColor(rgba(0, 50, 100, 0.4)) on all of "<font><u style="color:red;">hello</u></font>" yields "<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>" > +FAIL foreColor(rgba(0, 50, 100, 0.4)) on all of "<font><u style="color:red;">hello</u></font>" yields "<font><u style="color: rgba(0, 50, 100, 0.4);">hello</u></font>", expected "<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>" This test expects <font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font> after changing the foreground color to a color with alpha, but this just results in a bogus text color, since the font element does not support RGBA colors (I'm seeing a fully opaque dark green in Safari 12 when visiting data:text/html,<font%20color="rgba(0,%2050,%20100,%200.4)"><u>hello</u></font>). After this patch, we get <font><u style="color: rgba(0, 50, 100, 0.4);">hello</u></font>, which results in light blue, transparent text (as one would probably expect). I think this can be safely rebaselined.
Wenson Hsieh
Comment 16 2018-09-11 07:34:47 PDT
(In reply to Wenson Hsieh from comment #15) > (In reply to Build Bot from comment #13) > > Created attachment 349384 [details] > > Archive of layout-test-results from ews121 for ios-simulator-wk2 > > > > The attached test failures were seen while running run-webkit-tests on the > > ios-sim-ews. > > Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4 > > The test expectation here doesn't seem right to me: > > > -PASS foreColor(rgba(0, 50, 100, 0.4)) on all of "<font><u style="color:red;">hello</u></font>" yields "<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>" > > +FAIL foreColor(rgba(0, 50, 100, 0.4)) on all of "<font><u style="color:red;">hello</u></font>" yields "<font><u style="color: rgba(0, 50, 100, 0.4);">hello</u></font>", expected "<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>" > > This test expects <font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font> > after changing the foreground color to a color with alpha, but this just > results in a bogus text color, since the font element does not support RGBA > colors (I'm seeing a fully opaque dark green in Safari 12 when visiting > data:text/html,<font%20color="rgba(0,%2050,%20100,%200.4)"><u>hello</u></ > font>). After this patch, we get <font><u style="color: rgba(0, 50, 100, > 0.4);">hello</u></font>, which results in light blue, transparent text (as > one would probably expect). > > I think this can be safely rebaselined. Actually, instead of just rebaselining the test, I think I'll change this failing test case to just apply "rgb(0, 50, 100)" without alpha, and then add "rgba(0, 50, 100, 0.4)" as an additional test case.
Wenson Hsieh
Comment 17 2018-09-11 08:41:22 PDT
Created attachment 349397 [details] Patch for EWS
Wenson Hsieh
Comment 18 2018-09-11 09:41:55 PDT
Created attachment 349401 [details] Another patch for EWS
Wenson Hsieh
Comment 19 2018-09-11 09:46:18 PDT
> Actually, instead of just rebaselining the test, I think I'll change this > failing test case to just apply "rgb(0, 50, 100)" without alpha, and then > add "rgba(0, 50, 100, 0.4)" as an additional test case. On second thought, maybe it's not a great idea to use inline styles to represent RGBA font colors, when "StyleWithCSS" is set to false... Another approach is to just drop the alpha component when setting the color attribute of the font element, since we can't represent transparent colors using only attributes on the font element (rather than CSS). Then, for our API test, we can exercise the case where "StyleWithCSS" is true. I posted a separate patch that implements this approach.
Wenson Hsieh
Comment 20 2018-09-11 14:59:45 PDT
Chatted with Ryosuke about this, and agree that fulfilling user expectation is more important than respecting StyleWithCSS being false, when setting a font color with alpha ≠ 1. We'll go with the original approach. Committed r235914: <https://trac.webkit.org/changeset/235914>
Wenson Hsieh
Comment 22 2018-09-11 16:27:57 PDT
(In reply to Truitt Savell from comment #21) > Looks like the new API, FontManagerTests.ChangeFontColorWithColorPanel, test > is failing on Sierra WK1 from: https://trac.webkit.org/changeset/235914 > > > Log: > https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK1%20(Tests)/ > builds/12719/steps/run-api-tests/logs/stdio > > Run Failure: > https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK1%20(Tests)/ > builds/12719 Thanks — I'll take a look shortly.
Wenson Hsieh
Comment 23 2018-09-11 16:46:00 PDT
Reopening to attach new patch.
Wenson Hsieh
Comment 24 2018-09-11 16:46:01 PDT
WebKit Commit Bot
Comment 25 2018-09-11 23:08:36 PDT
Comment on attachment 349492 [details] Patch Clearing flags on attachment: 349492 Committed r235931: <https://trac.webkit.org/changeset/235931>
WebKit Commit Bot
Comment 26 2018-09-11 23:08:37 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.