From f722612e177b6d715e814b9cdc4139abbaf4061b Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 31 Jul 2022 23:38:55 +0200 Subject: [PATCH] Browser: Set preferred color scheme when constructing a tab Previously we would only tell OutOfProcessWebView about the preferred color scheme when changing it in the browser's settings. This patch implements reading in the current config value to set the scheme immediately :^) See SerenityOS update (July 2022) https://youtu.be/aO0b2X7tzuk?t=2171 --- Userland/Applications/Browser/Tab.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 89c33cc29e..12d5bc3bcc 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -114,6 +115,10 @@ Tab::Tab(BrowserWindow& window) auto& webview_container = *find_descendant_of_type_named("webview_container"); m_web_content_view = webview_container.add(); + + auto preferred_color_scheme = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, "auto"sv)); + m_web_content_view->set_preferred_color_scheme(preferred_color_scheme); + if (g_content_filters_enabled) m_web_content_view->set_content_filters(g_content_filters); else