Title: [198006] releases/WebKitGTK/webkit-2.10/Source/WebCore
Revision
198006
Author
[email protected]
Date
2016-03-11 04:58:28 -0800 (Fri, 11 Mar 2016)

Log Message

Merge r197609 - [GTK] Scrollbars are broken again with GTK+ >= 3.19.11
https://bugs.webkit.org/show_bug.cgi?id=154890

Reviewed by Michael Catanzaro.

Scrollbar style properties have been deprecated in GTK+, and it
seems that now deprecating means keeping the properties but
ignoring them. So, this reworks the whole scrollbars theme code
again to not cache style properties anymore, but retrieve them
from the GtkStyleContext. Previous GTK+ versions still need to
query the style properties, so I've added helper functions to get
all the style properties with the ifdefs, trying to keep the
common render code free of GTK+ versions ifdefs.

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::backButtonRect):
(WebCore::ScrollbarThemeGtk::forwardButtonRect):
(WebCore::ScrollbarThemeGtk::trackRect):
(WebCore::ScrollbarThemeGtk::thumbRect):
(WebCore::ScrollbarThemeGtk::paintTrackBackground):
(WebCore::ScrollbarThemeGtk::paintThumb):
(WebCore::ScrollbarThemeGtk::paint):
(WebCore::ScrollbarThemeGtk::scrollbarThickness):
(WebCore::ScrollbarThemeGtk::buttonSize):
(WebCore::ScrollbarThemeGtk::stepperSize):
(WebCore::ScrollbarThemeGtk::getStepperSpacing):
(WebCore::ScrollbarThemeGtk::troughUnderSteppers):
(WebCore::ScrollbarThemeGtk::minimumThumbLength):
(WebCore::ScrollbarThemeGtk::thumbFatness):
(WebCore::ScrollbarThemeGtk::getTroughBorder):
(WebCore::ScrollbarThemeGtk::getOrCreateStyleContext):
(WebCore::ScrollbarThemeGtk::updateThemeProperties):
(WebCore::ScrollbarThemeGtk::handleMousePressEvent):
* platform/gtk/ScrollbarThemeGtk.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (198005 => 198006)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-03-11 12:08:22 UTC (rev 198005)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-03-11 12:58:28 UTC (rev 198006)
@@ -1,3 +1,40 @@
+2016-03-04  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Scrollbars are broken again with GTK+ >= 3.19.11
+        https://bugs.webkit.org/show_bug.cgi?id=154890
+
+        Reviewed by Michael Catanzaro.
+
+        Scrollbar style properties have been deprecated in GTK+, and it
+        seems that now deprecating means keeping the properties but
+        ignoring them. So, this reworks the whole scrollbars theme code
+        again to not cache style properties anymore, but retrieve them
+        from the GtkStyleContext. Previous GTK+ versions still need to
+        query the style properties, so I've added helper functions to get
+        all the style properties with the ifdefs, trying to keep the
+        common render code free of GTK+ versions ifdefs.
+
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::ScrollbarThemeGtk::backButtonRect):
+        (WebCore::ScrollbarThemeGtk::forwardButtonRect):
+        (WebCore::ScrollbarThemeGtk::trackRect):
+        (WebCore::ScrollbarThemeGtk::thumbRect):
+        (WebCore::ScrollbarThemeGtk::paintTrackBackground):
+        (WebCore::ScrollbarThemeGtk::paintThumb):
+        (WebCore::ScrollbarThemeGtk::paint):
+        (WebCore::ScrollbarThemeGtk::scrollbarThickness):
+        (WebCore::ScrollbarThemeGtk::buttonSize):
+        (WebCore::ScrollbarThemeGtk::stepperSize):
+        (WebCore::ScrollbarThemeGtk::getStepperSpacing):
+        (WebCore::ScrollbarThemeGtk::troughUnderSteppers):
+        (WebCore::ScrollbarThemeGtk::minimumThumbLength):
+        (WebCore::ScrollbarThemeGtk::thumbFatness):
+        (WebCore::ScrollbarThemeGtk::getTroughBorder):
+        (WebCore::ScrollbarThemeGtk::getOrCreateStyleContext):
+        (WebCore::ScrollbarThemeGtk::updateThemeProperties):
+        (WebCore::ScrollbarThemeGtk::handleMousePressEvent):
+        * platform/gtk/ScrollbarThemeGtk.h:
+
 2016-02-18  Andy Estes  <[email protected]>
 
         Revert to dispatching the popstate event synchronously

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (198005 => 198006)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2016-03-11 12:08:22 UTC (rev 198005)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2016-03-11 12:58:28 UTC (rev 198006)
@@ -67,19 +67,21 @@
     if (part == BackButtonStartPart && !m_hasBackButtonStartPart)
         return IntRect();
 
