Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp |
| index ee06f78ae4a5b5859d0bee3a063d0764b0e2fc7f..064108300fcf568ac4496a2ca19d2634d78b2ff7 100644 |
| --- a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp |
| +++ b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp |
| @@ -450,6 +450,76 @@ TEST_F(MapCoordinatesTest, FixedPosInFixedPos) |
| EXPECT_EQ(FloatPoint(), mappedPoint); |
| } |
| +TEST_F(MapCoordinatesTest, FixedPosInTransform) |
| +{ |
| + setBodyInnerHTML("<style>#container { transform: translateY(100px); position: absolute; left: 0; top: 100px; }" |
| + ".fixed { position: fixed; top: 0; }" |
| + ".spacer { height: 2000px; } </style>" |
| + "<div id='container'><div class='fixed' id='target'></div></div>" |
| + "<div class='spacer'></div>"); |
| + |
| + document().view()->setScrollPosition(DoublePoint(0.0, 50), ProgrammaticScroll); |
| + document().view()->updateAllLifecyclePhases(); |
| + EXPECT_EQ(50, document().view()->scrollPosition().y()); |
| + |
| + LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| + LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
| + LayoutBox* body = container->parentBox(); |
| + LayoutBox* html = body->parentBox(); |
| + LayoutBox* view = html->parentBox(); |
| + ASSERT_TRUE(view->isLayoutView()); |
| + |
| + FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 100), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(target, view, FloatPoint(0, 100)); |
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| + |
| + mappedPoint = mapLocalToAncestor(target, container, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 0), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(target, container, FloatPoint(0, 0)); |
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| + |
| + mappedPoint = mapLocalToAncestor(container, view, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 100), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(container, view, FloatPoint(0, 100)); |
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| +} |
| + |
| +TEST_F(MapCoordinatesTest, FixedPosInContainPaint) |
| +{ |
| + setBodyInnerHTML("<style>#container { contain: paint; position: absolute; left: 0; top: 100px; }" |
| + ".fixed { position: fixed; top: 0; }" |
| + ".spacer { height: 2000px; } </style>" |
| + "<div id='container'><div class='fixed' id='target'></div></div>" |
| + "<div class='spacer'></div>"); |
| + |
| + document().view()->setScrollPosition(DoublePoint(0.0, 50), ProgrammaticScroll); |
| + document().view()->updateAllLifecyclePhases(); |
| + EXPECT_EQ(50, document().view()->scrollPosition().y()); |
| + |
| + LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| + LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
| + LayoutBox* body = container->parentBox(); |
| + LayoutBox* html = body->parentBox(); |
| + LayoutBox* view = html->parentBox(); |
| + ASSERT_TRUE(view->isLayoutView()); |
| + |
| + FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 100), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(target, view, FloatPoint(0, 100)); |
|
chrishtr
2016/07/26 18:11:03
Shouldn't this be 150px? (including scroll)
flackr
2016/07/26 21:06:51
No, the fixed position #target doesn't move when y
chrishtr
2016/07/26 21:49:11
But #container should move when the view is scroll
flackr
2016/07/26 22:36:11
view (the LayoutView) doesn't seem to refer to the
chrishtr
2016/07/26 23:24:56
Forgot that the view is currently special and does
|
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| + |
| + mappedPoint = mapLocalToAncestor(target, container, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 0), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(target, container, FloatPoint(0, 0)); |
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| + |
| + mappedPoint = mapLocalToAncestor(container, view, FloatPoint()); |
| + EXPECT_EQ(FloatPoint(0, 100), mappedPoint); |
| + mappedPoint = mapAncestorToLocal(container, view, FloatPoint(0, 100)); |
| + EXPECT_EQ(FloatPoint(), mappedPoint); |
| +} |
| + |
| // TODO(chrishtr): add more multi-frame tests. |
| TEST_F(MapCoordinatesTest, FixedPosInIFrameWhenMainFrameScrolled) |
| { |