Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2623933002: Use full viewport height for layout if URL bar is locked shown or hidden. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 page()->frameHost().visualViewport().setSize(newSize); 1758 page()->frameHost().visualViewport().setSize(newSize);
1759 page()->frameHost().visualViewport().clampToBoundaries(); 1759 page()->frameHost().visualViewport().clampToBoundaries();
1760 } 1760 }
1761 1761
1762 void WebViewImpl::performResize() { 1762 void WebViewImpl::performResize() {
1763 // We'll keep the initial containing block size from changing when the top 1763 // We'll keep the initial containing block size from changing when the top
1764 // controls hide so that the ICB will always be the same size as the 1764 // controls hide so that the ICB will always be the same size as the
1765 // viewport with the browser controls shown. 1765 // viewport with the browser controls shown.
1766 IntSize ICBSize = m_size; 1766 IntSize ICBSize = m_size;
1767 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && 1767 if (RuntimeEnabledFeatures::inertTopControlsEnabled() &&
1768 browserControls().permittedState() == WebBrowserControlsBoth &&
1768 !browserControls().shrinkViewport()) 1769 !browserControls().shrinkViewport())
1769 ICBSize.expand(0, -browserControls().height()); 1770 ICBSize.expand(0, -browserControls().height());
1770 1771
1771 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); 1772 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize);
1772 1773
1773 updatePageDefinedViewportConstraints( 1774 updatePageDefinedViewportConstraints(
1774 mainFrameImpl()->frame()->document()->viewportDescription()); 1775 mainFrameImpl()->frame()->document()->viewportDescription());
1775 updateMainFrameLayoutSize(); 1776 updateMainFrameLayoutSize();
1776 1777
1777 page()->frameHost().visualViewport().setSize(m_size); 1778 page()->frameHost().visualViewport().setSize(m_size);
1778 1779
1779 if (mainFrameImpl()->frameView()) { 1780 if (mainFrameImpl()->frameView()) {
1780 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize); 1781 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize);
1781 if (!mainFrameImpl()->frameView()->needsLayout()) 1782 if (!mainFrameImpl()->frameView()->needsLayout())
1782 postLayoutResize(mainFrameImpl()); 1783 postLayoutResize(mainFrameImpl());
1783 } 1784 }
1784 } 1785 }
1785 1786
1786 void WebViewImpl::updateBrowserControlsState(WebBrowserControlsState constraint, 1787 void WebViewImpl::updateBrowserControlsState(WebBrowserControlsState constraint,
1787 WebBrowserControlsState current, 1788 WebBrowserControlsState current,
1788 bool animate) { 1789 bool animate) {
1790 WebBrowserControlsState oldPermittedState =
1791 browserControls().permittedState();
1792
1789 browserControls().updateConstraintsAndState(constraint, current, animate); 1793 browserControls().updateConstraintsAndState(constraint, current, animate);
1790 1794
1795 // If the controls are going from a locked to an unlocked state, or
1796 // vice-versa, then we need to force a recompute of the ICB size since that
1797 // depends on the permitted browser controls state.
1798 if (oldPermittedState != constraint &&
1799 (oldPermittedState == WebBrowserControlsBoth ||
1800 constraint == WebBrowserControlsBoth)) {
1801 performResize();
1802 }
1803
1791 if (m_layerTreeView) 1804 if (m_layerTreeView)
1792 m_layerTreeView->updateBrowserControlsState(constraint, current, animate); 1805 m_layerTreeView->updateBrowserControlsState(constraint, current, animate);
1793 } 1806 }
1794 1807
1795 void WebViewImpl::didUpdateBrowserControls() { 1808 void WebViewImpl::didUpdateBrowserControls() {
1796 if (m_layerTreeView) { 1809 if (m_layerTreeView) {
1797 m_layerTreeView->setBrowserControlsShownRatio( 1810 m_layerTreeView->setBrowserControlsShownRatio(
1798 browserControls().shownRatio()); 1811 browserControls().shownRatio());
1799 m_layerTreeView->setBrowserControlsHeight( 1812 m_layerTreeView->setBrowserControlsHeight(
1800 browserControls().height(), browserControls().shrinkViewport()); 1813 browserControls().height(), browserControls().shrinkViewport());
(...skipping 26 matching lines...) Expand all
1827 // scale, its adjustment must also be scaled by the minimum scale. 1840 // scale, its adjustment must also be scaled by the minimum scale.
1828 view->setBrowserControlsViewportAdjustment( 1841 view->setBrowserControlsViewportAdjustment(
1829 browserControlsViewportAdjustment / minimumPageScaleFactor()); 1842 browserControlsViewportAdjustment / minimumPageScaleFactor());
1830 } 1843 }
1831 } 1844 }
1832 1845
1833 BrowserControls& WebViewImpl::browserControls() { 1846 BrowserControls& WebViewImpl::browserControls() {
1834 return page()->frameHost().browserControls(); 1847 return page()->frameHost().browserControls();
1835 } 1848 }
1836 1849
1837 void WebViewImpl::resizeViewWhileAnchored(FrameView* view, 1850 void WebViewImpl::resizeViewWhileAnchored(float browserControlsHeight,
1838 float browserControlsHeight,
1839 bool browserControlsShrinkLayout) { 1851 bool browserControlsShrinkLayout) {
1840 DCHECK(mainFrameImpl()); 1852 DCHECK(mainFrameImpl());
1841 1853
1842 browserControls().setHeight(browserControlsHeight, 1854 browserControls().setHeight(browserControlsHeight,
1843 browserControlsShrinkLayout); 1855 browserControlsShrinkLayout);
1844 1856
1845 { 1857 {
1846 // Avoids unnecessary invalidations while various bits of state in 1858 // Avoids unnecessary invalidations while various bits of state in
1847 // TextAutosizer are updated. 1859 // TextAutosizer are updated.
1848 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); 1860 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 bool isRotation = 1904 bool isRotation =
1893 page()->settings().mainFrameResizesAreOrientationChanges() && 1905 page()->settings().mainFrameResizesAreOrientationChanges() &&
1894 m_size.width && contentsSize().width() && newSize.width != m_size.width && 1906 m_size.width && contentsSize().width() && newSize.width != m_size.width &&
1895 !m_fullscreenController->isFullscreen(); 1907 !m_fullscreenController->isFullscreen();
1896 m_size = newSize; 1908 m_size = newSize;
1897 1909
1898 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY); 1910 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY);
1899 if (isRotation) { 1911 if (isRotation) {
1900 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords, 1912 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords,
1901 pageScaleConstraintsSet()); 1913 pageScaleConstraintsSet());
1902 resizeViewWhileAnchored(view, browserControlsHeight, 1914 resizeViewWhileAnchored(browserControlsHeight, browserControlsShrinkLayout);
1903 browserControlsShrinkLayout);
1904 } else { 1915 } else {
1905 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor); 1916 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor);
1906 resizeViewWhileAnchored(view, browserControlsHeight, 1917 resizeViewWhileAnchored(browserControlsHeight, browserControlsShrinkLayout);
1907 browserControlsShrinkLayout);
1908 } 1918 }
1909 sendResizeEventAndRepaint(); 1919 sendResizeEventAndRepaint();
1910 } 1920 }
1911 1921
1912 void WebViewImpl::resize(const WebSize& newSize) { 1922 void WebViewImpl::resize(const WebSize& newSize) {
1913 if (m_shouldAutoResize || m_size == newSize) 1923 if (m_shouldAutoResize || m_size == newSize)
1914 return; 1924 return;
1915 1925
1916 resizeWithBrowserControls(newSize, browserControls().height(), 1926 resizeWithBrowserControls(newSize, browserControls().height(),
1917 browserControls().shrinkViewport()); 1927 browserControls().shrinkViewport());
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
4197 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4207 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4198 return nullptr; 4208 return nullptr;
4199 return focusedFrame; 4209 return focusedFrame;
4200 } 4210 }
4201 4211
4202 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4212 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4203 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4213 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4204 } 4214 }
4205 4215
4206 } // namespace blink 4216 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698