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

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

Issue 2720743002: vh units shouldn't add controls height when controls are locked to hidden. (Closed)
Patch Set: Created 3 years, 9 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/core/frame/FrameView.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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 visualViewport().clampToBoundaries(); 998 visualViewport().clampToBoundaries();
999 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); 999 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll);
1000 1000
1001 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); 1001 ASSERT_EQ(80.f, webView->browserControls().contentOffset());
1002 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); 1002 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height());
1003 1003
1004 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); 1004 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd));
1005 } 1005 }
1006 } 1006 }
1007 1007
1008 // Ensure that vh units are correct when browser controls are in a locked
1009 // state. That is, normally we need to add the browser controls height to vh
1010 // units since 100vh includes the browser controls even if they're hidden while
1011 // the ICB height does not. When the controls are locked hidden, the ICB size
1012 // is the full viewport height so there's no need to add the browser controls
1013 // height. crbug.com/688738.
1014 TEST_F(BrowserControlsTest, MAYBE(ViewportUnitsWhenControlsLocked)) {
1015 // Initialize with the browser controls showing.
1016 WebViewImpl* webView = initialize("vh-height.html");
1017 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
1018 webView->updateBrowserControlsState(WebBrowserControlsBoth,
1019 WebBrowserControlsShown, false);
1020 webView->browserControls().setShownRatio(1);
1021 webView->updateAllLifecyclePhases();
1022
1023 ASSERT_EQ(100.f, webView->browserControls().contentOffset());
1024 ASSERT_EQ(300, frame()->view()->layoutSize().height());
1025
1026 Element* absPos = getElementById(WebString::fromUTF8("abs"));
1027 Element* fixedPos = getElementById(WebString::fromUTF8("fixed"));
1028
1029 // Lock the browser controls to hidden.
1030 {
1031 webView->updateBrowserControlsState(WebBrowserControlsHidden,
1032 WebBrowserControlsHidden, false);
1033 webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false);
1034 webView->updateAllLifecyclePhases();
1035
1036 ASSERT_EQ(0.f, webView->browserControls().contentOffset());
1037 ASSERT_EQ(400, frame()->view()->layoutSize().height());
1038
1039 // Make sure we're not adding the browser controls height to the vh units
1040 // as when they're locked to hidden, the ICB fills the entire viewport
1041 // already.
1042 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
1043 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
1044 EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height());
1045 }
1046
1047 // Lock the browser controls to shown. This should cause the vh units to
1048 // behave as usual by including the browser controls region in 100vh.
1049 {
1050 webView->updateBrowserControlsState(WebBrowserControlsShown,
1051 WebBrowserControlsShown, false);
1052 webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
1053 webView->updateAllLifecyclePhases();
1054
1055 ASSERT_EQ(100.f, webView->browserControls().contentOffset());
1056 ASSERT_EQ(300, frame()->view()->layoutSize().height());
1057
1058 // Make sure we're not adding the browser controls height to the vh units as
1059 // when they're locked to hidden, the ICB fills the entire viewport already.
1060 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
1061 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
1062 EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height());
1063 }
1064 }
1065
1008 } // namespace blink 1066 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698