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

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

Issue 2246803002: Exclude elements with overflow-anchor:none from anchor node selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 4 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/ScrollAnchor.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 84a7c4024be401ca6710f1845a4ee5d9ae25493d..5ded45198cbaad7a56b1b47c875c521c6cb5e357 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -561,6 +561,48 @@ TEST_F(ScrollAnchorTest, DescendsIntoContainerWithFloat)
scrollAnchor(viewport).anchorObject());
}
+// Test then an element and its children are not selected as the anchor when
+// it has the overflow-anchor property set to none.
+TEST_F(ScrollAnchorTest, OptOutElement)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 1000px }"
+ " .div {"
+ " height: 100px; width: 100px;"
+ " border: 1px solid gray; background-color: #afa;"
+ " }"
+ " #innerDiv {"
+ " height: 50px; width: 50px;"
+ " border: 1px solid gray; background-color: pink;"
+ " }"
+ "</style>"
+ "<div id='changer'></div>"
+ "<div class='div' id='firstDiv'><div id='innerDiv'></div></div>"
+ "<div class='div' id='secondDiv'></div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(DoubleSize(0, 50));
+
+ // No opt-out.
+ setHeight(document().getElementById("changer"), 100);
+ EXPECT_EQ(150, viewport->scrollPosition().y());
+ EXPECT_EQ(document().getElementById("innerDiv")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+
+ // Clear anchor and opt-out element.
+ scrollLayoutViewport(DoubleSize(0, 10));
+ document().getElementById("firstDiv")->setAttribute(HTMLNames::styleAttr,
+ AtomicString("overflow-anchor: none"));
+ update();
+
+ // Opted out element and it's children skipped.
+ setHeight(document().getElementById("changer"), 200);
+ EXPECT_EQ(260, viewport->scrollPosition().y());
+ EXPECT_EQ(document().getElementById("secondDiv")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, OptOutBody)
{
setBodyInnerHTML(
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698