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

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

Issue 1831993002: Handle position:absolute candidates correctly in ScrollAnchor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 0f7a5e07a13895f98d4b7499f76c2beb129d894c..f52e831c167a4f6402a05480ed27d987ad4668de 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -180,6 +180,46 @@ TEST_F(ScrollAnchorTest, ExcludeFixedPosition)
scrollAnchor(layoutViewport()).anchorObject());
}
+TEST_F(ScrollAnchorTest, ExcludeAbsolutePosition)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body { margin: 0; }"
+ " #scroller { overflow: scroll; width: 500px; height: 400px; }"
+ " #space { height: 1000px; }"
+ " #abs {"
+ " position: absolute; background-color: red;"
+ " left: 200px; top: 100px; width: 100px; height: 100px;"
+ " }"
+ " #rel {"
+ " position: relative; background-color: green;"
+ " left: 50px; top: 100px; width: 100px; height: 75px;"
+ " }"
+ "</style>"
+ "<div id='scroller'><div id='space'>"
+ " <div id='abs'></div>"
+ " <div id='rel'></div>"
+ "</div></div>");
+
+ Element* scrollerElement = document().getElementById("scroller");
+ ScrollableArea* scroller = scrollerForElement(scrollerElement);
+ Element* absPos = document().getElementById("abs");
+ Element* relPos = document().getElementById("rel");
+
+ scroller->scrollBy(DoubleSize(0, 25), UserScroll);
+ setHeight(relPos, 100);
+
+ // When the scroller is position:static, the anchor cannot be position:absolute.
+ EXPECT_EQ(relPos->layoutObject(), scrollAnchor(scroller).anchorObject());
+
+ scrollerElement->setAttribute(HTMLNames::styleAttr, "position: relative");
+ scroller->scrollBy(DoubleSize(0, 25), UserScroll);
+ setHeight(relPos, 125);
+
+ // When the scroller is position:relative, the anchor may be position:absolute.
+ EXPECT_EQ(absPos->layoutObject(), scrollAnchor(scroller).anchorObject());
+}
+
class ScrollAnchorCornerTest : public ScrollAnchorTest {
protected:
void checkCorner(const AtomicString& id, Corner corner, DoublePoint startPos, DoubleSize expectedAdjustment)

Powered by Google App Engine
This is Rietveld 408576698