Backed out changeset 810b7212a529 (bug 1320686) for causing Valgrind leaks.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 29 Nov 2016 21:16:06 -0500
changeset 324765 66c6b9f68e500b51fbfdf31768757ce49e0bc365
parent 324764 5644a5462ce5ab400a81fd350f06b9ea2fc40db6
child 324766 896204eba38856f07ab347ee70511c88040a101f
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
bugs1320686
milestone53.0a1
backs out810b7212a529e78d9f78ff8d4b78bb46d2049776
Backed out changeset 810b7212a529 (bug 1320686) for causing Valgrind leaks.
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1148,27 +1148,32 @@ nsLookAndFeel::Init()
     sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);
 
     style = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
     gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sInfoText = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);
 
-    style = ClaimStyleContext(MOZ_GTK_MENUITEM);
-    {
-        GtkStyleContext* accelStyle =
-            CreateStyleForWidget(gtk_accel_label_new("M"), style);
-        gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_NORMAL, &color);
-        sMenuText = GDK_RGBA_TO_NS_RGBA(color);
-        gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_INSENSITIVE, &color);
-        sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
-        g_object_unref(accelStyle);
-    }
-    ReleaseStyleContext(style);
+    // menu foreground & menu background
+    GtkWidget *accel_label = gtk_accel_label_new("M");
+    GtkWidget *menuitem = gtk_menu_item_new();
+    GtkWidget *menu = gtk_menu_new();
+
+    g_object_ref_sink(menu);
+
+    gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+    style = gtk_widget_get_style_context(accel_label);
+    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    sMenuText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
+    sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
+    g_object_unref(menu);
 
     style = ClaimStyleContext(MOZ_GTK_MENUPOPUP);
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);
 
     style = ClaimStyleContext(MOZ_GTK_MENUITEM);
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
@@ -1181,32 +1186,33 @@ nsLookAndFeel::Init()
     // button styles
     GtkWidget *parent = gtk_fixed_new();
     GtkWidget *button = gtk_button_new();
     GtkWidget *label = gtk_label_new("M");
 #if (MOZ_WIDGET_GTK == 2)
     GtkWidget *combobox = gtk_combo_box_new();
     GtkWidget *comboboxLabel = gtk_label_new("M");
     gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel);
+#else
+    GtkWidget *combobox = gtk_combo_box_new_with_entry();
+    GtkWidget *comboboxLabel = gtk_bin_get_child(GTK_BIN(combobox));
 #endif
     GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
     GtkWidget *treeView = gtk_tree_view_new();
     GtkWidget *linkButton = gtk_link_button_new("http://example.com/");
     GtkWidget *menuBar = gtk_menu_bar_new();
     GtkWidget *menuBarItem = gtk_menu_item_new();
     GtkWidget *entry = gtk_entry_new();
     GtkWidget *textView = gtk_text_view_new();
 
     gtk_container_add(GTK_CONTAINER(button), label);
     gtk_container_add(GTK_CONTAINER(parent), button);
     gtk_container_add(GTK_CONTAINER(parent), treeView);
     gtk_container_add(GTK_CONTAINER(parent), linkButton);
-#if (MOZ_WIDGET_GTK == 2)
     gtk_container_add(GTK_CONTAINER(parent), combobox);
-#endif
     gtk_container_add(GTK_CONTAINER(parent), menuBar);
     gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuBarItem);
     gtk_container_add(GTK_CONTAINER(window), parent);
     gtk_container_add(GTK_CONTAINER(parent), entry);
     gtk_container_add(GTK_CONTAINER(parent), textView);
     
 #if (MOZ_WIDGET_GTK == 2)
     gtk_widget_set_style(button, nullptr);
@@ -1296,34 +1302,27 @@ nsLookAndFeel::Init()
         &color);
     sTextSelectedBackground = GDK_RGBA_TO_NS_RGBA(color);
     gtk_style_context_get_color(style,
         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);
-    {
-        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);
-    }
-    ReleaseStyleContext(style);
+    // Button text, background, border
+    style = gtk_widget_get_style_context(label);
+    gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+    sButtonText = GDK_RGBA_TO_NS_RGBA(color);
+    gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+    sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
 
     // Combobox text color
-    style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
+    style = gtk_widget_get_style_context(comboboxLabel);
     gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
-    ReleaseStyleContext(style);
 
     // Menubar text and hover text colors    
     style = ClaimStyleContext(MOZ_GTK_MENUBARITEM);
     gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
     gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
     sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
     ReleaseStyleContext(style);