-    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext();
-    int x = scrollbar.x() + m_cachedProperties.troughBorderWidth;
-    int y = scrollbar.y() + m_cachedProperties.troughBorderWidth;
-    IntSize size = buttonSize(scrollbar);
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+    GtkBorder troughBorder;
+    getTroughBorder(scrollbar, &troughBorder);
+    int x = scrollbar.x() + troughBorder.left;
+    int y = scrollbar.y() + troughBorder.top;
+    IntSize size = buttonSize(scrollbar, part);
     if (part == BackButtonStartPart)
         return IntRect(x, y, size.width(), size.height());
 
     // BackButtonEndPart (alternate button)
     if (scrollbar.orientation() == HorizontalScrollbar)
-        return IntRect(scrollbar.x() + scrollbar.width() - m_cachedProperties.troughBorderWidth - (2 * size.width()), y, size.width(), size.height());
+        return IntRect(scrollbar.x() + scrollbar.width() - troughBorder.left - (2 * size.width()), y, size.width(), size.height());
 
     // VerticalScrollbar alternate button
-    return IntRect(x, scrollbar.y() + scrollbar.height() - m_cachedProperties.troughBorderWidth - (2 * size.height()), size.width(), size.height());
+    return IntRect(x, scrollbar.y() + scrollbar.height() - troughBorder.top - (2 * size.height()), size.width(), size.height());
 #else
     UNUSED_PARAM(scrollbar);
     UNUSED_PARAM(part);
@@ -95,24 +97,26 @@
     if (part == ForwardButtonEndPart && !m_hasForwardButtonEndPart)
         return IntRect();
 
-    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext();
-    IntSize size = buttonSize(scrollbar);
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+    GtkBorder troughBorder;
+    getTroughBorder(scrollbar, &troughBorder);
+    IntSize size = buttonSize(scrollbar, part);
     if (scrollbar.orientation() == HorizontalScrollbar) {
-        int y = scrollbar.y() + m_cachedProperties.troughBorderWidth;
+        int y = scrollbar.y() + troughBorder.top;
         if (part == ForwardButtonEndPart)
-            return IntRect(scrollbar.x() + scrollbar.width() - size.width() - m_cachedProperties.troughBorderWidth, y, size.width(), size.height());
+            return IntRect(scrollbar.x() + scrollbar.width() - size.width() - troughBorder.left, y, size.width(), size.height());
 
         // ForwardButtonStartPart (alternate button)
-        return IntRect(scrollbar.x() + m_cachedProperties.troughBorderWidth + size.width(), y, size.width(), size.height());
+        return IntRect(scrollbar.x() + troughBorder.left + size.width(), y, size.width(), size.height());
     }
 
     // VerticalScrollbar
-    int x = scrollbar.x() + m_cachedProperties.troughBorderWidth;
+    int x = scrollbar.x() + troughBorder.left;
     if (part == ForwardButtonEndPart)
-        return IntRect(x, scrollbar.y() + scrollbar.height() - size.height() - m_cachedProperties.troughBorderWidth, size.width(), size.height());
+        return IntRect(x, scrollbar.y() + scrollbar.height() - size.height() - troughBorder.top, size.width(), size.height());
 
     // ForwardButtonStartPart (alternate button)
-    return IntRect(x, scrollbar.y() + m_cachedProperties.troughBorderWidth + size.height(), size.width(), size.height());
+    return IntRect(x, scrollbar.y() + troughBorder.top + size.height(), size.width(), size.height());
 #else
     UNUSED_PARAM(scrollbar);
     UNUSED_PARAM(part);
