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

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

Issue 2360833002: Only anchor along the block layout axis. (Closed)
Patch Set: 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
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 f767cb6377bd0a8fc0f7f3245025ee58a68bbd7a..27be5d883ca3dac9952757b448ba90c74f4180ba 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -59,7 +59,7 @@ protected:
{
Element* scrollingElement = document().scrollingElement();
if (delta.width())
- scrollingElement->setScrollTop(scrollingElement->scrollLeft() + delta.width());
+ scrollingElement->setScrollLeft(scrollingElement->scrollLeft() + delta.width());
if (delta.height())
scrollingElement->setScrollTop(scrollingElement->scrollTop() + delta.height());
}
@@ -941,4 +941,63 @@ TEST_F(ScrollAnchorCornerTest, CornersVerticalRL)
checkCorner(Corner::TopRight, DoublePoint(-20, 20), DoubleSize(-100, 0));
}
+TEST_F(ScrollAnchorTest, IgnoreNonBlockLayoutAxis)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body {"
+ " margin: 0; line-height: 0;"
+ " width: 1200px; height: 1200px;"
+ " }"
+ " div {"
+ " width: 100px; height: 100px;"
+ " border: 5px solid gray;"
+ " display: inline-block;"
+ " box-sizing: border-box;"
+ " }"
+ "</style>"
+ "<div id='a'></div><br>"
+ "<div id='b'></div><div id='c'></div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(DoubleSize(150, 0));
+
+ Element* a = document().getElementById("a");
+ Element* b = document().getElementById("b");
+ Element* c = document().getElementById("c");
+
+ a->setAttribute(HTMLNames::styleAttr, "height: 150px");
+ update();
+ EXPECT_EQ(DoublePoint(150, 0), viewport->scrollPositionDouble());
+ EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
+
+ scrollLayoutViewport(DoubleSize(0, 50));
+
+ a->setAttribute(HTMLNames::styleAttr, "height: 200px");
+ b->setAttribute(HTMLNames::styleAttr, "width: 150px");
+ update();
+ EXPECT_EQ(DoublePoint(150, 100), viewport->scrollPositionDouble());
+ EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject());
+
+ a->setAttribute(HTMLNames::styleAttr, "height: 100px");
+ b->setAttribute(HTMLNames::styleAttr, "width: 100px");
+ document().documentElement()->setAttribute(HTMLNames::styleAttr, "writing-mode: vertical-rl");
+ document().scrollingElement()->setScrollLeft(0);
+ document().scrollingElement()->setScrollTop(0);
+ scrollLayoutViewport(DoubleSize(0, 150));
+
+ a->setAttribute(HTMLNames::styleAttr, "width: 150px");
+ update();
+ EXPECT_EQ(DoublePoint(0, 150), viewport->scrollPositionDouble());
+ EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
+
+ scrollLayoutViewport(DoubleSize(-50, 0));
+
+ a->setAttribute(HTMLNames::styleAttr, "width: 200px");
+ b->setAttribute(HTMLNames::styleAttr, "height: 150px");
+ update();
+ EXPECT_EQ(DoublePoint(-100, 150), viewport->scrollPositionDouble());
+ EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject());
+}
+
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698