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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 405263002: Base new scale on minimum-scale after orientation change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring back contentsSize != 0 check Created 6 years, 5 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 | « no previous file | 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 0b51201eacc6342ef32be2a79747870292683e5f..33e54e8dfd1c71773f0a31c36864a74e9e39d67e 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -1640,15 +1640,13 @@ void WebViewImpl::resize(const WebSize& newSize)
if (!view)
return;
- WebSize oldSize = m_size;
+ bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrientationChanges()
+ && m_size.width && contentsSize().width() && newSize.width != m_size.width && !m_fullscreenController->isFullscreen();
float oldPageScaleFactor = pageScaleFactor();
- int oldContentsWidth = contentsSize().width();
+ float oldMinimumPageScaleFactor = minimumPageScaleFactor();
m_size = newSize;
- bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrientationChanges()
- && oldSize.width && oldContentsWidth && newSize.width != oldSize.width && !m_fullscreenController->isFullscreen();
-
ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHandler());
if (shouldAnchorAndRescaleViewport) {
viewportAnchor.setAnchor(view->visibleContentRect(),
@@ -1671,20 +1669,10 @@ void WebViewImpl::resize(const WebSize& newSize)
view->layout();
if (shouldAnchorAndRescaleViewport) {
- float viewportWidthRatio = static_cast<float>(newSize.width) / oldSize.width;
- float contentsWidthRatio = static_cast<float>(contentsSize().width()) / oldContentsWidth;
- float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
-
- IntSize viewportSize = view->visibleContentRect().size();
- if (scaleMultiplier != 1) {
- float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier;
- viewportSize.scale(pageScaleFactor() / newPageScaleFactor);
- IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(viewportSize);
- setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale);
- } else {
- IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnchor.computeOrigin(viewportSize), pageScaleFactor());
- updateMainFrameScrollPosition(scrollOffsetAtNewScale, false);
- }
+ float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleFactor * minimumPageScaleFactor();
+ IntSize scaledViewportSize = newSize;
+ scaledViewportSize.scale(1 / newPageScaleFactor);
+ setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(scaledViewportSize));
}
}
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698