[Qt] Tap-to zoom should navigate when appropiate
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 15:27:07 +0000 (15:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 15:27:07 +0000 (15:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84602

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-04-24
Reviewed by Simon Hausmann.

When a zoomable area is returned and has the same zoom-level as the current,
examine if the using this target would expose currently unexposed parts of
the zoom-target. If it does, pan to that area instead of zooming back.

* UIProcess/qt/QtViewportInteractionEngine.cpp:
(WebKit::QtViewportInteractionEngine::zoomToAreaGestureEnded):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115059 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp

index 29d17d0..768b8ac 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-24  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
+
+        [Qt] Tap-to zoom should navigate when appropiate
+        https://bugs.webkit.org/show_bug.cgi?id=84602
+
+        Reviewed by Simon Hausmann.
+
+        When a zoomable area is returned and has the same zoom-level as the current, 
+        examine if the using this target would expose currently unexposed parts of
+        the zoom-target. If it does, pan to that area instead of zooming back.
+
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::zoomToAreaGestureEnded):
+
 2012-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Add WebKitCookieManager::changed signal to WebKit2 GTK+ API
index 96bb7fe..9b0c6d3 100644 (file)
@@ -387,15 +387,20 @@ void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoi
 
     QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
 
-    enum { ZoomIn, ZoomBack, ZoomOut } zoomAction = ZoomIn;
+    enum { ZoomIn, ZoomBack, ZoomOut, NoZoom } zoomAction = ZoomIn;
 
     if (!m_scaleStack.isEmpty()) {
         // Zoom back out if attempting to scale to the same current scale, or
         // attempting to continue scaling out from the inner most level.
         // Use fuzzy compare with a fixed error to be able to deal with largish differences due to pixel rounding.
         if (fuzzyCompare(endItemScale, currentScale, 0.01)) {
-            // FIXME: Check if we should move the viewport instead of zooming back.
-            zoomAction = ZoomBack;
+            // If moving the viewport would expose more of the targetRect and move at least 40 pixels, update position but do not scale out.
+            QRectF currentContentRect(m_viewport->contentPos() / currentScale, viewportRect.size() / currentScale);
+            QRectF targetIntersection = endVisibleContentRect.intersected(targetArea);
+            if (!currentContentRect.contains(targetIntersection) && (qAbs(endVisibleContentRect.top() - currentContentRect.top()) >= 40 || qAbs(endVisibleContentRect.left() - currentContentRect.left()) >= 40))
+                zoomAction = NoZoom;
+            else
+                zoomAction = ZoomBack;
         } else if (fuzzyCompare(endItemScale, m_zoomOutScale, 0.01))
             zoomAction = ZoomBack;
         else if (endItemScale < currentScale)
@@ -421,6 +426,8 @@ void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoi
             m_scaleStack.removeLast();
         m_zoomOutScale = endItemScale;
         break;
+    case NoZoom:
+        break;
     }
 
     animateItemRectVisible(endVisibleContentRect);