firefox/mozilla-1272332.patch

72 lines
2.7 KiB
Diff

# HG changeset patch
# User Nicolas Silva <nsilva@mozilla.com>
# Parent 14c5bf11d37b9e92d27f7089d9392de2ac339bb3
Bug 1272332 - Allow gtk the global dark theme behind a pref. r=karlt
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4560,16 +4560,17 @@ pref("gfx.content.use-native-pushlayer",
#ifdef ANDROID
pref("gfx.apitrace.enabled",false);
#endif
#ifdef MOZ_X11
pref("gfx.content.use-native-pushlayer", true);
#ifdef MOZ_WIDGET_GTK
pref("gfx.xrender.enabled",false);
+pref("widget.allow-gtk-dark-theme", false);
#endif
#endif
#ifdef XP_WIN
pref("gfx.content.use-native-pushlayer", true);
// Whether to disable the automatic detection and use of direct2d.
pref("gfx.direct2d.disabled", false);
diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1093,26 +1093,32 @@ 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 (dark) {
- g_object_set(settings, dark_setting, FALSE, nullptr);
+ bool isContentProcess = XRE_IsContentProcess();
+ bool allowDarkTheme = mozilla::Preferences::GetBool("widget.allow-gtk-dark-theme", false);
+
+ if (isContentProcess || !allowDarkTheme) {
+ // 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) {
+ g_object_set(settings, dark_setting, FALSE, nullptr);
+ }
}
GtkWidgetPath *path = gtk_widget_path_new();
gtk_widget_path_append_type(path, GTK_TYPE_WINDOW);
mBackgroundStyle = create_context(path);
gtk_style_context_add_class(mBackgroundStyle, GTK_STYLE_CLASS_BACKGROUND);