Bug 1365556 - remove text-button class from MOZ_GTK_BUTTON style, r?karlt draft
authorMartin Stransky <stransky@redhat.com>
Wed, 26 Jul 2017 19:22:52 +0200
changeset 616062 4509c508ae4fa10522a179f64c447b98bbae9fe7
parent 615935 388d81ed93fa640f91d155f36254667c734157cf
child 639352 4d7504cd6de79bff3c4a2a1dcc680078d36933e8
push id70558
push userstransky@redhat.com
push dateWed, 26 Jul 2017 17:23:22 +0000
reviewerskarlt
bugs1365556
milestone56.0a1
Bug 1365556 - remove text-button class from MOZ_GTK_BUTTON style, r?karlt When GtkButton is created by gtk_button_new_with_label() it has text-button class. When any child widget is added this class is removed. We want to emulate the GtkLabel placed inside GtkButton so remove temporary text-button class on Gtk+ <= 3.10 where it causes issues with Adwaita theme. MozReview-Commit-ID: HYWSKUVcvyI
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1362,23 +1362,36 @@ nsLookAndFeel::EnsureInit()
         static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
         &color);
     sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);
 
     // Button text color
     style = ClaimStyleContext(MOZ_GTK_BUTTON);
     {
+        // MOZ_GTK_BUTTON creates GtkButton by gtk_button_new_with_label()
+        // which confuses Adwaita theme on Gtk+ 3.10 (Bug 1365556).
+        bool removeTextClass = (gtk_major_version > 3 ||
+            (gtk_major_version == 3 && gtk_minor_version <= 10));
+        if (removeTextClass) {
+            gtk_style_context_remove_class(style, "text-button");
+            gtk_style_context_invalidate(style);
+        }
+
         GtkStyleContext* labelStyle =
             CreateStyleForWidget(gtk_label_new("M"), style);
         gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
         sButtonText = GDK_RGBA_TO_NS_RGBA(color);
         gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_PRELIGHT, &color);
         sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
         g_object_unref(labelStyle);
+
+        if (removeTextClass) {
+            gtk_style_context_add_class(style, "text-button");
+        }
     }
     ReleaseStyleContext(style);
 
     // Combobox text color
     style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
     gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);