Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2433)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 584833003: Made double-tap zoom work in pinch virtual viewport mode. (Blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix assert Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index c9ca40a569f60048688a9fd98dd7e5f6944bcb0d..98b91e32b3178fba30e4268cf835564db8a63901 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -2967,7 +2967,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
@@ -3026,6 +3029,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());
@@ -3034,7 +3048,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);
@@ -3310,8 +3324,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();
@@ -4230,29 +4244,32 @@ void WebViewImpl::applyViewportDeltas(
float pageScaleDelta,
float topControlsDelta)
{
- // FIXME(bokan): Will be replaced in 3-sided patch once Chromium side is landed.
- applyViewportDeltas(pinchViewportDelta + mainFrameDelta, pageScaleDelta, topControlsDelta);
-}
+ ASSERT(pinchVirtualViewportEnabled());
-void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScaleDelta, float topControlsDelta)
-{
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();
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698