Bug 1216582 - [gtk3] Scrollbar buttons not drawn correctly. r=karlt a=lizzard
authorJan Horak <jhorak@redhat.com>
Thu, 22 Oct 2015 01:00:00 +0200
changeset 296740 807e612c17ef
parent 296739 5ca6857c26e5
child 296741 94c40ce2d93b
push id5316
push userkwierso@gmail.com
push date2015-11-16 20:42 +0000
treeherdermozilla-beta@c66289e84c50 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, lizzard
bugs1216582
milestone43.0
Bug 1216582 - [gtk3] Scrollbar buttons not drawn correctly. r=karlt a=lizzard
widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -1119,41 +1119,55 @@ moz_gtk_scrollbar_button_paint(cairo_t *
         arrow_angle = (flags & MOZ_GTK_STEPPER_DOWN) ? ARROW_DOWN : ARROW_UP;        
     } else {
         arrow_angle = (flags & MOZ_GTK_STEPPER_DOWN) ? ARROW_RIGHT : ARROW_LEFT;        
     }
 
     style = gtk_widget_get_style_context(scrollbar);
   
     gtk_style_context_save(style);
-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR);  
+    gtk_style_context_add_class(style, GTK_STYLE_CLASS_BUTTON);
     gtk_style_context_set_state(style, state_flags);
+    if (arrow_angle == ARROW_RIGHT) {
+        gtk_style_context_add_class(style, GTK_STYLE_CLASS_RIGHT);
+    } else if (arrow_angle == ARROW_DOWN) {
+        gtk_style_context_add_class(style, GTK_STYLE_CLASS_BOTTOM);
+    } else if (arrow_angle == ARROW_LEFT) {
+        gtk_style_context_add_class(style, GTK_STYLE_CLASS_LEFT);
+    } else {
+        gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOP);
+    }
   
     gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
     gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
 
     arrow_rect.width = rect->width / 2;
     arrow_rect.height = rect->height / 2;
-    arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
-    arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
+    
+    gfloat arrow_scaling;
+    gtk_widget_style_get (scrollbar, "arrow-scaling", &arrow_scaling, NULL);
+
+    gdouble arrow_size = MIN(rect->width, rect->height) * arrow_scaling;
+    arrow_rect.x = rect->x + (rect->width - arrow_size) / 2;
+    arrow_rect.y = rect->y + (rect->height - arrow_size) / 2;
 
     if (state_flags & GTK_STATE_FLAG_ACTIVE) {
         gtk_widget_style_get(scrollbar,
                              "arrow-displacement-x", &arrow_displacement_x,
                              "arrow-displacement-y", &arrow_displacement_y,
                              NULL);
 
         arrow_rect.x += arrow_displacement_x;
         arrow_rect.y += arrow_displacement_y;
     }
   
     gtk_render_arrow(style, cr, arrow_angle,
                      arrow_rect.x,
                      arrow_rect.y, 
-                     arrow_rect.width);
+                     arrow_size);
   
     gtk_style_context_restore(style);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
 moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget,