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 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 page()->frameHost().visualViewport().setSize(newSize); | 1771 page()->frameHost().visualViewport().setSize(newSize); |
1772 page()->frameHost().visualViewport().clampToBoundaries(); | 1772 page()->frameHost().visualViewport().clampToBoundaries(); |
1773 } | 1773 } |
1774 | 1774 |
1775 void WebViewImpl::performResize() { | 1775 void WebViewImpl::performResize() { |
1776 // We'll keep the initial containing block size from changing when the top | 1776 // We'll keep the initial containing block size from changing when the top |
1777 // controls hide so that the ICB will always be the same size as the | 1777 // controls hide so that the ICB will always be the same size as the |
1778 // viewport with the browser controls shown. | 1778 // viewport with the browser controls shown. |
1779 IntSize ICBSize = m_size; | 1779 IntSize ICBSize = m_size; |
1780 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && | 1780 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && |
| 1781 browserControls().permittedState() == WebBrowserControlsBoth && |
1781 !browserControls().shrinkViewport()) | 1782 !browserControls().shrinkViewport()) |
1782 ICBSize.expand(0, -browserControls().height()); | 1783 ICBSize.expand(0, -browserControls().height()); |
1783 | 1784 |
1784 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); | 1785 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); |
1785 | 1786 |
1786 updatePageDefinedViewportConstraints( | 1787 updatePageDefinedViewportConstraints( |
1787 mainFrameImpl()->frame()->document()->viewportDescription()); | 1788 mainFrameImpl()->frame()->document()->viewportDescription()); |
1788 updateMainFrameLayoutSize(); | 1789 updateMainFrameLayoutSize(); |
1789 | 1790 |
1790 page()->frameHost().visualViewport().setSize(m_size); | 1791 page()->frameHost().visualViewport().setSize(m_size); |
1791 | 1792 |
1792 if (mainFrameImpl()->frameView()) { | 1793 if (mainFrameImpl()->frameView()) { |
1793 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize); | 1794 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize); |
1794 if (!mainFrameImpl()->frameView()->needsLayout()) | 1795 if (!mainFrameImpl()->frameView()->needsLayout()) |
1795 postLayoutResize(mainFrameImpl()); | 1796 postLayoutResize(mainFrameImpl()); |
1796 } | 1797 } |
1797 } | 1798 } |
1798 | 1799 |
1799 void WebViewImpl::updateBrowserControlsState(WebBrowserControlsState constraint, | 1800 void WebViewImpl::updateBrowserControlsState(WebBrowserControlsState constraint, |
1800 WebBrowserControlsState current, | 1801 WebBrowserControlsState current, |
1801 bool animate) { | 1802 bool animate) { |
| 1803 WebBrowserControlsState oldPermittedState = |
| 1804 browserControls().permittedState(); |
| 1805 |
1802 browserControls().updateConstraintsAndState(constraint, current, animate); | 1806 browserControls().updateConstraintsAndState(constraint, current, animate); |
1803 | 1807 |
| 1808 // If the controls are going from a locked to an unlocked state, or |
| 1809 // vice-versa, then we need to force a recompute of the ICB size since that |
| 1810 // depends on the permitted browser controls state. |
| 1811 if (oldPermittedState != constraint && |
| 1812 (oldPermittedState == WebBrowserControlsBoth || |
| 1813 constraint == WebBrowserControlsBoth)) { |
| 1814 performResize(); |
| 1815 } |
| 1816 |
1804 if (m_layerTreeView) | 1817 if (m_layerTreeView) |
1805 m_layerTreeView->updateBrowserControlsState(constraint, current, animate); | 1818 m_layerTreeView->updateBrowserControlsState(constraint, current, animate); |
1806 } | 1819 } |
1807 | 1820 |
1808 void WebViewImpl::didUpdateBrowserControls() { | 1821 void WebViewImpl::didUpdateBrowserControls() { |
1809 if (m_layerTreeView) { | 1822 if (m_layerTreeView) { |
1810 m_layerTreeView->setBrowserControlsShownRatio( | 1823 m_layerTreeView->setBrowserControlsShownRatio( |
1811 browserControls().shownRatio()); | 1824 browserControls().shownRatio()); |
1812 m_layerTreeView->setBrowserControlsHeight( | 1825 m_layerTreeView->setBrowserControlsHeight( |
1813 browserControls().height(), browserControls().shrinkViewport()); | 1826 browserControls().height(), browserControls().shrinkViewport()); |
(...skipping 26 matching lines...) Expand all Loading... |
1840 // scale, its adjustment must also be scaled by the minimum scale. | 1853 // scale, its adjustment must also be scaled by the minimum scale. |
1841 view->setBrowserControlsViewportAdjustment( | 1854 view->setBrowserControlsViewportAdjustment( |
1842 browserControlsViewportAdjustment / minimumPageScaleFactor()); | 1855 browserControlsViewportAdjustment / minimumPageScaleFactor()); |
1843 } | 1856 } |
1844 } | 1857 } |
1845 | 1858 |
1846 BrowserControls& WebViewImpl::browserControls() { | 1859 BrowserControls& WebViewImpl::browserControls() { |
1847 return page()->frameHost().browserControls(); | 1860 return page()->frameHost().browserControls(); |
1848 } | 1861 } |
1849 | 1862 |
1850 void WebViewImpl::resizeViewWhileAnchored(FrameView* view, | 1863 void WebViewImpl::resizeViewWhileAnchored(float browserControlsHeight, |
1851 float browserControlsHeight, | |
1852 bool browserControlsShrinkLayout) { | 1864 bool browserControlsShrinkLayout) { |
1853 DCHECK(mainFrameImpl()); | 1865 DCHECK(mainFrameImpl()); |
1854 | 1866 |
1855 browserControls().setHeight(browserControlsHeight, | 1867 browserControls().setHeight(browserControlsHeight, |
1856 browserControlsShrinkLayout); | 1868 browserControlsShrinkLayout); |
1857 | 1869 |
1858 { | 1870 { |
1859 // Avoids unnecessary invalidations while various bits of state in | 1871 // Avoids unnecessary invalidations while various bits of state in |
1860 // TextAutosizer are updated. | 1872 // TextAutosizer are updated. |
1861 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1873 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 bool isRotation = | 1917 bool isRotation = |
1906 page()->settings().mainFrameResizesAreOrientationChanges() && | 1918 page()->settings().mainFrameResizesAreOrientationChanges() && |
1907 m_size.width && contentsSize().width() && newSize.width != m_size.width && | 1919 m_size.width && contentsSize().width() && newSize.width != m_size.width && |
1908 !m_fullscreenController->isFullscreen(); | 1920 !m_fullscreenController->isFullscreen(); |
1909 m_size = newSize; | 1921 m_size = newSize; |
1910 | 1922 |
1911 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY); | 1923 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY); |
1912 if (isRotation) { | 1924 if (isRotation) { |
1913 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords, | 1925 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords, |
1914 pageScaleConstraintsSet()); | 1926 pageScaleConstraintsSet()); |
1915 resizeViewWhileAnchored(view, browserControlsHeight, | 1927 resizeViewWhileAnchored(browserControlsHeight, browserControlsShrinkLayout); |
1916 browserControlsShrinkLayout); | |
1917 } else { | 1928 } else { |
1918 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor); | 1929 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor); |
1919 resizeViewWhileAnchored(view, browserControlsHeight, | 1930 resizeViewWhileAnchored(browserControlsHeight, browserControlsShrinkLayout); |
1920 browserControlsShrinkLayout); | |
1921 } | 1931 } |
1922 sendResizeEventAndRepaint(); | 1932 sendResizeEventAndRepaint(); |
1923 } | 1933 } |
1924 | 1934 |
1925 void WebViewImpl::resize(const WebSize& newSize) { | 1935 void WebViewImpl::resize(const WebSize& newSize) { |
1926 if (m_shouldAutoResize || m_size == newSize) | 1936 if (m_shouldAutoResize || m_size == newSize) |
1927 return; | 1937 return; |
1928 | 1938 |
1929 resizeWithBrowserControls(newSize, browserControls().height(), | 1939 resizeWithBrowserControls(newSize, browserControls().height(), |
1930 browserControls().shrinkViewport()); | 1940 browserControls().shrinkViewport()); |
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4202 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4212 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
4203 return nullptr; | 4213 return nullptr; |
4204 return focusedFrame; | 4214 return focusedFrame; |
4205 } | 4215 } |
4206 | 4216 |
4207 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4217 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
4208 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4218 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
4209 } | 4219 } |
4210 | 4220 |
4211 } // namespace blink | 4221 } // namespace blink |
OLD | NEW |