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

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

Issue 2136323002: Properly calculate the localBounds for elements with overflow clipped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nit Created 4 years, 5 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 2fb1618e812e260690b26b83dba7947b51760d1b..87a3d5719383235bf4ee83d2f7b9ebe846057a97 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -155,6 +155,45 @@ TEST_F(ScrollAnchorTest, VisualViewportAnchors)
EXPECT_EQ(nullptr, scrollAnchor(lViewport).anchorObject());
}
+// Test that we ignore the clipped content when computing visibility otherwise
+// we may end up with an anchor that we think is in the viewport but is not.
+TEST_F(ScrollAnchorTest, ClippedScrollersSkipped)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 2000px; }"
+ " #scroller { overflow: scroll; width: 500px; height: 300px; }"
+ " .anchor {"
+ " position:relative; height: 100px; width: 150px;"
+ " background-color: #afa; border: 1px solid gray;"
+ " }"
+ " #forceScrolling { height: 500px; background-color: #fcc; }"
+ "</style>"
+ "<div id='scroller'>"
+ " <div id='innerChanger'></div>"
+ " <div id='innerAnchor' class='anchor'></div>"
+ " <div id='forceScrolling'></div>"
+ "</div>"
+ "<div id='outerChanger'></div>"
+ "<div id='outerAnchor' class='anchor'></div>");
+
+ ScrollableArea* scroller = scrollerForElement(document().getElementById("scroller"));
+ ScrollableArea* viewport = layoutViewport();
+
+ document().getElementById("scroller")->setScrollTop(100);
+ scrollLayoutViewport(DoubleSize(0, 350));
+
+ setHeight(document().getElementById("innerChanger"), 200);
+ setHeight(document().getElementById("outerChanger"), 150);
+
+ EXPECT_EQ(300, scroller->scrollPosition().y());
+ EXPECT_EQ(document().getElementById("innerAnchor")->layoutObject(),
+ scrollAnchor(scroller).anchorObject());
+ EXPECT_EQ(500, viewport->scrollPosition().y());
+ EXPECT_EQ(document().getElementById("outerAnchor")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, FractionalOffsetsAreRoundedBeforeComparing)
{
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