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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp b/third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp
index cf978ab21fb590ff463a40a1f7ad13015fb5dea7..ab77c775162b366b59cf8503a094b68a6e0ab16a 100644
--- a/third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp
+++ b/third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp
@@ -1006,4 +1006,62 @@ TEST_F(BrowserControlsTest,
}
}
+// Ensure that vh units are correct when browser controls are in a locked
+// state. That is, normally we need to add the browser controls height to vh
+// units since 100vh includes the browser controls even if they're hidden while
+// the ICB height does not. When the controls are locked hidden, the ICB size
+// is the full viewport height so there's no need to add the browser controls
+// height. crbug.com/688738.
+TEST_F(BrowserControlsTest, MAYBE(ViewportUnitsWhenControlsLocked)) {
+ // Initialize with the browser controls showing.
+ WebViewImpl* webView = initialize("vh-height.html");
+ webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
+ webView->updateBrowserControlsState(WebBrowserControlsBoth,
+ WebBrowserControlsShown, false);
+ webView->browserControls().setShownRatio(1);
+ webView->updateAllLifecyclePhases();
+
+ ASSERT_EQ(100.f, webView->browserControls().contentOffset());
+ ASSERT_EQ(300, frame()->view()->layoutSize().height());
+
+ Element* absPos = getElementById(WebString::fromUTF8("abs"));
+ Element* fixedPos = getElementById(WebString::fromUTF8("fixed"));
+
+ // Lock the browser controls to hidden.
+ {
+ webView->updateBrowserControlsState(WebBrowserControlsHidden,
+ WebBrowserControlsHidden, false);
+ webView->resizeWithBrowserControls(WebSize(400, 400), 100.f, false);
+ webView->updateAllLifecyclePhases();
+
+ ASSERT_EQ(0.f, webView->browserControls().contentOffset());
+ ASSERT_EQ(400, frame()->view()->layoutSize().height());
+
+ // Make sure we're not adding the browser controls height to the vh units
+ // as when they're locked to hidden, the ICB fills the entire viewport
+ // already.
+ EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
+ EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
+ EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height());
+ }
+
+ // Lock the browser controls to shown. This should cause the vh units to
+ // behave as usual by including the browser controls region in 100vh.
+ {
+ webView->updateBrowserControlsState(WebBrowserControlsShown,
+ WebBrowserControlsShown, false);
+ webView->resizeWithBrowserControls(WebSize(400, 300), 100.f, true);
+ webView->updateAllLifecyclePhases();
+
+ ASSERT_EQ(100.f, webView->browserControls().contentOffset());
+ ASSERT_EQ(300, frame()->view()->layoutSize().height());
+
+ // Make sure we're not adding the browser controls height to the vh units as
+ // when they're locked to hidden, the ICB fills the entire viewport already.
+ EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height());
+ EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height());
+ EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height());
+ }
+}
+
} // namespace blink
« 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