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

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

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