Bug 1158076 - disable dark themes in content process, r?karlt draft
authorMartin Stransky <stransky@redhat.com>
Tue, 14 Mar 2017 12:47:24 +0100
changeset 498138 b84eccd341c5a2a8ea04dec04e51574972c714e6
parent 498137 583192fe5fab56327ba978526cdceca1e6f9bcf5
child 549100 d1524ac19a9baa848562ed0811f730618a5d76b1
push id49127
push userstransky@redhat.com
push dateTue, 14 Mar 2017 11:48:00 +0000
reviewerskarlt
bugs1158076
milestone55.0a1
Bug 1158076 - disable dark themes in content process, r?karlt MozReview-Commit-ID: BbivJg8Iy3n
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -19,16 +19,17 @@
 #include <fontconfig/fontconfig.h>
 #include "gfxPlatformGtk.h"
 #include "nsScreenGtk.h"
 
 #include "gtkdrawing.h"
 #include "nsStyleConsts.h"
 #include "gfxFontConstants.h"
 #include "WidgetUtils.h"
+#include "nsIXULRuntime.h"
 
 #include <dlfcn.h>
 
 #include "mozilla/gfx/2D.h"
 
 #if MOZ_WIDGET_GTK != 2
 #include <cairo-gobject.h>
 #include "WidgetStyleCache.h"
@@ -1128,26 +1129,31 @@ nsLookAndFeel::Init()
     GdkRGBA color;
     GtkStyleContext *style;
 
     // Gtk manages a screen's CSS in the settings object so we
     // ask Gtk to create it explicitly. Otherwise we may end up
     // with wrong color theme, see Bug 972382
     GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default());
 
-    // Disable dark theme because it interacts poorly with widget styling in
-    // web content (see bug 1216658).
-    // To avoid triggering reload of theme settings unnecessarily, only set the
-    // setting when necessary.
-    const gchar* dark_setting = "gtk-application-prefer-dark-theme";
-    gboolean dark;
-    g_object_get(settings, dark_setting, &dark, nullptr);
+    if (!mozilla::BrowserTabsRemoteAutostart() || XRE_IsContentProcess()) {
+        // We're running in content process and e10s is enabled so we can safely
+        // set theme for web content and chrome will still use system-wide theme.
 
-    if (dark && !PR_GetEnv("MOZ_ALLOW_GTK_DARK_THEME")) {
-        g_object_set(settings, dark_setting, FALSE, nullptr);
+        // Disable dark theme because it interacts poorly with widget styling in
+        // web content (see bug 1216658).
+        // To avoid triggering reload of theme settings unnecessarily, only set the
+        // setting when necessary.
+        const gchar* dark_setting = "gtk-application-prefer-dark-theme";
+        gboolean dark;
+        g_object_get(settings, dark_setting, &dark, nullptr);
+
+        if (dark && !PR_GetEnv("MOZ_ALLOW_GTK_DARK_THEME")) {
+            g_object_set(settings, dark_setting, FALSE, nullptr);
+        }
     }
 
     // Scrollbar colors
     style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);