Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (197996 => 197997)
--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-03-11 06:47:10 UTC (rev 197996)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-03-11 06:59:57 UTC (rev 197997)
@@ -190,11 +190,6 @@
}
#ifndef GTK_API_VERSION_2
-static inline const char* orientationStyleClass(ScrollbarOrientation orientation)
-{
- return orientation == VerticalScrollbar ? "vertical" : "horizontal";
-}
-
// The GtkStyleContext returned by this function is cached by ScrollbarThemeGtk::paint for the
// duration of its scope, so a different GtkStyleContext with updated theme properties will be
// used for each call to paint.
@@ -217,7 +212,9 @@
#else
gtk_widget_path_iter_add_class(path.get(), -1, "scrollbar");
#endif
- gtk_widget_path_iter_add_class(path.get(), -1, orientationStyleClass(scrollbar ? scrollbar->orientation() : VerticalScrollbar));
+ ScrollbarOrientation orientation = scrollbar ? scrollbar->orientation() : VerticalScrollbar;
+ gtk_widget_path_iter_add_class(path.get(), -1, orientation == VerticalScrollbar ? "vertical" : "horizontal");
+ gtk_widget_path_iter_add_class(path.get(), -1, orientation == VerticalScrollbar ? "right" : "bottom");
gtk_style_context_set_path(styleContext.get(), path.get());
return styleContext;
@@ -317,10 +314,22 @@
if (troughUnderSteppers(scrollbar))
fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
- GRefPtr<GtkStyleContext> styleContext = createChildStyleContext(parentStyleContext.get(), "trough");
- adjustRectAccordingToMargin(styleContext.get(), fullScrollbarRect);
- gtk_render_background(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
- gtk_render_frame(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+ IntRect adjustedRect = fullScrollbarRect;
+ adjustRectAccordingToMargin(parentStyleContext.get(), adjustedRect);
+ gtk_render_background(parentStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
+ gtk_render_frame(parentStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
+
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(parentStyleContext.get(), "contents");
+ adjustedRect = fullScrollbarRect;
+ adjustRectAccordingToMargin(contentsStyleContext.get(), adjustedRect);
+ gtk_render_background(contentsStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
+ gtk_render_frame(contentsStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
+
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
+ adjustedRect = fullScrollbarRect;
+ adjustRectAccordingToMargin(troughStyleContext.get(), adjustedRect);
+ gtk_render_background(troughStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
+ gtk_render_frame(troughStyleContext.get(), context.platformContext()->cr(), adjustedRect.x(), adjustedRect.y(), adjustedRect.width(), adjustedRect.height());
}
void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar)
@@ -333,7 +342,8 @@
{
ScrollbarOrientation orientation = scrollbar.orientation();
GRefPtr<GtkStyleContext> parentStyleContext = getOrCreateStyleContext(&scrollbar, StyleContextMode::Paint);
- GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(parentStyleContext.get(), "trough");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(parentStyleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
GRefPtr<GtkStyleContext> styleContext = createChildStyleContext(troughStyleContext.get(), "slider");
unsigned flags = 0;
@@ -366,7 +376,8 @@
{
ScrollbarOrientation orientation = scrollbar.orientation();
GRefPtr<GtkStyleContext> parentStyleContext = getOrCreateStyleContext(&scrollbar, StyleContextMode::Paint);
- GRefPtr<GtkStyleContext> styleContext = createChildStyleContext(parentStyleContext.get(), "button");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(parentStyleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> styleContext = createChildStyleContext(contentsStyleContext.get(), "button");
unsigned flags = 0;
if ((BackButtonStartPart == part && scrollbar.currentPos())
@@ -537,10 +548,18 @@
{
GtkBorder troughBorder;
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext, "trough");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext, "contents");
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
GRefPtr<GtkStyleContext> sliderStyleContext = createChildStyleContext(troughStyleContext.get(), "slider");
int thumbFat = thumbFatness(sliderStyleContext.get(), orientation);
getTroughBorder(troughStyleContext.get(), &troughBorder);
+ // Since GTK+ 3.19 the scrollbar can have its own border too.
+ GtkBorder border;
+ gtk_style_context_get_border(styleContext, gtk_style_context_get_state(styleContext), &border);
+ troughBorder.left += border.left;
+ troughBorder.right += border.right;
+ troughBorder.top += border.top;
+ troughBorder.bottom += border.bottom;
#else
int thumbFat = thumbFatness(styleContext, orientation);
getTroughBorder(styleContext, &troughBorder);
@@ -560,7 +579,8 @@
{
GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(&scrollbar);
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(styleContext.get(), "button");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(contentsStyleContext.get(), "button");
switch (buttonPart) {
case BackButtonStartPart:
case ForwardButtonStartPart:
@@ -599,7 +619,8 @@
{
GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(&scrollbar);
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(styleContext.get(), "button");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(contentsStyleContext.get(), "button");
switch (buttonPart) {
case BackButtonStartPart:
case ForwardButtonStartPart:
@@ -639,7 +660,8 @@
GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(&scrollbar);
int minThumbLength = 0;
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.get(), "trough");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
GRefPtr<GtkStyleContext> sliderStyleContext = createChildStyleContext(troughStyleContext.get(), "slider");
gtk_style_context_get(sliderStyleContext.get(), gtk_style_context_get_state(sliderStyleContext.get()),
scrollbar.orientation() == VerticalScrollbar ? "min-height" : "min-width", &minThumbLength, nullptr);
@@ -674,7 +696,8 @@
{
GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(&scrollbar);
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.get(), "trough");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
GRefPtr<GtkStyleContext> sliderStyleContext = createChildStyleContext(troughStyleContext.get(), "slider");
return thumbFatness(sliderStyleContext.get(), scrollbar.orientation());
#else
@@ -697,8 +720,16 @@
{
GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(&scrollbar);
#if GTK_CHECK_VERSION(3, 19, 11)
- GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.get(), "trough");
+ GRefPtr<GtkStyleContext> contentsStyleContext = createChildStyleContext(styleContext.get(), "contents");
+ GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(contentsStyleContext.get(), "trough");
getTroughBorder(troughStyleContext.get(), border);
+ // Since GTK+ 3.19 the scrollbar can have its own border too.
+ GtkBorder scrollbarBorder;
+ gtk_style_context_get_border(styleContext.get(), gtk_style_context_get_state(styleContext.get()), &scrollbarBorder);
+ border->left += scrollbarBorder.left;
+ border->right += scrollbarBorder.right;
+ border->top += scrollbarBorder.top;
+ border->bottom += scrollbarBorder.bottom;
#else
getTroughBorder(styleContext.get(), border);
#endif