Title: [181744] trunk/Source/WebCore
Revision
181744
Author
[email protected]
Date
2015-03-19 03:24:50 -0700 (Thu, 19 Mar 2015)

Log Message

[GTK] Scrollbars look bad with GTK+ 3.16
https://bugs.webkit.org/show_bug.cgi?id=140800

Reviewed by Sergio Villar Senin.

Take margin into account when rendering scrollbars. This fixes the
huge scrollbars rendered with GTK+ 3.16. We don't need to check
the GTK+ version because in previous versions the marging were 0,
so the same code just works.

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::adjustRectAccordingToMargin):
(WebCore::ScrollbarThemeGtk::paintTrackBackground):
(WebCore::ScrollbarThemeGtk::paintThumb):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (181743 => 181744)


--- trunk/Source/WebCore/ChangeLog	2015-03-19 09:01:01 UTC (rev 181743)
+++ trunk/Source/WebCore/ChangeLog	2015-03-19 10:24:50 UTC (rev 181744)
@@ -1,3 +1,20 @@
+2015-03-19  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Scrollbars look bad with GTK+ 3.16
+        https://bugs.webkit.org/show_bug.cgi?id=140800
+
+        Reviewed by Sergio Villar Senin.
+
+        Take margin into account when rendering scrollbars. This fixes the
+        huge scrollbars rendered with GTK+ 3.16. We don't need to check
+        the GTK+ version because in previous versions the marging were 0,
+        so the same code just works.
+
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::adjustRectAccordingToMargin):
+        (WebCore::ScrollbarThemeGtk::paintTrackBackground):
+        (WebCore::ScrollbarThemeGtk::paintThumb):
+
 2015-03-19  Xabier Rodriguez Calvar <[email protected]> and Youenn Fablet  <[email protected]>
 
         [Streams API] Update ReadableStream API according new version of the specification

Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (181743 => 181744)


--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2015-03-19 09:01:01 UTC (rev 181743)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2015-03-19 10:24:50 UTC (rev 181744)
@@ -278,6 +278,14 @@
     gtk_style_context_add_class(context, orientation == VerticalScrollbar ?  GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
 }
 
+static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
+{
+    GtkBorder margin;
+    gtk_style_context_get_margin(context, state, &margin);
+    rect.move(margin.left, margin.right);
+    rect.contract(margin.left + margin.right, margin.top + margin.bottom);
+}
+
 void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
 {
     // Paint the track background. If the trough-under-steppers property is true, this
@@ -293,6 +301,7 @@
     applyScrollbarStyleContextClasses(styleContext, scrollbar->orientation());
     gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH);
 
+    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(0), fullScrollbarRect);
     gtk_render_background(styleContext, context->platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
     gtk_render_frame(styleContext, context->platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
 
@@ -327,7 +336,9 @@
         flags |= GTK_STATE_FLAG_PRELIGHT;
     gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags));
 
-    gtk_render_slider(styleContext, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(),
+    IntRect thumbRect(rect);
+    adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(flags), thumbRect);
+    gtk_render_slider(styleContext, context->platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),
         orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
 
     gtk_style_context_restore(styleContext);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to