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

Side by Side Diff: third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp

Issue 2663823002: Reland of Use full viewport height for layout if URL bar is locked shown or hidden. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 // Hiding the browser controls shouldn't change the height of the initial 719 // Hiding the browser controls shouldn't change the height of the initial
720 // containing block for non-position: fixed. Position: fixed however should 720 // containing block for non-position: fixed. Position: fixed however should
721 // use the entire height of the viewport however. 721 // use the entire height of the viewport however.
722 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); 722 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height());
723 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); 723 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
724 724
725 // The layout size should not change as a result of browser controls hiding. 725 // The layout size should not change as a result of browser controls hiding.
726 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); 726 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height());
727 } 727 }
728 728
729 // Ensure that browser controls do not affect the layout by showing and hiding
730 // except for position: fixed elements.
731 TEST_F(BrowserControlsTest, MAYBE(AffectLayoutHeightWhenConstrained)) {
732 // Initialize with the browser controls showing.
733 WebViewImpl* webView = initialize("percent-height.html");
734 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
735 webView->updateBrowserControlsState(WebBrowserControlsBoth,
736 WebBrowserControlsShown, false);
737 webView->browserControls().setShownRatio(1);
738 webView->updateAllLifecyclePhases();
739
740 Element* absPos = getElementById(WebString::fromUTF8("abs"));
741 Element* fixedPos = getElementById(WebString::fromUTF8("fixed"));
742
743 ASSERT_EQ(100.f, webView->browserControls().contentOffset());
744
745 // Hide the browser controls.
746 verticalScroll(-100.f);
747 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false);
748 webView->updateAllLifecyclePhases();
749 ASSERT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height());
750
751 // Now lock the controls in a hidden state. The layout and elements should
752 // resize without a WebView::resize.
753 webView->updateBrowserControlsState(WebBrowserControlsHidden,
754 WebBrowserControlsBoth, false);
755
756 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
757 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
758
759 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height());
760
761 // Unlock the controls, the sizes should change even though the controls are
762 // still hidden.
763 webView->updateBrowserControlsState(WebBrowserControlsBoth,
764 WebBrowserControlsBoth, false);
765
766 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height());
767 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
768
769 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height());
770
771 // Now lock the controls in a shown state.
772 webView->updateBrowserControlsState(WebBrowserControlsShown,
773 WebBrowserControlsBoth, false);
774 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
775
776 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height());
777 EXPECT_FLOAT_EQ(150.f, fixedPos->getBoundingClientRect()->height());
778
779 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height());
780
781 // Shown -> Hidden
782 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false);
783 webView->updateBrowserControlsState(WebBrowserControlsHidden,
784 WebBrowserControlsBoth, false);
785
786 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
787 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
788
789 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height());
790
791 // Go from Unlocked and showing, to locked and hidden but issue the resize
792 // before the constraint update to check for race issues.
793 webView->updateBrowserControlsState(WebBrowserControlsBoth,
794 WebBrowserControlsShown, false);
795 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
796 ASSERT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height());
797 webView->updateAllLifecyclePhases();
798
799 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false);
800 webView->updateBrowserControlsState(WebBrowserControlsHidden,
801 WebBrowserControlsHidden, false);
802
803 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
804 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
805
806 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height());
807 }
808
729 // Ensure that browser controls do not affect vh units. 809 // Ensure that browser controls do not affect vh units.
730 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { 810 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) {
731 // Initialize with the browser controls showing. 811 // Initialize with the browser controls showing.
732 WebViewImpl* webView = initialize("vh-height.html"); 812 WebViewImpl* webView = initialize("vh-height.html");
733 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); 813 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
734 webView->updateBrowserControlsState(WebBrowserControlsBoth, 814 webView->updateBrowserControlsState(WebBrowserControlsBoth,
735 WebBrowserControlsShown, false); 815 WebBrowserControlsShown, false);
736 webView->browserControls().setShownRatio(1); 816 webView->browserControls().setShownRatio(1);
737 webView->updateAllLifecyclePhases(); 817 webView->updateAllLifecyclePhases();
738 818
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); 999 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll);
920 1000
921 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); 1001 ASSERT_EQ(80.f, webView->browserControls().contentOffset());
922 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); 1002 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height());
923 1003
924 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); 1004 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd));
925 } 1005 }
926 } 1006 }
927 1007
928 } // namespace blink 1008 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698