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

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

Issue 2394053004: Clear scroll anchor on all parent scrollers from ScrollAnchor::clear (Closed)
Patch Set: Apply review comments Created 4 years, 2 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
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 2558ed33ab52b4e7e6919a608c794f3ed32b599a..de4941e2a439cedfc86c34bf9d809e5079568368 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -240,6 +240,34 @@ TEST_F(ScrollAnchorTest, AnchoringWhenContentRemovedFromScrollingDiv) {
scrollAnchor(scroller).anchorObject());
}
+// Test that a non-anchoring scroll on scroller clears scroll anchors for all
+// parent scrollers.
+TEST_F(ScrollAnchorTest, ClearScrollAnchorsOnAncestors) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 1000px } div { height: 200px }"
+ " #scroller { height: 100px; width: 200px; overflow: scroll; }"
+ "</style>"
+ "<div id='changer'>abc</div>"
+ "<div id='anchor'>def</div>"
+ "<div id='scroller'><div></div></div>");
+
+ ScrollableArea* viewport = layoutViewport();
+
+ scrollLayoutViewport(ScrollOffset(0, 250));
+ setHeight(document().getElementById("changer"), 300);
+
+ EXPECT_EQ(350, viewport->scrollOffsetInt().height());
+ EXPECT_EQ(document().getElementById("anchor")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+
+ // Scrolling the nested scroller should clear the anchor on the main frame.
+ ScrollableArea* scroller =
+ scrollerForElement(document().getElementById("scroller"));
+ scroller->scrollBy(ScrollOffset(0, 100), UserScroll);
+ EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, FractionalOffsetsAreRoundedBeforeComparing) {
setBodyInnerHTML(
"<style> body { height: 1000px } </style>"

Powered by Google App Engine
This is Rietveld 408576698