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

Unified Diff: third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp

Issue 2780883002: Correct overlay scrollbar check FrameView::scrollbarExistenceDidChange (Closed)
Patch Set: Rebase 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 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/ScrollbarsTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp b/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp
index a97e23189a1e5c67ac13a5393abe715013f503f2..17e1549b0cb421692ce58d2c55547c2945e53655 100644
--- a/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp
+++ b/third_party/WebKit/Source/web/tests/ScrollbarsTest.cpp
@@ -45,6 +45,65 @@ TEST_F(ScrollbarsTest, DocumentStyleRecalcPreservesScrollbars) {
ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar());
}
+// Ensure that causing a change in scrollbar existence causes a nested layout
+// to recalculate the existence of the opposite scrollbar. The bug here was
+// caused by trying to avoid the layout when overlays are enabled but not
+// checking whether the scrollbars should be custom - which do take up layout
+// space. https://crbug.com/668387.
+TEST_F(ScrollbarsTest, CustomScrollbarsCauseLayoutOnExistenceChange) {
+ // The bug reproduces only with RLS off. When RLS ships we can keep the test
+ // but remove this setting.
+ ScopedRootLayerScrollingForTest turnOffRootLayerScrolling(false);
+
+ // This test is specifically checking the behavior when overlay scrollbars
+ // are enabled.
+ DCHECK(ScrollbarTheme::theme().usesOverlayScrollbars());
+
+ webView().resize(WebSize(800, 600));
+ SimRequest request("https://example.com/test.html", "text/html");
+ loadURL("https://example.com/test.html");
+ request.complete(
+ "<!DOCTYPE html>"
+ "<style>"
+ " ::-webkit-scrollbar {"
+ " height: 16px;"
+ " width: 16px"
+ " }"
+ " ::-webkit-scrollbar-thumb {"
+ " background-color: rgba(0,0,0,.2);"
+ " }"
+ " html, body{"
+ " margin: 0;"
+ " height: 100%;"
+ " }"
+ " .box {"
+ " width: 100%;"
+ " height: 100%;"
+ " }"
+ " .transformed {"
+ " transform: translateY(100px);"
+ " }"
+ "</style>"
+ "<div id='box' class='box'></div>");
+
+ ScrollableArea* layoutViewport =
+ document().view()->layoutViewportScrollableArea();
+
+ compositor().beginFrame();
+ ASSERT_FALSE(layoutViewport->verticalScrollbar());
+ ASSERT_FALSE(layoutViewport->horizontalScrollbar());
+
+ // Adding translation will cause a vertical scrollbar to appear but not dirty
+ // layout otherwise. Ensure the change of scrollbar causes a layout to
+ // recalculate the page width with the vertical scrollbar added.
+ mainFrame().executeScript(WebScriptSource(
+ "document.getElementById('box').className = 'box transformed';"));
+ compositor().beginFrame();
+
+ ASSERT_TRUE(layoutViewport->verticalScrollbar());
+ ASSERT_FALSE(layoutViewport->horizontalScrollbar());
+}
+
typedef bool TestParamOverlayScrollbar;
class ScrollbarAppearanceTest
: public SimTest,
« 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