From 193644e354e682efb7d8298d6fdf5a0b28182c9b Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 18 May 2015 11:24:16 +0000 Subject: [PATCH] Merge r181744 - [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): --- Source/WebCore/ChangeLog | 17 +++++++++++++++++ .../WebCore/platform/gtk/ScrollbarThemeGtk3.cpp | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ce718ec7ed36..ebbde5ed5434 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,20 @@ +2015-03-19 Carlos Garcia Campos + + [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): + 2014-12-07 Youenn Fablet [Soup][Curl] HTTP header values should be treated as latin1, not UTF-8 diff --git a/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp b/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp index 9749c543f3dd..fccdc43cd107 100644 --- a/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp +++ b/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp @@ -72,6 +72,14 @@ static void applyScrollbarStyleContextClasses(GtkStyleContext* context, Scrollba 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 @@ -86,6 +94,7 @@ void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, Scrollbar applyScrollbarStyleContextClasses(m_context, scrollbar->orientation()); gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_TROUGH); + adjustRectAccordingToMargin(m_context, static_cast(0), fullScrollbarRect); gtk_render_background(m_context, context->platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height()); gtk_render_frame(m_context, context->platformContext()->cr(), @@ -120,8 +129,10 @@ void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClien flags |= GTK_STATE_FLAG_PRELIGHT; gtk_style_context_set_state(m_context, static_cast(flags)); - gtk_render_slider(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(), - orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); + IntRect thumbRect(rect); + adjustRectAccordingToMargin(m_context, static_cast(flags), thumbRect); + gtk_render_slider(m_context, context->platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(), + orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); gtk_style_context_restore(m_context); }