Skip to content

Commit

Permalink
Merge r181744 - [GTK] Scrollbars look bad with GTK+ 3.16
Browse files Browse the repository at this point in the history
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):
  • Loading branch information
carlosgcampos committed Mar 19, 2015
1 parent c159fdd commit e525471
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2015-03-19 Carlos Garcia Campos <cgarcia@igalia.com>

[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-17 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Wrong transfer annotations used in GObject DOM bindings
Expand Down
13 changes: 12 additions & 1 deletion Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
Expand Up @@ -278,6 +278,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
Expand All @@ -293,6 +301,7 @@ void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, Scrollbar
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());

Expand Down Expand Up @@ -327,7 +336,9 @@ void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClien
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);
Expand Down

0 comments on commit e525471

Please sign in to comment.