OLD | NEW |
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 Loading... |
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 | |
809 // Ensure that browser controls do not affect vh units. | 729 // Ensure that browser controls do not affect vh units. |
810 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { | 730 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { |
811 // Initialize with the browser controls showing. | 731 // Initialize with the browser controls showing. |
812 WebViewImpl* webView = initialize("vh-height.html"); | 732 WebViewImpl* webView = initialize("vh-height.html"); |
813 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 733 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
814 webView->updateBrowserControlsState(WebBrowserControlsBoth, | 734 webView->updateBrowserControlsState(WebBrowserControlsBoth, |
815 WebBrowserControlsShown, false); | 735 WebBrowserControlsShown, false); |
816 webView->browserControls().setShownRatio(1); | 736 webView->browserControls().setShownRatio(1); |
817 webView->updateAllLifecyclePhases(); | 737 webView->updateAllLifecyclePhases(); |
818 | 738 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); | 919 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); |
1000 | 920 |
1001 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); | 921 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); |
1002 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); | 922 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); |
1003 | 923 |
1004 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); | 924 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); |
1005 } | 925 } |
1006 } | 926 } |
1007 | 927 |
1008 } // namespace blink | 928 } // namespace blink |
OLD | NEW |