@@ -123,43 +127,59 @@
 IntRect ScrollbarThemeGtk::trackRect(Scrollbar& scrollbar, bool)
 {
 #ifndef GTK_API_VERSION_2
-    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext();
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
     // The padding along the thumb movement axis includes the trough border
     // plus the size of stepper spacing (the space between the stepper and
     // the place where the thumb stops). There is often no stepper spacing.
-    int movementAxisPadding = m_cachedProperties.troughBorderWidth + m_cachedProperties.stepperSpacing;
+    GtkBorder troughBorder;
+    getTroughBorder(scrollbar, &troughBorder);
+    GtkBorder stepperSpacing = { 0, 0, 0, 0 };
 
     // The fatness of the scrollbar on the non-movement axis.
-    int thickness = scrollbarThickness(scrollbar.controlSize());
+    int thickness = scrollbarThickness(styleContext.get(), scrollbar.orientation());
 
     int startButtonsOffset = 0;
     int buttonsWidth = 0;
     if (m_hasForwardButtonStartPart) {
-        startButtonsOffset += m_cachedProperties.stepperSize;
-        buttonsWidth += m_cachedProperties.stepperSize;
+        int buttonSize = stepperSize(scrollbar, ForwardButtonStartPart);
+        startButtonsOffset += buttonSize;
+        buttonsWidth += buttonSize;
     }
     if (m_hasBackButtonStartPart) {
-        startButtonsOffset += m_cachedProperties.stepperSize;
-        buttonsWidth += m_cachedProperties.stepperSize;
+        int buttonSize = stepperSize(scrollbar, BackButtonStartPart);
+        startButtonsOffset += buttonSize;
+        buttonsWidth += buttonSize;
+        GtkBorder margin;
+        getStepperSpacing(scrollbar, BackButtonStartPart, &margin);
+        stepperSpacing.left += margin.left;
+        stepperSpacing.right += margin.right;
+        stepperSpacing.top += margin.top;
+        stepperSpacing.bottom += margin.bottom;
     }
     if (m_hasBackButtonEndPart)
-        buttonsWidth += m_cachedProperties.stepperSize;
-    if (m_hasForwardButtonEndPart)
-        buttonsWidth += m_cachedProperties.stepperSize;
+        buttonsWidth += stepperSize(scrollbar, BackButtonEndPart);
+    if (m_hasForwardButtonEndPart) {
+        buttonsWidth += stepperSize(scrollbar, ForwardButtonEndPart);
+        GtkBorder margin;
+        getStepperSpacing(scrollbar, BackButtonStartPart, &margin);
+        stepperSpacing.left += margin.left;
+        stepperSpacing.right += margin.right;
+        stepperSpacing.top += margin.top;
+        stepperSpacing.bottom += margin.bottom;
+    }
 
     if (scrollbar.orientation() == HorizontalScrollbar) {
-        // Once the scrollbar becomes smaller than the natural size of the
-        // two buttons, the track disappears.
-        if (scrollbar.width() < 2 * thickness)
+        // Once the scrollbar becomes smaller than the natural size of the two buttons and the thumb, the track disappears.
+        if (scrollbar.width() < buttonsWidth + minimumThumbLength(scrollbar))
             return IntRect();
-        return IntRect(scrollbar.x() + movementAxisPadding + startButtonsOffset, scrollbar.y(),
-                       scrollbar.width() - (2 * movementAxisPadding) - buttonsWidth, thickness);
+        return IntRect(scrollbar.x() + troughBorder.left + stepperSpacing.left + startButtonsOffset, scrollbar.y(),
+            scrollbar.width() - (troughBorder.left + troughBorder.right) - (stepperSpacing.left + stepperSpacing.right) - buttonsWidth, thickness);
     }
 
-    if (scrollbar.height() < 2 * thickness)
+    if (scrollbar.height() < buttonsWidth + minimumThumbLength(scrollbar))
         return IntRect();
-    return IntRect(scrollbar.x(), scrollbar.y() + movementAxisPadding + startButtonsOffset,
-                   thickness, scrollbar.height() - (2 * movementAxisPadding) - buttonsWidth);
+    return IntRect(scrollbar.x(), scrollbar.y() + troughBorder.top + stepperSpacing.top + startButtonsOffset,
+        thickness, scrollbar.height() - (troughBorder.top + troughBorder.bottom) - (stepperSpacing.top + stepperSpacing.bottom) - buttonsWidth);
 #else
     UNUSED_PARAM(scrollbar);
     return IntRect();
@@ -188,15 +208,6 @@
     gtk_widget_path_iter_add_class(path.get(), -1, orientationStyleClass(orientation));
     gtk_style_context_set_path(styleContext.get(), path.get());
 
-    gtk_style_context_get_style(
-        styleContext.get(),
-        "slider-width", &m_cachedProperties.thumbFatness,
-        "trough-border", &m_cachedProperties.troughBorderWidth,
-        "stepper-size", &m_cachedProperties.stepperSize,
-        "stepper-spacing", &m_cachedProperties.stepperSpacing,
-        "trough-under-steppers", &m_cachedProperties.troughUnderSteppers,
-        nullptr);
-
     return styleContext;
 }
 
