Fix miscalculation of the overhang area used for painting. We were
not correctly accounting for scrollbars resulting in an non-negative
overhang even when we weren't over the edge.
Reviewed by Dan Bernstein.
* platform/ScrollView.cpp:
(WebCore::ScrollView::calculateOverhangAreasForPainting):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index fb54d77..116167e 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -896,7 +896,7 @@
IntRect verticalOverhangRect;
calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRect);
- if (!horizontalOverhangRect.isEmpty() || !verticalOverhangRect.isEmpty())
+ if (rect.intersects(horizontalOverhangRect) || rect.intersects(verticalOverhangRect))
paintOverhangAreas(context, horizontalOverhangRect, verticalOverhangRect, rect);
// Now paint the scrollbars.
@@ -919,13 +919,17 @@
void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntRect& verticalOverhangRect)
{
+ bool hasOverlayScrollbars = ScrollbarTheme::nativeTheme()->usesOverlayScrollbars();
+ int verticalScrollbarWidth = (verticalScrollbar() && !hasOverlayScrollbars) ? verticalScrollbar()->width() : 0;
+ int horizontalScrollbarHeight = (horizontalScrollbar() && !hasOverlayScrollbars) ? horizontalScrollbar()->height() : 0;
+
if (scrollY() < 0) {
horizontalOverhangRect = frameRect();
horizontalOverhangRect.setHeight(-scrollY());
- } else if (scrollY() > contentsHeight() - visibleContentRect(true).height()) {
- int height = scrollY() - (contentsHeight() - visibleContentRect(true).height());
+ } else if (scrollY() > contentsHeight() - visibleContentRect().height()) {
+ int height = scrollY() - (contentsHeight() - visibleContentRect().height());
horizontalOverhangRect = frameRect();
- horizontalOverhangRect.setY(frameRect().maxY() - height);
+ horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScrollbarHeight);
horizontalOverhangRect.setHeight(height);
}
@@ -937,11 +941,11 @@
verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height());
else
verticalOverhangRect.setY(frameRect().y());
- } else if (scrollX() > contentsWidth() - visibleContentRect(true).width()) {
- int width = scrollX() - (contentsWidth() - visibleContentRect(true).width());
+ } else if (scrollX() > contentsWidth() - visibleContentRect().width()) {
+ int width = scrollX() - (contentsWidth() - visibleContentRect().width());
verticalOverhangRect.setWidth(width);
verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height());
- verticalOverhangRect.setX(frameRect().maxX() - width);
+ verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbarWidth);
if (horizontalOverhangRect.y() == frameRect().y())
verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height());
else