Do not force viewport attributes' minimumScale value
authorChanghyup Jwa <ch.jwa@samsung.com>
Fri, 31 Aug 2012 07:57:46 +0000 (16:57 +0900)
committerChanghyup Jwa <ch.jwa@samsung.com>
Tue, 4 Sep 2012 07:31:37 +0000 (16:31 +0900)
[Title] Do not force viewport attributes' minimumScale value.
[Issue#] N/A
[Problem] Viewport attributes' minimumScale is forced by contents' width.
[Cause] minimumScale is recalculated by contents' width if it exceeds layout width
[Solution] Do not force minimumScale when userScalable is false.

This patch is pre-merged into webkit2-release-0.7
http://slp-info.sec.samsung.net/gerrit/#change,86755

Change-Id: I60c97053b94f486a14e160672c6da611e31a1607

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

index 295a3c4..d4aa812 100755 (executable)
@@ -756,19 +756,26 @@ void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
         drawingArea()->layerTreeHostProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
 #endif
 
-    // If scale factor was fitted to content's width, then minimize new scale factor too.
+    // FIXME: Currently minimum scale is recalculated by contents' width
+    // if contents' width exceeds viewport layout width and userScalable is true.
+    // But we should recalculate this when viewport argument's minimum scale is not fixed.
     double previousMinimumScale = m_viewportConstraints.minimumScale;
+    double minimumScaleByContentWidth = (double)viewSize().width() / size.width();
+    double defaultViewLevel = m_page->pageGroup()->preferences()->defaultViewLevel();
+
+    // If contents width exceeds viewport layout width and content is userScalable,
+    // update minimumScale.
+    if (m_viewportConstraints.userScalable && previousMinimumScale > minimumScaleByContentWidth)
+        m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
 
-    // If contents width exceeds viewport layout width, update minimumScale.
-    m_viewportConstraints.minimumScale = (float)viewSize().width() / size.width();
+    // If scale factor was minimized, then minimize new scale factor too.
+    double newScaleFactor = scaleFactor();
+    if (scaleFactor() == previousMinimumScale && m_viewportConstraints.userScalable && !defaultViewLevel)
+        newScaleFactor = m_viewportConstraints.minimumScale;
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
-    if (scaleFactor() == previousMinimumScale)
-        setVisibleContentRect(scrollPosition(), m_viewportConstraints.minimumScale, FloatPoint());
-    else
-        setVisibleContentRect(scrollPosition(), scaleFactor(), FloatPoint());
+    setVisibleContentRect(m_page->scrollPosition(), newScaleFactor, FloatPoint());
 #else
-    if (m_requestedScaleFactor == previousMinimumScale)
-        m_page->scalePage(m_viewportConstraints.minimumScale, scrollPosition());
+    m_page->scalePage(newScaleFactor, scrollPosition());
 #endif
     // After contents size is changed, update scroll bar.
     displayViewport();