Bug 416868 - "Size of native style toolkit arrow" (Correct arrow rect and make it advertise its size) [p=frnchfrgg-mozbugs@altern.org (RIVAUD Julien [_FrnchFrgg_]) r=Ventron sr=roc a1.9=damons]
authorreed@reedloden.com
Wed, 12 Mar 2008 07:00:35 -0700
changeset 12942 82e31e15bc4964964a0c8f14a494bf0f4da16b44
parent 12941 2bf8d7c55cc598874c75b916b13a92f03b57a25c
child 12943 442e479a1249a898727bfe04bbf5411e28eda5c1
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVentron, roc
bugs416868
milestone1.9b5pre
Bug 416868 - "Size of native style toolkit arrow" (Correct arrow rect and make it advertise its size) [p=frnchfrgg-mozbugs@altern.org (RIVAUD Julien [_FrnchFrgg_]) r=Ventron sr=roc a1.9=damons]
widget/src/gtk2/gtk2drawing.c
widget/src/gtk2/gtkdrawing.h
widget/src/gtk2/nsNativeThemeGTK.cpp
--- a/widget/src/gtk2/gtk2drawing.c
+++ b/widget/src/gtk2/gtk2drawing.c
@@ -1633,20 +1633,18 @@ moz_gtk_downarrow_paint(GdkDrawable* dra
     GtkStyle* style;
     GtkStateType state_type = ConvertGtkState(state);
     GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
     GdkRectangle arrow_rect;
 
     ensure_button_arrow_widget();
     style = gButtonArrowWidget->style;
 
-    arrow_rect.x = rect->x + 1 + XTHICKNESS(style);
-    arrow_rect.y = rect->y + 1 + YTHICKNESS(style);
-    arrow_rect.width = MAX(1, rect->width - (arrow_rect.x - rect->x) * 2);
-    arrow_rect.height = MAX(1, rect->height - (arrow_rect.y - rect->y) * 2);
+    calculate_arrow_rect(gButtonArrowWidget, rect, &arrow_rect,
+                         GTK_TEXT_DIR_LTR);
 
     TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
     gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
                     gButtonArrowWidget, "arrow",  GTK_ARROW_DOWN, TRUE,
                     arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);
 
     return MOZ_GTK_SUCCESS;
 }
@@ -2697,16 +2695,29 @@ moz_gtk_get_tab_scroll_arrow_size(gint* 
                          NULL);
 
     *height = *width = arrow_size;
 
     return MOZ_GTK_SUCCESS;
 }
 
 gint
+moz_gtk_get_downarrow_size(gint* width, gint* height)
+{
+    GtkRequisition requisition;
+    ensure_button_arrow_widget();
+
+    gtk_widget_size_request(gButtonArrowWidget, &requisition);
+    *width = requisition.width;
+    *height = requisition.height;
+
+    return MOZ_GTK_SUCCESS;
+}
+
+gint
 moz_gtk_get_toolbar_separator_width(gint* size)
 {
     gboolean wide_separators;
     gint separator_width;
     GtkStyle* style;
 
     ensure_toolbar_widget();
 
--- a/widget/src/gtk2/gtkdrawing.h
+++ b/widget/src/gtk2/gtkdrawing.h
@@ -348,16 +348,25 @@ gint moz_gtk_get_combo_box_entry_button_
  * width:   [OUT] the desired width
  * height:  [OUT] the desired height
  *
  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
  */
 gint moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height);
 
 /**
+ * Get the desired size of a toolbar button dropdown arrow
+ * width:   [OUT] the desired width
+ * height:  [OUT] the desired height
+ *
+ * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
+ */
+gint moz_gtk_get_downarrow_size(gint* width, gint* height);
+
+/**
  * Get the desired size of a toolbar separator
  * size:    [OUT] the desired width
  *
  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
  */
 gint moz_gtk_get_toolbar_separator_width(gint* size);
 
 /**
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -1111,17 +1111,22 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
       }
 
       // Include space for the indicator and the padding around it.
       aResult->width = indicator_size;
       aResult->height = indicator_size;
       *aIsOverridable = PR_FALSE;
     }
     break;
-
+  case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
+    {
+        moz_gtk_get_downarrow_size(&aResult->width, &aResult->height);
+        *aIsOverridable = PR_FALSE;
+    }
+    break;
   case NS_THEME_CHECKBOX_CONTAINER:
   case NS_THEME_RADIO_CONTAINER:
   case NS_THEME_CHECKBOX_LABEL:
   case NS_THEME_RADIO_LABEL:
   case NS_THEME_BUTTON:
   case NS_THEME_TOOLBAR_BUTTON:
   case NS_THEME_TREEVIEW_HEADER_CELL:
     {