@@ -244,7 +255,6 @@
     GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext();
     gtk_style_context_get_style(
         styleContext.get(),
-        "min-slider-length", &m_minThumbLength,
         "has-backward-stepper", &m_hasBackButtonStartPart,
         "has-forward-stepper", &m_hasForwardButtonEndPart,
         "has-secondary-backward-stepper", &m_hasBackButtonEndPart,
@@ -257,11 +267,17 @@
     GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
     IntRect trackRect = constrainTrackRectToTrackPieces(scrollbar, unconstrainedTrackRect);
     int thumbPos = thumbPosition(scrollbar);
+    int thumbFat = thumbFatness(scrollbar);
+    GtkBorder troughBorder = { 0, 0, 0, 0 };
+#if GTK_CHECK_VERSION(3, 19, 11)
+    getTroughBorder(scrollbar, &troughBorder);
+#endif
+
     if (scrollbar.orientation() == HorizontalScrollbar)
-        return IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - m_cachedProperties.thumbFatness) / 2, thumbLength(scrollbar), m_cachedProperties.thumbFatness);
+        return IntRect(trackRect.x() + thumbPos, trackRect.y() + troughBorder.top + (trackRect.height() - thumbFat) / 2, thumbLength(scrollbar), thumbFat);
 
     // VerticalScrollbar
-    return IntRect(trackRect.x() + (trackRect.width() - m_cachedProperties.thumbFatness) / 2, trackRect.y() + thumbPos, m_cachedProperties.thumbFatness, thumbLength(scrollbar));
+    return IntRect(trackRect.x() + troughBorder.left + (trackRect.width() - thumbFat) / 2, trackRect.y() + thumbPos, thumbFat, thumbLength(scrollbar));
 }
 
 static void adjustRectAccordingToMargin(GtkStyleContext* context, IntRect& rect)
@@ -279,7 +295,7 @@
     // should be the full size of the scrollbar, but if is false, it should only be the
     // track rect.
     IntRect fullScrollbarRect(rect);
-    if (m_cachedProperties.troughUnderSteppers)
+    if (troughUnderSteppers(scrollbar))
         fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height());
 
     GRefPtr<GtkStyleContext> styleContext = createChildStyleContext(parentStyleContext.get(), "trough");
@@ -392,15 +408,14 @@
     if (damageRect.intersects(trackPaintRect))
         scrollMask |= TrackBGPart;
 
