Diff
Modified: trunk/Source/WebKit2/ChangeLog (100124 => 100125)
--- trunk/Source/WebKit2/ChangeLog 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-14 11:55:36 UTC (rev 100125)
@@ -1,3 +1,20 @@
+2011-11-10 Kenneth Rohde Christiansen <[email protected]>
+
+ [Qt] the QQuickWebView should support double-tap to zoom
+ https://bugs.webkit.org/show_bug.cgi?id=72030
+
+ Reviewed by Andreas Kling.
+
+ * UIProcess/qt/QtViewInterface.cpp:
+ * UIProcess/qt/QtViewInterface.h:
+ * UIProcess/qt/QtViewportInteractionEngine.cpp:
+ (WebKit::QtViewportInteractionEngine::animateItemRectVisible):
+ (WebKit::QtViewportInteractionEngine::zoomToAreaGestureEnded):
+ (WebKit::QtViewportInteractionEngine::ensureContentWithinViewportBoundary):
+ * UIProcess/qt/QtViewportInteractionEngine.h:
+ * UIProcess/qt/QtWebPageProxy.cpp:
+ (QtWebPageProxy::didFindZoomableArea):
+
2011-11-14 Zalan Bujtas <[email protected]>
Build breaks with --no-_javascript_-debugger --no-inspector
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.cpp (100124 => 100125)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.cpp 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.cpp 2011-11-14 11:55:36 UTC (rev 100125)
@@ -42,10 +42,6 @@
Q_ASSERT(m_pageView);
}
-void QtViewInterface::didFindZoomableArea(const QPoint&, const QRect&)
-{
-}
-
QtSGUpdateQueue* QtViewInterface::sceneGraphUpdateQueue() const
{
return &m_pageView->d->sgUpdateQueue;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.h (100124 => 100125)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.h 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewInterface.h 2011-11-14 11:55:36 UTC (rev 100125)
@@ -75,8 +75,6 @@
virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction*);
virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
- virtual void didFindZoomableArea(const QPoint&, const QRect&);
-
virtual void didChangeUrl(const QUrl&);
virtual void didChangeTitle(const QString&);
virtual void didChangeToolTip(const QString&);
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (100124 => 100125)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-14 11:55:36 UTC (rev 100125)
@@ -143,6 +143,21 @@
m_content->setPos(- itemRect.topLeft() * itemScale);
}
+void QtViewportInteractionEngine::animateItemRectVisible(const QRectF& itemRect)
+{
+ QRectF currentItemRectVisible = m_content->mapRectFromItem(m_viewport, m_viewport->boundingRect());
+ if (itemRect == currentItemRectVisible)
+ return;
+
+ m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
+ m_scaleAnimation->setEasingCurve(QEasingCurve::OutCubic);
+
+ m_scaleAnimation->setStartValue(currentItemRectVisible);
+ m_scaleAnimation->setEndValue(itemRect);
+
+ m_scaleAnimation->start();
+}
+
void QtViewportInteractionEngine::scaleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/)
{
switch (newState) {
@@ -227,6 +242,42 @@
return QRectF(QPointF(0, 0), QSizeF(horizontalRange, verticalRange));
}
+void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoint, const QRectF& targetArea)
+{
+ if (!targetArea.isValid())
+ return;
+
+ if (scrollAnimationActive() || scaleAnimationActive())
+ return;
+
+ const int margin = 10; // We want at least a little bit or margin.
+ QRectF endArea = targetArea.adjusted(-margin, -margin, margin, margin);
+ endArea.setX(endArea.x() * m_constraints.devicePixelRatio);
+ endArea.setY(endArea.y() * m_constraints.devicePixelRatio);
+ endArea.setWidth(endArea.width() * m_constraints.devicePixelRatio);
+ endArea.setHeight(endArea.height() * m_constraints.devicePixelRatio);
+
+ const QRectF viewportRect = m_viewport->boundingRect();
+
+ qreal targetCSSScale = cssScaleFromItem(viewportRect.size().width() / endArea.size().width());
+ qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(qMin(targetCSSScale, qreal(2.5))));
+
+ // 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.
+ const QPointF hotspot = QPointF(endArea.center().x(), touchPoint.y() * m_constraints.devicePixelRatio);
+ const QPointF viewportHotspot = viewportRect.center();
+
+ QPointF endPosition = hotspot * endItemScale - viewportHotspot;
+
+ QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
+ endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
+
+ QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
+
+ animateItemRectVisible(endVisibleContentRect);
+}
+
void QtViewportInteractionEngine::ensureContentWithinViewportBoundary()
{
if (scrollAnimationActive() || scaleAnimationActive())
@@ -248,20 +299,12 @@
QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
- QRectF startVisibleContentRect = m_content->mapRectFromItem(m_viewport, viewportRect);
QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
- if (endVisibleContentRect == startVisibleContentRect)
- return;
-
- if (userHasScaledContent) {
- m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
- m_scaleAnimation->setEasingCurve(QEasingCurve::OutCubic);
- m_scaleAnimation->setStartValue(startVisibleContentRect);
- m_scaleAnimation->setEndValue(endVisibleContentRect);
- m_scaleAnimation->start();
- } else
+ if (!userHasScaledContent)
setItemRectVisible(endVisibleContentRect);
+ else
+ animateItemRectVisible(endVisibleContentRect);
}
void QtViewportInteractionEngine::reset()
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (100124 => 100125)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-14 11:55:36 UTC (rev 100125)
@@ -66,7 +66,9 @@
void reset();
void setConstraints(const Constraints&);
+
void setItemRectVisible(const QRectF&);
+ void animateItemRectVisible(const QRectF&);
void pagePositionRequest(const QPoint& pos);
@@ -87,6 +89,8 @@
void pinchGestureRequestUpdate(const QPointF& pinchCenterInContentCoordinates, qreal totalScaleFactor);
void pinchGestureEnded();
+ void zoomToAreaGestureEnded(const QPointF& touchPoint, const QRectF& endArea);
+
Q_SIGNALS:
void viewportUpdateRequested();
void viewportTrajectoryVectorChanged(const QPointF&);
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (100124 => 100125)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-11-14 11:52:50 UTC (rev 100124)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-11-14 11:55:36 UTC (rev 100125)
@@ -548,7 +548,9 @@
void QtWebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
{
- m_viewInterface->didFindZoomableArea(QPoint(target), QRect(area));
+ // FIXME: As the find method might not respond immediately during load etc,
+ // we should ignore all but the latest request.
+ m_interactionEngine->zoomToAreaGestureEnded(QPointF(target), QRectF(area));
}
void QtWebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& message)