| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // Hiding the browser controls shouldn't change the height of the initial | 653 // Hiding the browser controls shouldn't change the height of the initial |
| 654 // containing block for non-position: fixed. Position: fixed however should | 654 // containing block for non-position: fixed. Position: fixed however should |
| 655 // use the entire height of the viewport however. | 655 // use the entire height of the viewport however. |
| 656 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); | 656 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); |
| 657 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); | 657 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 658 | 658 |
| 659 // The layout size should not change as a result of browser controls hiding. | 659 // The layout size should not change as a result of browser controls hiding. |
| 660 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); | 660 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 661 } | 661 } |
| 662 | 662 |
| 663 // Ensure that browser controls do not affect the layout by showing and hiding |
| 664 // except for position: fixed elements. |
| 665 TEST_F(BrowserControlsTest, MAYBE(AffectLayoutHeightWhenConstrained)) { |
| 666 // Initialize with the browser controls showing. |
| 667 WebViewImpl* webView = initialize("percent-height.html"); |
| 668 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 669 webView->updateBrowserControlsState(WebBrowserControlsBoth, |
| 670 WebBrowserControlsShown, false); |
| 671 webView->browserControls().setShownRatio(1); |
| 672 webView->updateAllLifecyclePhases(); |
| 673 |
| 674 Element* absPos = getElementById(WebString::fromUTF8("abs")); |
| 675 Element* fixedPos = getElementById(WebString::fromUTF8("fixed")); |
| 676 |
| 677 ASSERT_EQ(100.f, webView->browserControls().contentOffset()); |
| 678 |
| 679 // Hide the browser controls. |
| 680 verticalScroll(-100.f); |
| 681 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false); |
| 682 webView->updateAllLifecyclePhases(); |
| 683 ASSERT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 684 |
| 685 // Now lock the controls in a hidden state. The layout and elements should |
| 686 // resize without a WebView::resize. |
| 687 webView->updateBrowserControlsState(WebBrowserControlsHidden, |
| 688 WebBrowserControlsBoth, false); |
| 689 |
| 690 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height()); |
| 691 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 692 |
| 693 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 694 |
| 695 // Unlock the controls, the sizes should change even though the controls are |
| 696 // still hidden. |
| 697 webView->updateBrowserControlsState(WebBrowserControlsBoth, |
| 698 WebBrowserControlsBoth, false); |
| 699 |
| 700 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); |
| 701 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 702 |
| 703 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 704 |
| 705 // Now lock the controls in a shown state. |
| 706 webView->updateBrowserControlsState(WebBrowserControlsShown, |
| 707 WebBrowserControlsBoth, false); |
| 708 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 709 |
| 710 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); |
| 711 EXPECT_FLOAT_EQ(150.f, fixedPos->getBoundingClientRect()->height()); |
| 712 |
| 713 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 714 |
| 715 // Shown -> Hidden |
| 716 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false); |
| 717 webView->updateBrowserControlsState(WebBrowserControlsHidden, |
| 718 WebBrowserControlsBoth, false); |
| 719 |
| 720 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height()); |
| 721 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 722 |
| 723 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 724 |
| 725 // Go from Unlocked and showing, to locked and hidden but issue the resize |
| 726 // before the constraint update to check for race issues. |
| 727 webView->updateBrowserControlsState(WebBrowserControlsBoth, |
| 728 WebBrowserControlsShown, false); |
| 729 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 730 ASSERT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 731 webView->updateAllLifecyclePhases(); |
| 732 |
| 733 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false); |
| 734 webView->updateBrowserControlsState(WebBrowserControlsHidden, |
| 735 WebBrowserControlsHidden, false); |
| 736 |
| 737 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height()); |
| 738 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 739 |
| 740 EXPECT_EQ(400, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 741 } |
| 742 |
| 663 // Ensure that browser controls do not affect vh units. | 743 // Ensure that browser controls do not affect vh units. |
| 664 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { | 744 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { |
| 665 // Initialize with the browser controls showing. | 745 // Initialize with the browser controls showing. |
| 666 WebViewImpl* webView = initialize("vh-height.html"); | 746 WebViewImpl* webView = initialize("vh-height.html"); |
| 667 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 747 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 668 webView->updateBrowserControlsState(WebBrowserControlsBoth, | 748 webView->updateBrowserControlsState(WebBrowserControlsBoth, |
| 669 WebBrowserControlsShown, false); | 749 WebBrowserControlsShown, false); |
| 670 webView->browserControls().setShownRatio(1); | 750 webView->browserControls().setShownRatio(1); |
| 671 webView->updateAllLifecyclePhases(); | 751 webView->updateAllLifecyclePhases(); |
| 672 | 752 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 view->setScrollOffset(view->scrollOffset(), ProgrammaticScroll); | 932 view->setScrollOffset(view->scrollOffset(), ProgrammaticScroll); |
| 853 | 933 |
| 854 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); | 934 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); |
| 855 EXPECT_EQ(expectedRootOffset, rootViewport->scrollOffset().height()); | 935 EXPECT_EQ(expectedRootOffset, rootViewport->scrollOffset().height()); |
| 856 | 936 |
| 857 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); | 937 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); |
| 858 } | 938 } |
| 859 } | 939 } |
| 860 | 940 |
| 861 } // namespace blink | 941 } // namespace blink |
| OLD | NEW |