Chromium Code Reviews| 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 101b4996b6491be950bf4a55c23d687e70fa289a..06f5e1f29bc40a79e3c990fdbc79d7c8f911cf88 100644 |
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| @@ -1828,11 +1828,6 @@ void WebViewImpl::performResize() |
| } |
| } |
| -void WebViewImpl::setTopControlsHeight(float height, bool topControlsShrinkLayoutSize) |
| -{ |
| - topControls().setHeight(height, topControlsShrinkLayoutSize); |
| -} |
| - |
| void WebViewImpl::updateTopControlsState(WebTopControlsState constraint, WebTopControlsState current, bool animate) |
| { |
| topControls().updateConstraints(constraint); |
| @@ -1856,11 +1851,24 @@ void WebViewImpl::didUpdateTopControls() |
| return; |
| VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
| - float topControlsViewportAdjustment = topControls().layoutHeight() - topControls().contentOffset(); |
| - visualViewport.setTopControlsAdjustment(topControlsViewportAdjustment); |
| - // Shrink the FrameView by the amount that will maintain the aspect-ratio with the VisualViewport. |
| - view->setTopControlsViewportAdjustment(topControlsViewportAdjustment / minimumPageScaleFactor()); |
| + { |
| + // This object will save the current visual viewport offset w.r.t. the |
| + // document and restore it when the object goes out of scope. It's |
| + // needed since the top controls adjustment will change the maximum |
| + // scroll offset and we may need to reposition them to keep the user's |
| + // apparent position unchanged. |
| + ResizeViewportAnchor anchor(*view, visualViewport); |
| + |
| + float topControlsViewportAdjustment = |
| + topControls().layoutHeight() - topControls().contentOffset(); |
| + visualViewport.setTopControlsAdjustment(topControlsViewportAdjustment); |
| + |
| + // Since the FrameView is sized to be the visual viewport at minimum |
| + // scale, its adjustment must also be scaled by the minimum scale. |
| + view->setTopControlsViewportAdjustment( |
| + topControlsViewportAdjustment / minimumPageScaleFactor()); |
| + } |
| } |
| TopControls& WebViewImpl::topControls() |
| @@ -1868,11 +1876,13 @@ TopControls& WebViewImpl::topControls() |
| return page()->frameHost().topControls(); |
| } |
| -void WebViewImpl::resizeViewWhileAnchored(FrameView* view) |
| +void WebViewImpl::resizeViewWhileAnchored(FrameView* view, float topControlsHeight, bool topControlsShrinkLayoutSize) |
| { |
| DCHECK(mainFrameImpl()); |
| DCHECK(mainFrameImpl()->frame()->isLocalFrame()); |
| + topControls().setHeight(topControlsHeight, topControlsShrinkLayoutSize); |
| + |
| { |
| // Avoids unnecessary invalidations while various bits of state in TextAutosizer are updated. |
| TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
| @@ -1886,9 +1896,12 @@ void WebViewImpl::resizeViewWhileAnchored(FrameView* view) |
| updateAllLifecyclePhases(); |
| } |
| -void WebViewImpl::resize(const WebSize& newSize) |
| +void WebViewImpl::resize(const WebSize& newSize, float topControlsHeight, bool topControlsShrinkLayoutSize) |
| { |
| - if (m_shouldAutoResize || m_size == newSize) |
| + if (m_shouldAutoResize |
| + || (m_size == newSize |
| + && topControlsHeight == topControls().height() |
| + && topControlsShrinkLayoutSize == topControls().shrinkViewport())) |
| return; |
| if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) { |
| @@ -1919,14 +1932,19 @@ void WebViewImpl::resize(const WebSize& newSize) |
| FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY); |
| if (isRotation) { |
| RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords, pageScaleConstraintsSet()); |
| - resizeViewWhileAnchored(view); |
| + resizeViewWhileAnchored(view, topControlsHeight, topControlsShrinkLayoutSize); |
| } else { |
| ResizeViewportAnchor anchor(*view, visualViewport); |
| - resizeViewWhileAnchored(view); |
| + resizeViewWhileAnchored(view, topControlsHeight, topControlsShrinkLayoutSize); |
| } |
| sendResizeEventAndRepaint(); |
| } |
| +void WebViewImpl::resize(const WebSize& newSize) |
|
aelias_OOO_until_Jul13
2016/04/07 02:39:54
Does this still need to exist? Can we make all cal
bokan
2016/04/07 02:42:37
Unfortunately, there's lots of WebWidget types tha
aelias_OOO_until_Jul13
2016/04/07 02:50:23
Should the expanded resize() method be defined in
|
| +{ |
| + resize(newSize, topControls().height(), topControls().shrinkViewport()); |
| +} |
| + |
| void WebViewImpl::didEnterFullScreen() |
| { |
| m_fullscreenController->didEnterFullScreen(); |
| @@ -4102,9 +4120,6 @@ void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) |
| if (view->needsLayout()) |
| view->layout(); |
| - // In case we didn't have a size when the top controls were updated. |
| - didUpdateTopControls(); |
| - |
| m_client->didUpdateLayout(); |
| } |
| @@ -4360,25 +4375,32 @@ void WebViewImpl::applyViewportDeltas( |
| if (!frameView) |
| return; |
| + ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); |
| + VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
| + |
| + // Store the desired offsets for visual and layout viewports before setting |
| + // the top controls ratio since doing so will change the bounds and move the |
| + // viewports to keep the offsets valid. The compositor may have already done |
| + // that so we don't want to double apply the deltas here. |
| + FloatPoint visualViewportOffset = visualViewport.visibleRect().location(); |
| + visualViewportOffset.move( |
| + visualViewportDelta.width, |
| + visualViewportDelta.height); |
| + DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() |
| + + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); |
| + |
| topControls().setShownRatio(topControls().shownRatio() + topControlsShownRatioDelta); |
| - FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visibleRect().location(); |
| - visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.height); |
| setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualViewportOffset); |
| if (pageScaleDelta != 1) { |
| m_doubleTapZoomPending = false; |
| - page()->frameHost().visualViewport().userDidChangeScale(); |
| + visualViewport.userDidChangeScale(); |
| } |
| m_elasticOverscroll += elasticOverscrollDelta; |
| frameView->didUpdateElasticOverscroll(); |
| - ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); |
| - |
| - DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() |
| - + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); |
| - |
| if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { |
| layoutViewport->setScrollPosition(layoutViewportPosition, CompositorScroll); |
| if (DocumentLoader* documentLoader = mainFrameImpl()->frame()->loader().documentLoader()) |