Bug 1310850 - Zero scrollbar size could also happen when running GTK 3.20 so we need to set the minimum size of the scrollbar to the minimum size of a thumb. r=karlt
authorJan Horak <jhorak@redhat.com>
Tue, 25 Oct 2016 11:27:00 -0400
changeset 319845 3a035c4acf604e6591157b664f67c73fcb7162fb
parent 319844 68f683a2034bb280a323242b4de87c958ed7c6f4
child 319846 d65a9494010ec7dd1ac87f63a844d7fca0270293
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1310850
milestone52.0a1
Bug 1310850 - Zero scrollbar size could also happen when running GTK 3.20 so we need to set the minimum size of the scrollbar to the minimum size of a thumb. r=karlt
widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1470,25 +1470,42 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
         aResult->height = metrics;
       }
       *aIsOverridable = false;
     }
     break;
     case NS_THEME_SCROLLBAR_HORIZONTAL:
     case NS_THEME_SCROLLBAR_VERTICAL:
     {
+      /* While we enforce a minimum size for the thumb, this is ignored
+       * for the some scrollbars if buttons are hidden (bug 513006) because
+       * the thumb isn't a direct child of the scrollbar, unlike the buttons
+       * or track. So add a minimum size to the track as well to prevent a
+       * 0-width scrollbar. */
       if (gtk_check_version(3,20,0) == nullptr) {
-          moz_gtk_get_widget_min_size(NativeThemeToGtkTheme(aWidgetType, aFrame),
-                                      &(aResult->width), &(aResult->height));
+        // Thumb min dimensions to start with
+        WidgetNodeType thumbType = aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ?
+          MOZ_GTK_SCROLLBAR_THUMB_VERTICAL : MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
+        moz_gtk_get_widget_min_size(thumbType, &(aResult->width), &(aResult->height));
+
+        // Add scrollbar's borders
+        nsIntMargin border;
+        nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
+                                          aFrame, aWidgetType, &border);
+        aResult->width += border.left + border.right;
+        aResult->height += border.top + border.bottom;
+
+        // Add track's borders
+        uint8_t trackType = aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ?
+          NS_THEME_SCROLLBARTRACK_VERTICAL : NS_THEME_SCROLLBARTRACK_HORIZONTAL;
+        nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
+                                          aFrame, trackType, &border);
+        aResult->width += border.left + border.right;
+        aResult->height += border.top + border.bottom;
       } else {
-        /* While we enforce a minimum size for the thumb, this is ignored
-         * for the some scrollbars if buttons are hidden (bug 513006) because
-         * the thumb isn't a direct child of the scrollbar, unlike the buttons
-         * or track. So add a minimum size to the track as well to prevent a
-         * 0-width scrollbar. */
         MozGtkScrollbarMetrics metrics;
         moz_gtk_get_scrollbar_metrics(&metrics);
 
         // Require room for the slider in the track if we don't have buttons.
         bool hasScrollbarButtons = moz_gtk_has_scrollbar_buttons();
 
         if (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL) {
           aResult->width = metrics.slider_width + 2 * metrics.trough_border;