Keep visible content width on rotation
authorChanghyup Jwa <ch.jwa@samsung.com>
Mon, 3 Jun 2013 07:47:44 +0000 (16:47 +0900)
committerGerrit Code Review <gerrit2@kim11>
Tue, 4 Jun 2013 08:12:58 +0000 (17:12 +0900)
[Title] Keep visible content width on rotation
[Issue#] N_SE-39623
[Problem] Scale factor is not kept after device rotation from portrait to
        landscape and getting back to portrait
[Cause] Webkit just keep current scale factor, not visible content width
[Solution] Keep visible content width on rotation

Change-Id: I81a25acee942539e5428461a98a0214fa6171ff1

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp

index c2c0902..ad113e8 100755 (executable)
@@ -367,6 +367,7 @@ void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
 
 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
 {
+    double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
     m_viewportConstraints = computeViewportConstraints(attributes);
 
     // if content is reloaded, contents size will not be changed
@@ -387,6 +388,7 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
         return;
 
     float newScale = scaleFactor();
+    IntPoint newScrollPosition = m_visibleContentRect.location();
     Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
     int angle = ecore_evas_rotation_get(ee);
     bool isRotated = (angle != m_viewportAngle);
@@ -394,8 +396,8 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
     // if it's rotated, we need to fit content to viewport by minimize the scale
     if (isRotated) {
         m_viewportAngle = angle;
-        if (m_viewportFitsToContent)
-            newScale = m_viewportConstraints.minimumScale;
+        newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
+        newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
     }
 
 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
@@ -404,9 +406,9 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
-    setVisibleContentRect(m_visibleContentRect, newScale);
+    setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
 #else
-    m_viewImpl->page()->scalePage(newScale, m_visibleContentRect.location());
+    m_viewImpl->page()->scalePage(newScale, newScrollPosition);
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)