Bug 1335705 - Consider also margin when determine range widget slider size, r?karlt draft
authorMartin Stransky <stransky@redhat.com>
Fri, 03 Feb 2017 16:12:15 +0100
changeset 470285 c2e5f7e049789b26bb61d6aeca862215142638bc
parent 469123 f3d187bd0733b1182dffc97b5dfe623e18f92a44
child 470288 7caf659c68d3cb75464c4029d0f5e664bccc5a1e
push id43987
push userstransky@redhat.com
push dateFri, 03 Feb 2017 15:13:36 +0000
reviewerskarlt
bugs1335705
milestone54.0a1
Bug 1335705 - Consider also margin when determine range widget slider size, r?karlt MozReview-Commit-ID: GyL3S3jZDQW
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -2549,20 +2549,38 @@ moz_gtk_get_scalethumb_metrics(GtkOrient
                                   "slider_width", thumb_height,
                                   NULL);
       ReleaseStyleContext(style);
   } else {
       WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ?
                                MOZ_GTK_SCALE_THUMB_HORIZONTAL:
                                MOZ_GTK_SCALE_THUMB_VERTICAL;
       GtkStyleContext* style = ClaimStyleContext(widget);
+
+      gint min_width, min_height;
       gtk_style_context_get(style, gtk_style_context_get_state(style),
-                            "min-width", thumb_length,
-                            "min-height", thumb_height,
+                            "min-width", &min_width,
+                            "min-height", &min_height,
                              nullptr);
+      GtkBorder margin;
+      gtk_style_context_get_margin(style, gtk_style_context_get_state(style),
+                                   &margin);
+      gint margin_width = margin.left + margin.right;
+      gint margin_height = margin.top + margin.bottom;
+
+      // Negative margin of slider element also determines its minimal size
+      // so use bigger of those two values.
+      if (margin_width < 0 && min_width < - margin_width)
+          min_width = - margin_width;
+      if (margin_height < 0 && min_height < - margin_height)
+          min_height = - margin_height;
+
+      *thumb_length = min_width;
+      *thumb_height = min_height;
+
       ReleaseStyleContext(style);
   }
 
   return MOZ_GTK_SUCCESS;
 }
 
 gint
 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)