| 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..794d8c86e12c9fdea9013ca355bd20b1ae2f8da8 100644
|
| --- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| @@ -1496,8 +1496,8 @@ TEST_P(CompositedLayerMappingTest, StickyPositionContentOffset) {
|
| ->contentLayer()
|
| ->layer()
|
| ->stickyPositionConstraint();
|
| - EXPECT_EQ(IntPoint(-11, -11),
|
| - IntPoint(constraint1.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(-11, -11),
|
| + FloatPoint(constraint1.parentRelativeStickyBoxOffset));
|
|
|
| // Since the nested div will be squashed into the same composited layer the
|
| // sticky element is offset by the nested element's offset.
|
| @@ -1507,8 +1507,8 @@ TEST_P(CompositedLayerMappingTest, StickyPositionContentOffset) {
|
| ->contentLayer()
|
| ->layer()
|
| ->stickyPositionConstraint();
|
| - EXPECT_EQ(IntPoint(-50, -50),
|
| - IntPoint(constraint2.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(-50, -50),
|
| + FloatPoint(constraint2.parentRelativeStickyBoxOffset));
|
| }
|
|
|
| TEST_P(CompositedLayerMappingTest, StickyPositionTableCellContentOffset) {
|
| @@ -1536,8 +1536,8 @@ TEST_P(CompositedLayerMappingTest, StickyPositionTableCellContentOffset) {
|
| ->contentLayer()
|
| ->layer()
|
| ->stickyPositionConstraint();
|
| - EXPECT_EQ(IntPoint(0, 50),
|
| - IntPoint(constraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 50),
|
| + FloatPoint(constraint.parentRelativeStickyBoxOffset));
|
| }
|
|
|
| TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) {
|
| @@ -1564,8 +1564,8 @@ TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) {
|
| ->contentLayer()
|
| ->layer()
|
| ->stickyPositionConstraint();
|
| - EXPECT_EQ(IntPoint(0, 10),
|
| - IntPoint(constraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 10),
|
| + FloatPoint(constraint.parentRelativeStickyBoxOffset));
|
|
|
| // Now scroll the page - this should not affect the parent-relative offset.
|
| LayoutBoxModelObject* scroller =
|
| @@ -1584,8 +1584,102 @@ TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) {
|
| ->contentLayer()
|
| ->layer()
|
| ->stickyPositionConstraint();
|
| - EXPECT_EQ(IntPoint(0, 10),
|
| - IntPoint(constraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 10),
|
| + FloatPoint(constraint.parentRelativeStickyBoxOffset));
|
| +}
|
| +
|
| +TEST_P(CompositedLayerMappingTest, StickyPositionNestedStickyContentOffset) {
|
| + setBodyInnerHTML(
|
| + "<style>.composited { will-change: transform; }"
|
| + "#scroller { overflow: auto; height: 200px; width: 200px; }"
|
| + ".container { height: 500px; }"
|
| + "#outerSticky { position: sticky; top: 0; height: 100px; }"
|
| + "#middleSticky { position: sticky; top: 10px; height: 50px; }"
|
| + "#innerSticky { position: sticky; top: 25px; height: 25px; }</style>"
|
| + "<div id='scroller' class='composited'>"
|
| + " <div style='height: 50px'></div>"
|
| + " <div class='composited container'>"
|
| + " <div style='height: 10px;'></div>"
|
| + " <div id='outerSticky' class='composited'>"
|
| + " <div id='middleSticky' class='composited'>"
|
| + " <div style='height: 5px;'></div>"
|
| + " <div id='innerSticky' class='composited'></div>"
|
| + " </div>"
|
| + " </div>"
|
| + " </div>"
|
| + "</div>");
|
| +
|
| + PaintLayer* outerSticky =
|
| + toLayoutBox(getLayoutObjectByElementId("outerSticky"))->layer();
|
| + PaintLayer* middleSticky =
|
| + toLayoutBox(getLayoutObjectByElementId("middleSticky"))->layer();
|
| + PaintLayer* innerSticky =
|
| + toLayoutBox(getLayoutObjectByElementId("innerSticky"))->layer();
|
| +
|
| + WebLayerStickyPositionConstraint outerStickyConstraint =
|
| + outerSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| + WebLayerStickyPositionConstraint middleStickyConstraint =
|
| + middleSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| + WebLayerStickyPositionConstraint innerStickyConstraint =
|
| + innerSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| +
|
| + EXPECT_EQ(FloatPoint(0, 10),
|
| + FloatPoint(outerStickyConstraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 0),
|
| + FloatPoint(middleStickyConstraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 5),
|
| + FloatPoint(innerStickyConstraint.parentRelativeStickyBoxOffset));
|
| +
|
| + // Scroll the content to engage the sticky elements.
|
| + LayoutBoxModelObject* scroller =
|
| + toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
|
| + PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
|
| + scrollableArea->scrollToAbsolutePosition(
|
| + FloatPoint(scrollableArea->scrollPosition().x(), 110));
|
| + ASSERT_EQ(110.0, scrollableArea->scrollPosition().y());
|
| +
|
| + outerSticky->setNeedsCompositingInputsUpdate();
|
| + middleSticky->setNeedsCompositingInputsUpdate();
|
| + innerSticky->setNeedsCompositingInputsUpdate();
|
| +
|
| + document().view()->updateLifecycleToCompositingCleanPlusScrolling();
|
| +
|
| + outerStickyConstraint = outerSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| + middleStickyConstraint = middleSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| + innerStickyConstraint = innerSticky->compositedLayerMapping()
|
| + ->mainGraphicsLayer()
|
| + ->contentLayer()
|
| + ->layer()
|
| + ->stickyPositionConstraint();
|
| +
|
| + // After scrolling and despite ancestor sticky changes, the offset relative to
|
| + // the parent layer should remain constant.
|
| + EXPECT_EQ(FloatPoint(0, 10),
|
| + FloatPoint(outerStickyConstraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 0),
|
| + FloatPoint(middleStickyConstraint.parentRelativeStickyBoxOffset));
|
| + EXPECT_EQ(FloatPoint(0, 5),
|
| + FloatPoint(innerStickyConstraint.parentRelativeStickyBoxOffset));
|
| }
|
|
|
| } // namespace blink
|
|
|