summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/qt
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-11-22 09:09:45 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-11-22 09:10:13 +0100
commit470286ecfe79d59df14944e5b5d34630fc739391 (patch)
tree43983212872e06cebefd2ae474418fa2908ca54c /Source/WebKit2/UIProcess/qt
parent23037105e948c2065da5a937d3a2396b0ff45c1e (diff)
downloadqtwebkit-470286ecfe79d59df14944e5b5d34630fc739391.tar.gz
Imported WebKit commit e89504fa9195b2063b2530961d4b73dd08de3242 (http://svn.webkit.org/repository/webkit/trunk@135485)
Change-Id: I03774e5ac79721c13ffa30d152537a74d0b12e66 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/qt')
-rw-r--r--Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp64
-rw-r--r--Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h1
-rw-r--r--Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp5
3 files changed, 43 insertions, 27 deletions
diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
index a55fd9197..1cf3ae568 100644
--- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
@@ -243,25 +243,23 @@ void PageViewportControllerClientQt::zoomToAreaGestureEnded(const QPointF& touch
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(targetScale, currentScale, 0.01)) {
- // 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_viewportItem->mapRectToWebContent(viewportRect));
- 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(targetScale, m_zoomOutScale, 0.01))
+ // 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 (!m_scaleStack.isEmpty() && fuzzyCompare(targetScale, currentScale, 0.01)) {
+ // 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_viewportItem->mapRectToWebContent(viewportRect));
+ 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 (targetScale < currentScale)
- zoomAction = ZoomOut;
- }
+ } else if (fuzzyCompare(targetScale, m_zoomOutScale, 0.01))
+ zoomAction = ZoomBack;
+ else if (targetScale < currentScale)
+ zoomAction = ZoomOut;
switch (zoomAction) {
case ZoomIn:
@@ -269,11 +267,18 @@ void PageViewportControllerClientQt::zoomToAreaGestureEnded(const QPointF& touch
m_zoomOutScale = targetScale;
break;
case ZoomBack: {
- ScaleStackItem lastScale = m_scaleStack.takeLast();
- targetScale = lastScale.scale;
- // Recalculate endPosition and clamp it according to the new scale.
- endPosition.setY(hotspot.y() - viewportHotspot.y() / targetScale);
- endPosition.setX(lastScale.xPosition);
+ if (m_scaleStack.isEmpty()) {
+ targetScale = m_controller->minimumContentsScale() * m_controller->devicePixelRatio();
+ endPosition.setY(hotspot.y() - viewportHotspot.y() / targetScale);
+ endPosition.setX(0);
+ m_zoomOutScale = 0;
+ } else {
+ ScaleStackItem lastScale = m_scaleStack.takeLast();
+ targetScale = lastScale.scale;
+ // Recalculate endPosition and clamp it according to the new scale.
+ endPosition.setY(hotspot.y() - viewportHotspot.y() / targetScale);
+ endPosition.setX(lastScale.xPosition);
+ }
endPosition = m_controller->clampViewportToContents(endPosition, targetScale);
endVisibleContentRect = QRectF(endPosition, viewportRect.size() / targetScale);
break;
@@ -291,6 +296,12 @@ void PageViewportControllerClientQt::zoomToAreaGestureEnded(const QPointF& touch
animateContentRectVisible(endVisibleContentRect);
}
+void PageViewportControllerClientQt::clearRelativeZoomState()
+{
+ m_zoomOutScale = 0;
+ m_scaleStack.clear();
+}
+
QRectF PageViewportControllerClientQt::nearestValidVisibleContentsRect() const
{
float targetScale = m_controller->innerBoundedViewportScale(m_pageItem->contentsScale());
@@ -314,8 +325,7 @@ void PageViewportControllerClientQt::setViewportPosition(const FloatPoint& conte
void PageViewportControllerClientQt::setContentsScale(float localScale, bool treatAsInitialValue)
{
if (treatAsInitialValue) {
- m_zoomOutScale = 0;
- m_scaleStack.clear();
+ clearRelativeZoomState();
setContentRectVisiblePositionAtScale(QPointF(), localScale);
} else
scaleContent(localScale);
@@ -415,8 +425,7 @@ void PageViewportControllerClientQt::pinchGestureStarted(const QPointF& pinchCen
if (!m_controller->allowsUserScaling())
return;
- m_scaleStack.clear();
- m_zoomOutScale = 0.0;
+ clearRelativeZoomState();
m_controller->suspendContent();
@@ -490,6 +499,7 @@ void PageViewportControllerClientQt::didChangeVisibleContents()
void PageViewportControllerClientQt::didChangeViewportAttributes()
{
+ clearRelativeZoomState();
emit m_viewportItem->experimental()->test()->viewportChanged();
}
diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h
index 6255f9429..687f29193 100644
--- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h
+++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h
@@ -128,6 +128,7 @@ private:
void setContentRectVisiblePositionAtScale(const QPointF& location, qreal itemScale);
void animateContentRectVisible(const QRectF& contentRect);
void scaleContent(qreal itemScale, const QPointF& centerInCSSCoordinates = QPointF());
+ void clearRelativeZoomState();
ScaleAnimation* m_scaleAnimation;
QPointF m_lastPinchCenterInViewportCoordinates;
diff --git a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
index dcc05b947..95f041282 100644
--- a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
@@ -81,6 +81,11 @@ void WebInspectorProxy::platformDetach()
notImplemented();
}
+void WebInspectorProxy::platformAttachAvailabilityChanged(bool)
+{
+ notImplemented();
+}
+
void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
{
notImplemented();