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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2765503003: Fix position:sticky location bug when scroller is not a stacking context (Closed)
Patch Set: Add unittest 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/layout/compositing/CompositedLayerMappingTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
index 0e2bee46da5a69c85e3461504b0afec24a9aa556..5aa01622c2c65023dbfc600d8a100c31d77be53f 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
@@ -1541,6 +1541,63 @@ TEST_P(CompositedLayerMappingTest, StickyPositionTableCellContentOffset) {
}
TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) {
+ // Using backface-visibility: hidden causes the scroller to become composited
+ // without creating a stacking context. This is important as enclosing layer
+ // scroll correction works differently depending on whether you are in a
+ // stacking context or not.
+ setBodyInnerHTML(
+ "<style>.composited { backface-visibility: hidden; }"
+ "#scroller { overflow: auto; height: 200px; width: 200px; }"
+ ".container { height: 500px; }"
+ ".innerPadding { height: 10px; }"
+ "#sticky { position: sticky; top: 25px; height: 50px; }</style>"
+ "<div id='scroller' class='composited'>"
+ "<div class='composited container'>"
flackr 2017/03/23 16:58:03 nit: indent.
smcgruer 2017/03/23 17:22:48 Done.
+ " <div class='composited container'>"
+ " <div class='innerPadding'></div>"
+ " <div id='sticky' class='composited'></div>"
+ " </div></div></div>");
+
+ PaintLayer* stickyLayer =
+ toLayoutBox(getLayoutObjectByElementId("sticky"))->layer();
+ CompositedLayerMapping* stickyMapping = stickyLayer->compositedLayerMapping();
+ ASSERT_TRUE(stickyMapping);
+
+ WebLayerStickyPositionConstraint constraint =
+ stickyMapping->mainGraphicsLayer()
+ ->contentLayer()
+ ->layer()
+ ->stickyPositionConstraint();
+ EXPECT_EQ(IntPoint(0, 10),
+ IntPoint(constraint.parentRelativeStickyBoxOffset));
+
+ // Now scroll the page - this should not affect the parent-relative offset.
+ LayoutBoxModelObject* scroller =
+ toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToAbsolutePosition(
+ FloatPoint(scrollableArea->scrollPosition().x(), 100));
+ ASSERT_EQ(100.0, scrollableArea->scrollPosition().y());
+
+ stickyLayer->setNeedsCompositingInputsUpdate();
+ EXPECT_TRUE(stickyLayer->needsCompositingInputsUpdate());
+ document().view()->updateLifecycleToCompositingCleanPlusScrolling();
+ EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate());
+
+ constraint = stickyMapping->mainGraphicsLayer()
+ ->contentLayer()
+ ->layer()
+ ->stickyPositionConstraint();
+ EXPECT_EQ(IntPoint(0, 10),
+ IntPoint(constraint.parentRelativeStickyBoxOffset));
+}
+
+TEST_P(CompositedLayerMappingTest,
+ StickyPositionEnclosingLayersWithStackingContextContentOffset) {
+ // Using will-change: transform causes the scroller to become a stacking
+ // context. This changes how its descendant layers interact with it; they no
+ // longer have a scrollParent and instead just refer to it only as their
+ // ancestorOverflowLayer.
setBodyInnerHTML(
"<style>.composited { will-change: transform; }"
"#scroller { overflow: auto; height: 200px; width: 200px; }"

Powered by Google App Engine
This is Rietveld 408576698