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

Unified Diff: third_party/WebKit/Source/core/frame/FrameViewTest.cpp

Issue 2769353002: Only create sticky position constraints for constrained sticky position. (Closed)
Patch Set: Set dependent patch. Created 3 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/frame/FrameViewTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
index e78918f7c7c59a1c86378089513177ec720548db..40498645a6aef0b30bc18419dec4e99b17d2cffd 100644
--- a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
@@ -172,31 +172,57 @@ TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
document().body()->setInnerHTML(
"<style>.container { height: 200%; }"
- "#sticky { position: sticky; top: 0; height: 50px; }</style>"
- "<div class='container'><div id='sticky'></div></div>");
+ "#sticky1 { position: sticky; top: 0; height: 50px; }"
+ "#sticky2 { position: sticky; height: 50px; }</style>"
+ "<div class='container'>"
+ " <div id='sticky1'></div>"
+ " <div id='sticky2'></div>"
+ "</div>");
document().view()->updateAllLifecyclePhases();
- LayoutBoxModelObject* sticky = toLayoutBoxModelObject(
- document().getElementById("sticky")->layoutObject());
+ LayoutBoxModelObject* sticky1 = toLayoutBoxModelObject(
+ document().getElementById("sticky1")->layoutObject());
+ LayoutBoxModelObject* sticky2 = toLayoutBoxModelObject(
+ document().getElementById("sticky2")->layoutObject());
EXPECT_TRUE(
- document().view()->viewportConstrainedObjects()->contains(sticky));
+ document().view()->viewportConstrainedObjects()->contains(sticky1));
+ // #sticky2 is not viewport constrained because it has no anchor edges.
+ EXPECT_FALSE(
+ document().view()->viewportConstrainedObjects()->contains(sticky2));
// Making the element non-sticky should remove it from the set of
// viewport-constrained objects.
- document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr,
- "position: relative");
+ document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr,
+ "position: relative");
document().view()->updateAllLifecyclePhases();
EXPECT_FALSE(
- document().view()->viewportConstrainedObjects()->contains(sticky));
+ document().view()->viewportConstrainedObjects()->contains(sticky1));
// And making it sticky again should put it back in that list.
- document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, "");
+ document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr, "");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(
+ document().view()->viewportConstrainedObjects()->contains(sticky1));
+
+ // Adding an anchor edge on the non-anchored sticky should add it to the
+ // viewport-constrained objects.
+ document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr,
+ "top: 0");
document().view()->updateAllLifecyclePhases();
EXPECT_TRUE(
- document().view()->viewportConstrainedObjects()->contains(sticky));
+ document().view()->viewportConstrainedObjects()->contains(sticky2));
+
+ // Removing the anchor edge on a sticky position element should remove it from
+ // the viewport-constrained objects.
+ document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr, "");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_FALSE(
+ document().view()->viewportConstrainedObjects()->contains(sticky2));
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698