Bug 1453930 - Use gtk_style_context_get_state() instead of GTK_STATE_FLAG_NORMAL to get widget border/margin/padding, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Fri, 13 Apr 2018 13:41:27 +0200
changeset 415296 33f57e147c46b96b1be57a2b4fe10d281a256589
parent 415295 bc9936221cb16956a86e335bad6f7daef67e7ba2
child 415297 5d34206436c6d78140a9d3a9296b90d8f1c37b98
push id33893
push usercbrindusan@mozilla.com
push dateTue, 24 Apr 2018 21:48:59 +0000
treeherdermozilla-central@cfe09d016e77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1453930
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453930 - Use gtk_style_context_get_state() instead of GTK_STATE_FLAG_NORMAL to get widget border/margin/padding, r=jhorak MozReview-Commit-ID: 6FaUpaaBt2Q
widget/gtk/gtk3drawing.cpp
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -79,31 +79,31 @@ moz_gtk_add_style_margin(GtkStyleContext
 }
 
 static void
 moz_gtk_add_style_border(GtkStyleContext* style,
                          gint* left, gint* top, gint* right, gint* bottom)
 {
     GtkBorder border;
 
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
 
     *left += border.left;
     *right += border.right;
     *top += border.top;
     *bottom += border.bottom;
 }
 
 static void
 moz_gtk_add_style_padding(GtkStyleContext* style,
                           gint* left, gint* top, gint* right, gint* bottom)
 {
     GtkBorder padding;
 
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
     *left += padding.left;
     *right += padding.right;
     *top += padding.top;
     *bottom += padding.bottom;
 }
 
 static void
