msuchy / rpms / firefox

Forked from rpms/firefox 6 years ago
Clone
5b8da38
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
5b8da38
--- a/modules/libpref/init/all.js
5b8da38
+++ b/modules/libpref/init/all.js
5b8da38
@@ -4733,16 +4733,18 @@ pref("gfx.content.always-paint", false);
5b8da38
 
5b8da38
 #ifdef ANDROID
5b8da38
 pref("gfx.apitrace.enabled",false);
5b8da38
 #endif
5b8da38
 
5b8da38
 #ifdef MOZ_X11
5b8da38
 #ifdef MOZ_WIDGET_GTK
5b8da38
 pref("gfx.xrender.enabled",false);
5b8da38
+pref("widget.chrome.allow-gtk-dark-theme", false);
5b8da38
+pref("widget.content.allow-gtk-dark-theme", false);
5b8da38
 #endif
5b8da38
 #endif
5b8da38
 
5b8da38
 #ifdef XP_WIN
5b8da38
 // Whether to disable the automatic detection and use of direct2d.
5b8da38
 pref("gfx.direct2d.disabled", false);
5b8da38
 
5b8da38
 // Whether to attempt to enable Direct2D regardless of automatic detection or
5b8da38
diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp
5b8da38
--- a/widget/gtk/nsLookAndFeel.cpp
5b8da38
+++ b/widget/gtk/nsLookAndFeel.cpp
5b8da38
@@ -1128,26 +1128,39 @@ nsLookAndFeel::Init()
5b8da38
     GdkRGBA color;
5b8da38
     GtkStyleContext *style;
5b8da38
 
5b8da38
     // Gtk manages a screen's CSS in the settings object so we
5b8da38
     // ask Gtk to create it explicitly. Otherwise we may end up
5b8da38
     // with wrong color theme, see Bug 972382
5b8da38
     GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default());
5b8da38
 
5b8da38
-    // Disable dark theme because it interacts poorly with widget styling in
5b8da38
-    // web content (see bug 1216658).
5b8da38
+    // Dark themes interacts poorly with widget styling (see bug 1216658).
5b8da38
+    // We disable dark themes by default for all processes (chrome, web content)
5b8da38
+    // but allow user to overide it by prefs.
5b8da38
+    const gchar* dark_setting = "gtk-application-prefer-dark-theme";
5b8da38
+    gboolean darkThemeDefault;
5b8da38
+    g_object_get(settings, dark_setting, &darkThemeDefault, nullptr);
5b8da38
+
5b8da38
     // To avoid triggering reload of theme settings unnecessarily, only set the
5b8da38
     // setting when necessary.
5b8da38
-    const gchar* dark_setting = "gtk-application-prefer-dark-theme";
5b8da38
-    gboolean dark;
5b8da38
-    g_object_get(settings, dark_setting, &dark, nullptr);
5b8da38
-
5b8da38
-    if (dark && !PR_GetEnv("MOZ_ALLOW_GTK_DARK_THEME")) {
5b8da38
-        g_object_set(settings, dark_setting, FALSE, nullptr);
5b8da38
+    if (darkThemeDefault) {
5b8da38
+        bool allowDarkTheme;
5b8da38
+        if (XRE_IsContentProcess()) {
5b8da38
+            allowDarkTheme =
5b8da38
+                mozilla::Preferences::GetBool("widget.content.allow-gtk-dark-theme",
5b8da38
+                                              false);
5b8da38
+        } else {
5b8da38
+            allowDarkTheme = (PR_GetEnv("MOZ_ALLOW_GTK_DARK_THEME") != nullptr) ||
5b8da38
+                mozilla::Preferences::GetBool("widget.chrome.allow-gtk-dark-theme",
5b8da38
+                                              false);
5b8da38
+        }
5b8da38
+        if (!allowDarkTheme) {
5b8da38
+            g_object_set(settings, dark_setting, FALSE, nullptr);
5b8da38
+        }
5b8da38
     }
5b8da38
 
5b8da38
     // Scrollbar colors
5b8da38
     style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
5b8da38
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color;;
5b8da38
     sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
5b8da38
     ReleaseStyleContext(style);
5b8da38
 
5b8da38