Bug 1158076 - disable dark themes in content process, r?karlt
MozReview-Commit-ID: BbivJg8Iy3n
--- 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);