@@ -224,18 +224,18 @@ moz_gtk_radio_get_metrics(gint* indicato
 }
 
 static gint
 moz_gtk_get_focus_outline_size(GtkStyleContext* style,
                                gint* focus_h_width, gint* focus_v_width)
 {
     GtkBorder border;
     GtkBorder padding;
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
     *focus_h_width = border.left + padding.left;
     *focus_v_width = border.top + padding.top;
     return MOZ_GTK_SUCCESS;
 }
 
 gint
 moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width)
 {
@@ -683,18 +683,18 @@ calculate_button_inner_rect(GtkWidget* b
 {
     GtkStyleContext* style;
     GtkBorder border;
     GtkBorder padding = {0, 0, 0, 0};
 
     style = gtk_widget_get_style_context(button);
 
     /* This mirrors gtkbutton's child positioning */
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
     inner_rect->x = rect->x + border.left + padding.left;
     inner_rect->y = rect->y + padding.top + border.top;
     inner_rect->width = MAX(1, rect->width - padding.left -
        padding.right - border.left * 2);
     inner_rect->height = MAX(1, rect->height - padding.top -
        padding.bottom - border.top * 2);
 
@@ -1611,17 +1611,17 @@ moz_gtk_toolbar_separator_paint(cairo_t 
 
         gtk_render_frame(style, cr,
                           rect->x + (rect->width - separator_width) / 2,
                           rect->y + rect->height * start_fraction,
                           separator_width,
                           rect->height * (end_fraction - start_fraction));
     } else {
         GtkBorder padding;
-        gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+        gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
         paint_width = padding.left;
         if (paint_width > rect->width)
             paint_width = rect->width;
 
         gtk_render_line(style, cr,
                         rect->x + (rect->width - paint_width) / 2,
                         rect->y + rect->height * start_fraction,
@@ -1780,17 +1780,17 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
 
 static gint
 moz_gtk_get_tab_thickness(GtkStyleContext *style)
 {
     if (!notebook_has_tab_gap)
       return 0; /* tabs do not overdraw the tabpanel border with "no gap" style */
 
     GtkBorder border;
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
     if (border.top < 2)
         return 2; /* some themes don't set ythickness correctly */
 
     return border.top;
 }
 
 gint
 moz_gtk_get_tab_thickness(WidgetNodeType aNodeType)
@@ -2117,17 +2117,17 @@ moz_gtk_menu_separator_paint(cairo_t *cr
 
     GtkStyleContext* style;
     gboolean wide_separators;
     gint separator_height;
     gint x, y, w;
     GtkBorder padding;
 
     style = GetStyleContext(MOZ_GTK_MENUSEPARATOR, direction);
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
     x = rect->x;
     y = rect->y;
     w = rect->width;
 
     gtk_style_context_save(style);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
 
@@ -2423,17 +2423,17 @@ moz_gtk_get_widget_border(WidgetNodeType
             if (comboBoxSeparator) {
                 style = gtk_widget_get_style_context(comboBoxSeparator);
                 gtk_style_context_get_style(style,
                                             "wide-separators", &wide_separators,
                                             "separator-width", &separator_width,
                                             NULL);
 
                 if (!wide_separators) {
-                    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL,
+                    gtk_style_context_get_border(style, gtk_style_context_get_state(style),
                                                  &border);
                     separator_width = border.left;
                 }
             }
 
             gtk_widget_get_preferred_size(GetWidget(MOZ_GTK_COMBOBOX_ARROW),
                                           NULL, &arrow_req);
 
@@ -2596,23 +2596,23 @@ moz_gtk_get_tab_border(gint* left, gint*
             if (direction == GTK_TEXT_DIR_RTL)
                 *right += initial_gap;
             else
                 *left += initial_gap;
         }
     } else {
         GtkBorder margin;
 
-        gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin);
+        gtk_style_context_get_margin(style, gtk_style_context_get_state(style), &margin);
         *left += margin.left;
         *right += margin.right;
 
         if (flags & MOZ_GTK_TAB_FIRST) {
             style = GetStyleContext(MOZ_GTK_NOTEBOOK_HEADER, direction);
-            gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin);
+            gtk_style_context_get_margin(style, gtk_style_context_get_state(style), &margin);
             *left += margin.left;
             *right += margin.right;
         }
     }
 
     return MOZ_GTK_SUCCESS;
 }
 
@@ -2677,17 +2677,17 @@ moz_gtk_get_toolbar_separator_width(gint
 
     GtkStyleContext* style = GetStyleContext(MOZ_GTK_TOOLBAR);
     gtk_style_context_get_style(style,
                                 "space-size", size,
                                 "wide-separators",  &wide_separators,
                                 "separator-width", &separator_width,
                                 NULL);
     /* Just in case... */
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
     *size = MAX(*size, (wide_separators ? separator_width : border.left));
     return MOZ_GTK_SUCCESS;
 }
 
 gint
 moz_gtk_get_expander_size(gint* size)
 {
     GtkStyleContext* style = GetStyleContext(MOZ_GTK_EXPANDER);
@@ -2708,17 +2708,17 @@ moz_gtk_get_treeview_expander_size(gint*
 // See gtk_menu_item_draw() for reference.
 gint
 moz_gtk_get_menu_separator_height(gint *size)
 {
     gboolean  wide_separators;
     gint      separator_height;
     GtkBorder padding;
     GtkStyleContext* style = GetStyleContext(MOZ_GTK_MENUSEPARATOR);
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
     gtk_style_context_save(style);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
 
     gtk_style_context_get_style(style,
                                 "wide-separators",  &wide_separators,
                                 "separator-height", &separator_height,
                                 NULL);
@@ -2740,18 +2740,18 @@ moz_gtk_get_entry_min_height(gint* heigh
                               "min-height", height,
                               nullptr);
     } else {
         *height = 0;
     }
 
     GtkBorder border;
     GtkBorder padding;
-    gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
-    gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
+    gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
+    gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
 
     *height += (border.top + border.bottom + padding.top + padding.bottom);
 }
 
 void
 moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
                           gint* scale_height)
 {
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -178,17 +178,17 @@ GetBorderColors(GtkStyleContext* aContex
     gtk_style_context_get(aContext, state, GTK_STYLE_PROPERTY_BORDER_STYLE,
                           &borderStyle, nullptr);
     bool visible = borderStyle != GTK_BORDER_STYLE_NONE &&
         borderStyle != GTK_BORDER_STYLE_HIDDEN;
     if (visible) {
         // GTK has an initial value of zero for border-widths, and so themes
         // need to explicitly set border-widths to make borders visible.
         GtkBorder border;
-        gtk_style_context_get_border(aContext, GTK_STATE_FLAG_NORMAL, &border);
+        gtk_style_context_get_border(aContext, state, &border);
         visible = border.top != 0 || border.right != 0 ||
             border.bottom != 0 || border.left != 0;
     }
 
     if (visible &&
         GetUnicoBorderGradientColors(aContext, aLightColor, aDarkColor))
         return true;