Fix incorrect scale factor after changing minimized view to fullscreen
authorChanghyup Jwa <ch.jwa@samsung.com>
Fri, 21 Jun 2013 06:53:55 +0000 (15:53 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 21 Oct 2013 05:12:38 +0000 (05:12 +0000)
[Title] Fix incorrect scale factor after changing minimized view to fullscreen
[Issue#] P130615-1169
[Problem] Scale factor is not kept after we change browser mode from minimized
        view to fullscreen mode
[Cause] Scale ratio is not kept properly by several resized callback and
        contents size change
[Solution] Keep scale ratio before triggering update viewport size. And restore
        this properly after viewport resize is done by WebProcess.

Change-Id: Id5b7232b1121d01392cbd1f842cc994eb4901513

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

index 0aa15a3..eb8859f 100755 (executable)
@@ -86,7 +86,7 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
     , m_viewFocused(false)
     , m_viewWindowActive(true)
     , m_pageDidRendered(true)
-    , m_viewportAngle(0)
+    , m_viewResizeCount(0)
     , m_viewportFitsToContent(false)
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     , m_visibleContentRect(IntRect())
@@ -137,8 +137,6 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
     m_autoFillManager = AutoFillManager::create(m_viewImpl);
 #endif
-    Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
-    m_viewportAngle = ecore_evas_rotation_get(ee);
 #endif
 
     setBackgroundColor(1, 1, 1, 1);
@@ -200,8 +198,12 @@ double PageClientImpl::adjustScaleWithViewport(double scale)
 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
 {
+    // save current visible content rect ratio per contents' size
+    m_viewResizeCount++;
+
 #if ENABLE(TIZEN_DLOG_SUPPORT)
-    TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
+    TIZEN_LOGI(" view size: [%d, %d], scale: [%.2f, %.2f, %.2f], resizeCount: [%d]", viewportSize.width(), viewportSize.height(),
+        m_scaleFactor, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale, m_viewResizeCount);
 #endif
 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
     if (m_deferUpdateViewportSize) {
@@ -414,7 +416,12 @@ void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
 
 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
 {
-    double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
+    m_viewResizeCount = max(m_viewResizeCount - 1, 0);
+    if (m_viewResizeCount)
+        return;
+
+    float scaleRatioBeforeResize = m_scaleFactor / m_viewportConstraints.minimumScale;
+
     m_viewportConstraints = computeViewportConstraints(attributes);
 
     // Initially, m_scaleFactor is not decided yet.
@@ -450,7 +457,7 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
 #endif
 
     // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
-    if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
+    if (!canUpdateVisibleContentRect())
         return;
 
     // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
@@ -463,25 +470,19 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
 
     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);
-
-    // if it's rotated, we need to fit content to viewport by minimize the scale
-    if (isRotated) {
-        m_viewportAngle = angle;
-        newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
-        if (m_viewportFitsToContent)
-            newScale = m_viewportConstraints.minimumScale;
-        newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
-    }
+
+    // we need to keep visible content rect after resizing view
+    newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeResize;
+    if (m_viewportFitsToContent)
+        newScale = m_viewportConstraints.minimumScale;
+    newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
 
 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
     if (m_waitFrameOfNewViewortSize)
         ewk_view_resume(m_viewImpl->view());
 #endif
 #if ENABLE(TIZEN_DLOG_SUPPORT)
-    TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
+    TIZEN_LOGI("scroll position: [%d, %d], new scale: [%.2f], ratio: [%.2f], fitted: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, scaleRatioBeforeResize, m_viewportFitsToContent ? "Fitted" : "Not fitted");
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
@@ -734,7 +735,7 @@ void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
 #else
     m_viewImpl->informContentsSizeChange(size);
 #endif
-    if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
+    if (!canUpdateVisibleContentRect())
         return;
 
     // FIXME: Do we really need to adjust visible content rect at here?
@@ -1451,7 +1452,7 @@ bool PageClientImpl::canUpdateVisibleContentRect()
     // Visible content rect can be updated when below conditions are satisfied
     // 1. page render is done(m_pageDidRendered && (m_viewImpl->page()->estimatedProgress())
     // 2. function call count of both updateViewportSize() and didChangeViewportProperties() should be matched
-    return m_pageDidRendered && (m_viewImpl->page()->estimatedProgress() > 0.1);
+    return m_pageDidRendered && (m_viewImpl->page()->estimatedProgress() > 0.1) && !m_viewResizeCount;
 }
 #endif
 
index 2a0dd12..8c78e8d 100755 (executable)
@@ -409,8 +409,9 @@ protected:
 
     bool m_pageDidRendered;
 
-    // Both angle and wasMinimized are added to handle device rotation
-    int m_viewportAngle;
+    // m_viewResizeCount is added to sync updateViewportSize() and didChangeViewportProperties()
+    int m_viewResizeCount;
+    // m_viewportFitsToContent is added to handle scale factor after load finish
     bool m_viewportFitsToContent;
 
     WebCore::IntRect m_focusedNodeRect;