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

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

Issue 1611693002: Revert of Don't change layout size due to top control show/hide (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We'll keep the initial containing block size from changing when the top 1840 pageScaleConstraintsSet().didChangeViewSize(m_size);
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);
1848 1841
1849 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); 1842 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription());
1850 updateMainFrameLayoutSize(); 1843 updateMainFrameLayoutSize();
1851 1844
1852 page()->frameHost().visualViewport().setSize(m_size); 1845 page()->frameHost().visualViewport().setSize(m_size);
1853 1846
1854 if (mainFrameImpl()->frameView()) { 1847 if (mainFrameImpl()->frameView()) {
1855 if (!mainFrameImpl()->frameView()->needsLayout()) 1848 if (!mainFrameImpl()->frameView()->needsLayout())
1856 postLayoutResize(mainFrameImpl()); 1849 postLayoutResize(mainFrameImpl());
1857 } 1850 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 { 1911 {
1919 if (m_shouldAutoResize || m_size == newSize) 1912 if (m_shouldAutoResize || m_size == newSize)
1920 return; 1913 return;
1921 1914
1922 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) { 1915 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) {
1923 // Viewport resize for a remote main frame does not require any 1916 // Viewport resize for a remote main frame does not require any
1924 // particular action, but the state needs to reflect the correct size 1917 // particular action, but the state needs to reflect the correct size
1925 // so that it can be used for initalization if the main frame gets 1918 // so that it can be used for initalization if the main frame gets
1926 // swapped to a LocalFrame at a later time. 1919 // swapped to a LocalFrame at a later time.
1927 m_size = newSize; 1920 m_size = newSize;
1928 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size); 1921 pageScaleConstraintsSet().didChangeViewSize(m_size);
1929 page()->frameHost().visualViewport().setSize(m_size); 1922 page()->frameHost().visualViewport().setSize(m_size);
1930 return; 1923 return;
1931 } 1924 }
1932 1925
1933 WebLocalFrameImpl* mainFrame = mainFrameImpl(); 1926 WebLocalFrameImpl* mainFrame = mainFrameImpl();
1934 if (!mainFrame) 1927 if (!mainFrame)
1935 return; 1928 return;
1936 1929
1937 FrameView* view = mainFrame->frameView(); 1930 FrameView* view = mainFrame->frameView();
1938 if (!view) 1931 if (!view)
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3297 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale; 3290 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale;
3298 } else { 3291 } else {
3299 constraints.minimumScale = -1; 3292 constraints.minimumScale = -1;
3300 constraints.maximumScale = -1; 3293 constraints.maximumScale = -1;
3301 } 3294 }
3302 page()->frameHost().setUserAgentPageScaleConstraints(constraints); 3295 page()->frameHost().setUserAgentPageScaleConstraints(constraints);
3303 } 3296 }
3304 3297
3305 IntSize WebViewImpl::mainFrameSize() 3298 IntSize WebViewImpl::mainFrameSize()
3306 { 3299 {
3307 // The frame size should match the viewport size at minimum scale, since the 3300 return pageScaleConstraintsSet().mainFrameSize();
3308 // viewport must always be contained by the frame.
3309 FloatSize frameSize(m_size);
3310 frameSize.scale(1 / minimumPageScaleFactor());
3311 return expandedIntSize(frameSize);
3312 } 3301 }
3313 3302
3314 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const 3303 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const
3315 { 3304 {
3316 return page()->frameHost().pageScaleConstraintsSet(); 3305 return page()->frameHost().pageScaleConstraintsSet();
3317 } 3306 }
3318 3307
3319 void WebViewImpl::refreshPageScaleFactorAfterLayout() 3308 void WebViewImpl::refreshPageScaleFactorAfterLayout()
3320 { 3309 {
3321 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) 3310 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view())
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 LocalFrame* frame = webframe->frame(); 4093 LocalFrame* frame = webframe->frame();
4105 if (!m_client || !frame->isLocalRoot()) 4094 if (!m_client || !frame->isLocalRoot())
4106 return; 4095 return;
4107 4096
4108 if (m_shouldAutoResize) { 4097 if (m_shouldAutoResize) {
4109 WebSize frameSize = frame->view()->frameRect().size(); 4098 WebSize frameSize = frame->view()->frameRect().size();
4110 if (frameSize != m_size) { 4099 if (frameSize != m_size) {
4111 m_size = frameSize; 4100 m_size = frameSize;
4112 4101
4113 page()->frameHost().visualViewport().setSize(m_size); 4102 page()->frameHost().visualViewport().setSize(m_size);
4114 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size ); 4103 pageScaleConstraintsSet().didChangeViewSize(m_size);
4115 4104
4116 m_client->didAutoResize(m_size); 4105 m_client->didAutoResize(m_size);
4117 sendResizeEventAndRepaint(); 4106 sendResizeEventAndRepaint();
4118 } 4107 }
4119 } 4108 }
4120 4109
4121 if (pageScaleConstraintsSet().constraintsDirty()) 4110 if (pageScaleConstraintsSet().constraintsDirty())
4122 refreshPageScaleFactorAfterLayout(); 4111 refreshPageScaleFactorAfterLayout();
4123 4112
4124 FrameView* view = webframe->frame()->view(); 4113 FrameView* view = webframe->frame()->view();
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
4639 { 4628 {
4640 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4629 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4641 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4630 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4642 if (!page()) 4631 if (!page())
4643 return 1; 4632 return 1;
4644 4633
4645 return page()->deviceScaleFactor(); 4634 return page()->deviceScaleFactor();
4646 } 4635 }
4647 4636
4648 } // namespace blink 4637 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | third_party/WebKit/Source/web/tests/TopControlsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698