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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 882683003: Normalize top controls offset to (0, 1), Blink-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 06e1c3efd3a9d6a137123b869811287b1502407b..5112ad5cacdb515248cd5ebbc9375bcb4c802816 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -413,7 +413,9 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_zoomFactorOverride(0)
, m_userGestureObserved(false)
, m_topControlsContentOffset(0)
- , m_topControlsLayoutHeight(0)
+ , m_topControlsHeight(0)
+ , m_topControlsShrinkLayoutSize(true)
+ , m_topControlsOffsetIsNormalized(true)
{
Page::PageClients pageClients;
pageClients.chromeClient = &m_chromeClientImpl;
@@ -1726,7 +1728,17 @@ void WebViewImpl::setTopControlsContentOffset(float offset)
void WebViewImpl::setTopControlsLayoutHeight(float height)
{
- m_topControlsLayoutHeight = height;
+ m_topControlsOffsetIsNormalized = false;
+ setTopControlsHeight(height, true);
+}
+
+void WebViewImpl::setTopControlsHeight(float height, bool topControlsShrinkLayoutSize)
+{
+ if (m_topControlsHeight == height && m_topControlsShrinkLayoutSize == topControlsShrinkLayoutSize)
+ return;
+
+ m_topControlsHeight = height;
+ m_topControlsShrinkLayoutSize = topControlsShrinkLayoutSize;
didUpdateTopControls();
}
@@ -1740,7 +1752,11 @@ void WebViewImpl::didUpdateTopControls()
if (!view)
return;
- float topControlsViewportAdjustment = m_topControlsLayoutHeight - m_topControlsContentOffset;
+ float topControlsViewportAdjustment = 0;
+ if (m_topControlsShrinkLayoutSize)
+ topControlsViewportAdjustment += m_topControlsHeight;
+ topControlsViewportAdjustment -= m_topControlsContentOffset * (m_topControlsOffsetIsNormalized ? m_topControlsHeight : 1);
+
if (!pinchVirtualViewportEnabled()) {
// The viewport bounds were adjusted on the compositor by this much due to top controls. Tell
// the FrameView about it so it can make correct scroll offset clamping decisions during compositor
« Source/web/WebViewImpl.h ('K') | « Source/web/WebViewImpl.h ('k') | public/web/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698