Bug 1216658 - Ignore Gt3 dark themes and use light theme's color scheme for native widgets. r=karlt, a=ritu FIREFOX_47_0b5_BUILD1 FIREFOX_47_0b5_RELEASE
authorNicolas Silva <nsilva@mozilla.com>
Fri, 29 Apr 2016 10:14:29 +0200
changeset 324357 93a53170dedffdff45bf9eb8dac6e5ef7a13c4ba
parent 324356 168613131e6a01c065897186ba2e91c3a9de3798
child 324358 ecb67929a43fcc530a454f50015af681d86774b0
push id5983
push usercbook@mozilla.com
push dateThu, 12 May 2016 07:38:32 +0000
treeherdermozilla-beta@93a53170dedf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, ritu
bugs1216658
milestone47.0
Bug 1216658 - Ignore Gt3 dark themes and use light theme's color scheme for native widgets. r=karlt, a=ritu
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1090,17 +1090,29 @@ nsLookAndFeel::Init()
     g_object_unref(menu);
 #else
     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
-    (void)gtk_settings_get_for_screen(gdk_screen_get_default());
+    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);
+    }
 
     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);
 
     mButtonStyle = create_context(path);