OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 | 1820 |
1821 WebLocalFrameImpl* mainFrame = mainFrameImpl(); | 1821 WebLocalFrameImpl* mainFrame = mainFrameImpl(); |
1822 if (!mainFrame) | 1822 if (!mainFrame) |
1823 return; | 1823 return; |
1824 | 1824 |
1825 FrameView* view = mainFrame->frameView(); | 1825 FrameView* view = mainFrame->frameView(); |
1826 if (!view) | 1826 if (!view) |
1827 return; | 1827 return; |
1828 | 1828 |
1829 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | 1829 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
1830 float topControlsViewportAdjustment = topControls().layoutHeight() - topCont rols().contentOffset(); | |
1831 visualViewport.setTopControlsAdjustment(topControlsViewportAdjustment); | |
1832 | 1830 |
1833 // Shrink the FrameView by the amount that will maintain the aspect-ratio wi th the VisualViewport. | 1831 { |
1834 view->setTopControlsViewportAdjustment(topControlsViewportAdjustment / minim umPageScaleFactor()); | 1832 // This object will save the current visual viewport offset w.r.t. the |
1833 // document and restore it when the object goes out of scope. It's | |
1834 // needed since the top controls adjustment will change the maximum | |
1835 // scroll offset and we may need to reposition them to keep the user's | |
1836 // apparent position unchanged. | |
1837 ResizeViewportAnchor anchor(*view, visualViewport); | |
1838 | |
1839 float topControlsViewportAdjustment = | |
1840 topControls().layoutHeight() - topControls().contentOffset(); | |
1841 visualViewport.setTopControlsAdjustment(topControlsViewportAdjustment); | |
1842 | |
1843 // Since the FrameView is sized to be the visual viewport at minimum | |
1844 // scale, its adjustment must also be scaled by the minimum scale. | |
1845 view->setTopControlsViewportAdjustment( | |
1846 topControlsViewportAdjustment / minimumPageScaleFactor()); | |
1847 | |
1848 // Clamp the scroll offset of each viewport now that their bounds have | |
1849 // changed. We'll try to restore hte saved scroll offset when anchor | |
majidvp
2016/04/01 17:09:36
s/hte/the/
bokan
2016/04/05 17:11:40
Done.
| |
1850 // goes out of scope. | |
1851 visualViewport.clampToBoundaries(); | |
1852 view->setScrollPosition(view->scrollPositionDouble(), ProgrammaticScroll ); | |
majidvp
2016/04/01 17:09:36
Shouldn't this be unnecessary? The anchor sets the
bokan
2016/04/05 17:11:40
But the anchor needs the viewports to be at their
| |
1853 } | |
1835 } | 1854 } |
1836 | 1855 |
1837 TopControls& WebViewImpl::topControls() | 1856 TopControls& WebViewImpl::topControls() |
1838 { | 1857 { |
1839 return page()->frameHost().topControls(); | 1858 return page()->frameHost().topControls(); |
1840 } | 1859 } |
1841 | 1860 |
1842 void WebViewImpl::resizeViewWhileAnchored(FrameView* view) | 1861 void WebViewImpl::resizeViewWhileAnchored(FrameView* view) |
1843 { | 1862 { |
1844 ASSERT(mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()); | 1863 ASSERT(mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()); |
(...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4323 const WebFloatSize& elasticOverscrollDelta, | 4342 const WebFloatSize& elasticOverscrollDelta, |
4324 float pageScaleDelta, | 4343 float pageScaleDelta, |
4325 float topControlsShownRatioDelta) | 4344 float topControlsShownRatioDelta) |
4326 { | 4345 { |
4327 if (!mainFrameImpl()) | 4346 if (!mainFrameImpl()) |
4328 return; | 4347 return; |
4329 FrameView* frameView = mainFrameImpl()->frameView(); | 4348 FrameView* frameView = mainFrameImpl()->frameView(); |
4330 if (!frameView) | 4349 if (!frameView) |
4331 return; | 4350 return; |
4332 | 4351 |
4352 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); | |
4353 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | |
4354 | |
4355 // Store the desired offsets for visual and layout viewports before setting | |
4356 // the top controls ratio since doing so will change the bounds and move the | |
4357 // viewports to keep the offsets valid. The compositor may have already done | |
4358 // that so we don't want to double apply the deltas here. | |
4359 FloatPoint visualViewportOffset = visualViewport.visibleRect().location(); | |
4360 visualViewportOffset.move( | |
4361 visualViewportDelta.width, | |
4362 visualViewportDelta.height); | |
4363 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() | |
4364 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); | |
4365 | |
4333 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta); | 4366 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta); |
4334 | 4367 |
4335 FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visib leRect().location(); | |
4336 visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.hei ght); | |
4337 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView portOffset); | 4368 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView portOffset); |
4338 | 4369 |
4339 if (pageScaleDelta != 1) { | 4370 if (pageScaleDelta != 1) { |
4340 m_doubleTapZoomPending = false; | 4371 m_doubleTapZoomPending = false; |
4341 page()->frameHost().visualViewport().userDidChangeScale(); | 4372 visualViewport.userDidChangeScale(); |
4342 } | 4373 } |
4343 | 4374 |
4344 m_elasticOverscroll += elasticOverscrollDelta; | 4375 m_elasticOverscroll += elasticOverscrollDelta; |
4345 frameView->didUpdateElasticOverscroll(); | 4376 frameView->didUpdateElasticOverscroll(); |
4346 | 4377 |
4347 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); | |
4348 | |
4349 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() | |
4350 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); | |
4351 | |
4352 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { | 4378 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { |
4353 layoutViewport->setScrollPosition(layoutViewportPosition, CompositorScro ll); | 4379 layoutViewport->setScrollPosition(layoutViewportPosition, CompositorScro ll); |
4354 if (DocumentLoader* documentLoader = mainFrameImpl()->frame()->loader(). documentLoader()) | 4380 if (DocumentLoader* documentLoader = mainFrameImpl()->frame()->loader(). documentLoader()) |
4355 documentLoader->initialScrollState().wasScrolledByUser = true; | 4381 documentLoader->initialScrollState().wasScrolledByUser = true; |
4356 } | 4382 } |
4357 } | 4383 } |
4358 | 4384 |
4359 void WebViewImpl::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t FrameId, const WebVector<WebFrameTimingEvent>& events) | 4385 void WebViewImpl::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t FrameId, const WebVector<WebFrameTimingEvent>& events) |
4360 { | 4386 { |
4361 Frame* frame = m_page ? m_page->mainFrame() : 0; | 4387 Frame* frame = m_page ? m_page->mainFrame() : 0; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4564 { | 4590 { |
4565 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than | 4591 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than |
4566 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4592 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4567 if (!page()) | 4593 if (!page()) |
4568 return 1; | 4594 return 1; |
4569 | 4595 |
4570 return page()->deviceScaleFactor(); | 4596 return page()->deviceScaleFactor(); |
4571 } | 4597 } |
4572 | 4598 |
4573 } // namespace blink | 4599 } // namespace blink |
OLD | NEW |