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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1830 } | 1830 } |
1831 | 1831 |
1832 void WebViewImpl::resizeVisualViewport(const WebSize& newSize) | 1832 void WebViewImpl::resizeVisualViewport(const WebSize& newSize) |
1833 { | 1833 { |
1834 page()->frameHost().visualViewport().setSize(newSize); | 1834 page()->frameHost().visualViewport().setSize(newSize); |
1835 page()->frameHost().visualViewport().clampToBoundaries(); | 1835 page()->frameHost().visualViewport().clampToBoundaries(); |
1836 } | 1836 } |
1837 | 1837 |
1838 void WebViewImpl::performResize() | 1838 void WebViewImpl::performResize() |
1839 { | 1839 { |
1840 pageScaleConstraintsSet().didChangeViewSize(m_size); | 1840 // We'll keep the initial containing block size from changing when the top |
1841 // controls hide so that the ICB will always be the same size as the | |
1842 // viewport with the top controls shown. | |
1843 IntSize ICBSize = m_size; | |
1844 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
| |
1845 ICBSize.expand(0, -topControls().height()); | |
1846 | |
1847 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); | |
1841 | 1848 |
1842 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); | 1849 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); |
1843 updateMainFrameLayoutSize(); | 1850 updateMainFrameLayoutSize(); |
1844 | 1851 |
1845 page()->frameHost().visualViewport().setSize(m_size); | 1852 page()->frameHost().visualViewport().setSize(m_size); |
1846 | 1853 |
1847 if (mainFrameImpl()->frameView()) { | 1854 if (mainFrameImpl()->frameView()) { |
1848 if (!mainFrameImpl()->frameView()->needsLayout()) | 1855 if (!mainFrameImpl()->frameView()->needsLayout()) |
1849 postLayoutResize(mainFrameImpl()); | 1856 postLayoutResize(mainFrameImpl()); |
1850 } | 1857 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1911 { | 1918 { |
1912 if (m_shouldAutoResize || m_size == newSize) | 1919 if (m_shouldAutoResize || m_size == newSize) |
1913 return; | 1920 return; |
1914 | 1921 |
1915 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) { | 1922 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) { |
1916 // Viewport resize for a remote main frame does not require any | 1923 // Viewport resize for a remote main frame does not require any |
1917 // particular action, but the state needs to reflect the correct size | 1924 // particular action, but the state needs to reflect the correct size |
1918 // so that it can be used for initalization if the main frame gets | 1925 // so that it can be used for initalization if the main frame gets |
1919 // swapped to a LocalFrame at a later time. | 1926 // swapped to a LocalFrame at a later time. |
1920 m_size = newSize; | 1927 m_size = newSize; |
1921 pageScaleConstraintsSet().didChangeViewSize(m_size); | 1928 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size); |
1922 page()->frameHost().visualViewport().setSize(m_size); | 1929 page()->frameHost().visualViewport().setSize(m_size); |
1923 return; | 1930 return; |
1924 } | 1931 } |
1925 | 1932 |
1926 WebLocalFrameImpl* mainFrame = mainFrameImpl(); | 1933 WebLocalFrameImpl* mainFrame = mainFrameImpl(); |
1927 if (!mainFrame) | 1934 if (!mainFrame) |
1928 return; | 1935 return; |
1929 | 1936 |
1930 FrameView* view = mainFrame->frameView(); | 1937 FrameView* view = mainFrame->frameView(); |
1931 if (!view) | 1938 if (!view) |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3287 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale; | 3294 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale; |
3288 } else { | 3295 } else { |
3289 constraints.minimumScale = -1; | 3296 constraints.minimumScale = -1; |
3290 constraints.maximumScale = -1; | 3297 constraints.maximumScale = -1; |
3291 } | 3298 } |
3292 page()->frameHost().setUserAgentPageScaleConstraints(constraints); | 3299 page()->frameHost().setUserAgentPageScaleConstraints(constraints); |
3293 } | 3300 } |
3294 | 3301 |
3295 IntSize WebViewImpl::mainFrameSize() | 3302 IntSize WebViewImpl::mainFrameSize() |
3296 { | 3303 { |
3297 return pageScaleConstraintsSet().mainFrameSize(); | 3304 // The frame size should match the viewport size at minimum scale, since the |
3305 // viewport must always be contained by the frame. | |
3306 FloatSize frameSize(m_size); | |
3307 frameSize.scale(1 / minimumPageScaleFactor()); | |
3308 return expandedIntSize(frameSize); | |
3298 } | 3309 } |
3299 | 3310 |
3300 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const | 3311 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const |
3301 { | 3312 { |
3302 return page()->frameHost().pageScaleConstraintsSet(); | 3313 return page()->frameHost().pageScaleConstraintsSet(); |
3303 } | 3314 } |
3304 | 3315 |
3305 void WebViewImpl::refreshPageScaleFactorAfterLayout() | 3316 void WebViewImpl::refreshPageScaleFactorAfterLayout() |
3306 { | 3317 { |
3307 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) | 3318 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) |
3308 return; | 3319 return; |
3309 FrameView* view = page()->deprecatedLocalMainFrame()->view(); | 3320 FrameView* view = page()->deprecatedLocalMainFrame()->view(); |
3321 Document* document = mainFrameImpl()->frame()->document(); | |
3310 | 3322 |
3311 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); | 3323 float oldMinimumPSF = minimumPageScaleFactor(); |
3324 | |
3325 updatePageDefinedViewportConstraints(document->viewportDescription()); | |
3312 pageScaleConstraintsSet().computeFinalConstraints(); | 3326 pageScaleConstraintsSet().computeFinalConstraints(); |
3313 | 3327 |
3328 // If the minimum page scale factor changed, the amount we add to the layout | |
3329 // size due to top controls for viewport units will also have changed. i.e. | |
3330 // For 100vh we need to add the top controls to the layout size but the | |
3331 // top controls height is scaled so that at minimum scale, 100vh covers | |
3332 // exactly the viewport height with top controls hidden. | |
3333 if (topControls().height() && oldMinimumPSF != minimumPageScaleFactor()) { | |
3334 if (document->isActive()) | |
3335 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
| |
3336 } | |
3337 | |
3314 int verticalScrollbarWidth = 0; | 3338 int verticalScrollbarWidth = 0; |
3315 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll bar()) | 3339 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScroll bar()) |
3316 verticalScrollbarWidth = view->verticalScrollbar()->width(); | 3340 verticalScrollbarWidth = view->verticalScrollbar()->width(); |
3317 pageScaleConstraintsSet().adjustFinalConstraintsToContentsSize(contentsSize( ), verticalScrollbarWidth, settings()->shrinksViewportContentToFit()); | 3341 pageScaleConstraintsSet().adjustFinalConstraintsToContentsSize(contentsSize( ), verticalScrollbarWidth, settings()->shrinksViewportContentToFit()); |
3318 | 3342 |
3319 float newPageScaleFactor = pageScaleFactor(); | 3343 float newPageScaleFactor = pageScaleFactor(); |
3320 if (pageScaleConstraintsSet().needsReset() && pageScaleConstraintsSet().fina lConstraints().initialScale != -1) { | 3344 if (pageScaleConstraintsSet().needsReset() && pageScaleConstraintsSet().fina lConstraints().initialScale != -1) { |
3321 newPageScaleFactor = pageScaleConstraintsSet().finalConstraints().initia lScale; | 3345 newPageScaleFactor = pageScaleConstraintsSet().finalConstraints().initia lScale; |
3322 pageScaleConstraintsSet().setNeedsReset(false); | 3346 pageScaleConstraintsSet().setNeedsReset(false); |
3323 } | 3347 } |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4090 LocalFrame* frame = webframe->frame(); | 4114 LocalFrame* frame = webframe->frame(); |
4091 if (!m_client || !frame->isLocalRoot()) | 4115 if (!m_client || !frame->isLocalRoot()) |
4092 return; | 4116 return; |
4093 | 4117 |
4094 if (m_shouldAutoResize) { | 4118 if (m_shouldAutoResize) { |
4095 WebSize frameSize = frame->view()->frameRect().size(); | 4119 WebSize frameSize = frame->view()->frameRect().size(); |
4096 if (frameSize != m_size) { | 4120 if (frameSize != m_size) { |
4097 m_size = frameSize; | 4121 m_size = frameSize; |
4098 | 4122 |
4099 page()->frameHost().visualViewport().setSize(m_size); | 4123 page()->frameHost().visualViewport().setSize(m_size); |
4100 pageScaleConstraintsSet().didChangeViewSize(m_size); | 4124 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size ); |
4101 | 4125 |
4102 m_client->didAutoResize(m_size); | 4126 m_client->didAutoResize(m_size); |
4103 sendResizeEventAndRepaint(); | 4127 sendResizeEventAndRepaint(); |
4104 } | 4128 } |
4105 } | 4129 } |
4106 | 4130 |
4107 if (pageScaleConstraintsSet().constraintsDirty()) | 4131 if (pageScaleConstraintsSet().constraintsDirty()) |
4108 refreshPageScaleFactorAfterLayout(); | 4132 refreshPageScaleFactorAfterLayout(); |
4109 | 4133 |
4110 FrameView* view = webframe->frame()->view(); | 4134 FrameView* view = webframe->frame()->view(); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4622 { | 4646 { |
4623 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than | 4647 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than |
4624 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4648 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4625 if (!page()) | 4649 if (!page()) |
4626 return 1; | 4650 return 1; |
4627 | 4651 |
4628 return page()->deviceScaleFactor(); | 4652 return page()->deviceScaleFactor(); |
4629 } | 4653 } |
4630 | 4654 |
4631 } // namespace blink | 4655 } // namespace blink |
OLD | NEW |