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

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

Issue 2022853002: Fix scroll anchoring crash from removing an anonymous block anchor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skip anonymous LayoutObjects Created 4 years, 7 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 56dbb25feb43622f06e1e712c2cc1d6793f12f72..ffc3a95832c3946005e99bc5e0fb735b72ede5d2 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -159,6 +159,37 @@ TEST_F(ScrollAnchorTest, AnchorWithLayerInScrollingDiv)
EXPECT_EQ(250, scroller->scrollPosition().y());
}
+TEST_F(ScrollAnchorTest, ExcludeAnonymousCandidates)
+{
+ setBodyInnerHTML(
+ "<style>"
+ " body { height: 3500px }"
+ " #div {"
+ " position: relative; background-color: pink;"
+ " top: 5px; left: 5px; width: 100px; height: 3500px;"
+ " }"
+ " #inline { padding-left: 10px }"
+ "</style>"
+ "<div id='div'>"
+ " <a id='inline'>text</a>"
+ " <p id='block'>Some text</p>"
+ "</div>");
+
+ ScrollableArea* viewport = layoutViewport();
+ Element* inlineElem = document().getElementById("inline");
+ EXPECT_TRUE(inlineElem->layoutObject()->parent()->isAnonymous());
+
+ // Scroll #div into view, making anonymous block a viable candidate.
+ document().getElementById("div")->scrollIntoView();
+
+ // Trigger layout and verify that we don't anchor to the anonymous block.
+ document().getElementById("div")->setAttribute(HTMLNames::styleAttr,
+ AtomicString("top: 6px"));
+ update();
+ EXPECT_EQ(inlineElem->layoutObject()->slowFirstChild(),
+ scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, FullyContainedInlineBlock)
{
// Exercises every WalkStatus value:
@@ -211,7 +242,7 @@ TEST_F(ScrollAnchorTest, ExcludeFixedPosition)
{
setBodyInnerHTML(
"<style>"
- " body { height: 1000px; padding: 20px }"
+ " body { height: 1000px; padding: 20px; }"
" div { position: relative; top: 100px; }"
" #f { position: fixed }"
"</style>"
« 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