Allow override of system's preferred color scheme
<rdar://problem/86366044>
Created attachment 446891 [details] Patch
Looks like all the EWS bots are red.
(In reply to Anders Carlsson from comment #3) > Looks like all the EWS bots are red. Very impressive. Do I win a prize?
Created attachment 447028 [details] Patch
Would appreciate feedback on the SPI naming - I put the word "explicitly" in there to make it clear that this isn't the preference coming from the system.
Comment on attachment 447028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447028&action=review > Source/WebKit/UIProcess/API/APIWebsitePolicies.h:135 > + WebCore::ColorSchemePreference userExplicitlyPrefersColorScheme() const { return m_userExplicitlyPrefersColorScheme; } This getter name feels slightly odd (it sounds like it would return a boolean that the "user explicitly prefers (a) color scheme").
Comment on attachment 447028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447028&action=review >> Source/WebKit/UIProcess/API/APIWebsitePolicies.h:135 >> + WebCore::ColorSchemePreference userExplicitlyPrefersColorScheme() const { return m_userExplicitlyPrefersColorScheme; } > > This getter name feels slightly odd (it sounds like it would return a boolean that the "user explicitly prefers (a) color scheme"). Do you think I should call it colorSchemePreference?
(In reply to Dean Jackson from comment #8) > Comment on attachment 447028 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=447028&action=review > > >> Source/WebKit/UIProcess/API/APIWebsitePolicies.h:135 > >> + WebCore::ColorSchemePreference userExplicitlyPrefersColorScheme() const { return m_userExplicitlyPrefersColorScheme; } > > > > This getter name feels slightly odd (it sounds like it would return a boolean that the "user explicitly prefers (a) color scheme"). > > Do you think I should call it colorSchemePreference? or preferredColorScheme? Or maybe shove the word "override" in there somewhere because it overrides the system preference?
Created attachment 447056 [details] Patch
Comment on attachment 447056 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447056&action=review > Source/WebCore/css/MediaQueryEvaluator.cpp:811 > + bool useDarkAppearance = [&] () -> auto { Are there other things that read useDarkAppearance that need to change? Should useDarkAppearance itself respect the bit on DocumentLoader?
There is an existing `ColorScheme` enum with holds the `Light` and `Dark` options. Maybe instead of adding a new enum you could use an std::optional<ColorScheme> where std::nullopt would indicate the lack of a preference?
Committed r287030 (?): <https://commits.webkit.org/r287030>