Bug 984075 - Extract arrow widget from GtkMenuButton widget instead of creating it directly which gives us proper arrow size. r=karlt
authorMartin Stransky <stransky@redhat.com>
Wed, 09 Apr 2014 02:31:00 +0200
changeset 196428 3bdbe71f21b2bac51276064354edfcc5d8283e0a
parent 196427 89a91619a2ae6c59457e580a056e75b6490eb0c0
child 196429 51eed87506d273a4b5c30e2a8b7d761462f4d519
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs984075
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 984075 - Extract arrow widget from GtkMenuButton widget instead of creating it directly which gives us proper arrow size. r=karlt
widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -15,17 +15,17 @@
 #include "nsDebug.h"
 #include "prinrval.h"
 
 #include <math.h>
 
 static GtkWidget* gProtoWindow;
 static GtkWidget* gProtoLayout;
 static GtkWidget* gButtonWidget;
-static GtkWidget* gToggleButtonWidget;
+static GtkWidget* gToggleMenuButtonWidget;
 static GtkWidget* gButtonArrowWidget;
 static GtkWidget* gCheckboxWidget;
 static GtkWidget* gRadiobuttonWidget;
 static GtkWidget* gHorizScrollbarWidget;
 static GtkWidget* gVertScrollbarWidget;
 static GtkWidget* gSpinWidget;
 static GtkWidget* gHScaleWidget;
 static GtkWidget* gVScaleWidget;
@@ -157,34 +157,31 @@ ensure_vpaned_widget()
     if (!gVPanedWidget) {
         gVPanedWidget = gtk_vpaned_new();
         setup_widget_prototype(gVPanedWidget);
     }
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
-ensure_toggle_button_widget()
+ensure_toggle_menu_button_widget()
 {
-    if (!gToggleButtonWidget) {
-        gToggleButtonWidget = gtk_toggle_button_new();
-        setup_widget_prototype(gToggleButtonWidget);
+    if (!gToggleMenuButtonWidget) {
+        gToggleMenuButtonWidget = gtk_menu_button_new();
+        setup_widget_prototype(gToggleMenuButtonWidget);
   }
   return MOZ_GTK_SUCCESS;
 }
 
 static gint
 ensure_button_arrow_widget()
 {
     if (!gButtonArrowWidget) {
-        ensure_toggle_button_widget();
-
-        gButtonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-        gtk_container_add(GTK_CONTAINER(gToggleButtonWidget), gButtonArrowWidget);
-        gtk_widget_realize(gButtonArrowWidget);
+        ensure_toggle_menu_button_widget();
+        gButtonArrowWidget = gtk_bin_get_child(GTK_BIN(gToggleMenuButtonWidget));
     }
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
 ensure_checkbox_widget()
 {
     if (!gCheckboxWidget) {
@@ -327,18 +324,18 @@ ensure_combo_box_widgets()
             g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
                                       &gComboBoxArrowWidget);
             gtk_widget_realize(gComboBoxArrowWidget);
         }
     } else {
         /* Shouldn't be reached with current internal gtk implementation; we
          * use a generic toggle button as last resort fallback to avoid
          * crashing. */
-        ensure_toggle_button_widget();
-        gComboBoxButtonWidget = gToggleButtonWidget;
+        ensure_toggle_menu_button_widget();
+        gComboBoxButtonWidget = gToggleMenuButtonWidget;
     }
 
     if (!gComboBoxArrowWidget) {
         /* Shouldn't be reached with current internal gtk implementation;
          * we gButtonArrowWidget as last resort fallback to avoid
          * crashing. */
         ensure_button_arrow_widget();
         gComboBoxArrowWidget = gButtonArrowWidget;
@@ -433,18 +430,18 @@ ensure_combo_box_entry_widgets()
             g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
                                       &gComboBoxEntryArrowWidget);
             gtk_widget_realize(gComboBoxEntryArrowWidget);
         }
     } else {
         /* Shouldn't be reached with current internal gtk implementation;
          * we use a generic toggle button as last resort fallback to avoid
          * crashing. */
-        ensure_toggle_button_widget();
-        gComboBoxEntryButtonWidget = gToggleButtonWidget;
+        ensure_toggle_menu_button_widget();
+        gComboBoxEntryButtonWidget = gToggleMenuButtonWidget;
     }
 
     if (!gComboBoxEntryArrowWidget) {
         /* Shouldn't be reached with current internal gtk implementation;
          * we gButtonArrowWidget as last resort fallback to avoid
          * crashing. */
         ensure_button_arrow_widget();
         gComboBoxEntryArrowWidget = gButtonArrowWidget;
@@ -3057,20 +3054,20 @@ moz_gtk_widget_paint(GtkThemeWidgetType 
 {
     /* A workaround for https://bugzilla.gnome.org/show_bug.cgi?id=694086
      */
     cairo_new_path(cr);
 
     switch (widget) {
     case MOZ_GTK_BUTTON:
         if (state->depressed) {
-            ensure_toggle_button_widget();
+            ensure_toggle_menu_button_widget();
             return moz_gtk_button_paint(cr, rect, state,
                                         (GtkReliefStyle) flags,
-                                        gToggleButtonWidget, direction);
+                                        gToggleMenuButtonWidget, direction);
         }
         ensure_button_widget();
         return moz_gtk_button_paint(cr, rect, state,
                                     (GtkReliefStyle) flags, gButtonWidget,
                                     direction);
         break;
     case MOZ_GTK_CHECKBUTTON:
     case MOZ_GTK_RADIOBUTTON:
@@ -3273,17 +3270,17 @@ moz_gtk_shutdown()
 
     /* TODO - replace it with appropriate widget */
     if (gTreeHeaderSortArrowWidget)
         gtk_widget_destroy(gTreeHeaderSortArrowWidget);
 
     gProtoWindow = NULL;
     gProtoLayout = NULL;
     gButtonWidget = NULL;
-    gToggleButtonWidget = NULL;
+    gToggleMenuButtonWidget = NULL;
     gButtonArrowWidget = NULL;
     gCheckboxWidget = NULL;
     gRadiobuttonWidget = NULL;
     gHorizScrollbarWidget = NULL;
     gVertScrollbarWidget = NULL;
     gSpinWidget = NULL;
     gHScaleWidget = NULL;
     gVScaleWidget = NULL;