RESOLVED FIXED Bug 208204
[GTK][WPE] Support color-schemes CSS property
https://bugs.webkit.org/show_bug.cgi?id=208204
Summary [GTK][WPE] Support color-schemes CSS property
Michael Catanzaro
Reported 2020-02-25 09:12:26 PST
Now that GTK port no longer uses foreign drawing to render widgets, since r257299, it's finally possible to support the color-schemes CSS property. (See bug #197947 for discussion of why this was not previously possible.) Overview of how dark mode works currently: Firefox and Chrome and WebKitGTK since r255342: indicate to the webpage whether user prefers a dark theme using prefers-color-scheme, but always render controls using light theme. (GOOD) Safari only: indicates to the webpage whether user prefers a dark theme using prefers-color-scheme, renders light controls usually EXCEPT if website opts-in to dark form controls using color-schemes CSS property. (BEST) Downsides: this would complicate the new built-in Adwaita theme, so we might not want to do it.
Attachments
Patch (65.37 KB, patch)
2021-07-15 03:08 PDT, Alice Mikhaylenko
no flags
Patch (64.58 KB, patch)
2021-07-15 08:45 PDT, Alice Mikhaylenko
ews-feeder: commit-queue-
Patch (64.65 KB, patch)
2021-07-15 09:17 PDT, Alice Mikhaylenko
no flags
Patch (64.65 KB, patch)
2021-07-15 09:18 PDT, Alice Mikhaylenko
aperez: review+
aperez: commit-queue-
Patch (64.21 KB, patch)
2021-07-15 12:24 PDT, Alice Mikhaylenko
no flags
Patch (64.24 KB, patch)
2021-07-16 08:23 PDT, Alice Mikhaylenko
no flags
Carlos Garcia Campos
Comment 1 2020-02-26 00:59:13 PST
Well, I think we can try, but I want to give some more time to the new theme code, get feedback and improve it a bit before adding a new feature like this. We have the whole release cycle :-)
Michael Catanzaro
Comment 2 2021-07-09 05:01:20 PDT
*** Bug 226627 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 3 2021-07-09 05:02:05 PDT
There's some justification for why this is important in bug #226627.
Michael Catanzaro
Comment 4 2021-07-11 16:50:34 PDT
I think this would also fix bug #227862.
Alice Mikhaylenko
Comment 5 2021-07-13 07:29:40 PDT
*** Bug 227862 has been marked as a duplicate of this bug. ***
Alice Mikhaylenko
Comment 6 2021-07-13 07:30:19 PDT
This requires flipping OS_DARK_MODE_SUPPORT as well, do we want to do that for WPE as well?
Adrian Perez
Comment 7 2021-07-13 08:07:11 PDT
(In reply to Alexander Mikhaylenko from comment #6) > This requires flipping OS_DARK_MODE_SUPPORT as well, do we want to do that > for WPE as well? Yes, please, that would be great. It can also be done in a follow-up patch if that would be easier =) Thanks!
Alice Mikhaylenko
Comment 8 2021-07-13 08:41:13 PDT
Wouldn't be easier, it must be done in lockstep: * having color-scheme without OS_DARK_MODE_SUPPORT results in a white background peeking from under entry corners and a a dark text on dark bg in entries and similar widgets * having OS_DARK_MODE_SUPPORT without color-scheme means all of the things listed in https://bugs.webkit.org/show_bug.cgi?id=197947 The WPE API can be done later but the flag has to be flipped at the same time. :)
Alice Mikhaylenko
Comment 9 2021-07-15 03:08:32 PDT
Created attachment 433572 [details] Patch This took longer than expected.
Michael Catanzaro
Comment 10 2021-07-15 07:58:20 PDT
Comment on attachment 433572 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=433572&action=review LGTM. Carlos Garcia will probably want to review this, though. > Source/cmake/OptionsWPE.cmake:288 > +SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1) This should be alphabetized.
Alice Mikhaylenko
Comment 11 2021-07-15 08:01:07 PDT
> This should be alphabetized. I would if the list was sorted in the first place. :) ``` SET_AND_EXPOSE_TO_BUILD(HAVE_ACCESSIBILITY ${ENABLE_ACCESSIBILITY}) SET_AND_EXPOSE_TO_BUILD(USE_ATK ${ENABLE_ACCESSIBILITY}) SET_AND_EXPOSE_TO_BUILD(USE_CAIRO TRUE) SET_AND_EXPOSE_TO_BUILD(USE_EGL TRUE) SET_AND_EXPOSE_TO_BUILD(USE_GCRYPT TRUE) SET_AND_EXPOSE_TO_BUILD(USE_LIBEPOXY TRUE) SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE TRUE) SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES TRUE) SET_AND_EXPOSE_TO_BUILD(HAVE_OPENGL_ES_3 TRUE) SET_AND_EXPOSE_TO_BUILD(USE_WPE_RENDERER TRUE) SET_AND_EXPOSE_TO_BUILD(USE_XDGMIME TRUE) if (WTF_CPU_ARM OR WTF_CPU_MIPS) SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE ${ENABLE_DEVELOPER_MODE}) endif () SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER TRUE) SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE) SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE) SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE) SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1) ```
Michael Catanzaro
Comment 12 2021-07-15 08:04:22 PDT
Comment on attachment 433572 [details] Patch Ah OK, the list *should* be sorted, but it doesn't matter. Don't worry about it then.
Alice Mikhaylenko
Comment 13 2021-07-15 08:16:47 PDT
One thing I wonder about is why `-webkit-control-background` is macOS/iOS-only. If it wasn't we wouldn't have needed the html.css changes.
Alice Mikhaylenko
Comment 14 2021-07-15 08:20:37 PDT
Hm, actually looks like it was an oversight: https://bugs.webkit.org/show_bug.cgi?id=223303 Then I suppose it would be fine to again expose it for `defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT` and have one less thing to worry about.
Michael Catanzaro
Comment 15 2021-07-15 08:24:10 PDT
I wondered about that too. I would say go ahead and expose it, indeed.
Alice Mikhaylenko
Comment 16 2021-07-15 08:45:16 PDT
Created attachment 433586 [details] Patch Changed. I thought maybe one possibility was having the color for pre-Mojave macOS, but seems it's already hidden behind an HAVE_OS_DARK_MODE_SUPPORT check, so _should_ be fine.
Alice Mikhaylenko
Comment 17 2021-07-15 09:17:02 PDT
Created attachment 433588 [details] Patch Ok, so I was wrong. It's mac || ios || os_dark_mode_support now.
Alice Mikhaylenko
Comment 18 2021-07-15 09:18:56 PDT
Created attachment 433589 [details] Patch So I was wrong and that color is used outside of OS_DARK_MODE_SUPPORT as well.
Alice Mikhaylenko
Comment 19 2021-07-15 09:19:27 PDT
Great, so bugzilla showed me an error the first time but still attached the patch.
Adrian Perez
Comment 20 2021-07-15 12:18:46 PDT
Comment on attachment 433589 [details] Patch This looks great, well done getting through all the churn to get the colors and theme rendering working with the dark color scheme \o/ View in context: https://bugs.webkit.org/attachment.cgi?id=433589&action=review > Source/WebCore/css/themeAdwaita.css:29 > + -webkit-mask-image: url("data:image/svg+xml;utf-8, \ TIL about CSS mask-image ^_^ > Source/WebCore/platform/adwaita/ThemeAdwaita.cpp:304 > + This addition of an empty line is not needed, please leave it out before landing :) > Source/WebCore/platform/adwaita/ThemeAdwaita.cpp:523 > + Ditto for this empty line.
Adrian Perez
Comment 21 2021-07-15 12:20:25 PDT
I also removed the question mark from the bug title, make sure to update the title line in the ChangeLog entries accordingly before landing as well.
Alice Mikhaylenko
Comment 22 2021-07-15 12:24:47 PDT
Created attachment 433609 [details] Patch > TIL about CSS mask-image ^_^ Yeah, I noticed the Apple style was doing it and it works nicely. :)
Alice Mikhaylenko
Comment 23 2021-07-16 08:23:26 PDT
Created attachment 433677 [details] Patch Michael said I can reupload it with Adrian's r+ intact
EWS
Comment 24 2021-07-16 09:39:22 PDT
Committed r279987 (239730@main): <https://commits.webkit.org/239730@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 433677 [details].
Carlos Alberto Lopez Perez
Comment 25 2021-07-21 12:44:50 PDT
(In reply to EWS from comment #24) > Committed r279987 (239730@main): <https://commits.webkit.org/239730@main> > > All reviewed patches have been landed. Closing bug and clearing flags on > attachment 433677 [details]. This caused 7 new unexpected test failures. See bug 228160
Note You need to log in before you can comment on or make changes to this bug.