bug 1230065 consider arrow size in dropdown minimum widget size r?acomminos draft
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 01 Mar 2016 13:12:03 +1300
changeset 336380 18e679b95ad5516f709e44bca4929b84b72b7020
parent 336379 ccc5e0bb229ab7af1c7c50e5831b552af1ab2aa9
child 515377 2348f04f5f89c3a29f459932566c7e48000cc85a
push id12046
push userktomlinson@mozilla.com
push dateThu, 03 Mar 2016 02:47:37 +0000
reviewersacomminos
bugs1230065
milestone47.0a1
bug 1230065 consider arrow size in dropdown minimum widget size r?acomminos MozReview-Commit-ID: E6MzVn5HEmI
widget/gtk/gtk2drawing.c
widget/gtk/gtk3drawing.c
widget/gtk/gtkdrawing.h
widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/gtk2drawing.c
+++ b/widget/gtk/gtk2drawing.c
@@ -3059,27 +3059,35 @@ moz_gtk_get_tab_scroll_arrow_size(gint* 
                          "scroll-arrow-hlength", &arrow_size,
                          NULL);
 
     *height = *width = arrow_size;
 
     return MOZ_GTK_SUCCESS;
 }
 
-gint
-moz_gtk_get_arrow_size(gint* width, gint* height)
+void
+moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType, gint* width, gint* height)
 {
+    GtkWidget* widget;
+    switch (widgetType) {
+        case MOZ_GTK_DROPDOWN:
+            ensure_combo_box_widgets();
+            widget = gComboBoxArrowWidget;
+            break;
+        default:
+            ensure_button_arrow_widget();
+            widget = gButtonArrowWidget;
+            break;
+    }
+
     GtkRequisition requisition;
-    ensure_button_arrow_widget();
-
-    gtk_widget_size_request(gButtonArrowWidget, &requisition);
+    gtk_widget_size_request(widget, &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;
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -2987,27 +2987,35 @@ moz_gtk_get_tab_scroll_arrow_size(gint* 
                          "scroll-arrow-hlength", &arrow_size,
                          NULL);
 
     *height = *width = arrow_size;
 
     return MOZ_GTK_SUCCESS;
 }
 
-gint
-moz_gtk_get_arrow_size(gint* width, gint* height)
+void
+moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType, gint* width, gint* height)
 {
+    GtkWidget* widget;
+    switch (widgetType) {
+        case MOZ_GTK_DROPDOWN:
+            ensure_combo_box_widgets();
+            widget = gComboBoxArrowWidget;
+            break;
+        default:
+            ensure_button_arrow_widget();
+            widget = gButtonArrowWidget;
+            break;
+    }
+
     GtkRequisition requisition;
-    ensure_button_arrow_widget();
-
-    gtk_widget_get_preferred_size(gButtonArrowWidget, NULL, &requisition);
+    gtk_widget_get_preferred_size(widget, NULL, &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;
     GtkStyleContext* style;
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -382,22 +382,24 @@ gint moz_gtk_get_combo_box_entry_button_
  * 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 an arrow in a button
- * width:   [OUT] the desired width
- * height:  [OUT] the desired height
  *
- * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
+ * widgetType: [IN]  the widget for which to get the arrow size
+ * width:      [OUT] the desired width
+ * height:     [OUT] the desired height
  */
-gint moz_gtk_get_arrow_size(gint* width, gint* height);
+void
+moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType,
+                       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/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1556,35 +1556,44 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
     }
     break;
   case NS_THEME_TOOLBAR_BUTTON_DROPDOWN:
   case NS_THEME_BUTTON_ARROW_UP:
   case NS_THEME_BUTTON_ARROW_DOWN:
   case NS_THEME_BUTTON_ARROW_NEXT:
   case NS_THEME_BUTTON_ARROW_PREVIOUS:
     {
-        moz_gtk_get_arrow_size(&aResult->width, &aResult->height);
-        *aIsOverridable = false;
+      moz_gtk_get_arrow_size(MOZ_GTK_TOOLBARBUTTON_ARROW,
+                             &aResult->width, &aResult->height);
+      *aIsOverridable = 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_DROPDOWN:
   case NS_THEME_TOOLBAR_BUTTON:
   case NS_THEME_TREEVIEW_HEADER_CELL:
     {
-      // Just include our border, and let the box code augment the size.
+      if (aWidgetType == NS_THEME_DROPDOWN) {
+        // Include the arrow size.
+        moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN,
+                               &aResult->width, &aResult->height);
+      }
+      // else the minimum size is missing consideration of container
+      // descendants; the value returned here will not be helpful, but the
+      // box model may consider border and padding with child minimum sizes.
+
       nsIntMargin border;
       nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
                                         aFrame, aWidgetType, &border);
-      aResult->width = border.left + border.right;
-      aResult->height = border.top + border.bottom;
+      aResult->width += border.left + border.right;
+      aResult->height += border.top + border.bottom;
     }
     break;
   case NS_THEME_TOOLBAR_SEPARATOR:
     {
       gint separator_width;
     
       moz_gtk_get_toolbar_separator_width(&separator_width);