| Index: Source/web/WebViewImpl.cpp
|
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
|
| index 06e1c3efd3a9d6a137123b869811287b1502407b..9215cbb8b3051a79e853a3332cde156d6d96001c 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
|
| @@ -1756,13 +1772,13 @@ void WebViewImpl::didUpdateTopControls()
|
|
|
| // On ChromeOS the pinch viewport can change size independent of the layout viewport due to the
|
| // on screen keyboard so we should only set the FrameView adjustment on Android.
|
| -#if OS(ANDROID)
|
| - // Shrink the FrameView by the amount that will maintain the aspect-ratio with the PinchViewport.
|
| - float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visibleRect().height();
|
| - float newHeight = view->unscaledVisibleContentSize(ExcludeScrollbars).width() / aspectRatio;
|
| - float adjustment = newHeight - view->unscaledVisibleContentSize(ExcludeScrollbars).height();
|
| - view->setTopControlsViewportAdjustment(adjustment);
|
| -#endif
|
| + if (settings() && settings()->mainFrameResizesAreOrientationChanges()) {
|
| + // Shrink the FrameView by the amount that will maintain the aspect-ratio with the PinchViewport.
|
| + float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visibleRect().height();
|
| + float newHeight = view->unscaledVisibleContentSize(ExcludeScrollbars).width() / aspectRatio;
|
| + float adjustment = newHeight - view->unscaledVisibleContentSize(ExcludeScrollbars).height();
|
| + view->setTopControlsViewportAdjustment(adjustment);
|
| + }
|
| }
|
| }
|
|
|
|
|