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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 597683007: Revert of Revert of Initial draft - modify ViewportAnchor to know about both inner and outer viewports. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/PinchViewportTest.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 a6c28a74e72c4c6e712e2d07c185f1504890f323..2c51ffb9caffe9832ac8562da29808753c45e904 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -1689,8 +1689,10 @@
ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHandler());
if (shouldAnchorAndRescaleViewport) {
- viewportAnchor.setAnchor(view->visibleContentRect(),
- FloatSize(viewportAnchorXCoord, viewportAnchorYCoord));
+ viewportAnchor.setAnchor(
+ view->visibleContentRect(),
+ visibleRectInDocument(),
+ FloatSize(viewportAnchorXCoord, viewportAnchorYCoord));
}
// FIXME: TextAutosizer does not yet support out-of-process frames.
@@ -1710,13 +1712,31 @@
if (shouldAnchorAndRescaleViewport) {
float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleFactor * minimumPageScaleFactor();
- IntSize scaledViewportSize = newSize;
- scaledViewportSize.scale(1 / newPageScaleFactor);
- setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(scaledViewportSize));
+ newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor);
+
+ FloatSize pinchViewportSize = FloatSize(newSize);
+ pinchViewportSize.scale(1 / newPageScaleFactor);
+
+ IntPoint mainFrameOrigin;
+ FloatPoint pinchViewportOrigin;
+ viewportAnchor.computeOrigins(*view, pinchViewportSize,
+ mainFrameOrigin, pinchViewportOrigin);
+ scrollAndRescaleViewports(newPageScaleFactor, mainFrameOrigin, pinchViewportOrigin);
}
}
sendResizeEventAndRepaint();
+}
+
+IntRect WebViewImpl::visibleRectInDocument() const
+{
+ if (pinchVirtualViewportEnabled()) {
+ // Inner viewport in the document coordinates
+ return enclosedIntRect(page()->frameHost().pinchViewport().visibleRectInDocument());
+ }
+
+ // Outer viewport in the document coordinates
+ return localFrameRootTemporary()->frameView()->visibleContentRect();
}
void WebViewImpl::willEndLiveResize()
@@ -2918,6 +2938,36 @@
return page()->frameHost().pinchViewport().visibleRect().location();
}
+void WebViewImpl::scrollAndRescaleViewports(float scaleFactor,
+ const IntPoint& mainFrameOrigin,
+ const FloatPoint& pinchViewportOrigin)
+{
+ // Old way
+ if (!pinchVirtualViewportEnabled()) {
+ setPageScaleFactor(scaleFactor, mainFrameOrigin);
+ return;
+ }
+
+ if (!page())
+ return;
+
+ if (!mainFrameImpl())
+ return;
+
+ FrameView * view = mainFrameImpl()->frameView();
+ if (!view)
+ return;
+
+ // Order is important: pinch viewport location is clamped based on
+ // main frame scroll position and pinch viewport scale.
+
+ view->setScrollOffset(mainFrameOrigin);
+
+ setPageScaleFactor(scaleFactor);
+
+ page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin);
+}
+
void WebViewImpl::setPageScaleFactor(float scaleFactor)
{
ASSERT(page());
@@ -2959,7 +3009,6 @@
else
page()->setPageScaleFactor(scaleFactor, newScrollOffset);
}
-
float WebViewImpl::deviceScaleFactor() const
{
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698