Bug 1335705 - Consider also margin when determine range widget slider size, r=karlt
authorMartin Stransky <stransky@redhat.com>
Thu, 23 Feb 2017 10:52:55 +0100
changeset 373716 2c2b324b9afbfc444d4983e8f88b2d9d500b4485
parent 373715 9d135a51856f1432c902d51bc8805a6609c3b3b1
child 373717 428e3fea1a3e36e7f8f959ea4d6ba7cb36124514
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1335705
milestone54.0a1
Bug 1335705 - Consider also margin when determine range widget slider size, r=karlt MozReview-Commit-ID: 49UgRJFjvns
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);
-      gtk_style_context_get(style, gtk_style_context_get_state(style),
-                            "min-width", thumb_length,
-                            "min-height", thumb_height,
+
+      gint min_width, min_height;
+      GtkStateFlags state = gtk_style_context_get_state(style);
+      gtk_style_context_get(style, state,
+                            "min-width", &min_width,
+                            "min-height", &min_height,
                              nullptr);
+      GtkBorder margin;
+      gtk_style_context_get_margin(style, state, &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 (min_width < -margin_width)
+          min_width = -margin_width;
+      if (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)