Fix full-page rubber band overhang appearing when gesturing during a slow page load.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 21:44:26 +0000 (21:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 21:44:26 +0000 (21:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68568

Chromium bug: http://code.google.com/p/chromium/issues/detail?id=97243

(This also happens on Safari.)

The problem was that ScrollView::overhangAmount() was returning a full-page overhang due to contentsSize() being 0 briefly during a page load, which was then getting used by ScrollAnimatorChromiumMac.mm to update the overhang on a gesture event. This change makes the relevant logic not return an overhang if the contentsSize() is empty.

Patch by Alexei Svitkine <asvitkine@chromium.org> on 2011-09-26
Reviewed by Adam Barth.

No new tests, since this is highly timing-related.

* platform/ScrollView.cpp:
(WebCore::ScrollView::overhangAmount):
(WebCore::ScrollView::wheelEvent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95997 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp

index 442dab9..0d3d37e 100644 (file)
@@ -1,3 +1,22 @@
+2011-09-26  Alexei Svitkine  <asvitkine@chromium.org>
+
+        Fix full-page rubber band overhang appearing when gesturing during a slow page load.
+        https://bugs.webkit.org/show_bug.cgi?id=68568
+
+        Chromium bug: http://code.google.com/p/chromium/issues/detail?id=97243
+
+        (This also happens on Safari.)
+
+        The problem was that ScrollView::overhangAmount() was returning a full-page overhang due to contentsSize() being 0 briefly during a page load, which was then getting used by ScrollAnimatorChromiumMac.mm to update the overhang on a gesture event. This change makes the relevant logic not return an overhang if the contentsSize() is empty.
+
+        Reviewed by Adam Barth.
+
+        No new tests, since this is highly timing-related.
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::overhangAmount):
+        (WebCore::ScrollView::wheelEvent):
+
 2011-09-26  W. James MacLean  <wjmaclean@chromium.org>
 
         [chromium] Revise zoom animator backend to use full transform instead of just scale.
index 514b52a..fd07a8e 100644 (file)
@@ -411,14 +411,14 @@ IntSize ScrollView::overhangAmount() const
     int physicalScrollY = scrollPosition().y() + m_scrollOrigin.y();
     if (physicalScrollY < 0)
         stretch.setHeight(physicalScrollY);
-    else if (physicalScrollY > contentsHeight() - visibleContentRect().height())
-        stretch.setHeight(physicalScrollY - (contentsHeight() - visibleContentRect().height()));
+    else if (contentsHeight() && physicalScrollY > contentsHeight() - visibleHeight())
+        stretch.setHeight(physicalScrollY - (contentsHeight() - visibleHeight()));
 
     int physicalScrollX = scrollPosition().x() + m_scrollOrigin.x();
     if (physicalScrollX < 0)
         stretch.setWidth(physicalScrollX);
-    else if (physicalScrollX > contentsWidth() - visibleContentRect().width())
-        stretch.setWidth(physicalScrollX - (contentsWidth() - visibleContentRect().width()));
+    else if (contentsWidth() && physicalScrollX > contentsWidth() - visibleWidth())
+        stretch.setWidth(physicalScrollX - (contentsWidth() - visibleWidth()));
 
     return stretch;
 }
@@ -1046,8 +1046,8 @@ void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRe
     if (physicalScrollY < 0) {
         horizontalOverhangRect = frameRect();
         horizontalOverhangRect.setHeight(-physicalScrollY);
-    } else if (physicalScrollY > contentsHeight() - visibleContentRect().height()) {
-        int height = physicalScrollY - (contentsHeight() - visibleContentRect().height());
+    } else if (contentsHeight() && physicalScrollY > contentsHeight() - visibleHeight()) {
+        int height = physicalScrollY - (contentsHeight() - visibleHeight());
         horizontalOverhangRect = frameRect();
         horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScrollbarHeight);
         horizontalOverhangRect.setHeight(height);
@@ -1062,8 +1062,8 @@ void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRe
             verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height());
         else
             verticalOverhangRect.setY(frameRect().y());
-    } else if (physicalScrollX > contentsWidth() - visibleContentRect().width()) {
-        int width = physicalScrollX - (contentsWidth() - visibleContentRect().width());
+    } else if (contentsWidth() && physicalScrollX > contentsWidth() - visibleWidth()) {
+        int width = physicalScrollX - (contentsWidth() - visibleWidth());
         verticalOverhangRect.setWidth(width);
         verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height());
         verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbarWidth);