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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 556703005: 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: ViewportAnchor passes the inner viewport offset relative to outer viewport; fixed bugs 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
« Source/web/ViewportAnchor.cpp ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | 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 a170b30c711d430597a550f8a410233e7b41e766..b9642e142328c4ed749b90f97adf8c4ff0251acb 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -1679,8 +1679,10 @@ void WebViewImpl::resize(const WebSize& newSize)
ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHandler());
if (shouldAnchorAndRescaleViewport) {
- viewportAnchor.setAnchor(view->visibleContentRect(),
- FloatSize(viewportAnchorXCoord, viewportAnchorYCoord));
+ viewportAnchor.setAnchor(
+ localFrameRootTemporary()->frameView()->visibleContentRect(),
bokan 2014/09/12 20:53:07 Just use the local 'view' as before.
timav 2014/09/12 23:33:35 Acknowledged.
timav 2014/09/15 20:04:35 Done.
+ visibleRectInDocument(),
+ FloatSize(viewportAnchorXCoord, viewportAnchorYCoord));
}
// FIXME: TextAutosizer does not yet support out-of-process frames.
@@ -1700,15 +1702,34 @@ void WebViewImpl::resize(const WebSize& newSize)
if (shouldAnchorAndRescaleViewport) {
float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleFactor * minimumPageScaleFactor();
- IntSize scaledViewportSize = newSize;
- scaledViewportSize.scale(1 / newPageScaleFactor);
- setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(scaledViewportSize));
+ newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor);
+
+ IntSize pinchViewportSize = newSize;
+ pinchViewportSize.scale(1 / newPageScaleFactor);
+
+ IntSize mainFrameSize = localFrameRootTemporary()->frameView()->visibleContentRect().size();
bokan 2014/09/12 20:53:07 ditto here, localFrameRootTemporary()->frameView()
timav 2014/09/12 23:33:35 Acknowledged.
timav 2014/09/15 20:04:35 Done.
+
+ IntPoint mainFrameOrigin;
+ FloatPoint pinchViewportOrigin;
+ viewportAnchor.computeOrigins(mainFrameSize, 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()
{
if (mainFrameImpl() && mainFrameImpl()->frameView())
@@ -2897,6 +2918,39 @@ WebFloatPoint WebViewImpl::pinchViewportOffset() const
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.
bokan 2014/09/12 20:53:07 The inner viewport is always set relative to the o
timav 2014/09/12 23:33:35 I think you are right for the outer viewport, i.e.
bokan 2014/09/15 15:36:35 You're right, I misspoke, the scale needs to be ap
timav 2014/09/15 20:04:35 Done.
+
+ // Set outer viewport position.
+ view->setScrollOffset(mainFrameOrigin);
+
+ // Set the scale.
+ setPageScaleFactor(scaleFactor);
+
+ // Set inner viewport position.
+ page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin);
+}
+
void WebViewImpl::setPageScaleFactor(float scaleFactor)
{
ASSERT(page());
@@ -2939,7 +2993,6 @@ void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin)
page()->setPageScaleFactor(scaleFactor, newScrollOffset);
}
-
float WebViewImpl::deviceScaleFactor() const
{
if (!page())
« Source/web/ViewportAnchor.cpp ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698