-    if (m_cachedProperties.troughUnderSteppers && (scrollMask & BackButtonStartPart
+    if (troughUnderSteppers(scrollbar) && (scrollMask & BackButtonStartPart
             || scrollMask & BackButtonEndPart
             || scrollMask & ForwardButtonStartPart
             || scrollMask & ForwardButtonEndPart))
         scrollMask |= TrackBGPart;
 
-    bool thumbPresent = hasThumb(scrollbar);
     IntRect currentThumbRect;
-    if (thumbPresent) {
+    if (hasThumb(scrollbar)) {
         IntRect track = trackRect(scrollbar, false);
         currentThumbRect = thumbRect(scrollbar, track);
         if (damageRect.intersects(currentThumbRect))
@@ -408,9 +423,10 @@
     }
 
     ScrollbarControlPartMask allButtons = BackButtonStartPart | BackButtonEndPart | ForwardButtonStartPart | ForwardButtonEndPart;
-    if (scrollMask & TrackBGPart || scrollMask & ThumbPart || scrollMask & allButtons)
+    if (scrollMask & TrackBGPart || scrollMask & ThumbPart || scrollMask & allButtons) {
         paintScrollbarBackground(graphicsContext, scrollbar);
         paintTrackBackground(graphicsContext, scrollbar, trackPaintRect);
+    }
 
     // Paint the back and forward buttons.
     if (scrollMask & BackButtonStartPart)
@@ -434,26 +450,177 @@
     return (event.shiftKey() && event.button() == LeftButton) || (event.button() == MiddleButton);
 }
 
+int ScrollbarThemeGtk::scrollbarThickness(GtkStyleContext* styleContext, ScrollbarOrientation orientation)
+{
+    GtkBorder troughBorder;
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext, "trough");
+    GRefPtr<GtkStyleContext> sliderStyleContext = createChildStyleContext(troughStyleContext.get(), "slider");
+    int thumbFat = thumbFatness(sliderStyleContext.get(), orientation);
+    getTroughBorder(troughStyleContext.get(), &troughBorder);
+#else
+    int thumbFat = thumbFatness(styleContext, orientation);
+    getTroughBorder(styleContext, &troughBorder);
+#endif
+    if (orientation == VerticalScrollbar)
+        return thumbFat + troughBorder.left + troughBorder.right;
+    return thumbFat + troughBorder.top + troughBorder.bottom;
+}
+
 int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
 {
     GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext();
-    return m_cachedProperties.thumbFatness + (m_cachedProperties.troughBorderWidth * 2);
+    return scrollbarThickness(styleContext.get());
 }
 
-IntSize ScrollbarThemeGtk::buttonSize(Scrollbar& scrollbar)
+IntSize ScrollbarThemeGtk::buttonSize(Scrollbar& scrollbar, ScrollbarPart buttonPart)
 {
     GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(styleContext.get(), "button");
+    switch (buttonPart) {
+    case BackButtonStartPart:
+    case ForwardButtonStartPart:
+        gtk_style_context_add_class(buttonStyleContext.get(), "up");
+        break;
+    case BackButtonEndPart:
+    case ForwardButtonEndPart:
+        gtk_style_context_add_class(buttonStyleContext.get(), "down");
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+    int minWidth = 0, minHeight = 0;
+    gtk_style_context_get(buttonStyleContext.get(), gtk_style_context_get_state(buttonStyleContext.get()),
+        "min-width", &minWidth, "min-height", &minHeight, nullptr);
+    return IntSize(minWidth, minHeight);
+#else
+    UNUSED_PARAM(buttonPart);
+    int stepperSize;
+    gtk_style_context_get_style(styleContext.get(), "stepper-size", &stepperSize, nullptr);
     if (scrollbar.orientation() == VerticalScrollbar)
-        return IntSize(m_cachedProperties.thumbFatness, m_cachedProperties.stepperSize);
+        return IntSize(thumbFatness(scrollbar), stepperSize);
 
     // HorizontalScrollbar
-    return IntSize(m_cachedProperties.stepperSize, m_cachedProperties.thumbFatness);
+    return IntSize(stepperSize, thumbFatness(scrollbar));
+#endif
 }
 
-int ScrollbarThemeGtk::minimumThumbLength(Scrollbar&)
+int ScrollbarThemeGtk::stepperSize(Scrollbar& scrollbar, ScrollbarPart buttonPart)
 {
-    return m_minThumbLength;
+    IntSize size = buttonSize(scrollbar, buttonPart);
+    return scrollbar.orientation() == VerticalScrollbar ? size.height() : size.width();
 }
+
+void ScrollbarThemeGtk::getStepperSpacing(Scrollbar& scrollbar, ScrollbarPart buttonPart, GtkBorder* margin)
+{
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> buttonStyleContext = createChildStyleContext(styleContext.get(), "button");
+    switch (buttonPart) {
+    case BackButtonStartPart:
+    case ForwardButtonStartPart:
+        gtk_style_context_add_class(buttonStyleContext.get(), "up");
+        break;
+    case BackButtonEndPart:
+    case ForwardButtonEndPart:
+        gtk_style_context_add_class(buttonStyleContext.get(), "down");
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+    gtk_style_context_get_margin(buttonStyleContext.get(), gtk_style_context_get_state(buttonStyleContext.get()), margin);
+#else
+    UNUSED_PARAM(buttonPart);
+    int stepperSpacing = 0;
+    gtk_style_context_get_style(styleContext.get(), "stepper-spacing", &stepperSpacing, nullptr);
+    margin->left = margin->right = margin->top = margin->bottom = stepperSpacing;
+#endif
+}
+
+bool ScrollbarThemeGtk::troughUnderSteppers(Scrollbar& scrollbar)
+{
+#if !GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+    gboolean underSteppers;
+    gtk_style_context_get_style(styleContext.get(), "trough-under-steppers", &underSteppers, nullptr);
+    return underSteppers;
+#else
+    UNUSED_PARAM(scrollbar);
+    // This is now ignored by GTK+ and considered always true.
+    return true;
+#endif
+}
+int ScrollbarThemeGtk::minimumThumbLength(Scrollbar& scrollbar)
+{
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+    int minThumbLength = 0;
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.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);
+#else
+    gtk_style_context_get_style(styleContext.get(), "min-slider-length", &minThumbLength, nullptr);
+#endif
+    return minThumbLength;
+}
+
+int ScrollbarThemeGtk::thumbFatness(GtkStyleContext* styleContext, ScrollbarOrientation orientation)
+{
+    int thumbFat = 0;
+#if GTK_CHECK_VERSION(3, 19, 11)
+    gtk_style_context_get(styleContext, gtk_style_context_get_state(styleContext),
+        orientation == VerticalScrollbar ? "min-width" : "min-height", &thumbFat, nullptr);
+    GtkBorder margin;
+    gtk_style_context_get_margin(styleContext, gtk_style_context_get_state(styleContext), &margin);
+    GtkBorder border;
+    gtk_style_context_get_border(styleContext, gtk_style_context_get_state(styleContext), &border);
+    if (orientation == VerticalScrollbar)
+        thumbFat += margin.left + margin.right + border.left + border.right;
+    else
+        thumbFat += margin.top + margin.bottom + border.top + border.bottom;
+#else
+    UNUSED_PARAM(orientation);
+    gtk_style_context_get_style(styleContext, "slider-width", &thumbFat, nullptr);
+#endif
+    return thumbFat;
+}
+
+int ScrollbarThemeGtk::thumbFatness(Scrollbar& scrollbar)
+{
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.get(), "trough");
+    GRefPtr<GtkStyleContext> sliderStyleContext = createChildStyleContext(troughStyleContext.get(), "slider");
+    return thumbFatness(sliderStyleContext.get(), scrollbar.orientation());
+#else
+    return thumbFatness(styleContext.get(), scrollbar.orientation());
+#endif
+}
+
+void ScrollbarThemeGtk::getTroughBorder(GtkStyleContext* styleContext, GtkBorder* border)
+{
+#if GTK_CHECK_VERSION(3, 19, 11)
+    gtk_style_context_get_border(styleContext, gtk_style_context_get_state(styleContext), border);
+#else
+    int troughBorderWidth = 0;
+    gtk_style_context_get_style(styleContext, "trough-border", &troughBorderWidth, nullptr);
+    border->top = border->bottom = border->left = border->right = troughBorderWidth;
+#endif
+}
+
+void ScrollbarThemeGtk::getTroughBorder(Scrollbar& scrollbar, GtkBorder* border)
+{
+    GRefPtr<GtkStyleContext> styleContext = getOrCreateStyleContext(scrollbar.orientation());
+#if GTK_CHECK_VERSION(3, 19, 11)
+    GRefPtr<GtkStyleContext> troughStyleContext = createChildStyleContext(styleContext.get(), "trough");
+    getTroughBorder(troughStyleContext.get(), border);
+#else
+    getTroughBorder(styleContext.get(), border);
+#endif
+}
+
 #endif // GTK_API_VERSION_2
 
 }

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h (198005 => 198006)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h	2016-03-11 12:08:22 UTC (rev 198005)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/gtk/ScrollbarThemeGtk.h	2016-03-11 12:58:28 UTC (rev 198006)
@@ -66,19 +66,17 @@
     void updateThemeProperties();
     GRefPtr<GtkStyleContext> getOrCreateStyleContext(ScrollbarOrientation = VerticalScrollbar);
 
-    IntSize buttonSize(Scrollbar&);
+    IntSize buttonSize(Scrollbar&, ScrollbarPart);
+    int stepperSize(Scrollbar&, ScrollbarPart);
+    int thumbFatness(Scrollbar&);
+    int thumbFatness(GtkStyleContext*, ScrollbarOrientation = VerticalScrollbar);
+    void getTroughBorder(Scrollbar&, GtkBorder*);
+    void getTroughBorder(GtkStyleContext*, GtkBorder*);
+    int scrollbarThickness(GtkStyleContext*, ScrollbarOrientation = VerticalScrollbar);
+    void getStepperSpacing(Scrollbar&, ScrollbarPart, GtkBorder*);
+    bool troughUnderSteppers(Scrollbar&);
 
-    struct Properties {
-        int thumbFatness;
-        int troughBorderWidth;
-        int stepperSize;
-        int stepperSpacing;
-        gboolean troughUnderSteppers;
-    };
-
     GRefPtr<GtkStyleContext> m_cachedStyleContext;
-    Properties m_cachedProperties;
-    int m_minThumbLength;
     gboolean m_hasForwardButtonStartPart;
     gboolean m_hasForwardButtonEndPart;
     gboolean m_hasBackButtonStartPart;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to