Enable input field zoom
authorChanghyup Jwa <ch.jwa@samsung.com>
Sun, 9 Sep 2012 07:02:10 +0000 (16:02 +0900)
committerChanghyup Jwa <ch.jwa@samsung.com>
Mon, 10 Sep 2012 04:50:20 +0000 (13:50 +0900)
[Title] Enable input field zoom
[Issue] N/A
[Problem] Input field zoom was not working
[Cause] ewk_view_focused_node_adjust() was not called
[Solution] Call ewk_view_focused_node_adjust() on viewport attributes are
        changed or contents size is changed.

Change-Id: Ic6016dd6c5db90fd4868594fd33682bf307f0a1a

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

index d25619e..fd16ede 100755 (executable)
@@ -307,6 +307,7 @@ void PageClientImpl::initializeScale()
 
 void PageClientImpl::updateScale()
 {
+    double newScale = scaleFactor();
     if (m_layoutAndScaleState == BeforeCommitLoad) {
         // Before commit load, we don't need to update visible content rect.
         // ex) While we navigate from m.mt.co.kr to www.mt.co.kr(desktop),
@@ -316,14 +317,21 @@ void PageClientImpl::updateScale()
         // m_visibleContentRect.location should be set to (0, 0).
         // If location is not (0, 0), user scrolled flag is set to TRUE by calling setVisibleContentRect().
         m_visibleContentRect.setLocation(IntPoint(0, 0));
+        newScale = m_viewportConstraints.initialScale;
+    } else {
+        // if current scale factor exceeds changed viewport constraints' scale range,
+        // re-initialize scale factor with initial scale factor.
+        double adjustedScale = adjustScaleWithViewport(newScale);
+        if (adjustedScale != newScale)
+            newScale = m_viewportConstraints.initialScale;
     }
 
     // We should update scale factor and scroll position even they are not changed.
     // Because, contents size can be changed smaller by IME and visible content rect can be outside of contents boundary.
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
-    setVisibleContentRect(scrollPosition(), m_viewportConstraints.initialScale, FloatPoint());
+    setVisibleContentRect(scrollPosition(), newScale, FloatPoint());
 #else
-    m_page->scalePage(m_viewportConstraints.initialScale, m_page->scrollPosition());
+    m_page->scalePage(newScale, scrollPosition());
 #endif
 }
 
@@ -437,7 +445,8 @@ void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
 {
     m_viewportConstraints = computeViewportConstraints(attributes);
-    updateScale();
+    if (!ewk_view_focused_node_adjust(m_viewWidget))
+        updateScale();
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
     updateTextSelectionHandlesAndContextMenu(true);
@@ -736,6 +745,9 @@ void PageClientImpl::didFinishProgress()
 
 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
 {
+    if (size.isEmpty())
+        return;
+
 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
     IntSize scaledSize = size;
     scaledSize.scale(scaleFactor());
@@ -760,15 +772,20 @@ void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
 
     // If contents width exceeds viewport layout width and content is userScalable,
     // update minimumScale.
-    if (m_viewportConstraints.userScalable && previousMinimumScale > minimumScaleByContentWidth)
+    if (m_viewportConstraints.userScalable)
         m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
 
-    // If scale factor was minimized, then minimize new scale factor too.
+    // If input field zoom worked, we don't need to update current scale factor anymore.
+    if (ewk_view_focused_node_adjust(m_viewWidget))
+        return;
+
+    // If current scale factor was minimized, minimize new scale factor
     double newScaleFactor = scaleFactor();
     if (scaleFactor() == previousMinimumScale && m_viewportConstraints.userScalable && !defaultViewLevel)
         newScaleFactor = m_viewportConstraints.minimumScale;
+
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
-    setVisibleContentRect(m_page->scrollPosition(), newScaleFactor, FloatPoint());
+    setVisibleContentRect(scrollPosition(), newScaleFactor, FloatPoint());
 #else
     m_page->scalePage(newScaleFactor, scrollPosition());
 #endif
@@ -803,6 +820,7 @@ void PageClientImpl::didCommitLoadForMainFrame(bool)
         // ex) During the navigation from http://m.mt.co.kr/new/ to http://www.mt.co.kr(desktop)
         suspendPainting();
         m_layoutAndScaleState = DidCommitLoaded;
+        m_visibleContentRect.setLocation(IntPoint(0, 0));
     }
     return;
 #endif