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()) |
| 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3290 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints(
).maximumScale; | 3297 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints(
).maximumScale; |
3291 } else { | 3298 } else { |
3292 constraints.minimumScale = -1; | 3299 constraints.minimumScale = -1; |
3293 constraints.maximumScale = -1; | 3300 constraints.maximumScale = -1; |
3294 } | 3301 } |
3295 page()->frameHost().setUserAgentPageScaleConstraints(constraints); | 3302 page()->frameHost().setUserAgentPageScaleConstraints(constraints); |
3296 } | 3303 } |
3297 | 3304 |
3298 IntSize WebViewImpl::mainFrameSize() | 3305 IntSize WebViewImpl::mainFrameSize() |
3299 { | 3306 { |
3300 return pageScaleConstraintsSet().mainFrameSize(); | 3307 // The frame size should match the viewport size at minimum scale, since the |
| 3308 // viewport must always be contained by the frame. |
| 3309 FloatSize frameSize(m_size); |
| 3310 frameSize.scale(1 / minimumPageScaleFactor()); |
| 3311 return expandedIntSize(frameSize); |
3301 } | 3312 } |
3302 | 3313 |
3303 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const | 3314 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const |
3304 { | 3315 { |
3305 return page()->frameHost().pageScaleConstraintsSet(); | 3316 return page()->frameHost().pageScaleConstraintsSet(); |
3306 } | 3317 } |
3307 | 3318 |
3308 void WebViewImpl::refreshPageScaleFactorAfterLayout() | 3319 void WebViewImpl::refreshPageScaleFactorAfterLayout() |
3309 { | 3320 { |
3310 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()-
>isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) | 3321 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()-
>isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4093 LocalFrame* frame = webframe->frame(); | 4104 LocalFrame* frame = webframe->frame(); |
4094 if (!m_client || !frame->isLocalRoot()) | 4105 if (!m_client || !frame->isLocalRoot()) |
4095 return; | 4106 return; |
4096 | 4107 |
4097 if (m_shouldAutoResize) { | 4108 if (m_shouldAutoResize) { |
4098 WebSize frameSize = frame->view()->frameRect().size(); | 4109 WebSize frameSize = frame->view()->frameRect().size(); |
4099 if (frameSize != m_size) { | 4110 if (frameSize != m_size) { |
4100 m_size = frameSize; | 4111 m_size = frameSize; |
4101 | 4112 |
4102 page()->frameHost().visualViewport().setSize(m_size); | 4113 page()->frameHost().visualViewport().setSize(m_size); |
4103 pageScaleConstraintsSet().didChangeViewSize(m_size); | 4114 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size
); |
4104 | 4115 |
4105 m_client->didAutoResize(m_size); | 4116 m_client->didAutoResize(m_size); |
4106 sendResizeEventAndRepaint(); | 4117 sendResizeEventAndRepaint(); |
4107 } | 4118 } |
4108 } | 4119 } |
4109 | 4120 |
4110 if (pageScaleConstraintsSet().constraintsDirty()) | 4121 if (pageScaleConstraintsSet().constraintsDirty()) |
4111 refreshPageScaleFactorAfterLayout(); | 4122 refreshPageScaleFactorAfterLayout(); |
4112 | 4123 |
4113 FrameView* view = webframe->frame()->view(); | 4124 FrameView* view = webframe->frame()->view(); |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4628 { | 4639 { |
4629 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4640 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
4630 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4641 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4631 if (!page()) | 4642 if (!page()) |
4632 return 1; | 4643 return 1; |
4633 | 4644 |
4634 return page()->deviceScaleFactor(); | 4645 return page()->deviceScaleFactor(); |
4635 } | 4646 } |
4636 | 4647 |
4637 } // namespace blink | 4648 } // namespace blink |
OLD | NEW |