[Qt] Zoom out on second double-tap.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 13:14:50 +0000 (13:14 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 13:14:50 +0000 (13:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84145

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

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

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

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

index 64ddc57..0a741e8 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-17  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
+
+        [Qt] Zoom out on second double-tap.
+        https://bugs.webkit.org/show_bug.cgi?id=84145
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
+        (WebKit::QtViewportInteractionEngine::zoomToAreaGestureEnded):
+        (WebKit::QtViewportInteractionEngine::pinchGestureStarted):
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        (QtViewportInteractionEngine):
+
 2012-04-17  Mariusz Grzegorczyk  <mariusz.g@samsung.com>
 
         [EFL][WK2] Fix build break when CONTEXT_MENUS is disabled.
index 4b2b2c5..175d7ee 100644 (file)
@@ -125,6 +125,7 @@ QtViewportInteractionEngine::QtViewportInteractionEngine(QQuickWebView* viewport
     , m_suspendCount(0)
     , m_hasSuspendedContent(false)
     , m_hadUserInteraction(false)
+    , m_zoomedToArea(false)
     , m_scaleAnimation(new ScaleAnimation(this))
     , m_pinchStartScale(-1)
 {
@@ -363,7 +364,7 @@ void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoi
     if (scrollAnimationActive() || scaleAnimationActive())
         return;
 
-    const int margin = 10; // We want at least a little bit or margin.
+    const int margin = 10; // We want at least a little bit of margin.
     QRectF endArea = itemRectFromCSS(targetArea.adjusted(-margin, -margin, margin, margin));
 
     const QRectF viewportRect = m_viewport->boundingRect();
@@ -371,6 +372,13 @@ void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoi
     qreal targetCSSScale = cssScaleFromItem(viewportRect.size().width() / endArea.size().width());
     qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(qMin(targetCSSScale, qreal(2.5))));
 
+    // Zoom back out on a second double click, but still center on the new touch point.
+    if (m_zoomedToArea) {
+        m_zoomedToArea = false;
+        endItemScale = 1.0;
+    } else
+        m_zoomedToArea = true;
+
     // We want to end up with the target area filling the whole width of the viewport (if possible),
     // and centralized vertically where the user requested zoom. Thus our hotspot is the center of
     // the targetArea x-wise and the requested zoom position, y-wise.
@@ -525,6 +533,7 @@ void QtViewportInteractionEngine::pinchGestureStarted(const QPointF& pinchCenter
         return;
 
     m_hadUserInteraction = true;
+    m_zoomedToArea = false;
 
     m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this, ViewportUpdateDeferrer::DeferUpdateAndSuspendContent));
 
index 5eb5514..e23d3a5 100644 (file)
@@ -145,6 +145,7 @@ private:
     OwnPtr<ViewportUpdateDeferrer> m_touchUpdateDeferrer;
 
     bool m_hadUserInteraction;
+    bool m_zoomedToArea;
 
     class ScaleAnimation : public QVariantAnimation {
     public: