Index: Source/web/WebViewImpl.cpp |
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
index 32ea4c39b4ab1fa813e1725558d86faaaeec4bb4..0d9dde67c749c45200d450039785c420084c0b6a 100644 |
--- a/Source/web/WebViewImpl.cpp |
+++ b/Source/web/WebViewImpl.cpp |
@@ -2914,7 +2914,10 @@ IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) |
if (!view) |
return offset; |
- return view->clampOffsetAtScale(offset, scale); |
+ if (!pinchVirtualViewportEnabled()) |
+ return view->clampOffsetAtScale(offset, scale); |
+ |
+ return page()->frameHost().pinchViewport().clampDocumentOffsetAtScale(offset, scale); |
} |
bool WebViewImpl::pinchVirtualViewportEnabled() const |
@@ -2973,6 +2976,17 @@ void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, |
page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); |
} |
+void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, const FloatPoint& location) |
+{ |
+ ASSERT(pinchVirtualViewportEnabled()); |
+ ASSERT(page()); |
+ |
+ page()->frameHost().pinchViewport().setScaleAndLocation( |
+ clampPageScaleFactorToLimits(scaleFactor), |
+ location); |
+ deviceOrPageScaleFactorChanged(); |
+} |
+ |
void WebViewImpl::setPageScaleFactor(float scaleFactor) |
{ |
ASSERT(page()); |
@@ -2981,7 +2995,7 @@ void WebViewImpl::setPageScaleFactor(float scaleFactor) |
if (scaleFactor == pageScaleFactor()) |
return; |
- // TODO(bokan): Old-style pinch path. Remove when we're migrated to |
+ // FIXME(bokan): Old-style pinch path. Remove when we're migrated to |
// virtual viewport pinch. |
if (!pinchVirtualViewportEnabled()) { |
IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->scrollOffset().height); |
@@ -3257,8 +3271,8 @@ float WebViewImpl::maximumPageScaleFactor() const |
void WebViewImpl::resetScrollAndScaleState() |
{ |
- // TODO: This is done by the pinchViewport().reset() call below and can be removed when |
- // the new pinch path is the only one. |
+ // FIXME(bokan): This is done by the pinchViewport().reset() call below and |
+ // can be removed when the new pinch path is the only one. |
setPageScaleFactor(1); |
updateMainFrameScrollPosition(IntPoint(), true); |
page()->frameHost().pinchViewport().reset(); |
@@ -4193,25 +4207,38 @@ void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition, |
frameView->setInProgrammaticScroll(oldProgrammaticScroll); |
} |
-void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScaleDelta, float topControlsDelta) |
+void WebViewImpl::applyViewportDeltas( |
+ const WebSize& pinchViewportDelta, |
+ const WebSize& mainFrameDelta, |
+ float pageScaleDelta, |
+ float topControlsDelta) |
{ |
+ ASSERT(pinchVirtualViewportEnabled()); |
+ |
if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
return; |
setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); |
- if (pinchVirtualViewportEnabled()) { |
- if (pageScaleDelta != 1) { |
- // When the virtual viewport is enabled, offsets are already set for us. |
- setPageScaleFactor(pageScaleFactor() * pageScaleDelta); |
- m_doubleTapZoomPending = false; |
- } |
+ FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visibleRect().location(); |
+ pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height); |
+ setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewportOffset); |
+ |
+ if (pageScaleDelta != 1) |
+ m_doubleTapZoomPending = false; |
+ IntPoint mainFrameScrollOffset = IntPoint(mainFrame()->scrollOffset()); |
+ mainFrameScrollOffset.move(mainFrameDelta.width, mainFrameDelta.height); |
+ updateMainFrameScrollPosition(mainFrameScrollOffset, false); |
+} |
+ |
+void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScaleDelta, float topControlsDelta) |
+{ |
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
return; |
- } |
- // TODO(bokan): Old pinch path only - virtual viewport pinch scrolls are automatically updated via GraphicsLayer::DidScroll. |
- // this should be removed once old pinch is removed. |
+ setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); |
+ |
if (pageScaleDelta == 1) { |
TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollBy", "x", scrollDelta.width, "y", scrollDelta.height); |
WebSize webScrollOffset = mainFrame()->scrollOffset(); |