Modified: trunk/Source/WebCore/ChangeLog (205852 => 205853)
--- trunk/Source/WebCore/ChangeLog 2016-09-13 06:12:42 UTC (rev 205852)
+++ trunk/Source/WebCore/ChangeLog 2016-09-13 06:15:09 UTC (rev 205853)
@@ -1,5 +1,22 @@
2016-09-12 Carlos Garcia Campos <[email protected]>
+ [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 <[email protected]>
+
[GTK] Crash of WebProcess on the last WebView disconnect (take two)
https://bugs.webkit.org/show_bug.cgi?id=161842
Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (205852 => 205853)
--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-09-13 06:12:42 UTC (rev 205852)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp 2016-09-13 06:15:09 UTC (rev 205853)
@@ -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();
}