[iOS][WK2] The top/bottom edges should not be sticky when restoring the scroll positi...
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 00:32:33 +0000 (00:32 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 00:32:33 +0000 (00:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132931

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-05-14
Reviewed by Sam Weinig.

The goal of dynamicSizeUpdateHistory is to make dynamic resize completely reversible.
Because of the stick-to-edges heuristics, this was not true near the top and bottom edges.

For example, start in landscape, scroll the page a bit, then rotate to portrait. Now you have
a lot more vertical space, and the top edge of the document is at the edge of the scrollview.
Rotate back to landscape: the position is restored  correct, but it is then overriden by
the stick-to-edges branch.

When we restore the position from history, we should only put it back in the valid bounds, skipping
stick-to-edges entirely.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dynamicViewportSizeUpdate):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 35e0ebb..0eb5b2f 100644 (file)
@@ -1,3 +1,24 @@
+2014-05-14  Benjamin Poulain  <bpoulain@apple.com>
+
+        [iOS][WK2] The top/bottom edges should not be sticky when restoring the scroll position from the dynamic size update history
+        https://bugs.webkit.org/show_bug.cgi?id=132931
+
+        Reviewed by Sam Weinig.
+
+        The goal of dynamicSizeUpdateHistory is to make dynamic resize completely reversible.
+        Because of the stick-to-edges heuristics, this was not true near the top and bottom edges.
+
+        For example, start in landscape, scroll the page a bit, then rotate to portrait. Now you have
+        a lot more vertical space, and the top edge of the document is at the edge of the scrollview.
+        Rotate back to landscape: the position is restored  correct, but it is then overriden by
+        the stick-to-edges branch.
+
+        When we restore the position from history, we should only put it back in the valid bounds, skipping
+        stick-to-edges entirely.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::dynamicViewportSizeUpdate):
+
 2014-05-14  Tim Horton  <timothy_horton@apple.com>
 
         Enable IOSurface view snapshots for 10.9+
index 346200c..8bf8510 100644 (file)
@@ -2002,12 +2002,14 @@ void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, cons
         newUnobscuredContentRect.setWidth(std::min(static_cast<float>(newContentSize.width()), newUnobscuredContentRect.width()));
         newUnobscuredContentRect.setHeight(std::min(static_cast<float>(newContentSize.height()), newUnobscuredContentRect.height()));
 
+        bool positionWasRestoredFromSizeUpdateHistory = false;
         const auto& previousPosition = m_dynamicSizeUpdateHistory.find(std::pair<IntSize, float>(newContentSize, scale));
         if (previousPosition != m_dynamicSizeUpdateHistory.end()) {
             IntPoint restoredPosition = previousPosition->value;
             FloatPoint deltaPosition(restoredPosition.x() - newUnobscuredContentRect.x(), restoredPosition.y() - newUnobscuredContentRect.y());
             newUnobscuredContentRect.moveBy(deltaPosition);
             newExposedContentRect.moveBy(deltaPosition);
+            positionWasRestoredFromSizeUpdateHistory = true;
         } else if (oldContentSize != newContentSize) {
             FloatPoint newRelativeContentCenter;
 
@@ -2030,14 +2032,16 @@ void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, cons
         }
 
         // Make the top/bottom edges "sticky" within 1 pixel.
-        if (targetUnobscuredRect.maxY() > oldContentSize.height() - 1) {
-            float bottomVerticalPosition = newContentSize.height() - newUnobscuredContentRect.height();
-            newUnobscuredContentRect.setY(bottomVerticalPosition);
-            newExposedContentRect.setY(bottomVerticalPosition);
-        }
-        if (targetUnobscuredRect.y() < 1) {
-            newUnobscuredContentRect.setY(0);
-            newExposedContentRect.setY(0);
+        if (!positionWasRestoredFromSizeUpdateHistory) {
+            if (targetUnobscuredRect.maxY() > oldContentSize.height() - 1) {
+                float bottomVerticalPosition = newContentSize.height() - newUnobscuredContentRect.height();
+                newUnobscuredContentRect.setY(bottomVerticalPosition);
+                newExposedContentRect.setY(bottomVerticalPosition);
+            }
+            if (targetUnobscuredRect.y() < 1) {
+                newUnobscuredContentRect.setY(0);
+                newExposedContentRect.setY(0);
+            }
         }
 
         float horizontalAdjustment = 0;