From f2f064b18c5e94e09095f253b6cfe3b65e4f447f Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 17 Apr 2012 13:14:50 +0000 Subject: [PATCH] [Qt] Zoom out on second double-tap. https://bugs.webkit.org/show_bug.cgi?id=84145 Patch by Allan Sandfeld Jensen 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 | 14 ++++++++++++++ .../WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp | 11 ++++++++++- Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 64ddc57..0a741e8 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,17 @@ +2012-04-17 Allan Sandfeld Jensen + + [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 [EFL][WK2] Fix build break when CONTEXT_MENUS is disabled. diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp index 4b2b2c5..175d7ee 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp +++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp @@ -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)); diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h index 5eb5514..e23d3a5 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h +++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h @@ -145,6 +145,7 @@ private: OwnPtr m_touchUpdateDeferrer; bool m_hadUserInteraction; + bool m_zoomedToArea; class ScaleAnimation : public QVariantAnimation { public: -- 2.7.4