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

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

Issue 2245873002: Disable anchoring if ancestor changes padding or margin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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..2f64fedaea09b47d616641862722dc27a2398dab 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -640,6 +640,35 @@ TEST_F(ScrollAnchorTest, OptOutScrollingDiv)
scrollAnchor(viewport).anchorObject());
}
+TEST_F(ScrollAnchorTest, ExcludeAnchoringIfAncestorChangesPaddingOrMargin)
+{
+ setBodyInnerHTML(
+ "<style> body { height: 1000px; margin: 0px; } div { height: 100px } </style>"
+ "<div id='block1'>abc</div>"
+ "<div id='block2'>def</div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ scrollLayoutViewport(DoubleSize(0, 150));
+
+ // Padding change on anchor's ancestor shouldn't trigger anchoring.
+ document().body()->setAttribute(HTMLNames::styleAttr,
+ AtomicString(String::format("padding: %dpx", 10)));
+ update();
+ EXPECT_EQ(150, viewport->scrollPosition().y());
+
+ // Margin change on anchor's ancestor shouldn't trigger anchoring.
+ document().body()->setAttribute(HTMLNames::styleAttr,
+ AtomicString(String::format("margin: %dpx", 10)));
+ update();
+ EXPECT_EQ(150, viewport->scrollPosition().y());
+
+ // Padding change on other elements should trigger anchoring.
+ document().getElementById("block1")->setAttribute(HTMLNames::styleAttr,
+ AtomicString(String::format("padding: %dpx", 10)));
+ update();
+ EXPECT_EQ(170, viewport->scrollPosition().y());
+}
+
class ScrollAnchorCornerTest : public ScrollAnchorTest {
protected:
void checkCorner(const AtomicString& id, Corner corner, DoublePoint startPos, DoubleSize expectedAdjustment)
« 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