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

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1573283002: Don't change layout size due to top control show/hide (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index 30d37eb148d2eb45eed04007a1f343dbf575a529..61b0ee1ddb9f08e8529487f9877dd22ab1422424 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -1837,7 +1837,14 @@ void WebViewImpl::resizeVisualViewport(const WebSize& newSize)
void WebViewImpl::performResize()
{
- pageScaleConstraintsSet().didChangeViewSize(m_size);
+ // We'll keep the initial containing block size from changing when the top
+ // controls hide so that the ICB will always be the same size as the
+ // viewport with the top controls shown.
+ IntSize ICBSize = m_size;
+ if (!topControls().shrinkViewport())
aelias_OOO_until_Jul13 2016/01/16 04:17:38 TopControls::layoutHeight() already includes this
bokan 2016/01/19 00:05:31 It's actually the converse. When the top controls
+ ICBSize.expand(0, -topControls().height());
+
+ pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize);
updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->viewportDescription());
updateMainFrameLayoutSize();
@@ -1918,7 +1925,7 @@ void WebViewImpl::resize(const WebSize& newSize)
// so that it can be used for initalization if the main frame gets
// swapped to a LocalFrame at a later time.
m_size = newSize;
- pageScaleConstraintsSet().didChangeViewSize(m_size);
+ pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size);
page()->frameHost().visualViewport().setSize(m_size);
return;
}
@@ -3294,7 +3301,11 @@ void WebViewImpl::setIgnoreViewportTagScaleLimits(bool ignore)
IntSize WebViewImpl::mainFrameSize()
{
- return pageScaleConstraintsSet().mainFrameSize();
+ // The frame size should match the viewport size at minimum scale, since the
+ // viewport must always be contained by the frame.
+ FloatSize frameSize(m_size);
+ frameSize.scale(1 / minimumPageScaleFactor());
+ return expandedIntSize(frameSize);
}
PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const
@@ -3307,10 +3318,23 @@ void WebViewImpl::refreshPageScaleFactorAfterLayout()
if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->isLocalFrame() || !page()->deprecatedLocalMainFrame()->view())
return;
FrameView* view = page()->deprecatedLocalMainFrame()->view();
+ Document* document = mainFrameImpl()->frame()->document();
- updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->viewportDescription());
+ float oldMinimumPSF = minimumPageScaleFactor();
+
+ updatePageDefinedViewportConstraints(document->viewportDescription());
pageScaleConstraintsSet().computeFinalConstraints();
+ // If the minimum page scale factor changed, the amount we add to the layout
+ // size due to top controls for viewport units will also have changed. i.e.
+ // For 100vh we need to add the top controls to the layout size but the
+ // top controls height is scaled so that at minimum scale, 100vh covers
+ // exactly the viewport height with top controls hidden.
+ if (topControls().height() && oldMinimumPSF != minimumPageScaleFactor()) {
+ if (document->isActive())
+ document->notifyResizeForViewportUnits();
aelias_OOO_until_Jul13 2016/01/16 04:17:38 Likewise a test that fails if this isn't called.
bokan 2016/01/19 00:05:31 This is no longer needed now that I use the layout
+ }
+
int verticalScrollbarWidth = 0;
if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScrollbar())
verticalScrollbarWidth = view->verticalScrollbar()->width();
@@ -4097,7 +4121,7 @@ void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
m_size = frameSize;
page()->frameHost().visualViewport().setSize(m_size);
- pageScaleConstraintsSet().didChangeViewSize(m_size);
+ pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size);
m_client->didAutoResize(m_size);
sendResizeEventAndRepaint();

Powered by Google App Engine
This is Rietveld 408576698