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

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp

Issue 2310223002: Disable scroll anchoring is an element within the scroll changes its in-flow state (Closed)
Patch Set: s\do while\while Created 4 years, 3 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/layout/LayoutObject.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/core/layout/ScrollAnchorTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
index 79344e7269b2a52b4790c98737a5b62d2f0b549f..c75f21c83934872a5b377556f322211094810bb4 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -502,6 +502,57 @@ TEST_F(ScrollAnchorTest, DescendsIntoContainerWithFloat)
scrollAnchor(viewport).anchorObject());
}
+// This test verifies that scroll anchoring is disabled when any element within
+// the main scroller changes its in-flow state.
+TEST_F(ScrollAnchorTest, ChangeInFlowStateDisablesAnchoringForMainScroller)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 1000px; }"
+ " #header { background-color: #F5B335; height: 50px; width: 100%; }"
+ " #content { background-color: #D3D3D3; height: 200px; }"
+ "</style>"
+ "<div id='header'></div>"
+ "<div id='content'></div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(DoubleSize(0, 200));
+
+ document().getElementById("header")->setAttribute(
+ HTMLNames::styleAttr, "position: fixed;");
+ update();
+
+ EXPECT_EQ(200, viewport->scrollPosition().y());
+}
+
+// This test verifies that scroll anchoring is disabled when any element within
+// a scrolling div changes its in-flow state.
+TEST_F(ScrollAnchorTest, ChangeInFlowStateDisablesAnchoringForScrollingDiv)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " #container { position: relative; width: 500px; }"
+ " #scroller { height: 200px; overflow: scroll; }"
+ " #changer { background-color: #F5B335; height: 50px; width: 100%; }"
+ " #anchor { background-color: #D3D3D3; height: 300px; }"
+ "</style>"
+ "<div id='container'>"
+ " <div id='scroller'>"
+ " <div id='changer'></div>"
+ " <div id='anchor'></div>"
+ " </div>"
+ "</div>");
+
+ ScrollableArea* scroller = scrollerForElement(document().getElementById("scroller"));
+ document().getElementById("scroller")->setScrollTop(100);
+
+ document().getElementById("changer")->setAttribute(
+ HTMLNames::styleAttr, "position: absolute;");
+ update();
+
+ EXPECT_EQ(100, scroller->scrollPosition().y());
+}
+
TEST_F(ScrollAnchorTest, FlexboxDelayedClampingAlsoDelaysAdjustment)
{
setBodyInnerHTML(
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698