Title: [205957] releases/WebKitGTK/webkit-2.14/Source/WebCore
Revision
205957
Author
carlo...@webkit.org
Date
2016-09-15 01:00:45 -0700 (Thu, 15 Sep 2016)

Log Message

Merge r205853 - [GTK] Scrollbar  too large
https://bugs.webkit.org/show_bug.cgi?id=161735

Reviewed by Michael Catanzaro.

We were not calculating the total scrollbar size correctly when the theme defines a minimum width/height. In
that case we need to take the extra size into account (border, margin, padding), but not adding the minimum
size. We were also adjusting the thumb position when rendering in indicator mode, but we really need to adjust
the whole rectangle. This worked in Adwaita because it uses a transparent track when in indicator mode. We are
also now taking into account the text direction when doing this adjustment for the indicator mode.

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::paint):
(WebCore::ScrollbarThemeGtk::scrollbarThickness):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (205956 => 205957)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-09-15 07:59:10 UTC (rev 205956)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-09-15 08:00:45 UTC (rev 205957)
@@ -1,5 +1,22 @@
 2016-09-12  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK] Scrollbar  too large
+        https://bugs.webkit.org/show_bug.cgi?id=161735
+
+        Reviewed by Michael Catanzaro.
+
+        We were not calculating the total scrollbar size correctly when the theme defines a minimum width/height. In
+        that case we need to take the extra size into account (border, margin, padding), but not adding the minimum
+        size. We were also adjusting the thumb position when rendering in indicator mode, but we really need to adjust
+        the whole rectangle. This worked in Adwaita because it uses a transparent track when in indicator mode. We are
+        also now taking into account the text direction when doing this adjustment for the indicator mode.
+
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::ScrollbarThemeGtk::paint):
+        (WebCore::ScrollbarThemeGtk::scrollbarThickness):
+
+2016-09-12  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Crash of WebProcess on the last WebView disconnect (take two)
         https://bugs.webkit.org/show_bug.cgi?id=161842
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (205956 => 205957)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2016-09-15 07:59:10 UTC (rev 205956)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp	2016-09-15 08:00:45 UTC (rev 205957)
@@ -476,10 +476,12 @@
     if (!rect.intersects(damageRect))
         return true;
 
+    bool scrollbarOnLeft = scrollbar.scrollableArea().shouldPlaceBlockDirectionScrollbarOnLeft();
+
     RenderThemeGadget::Info info = { RenderThemeGadget::Type::Scrollbar, "scrollbar", scrollbarPartStateFlags(scrollbar, AllParts, true), { } };
     if (scrollbar.orientation() == VerticalScrollbar) {
         info.classList.append("vertical");
-        info.classList.append("right");
+        info.classList.append(scrollbarOnLeft ? "left" : "right");
     } else {
         info.classList.append("horizontal");
         info.classList.append("bottom");
@@ -525,6 +527,33 @@
         children, scrollbarGadget.get());
     RenderThemeGadget* troughGadget = contentsGadget->child(troughPosition);
 
+    IntSize preferredSize = contentsGadget->preferredSize();
+    std::unique_ptr<RenderThemeGadget> sliderGadget;
+    int thumbSize = thumbLength(scrollbar);
+    if (thumbSize) {
+        info.name = "slider";
+        info.state = scrollbarPartStateFlags(scrollbar, ThumbPart);
+        sliderGadget = RenderThemeGadget::create(info, troughGadget);
+        preferredSize = preferredSize.expandedTo(sliderGadget->preferredSize());
+    }
+    preferredSize += scrollbarGadget->preferredSize() - scrollbarGadget->minimumSize();
+
+    FloatRect contentsRect(rect);
+    // When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when
+    // drawing the indicator we need to adjust the rectangle to its actual size in indicator mode.
+    if (scrollbar.orientation() == VerticalScrollbar) {
+        if (rect.width() != preferredSize.width()) {
+            if (!scrollbarOnLeft)
+                contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0);
+            contentsRect.setWidth(preferredSize.width());
+        }
+    } else {
+        if (rect.height() != preferredSize.height()) {
+            contentsRect.move(0, std::abs(rect.height() - preferredSize.height()));
+            contentsRect.setHeight(preferredSize.height());
+        }
+    }
+
     if (opacity != 1) {
         graphicsContext.save();
         graphicsContext.clip(damageRect);
@@ -531,8 +560,7 @@
         graphicsContext.beginTransparencyLayer(opacity);
     }
 
-    FloatRect contentsRect;
-    scrollbarGadget->render(graphicsContext.platformContext()->cr(), rect, &contentsRect);
+    scrollbarGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect);
     contentsGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect);
 
     if (steppers.contains(RenderThemeScrollbarGadget::Steppers::Backward)) {
@@ -606,25 +634,15 @@
     }
 
     troughGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect);
-
-    if (int thumbSize = thumbLength(scrollbar)) {
-        info.name = "slider";
-        info.state = scrollbarPartStateFlags(scrollbar, ThumbPart);
-        auto sliderGadget = RenderThemeGadget::create(info, troughGadget);
-
-        // When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when
-        // drawing the indicator we need to adjust the rectangle to its actual size in indicator mode.
-        bool isIndicator = m_usesOverlayScrollbars && scrollbar.hoveredPart() == NoPart;
+    if (sliderGadget) {
         if (scrollbar.orientation() == VerticalScrollbar) {
-            int sliderWidth = sliderGadget->preferredSize().width();
-            contentsRect.move(isIndicator ? contentsRect.width() - sliderWidth : 0, thumbPosition(scrollbar));
-            contentsRect.setWidth(sliderWidth);
+            contentsRect.move(0, thumbPosition(scrollbar));
+            contentsRect.setWidth(sliderGadget->preferredSize().width());
             contentsRect.setHeight(thumbSize);
         } else {
-            int sliderHeight = sliderGadget->preferredSize().height();
-            contentsRect.move(thumbPosition(scrollbar), isIndicator ? contentsRect.height() - sliderHeight : 0);
+            contentsRect.move(thumbPosition(scrollbar), 0);
             contentsRect.setWidth(thumbSize);
-            contentsRect.setHeight(sliderHeight);
+            contentsRect.setHeight(sliderGadget->preferredSize().height());
         }
         if (contentsRect.intersects(damageRect))
             sliderGadget->render(graphicsContext.platformContext()->cr(), contentsRect);
@@ -850,10 +868,9 @@
     auto contentsGadget = std::make_unique<RenderThemeBoxGadget>(info, GTK_ORIENTATION_VERTICAL, children, scrollbarGadget.get());
     info.name = "slider";
     auto sliderGadget = RenderThemeGadget::create(info, contentsGadget->child(troughPositon));
-    IntSize preferredSize = scrollbarGadget->preferredSize();
     IntSize contentsPreferredSize = contentsGadget->preferredSize();
     contentsPreferredSize = contentsPreferredSize.expandedTo(sliderGadget->preferredSize());
-    preferredSize += contentsPreferredSize;
+    IntSize preferredSize = contentsPreferredSize + scrollbarGadget->preferredSize() - scrollbarGadget->minimumSize();
 
     return preferredSize.width();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to