Fix incorrect scroll position adjustment on device rotation
authorChanghyup Jwa <ch.jwa@samsung.com>
Wed, 27 Mar 2013 05:27:07 +0000 (14:27 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 27 Mar 2013 07:53:34 +0000 (16:53 +0900)
[Title] Fix incorrect scroll position adjustment on device rotation
[issue#] N/A
[Problem] Scroll position moved incorrectly on device rotation
[Cause] By patch d7e58608b9d5f779a796e0459a60849079c10faf, scroll position
        is adjusted by constrainsScrollingToContentEdge
[Solution] Disable constrainsScrollingToContentEdge until viewport attibutes
        change handling

Change-Id: Ica53a9a68e4bb6c4ccfa0b436005bddaa745fd13

Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index f0ee7fd..1cd2233 100755 (executable)
@@ -1073,6 +1073,12 @@ void WebPage::sendViewportAttributesChanged()
     // In this case, JS returns incorrect inner size value because scale factor is not updated yet
     // So, we update fixed visible content rect at here.
     // FIXME: scale factor needs to be calculated and set fixed visible content rect
+
+    // if constrainsScrollingToContentEdge is true, scroll position will be adjusted with contents size.
+    // disable this to avoid adjust scroll position on setFixedVisibleContentRect() because contents size is not fixed yet.
+    bool constrainsScrollingToContentEdge = mainFrameView()->constrainsScrollingToContentEdge();
+    mainFrameView()->setConstrainsScrollingToContentEdge(false);
+
     FloatSize contentFixedSize = m_viewportSize;
     contentFixedSize.scale(1 / (attr.initialScale * attr.devicePixelRatio));
     mainFrameView()->setFixedVisibleContentRect(IntRect(mainFrameView()->scrollPosition(), roundedIntSize(contentFixedSize)));
@@ -1089,6 +1095,11 @@ void WebPage::sendViewportAttributesChanged()
 
     setResizesToContentsUsingLayoutSize(IntSize(static_cast<int>(attr.layoutSize.width()), static_cast<int>(attr.layoutSize.height())));
 
+#if ENABLE(TIZEN_VIEWPORT_META_TAG)
+    // recover constrainsScrollingToContentEdge
+    mainFrameView()->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdge);
+#endif
+
     send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
 }