Commit 510dfbbe authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Fix TransformState 3d flattening with 2d offset

In, https://chromium-review.googlesource.com/c/chromium/src/+/1614448,
I mistakenly removed the TransformAccumulation parameter when
TransformState::ApplyTransform() calls TransformState::Move() for
2d translations

Bug: 968112
Change-Id: I1c628f3884f89f726a9fdc757e8db78469545c8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635864Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664511}
parent a751329d
......@@ -115,7 +115,8 @@ void TransformState::ApplyTransform(
TransformAccumulation accumulate) {
if (transform_from_container.IsIntegerTranslation()) {
Move(PhysicalOffset::FromFloatSizeRound(
transform_from_container.To2DTranslation()));
transform_from_container.To2DTranslation()),
accumulate);
return;
}
......
......@@ -1621,15 +1621,12 @@ TEST_F(MapCoordinatesTest, LocalToAncestorTransform) {
}
TEST_F(MapCoordinatesTest, LocalToAbsoluteTransformFlattens) {
// This Page is not actually being shown by a compositor, but we act like it
// will in order to test behaviour.
GetPage().GetSettings().SetAcceleratedCompositingEnabled(true);
// This is required to test 3d transforms.
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div style='position: absolute; left: 0; top: 0;'>
<div style='transform: rotateY(45deg);
-webkit-transform-style:preserve-3d;'>
<div style='transform: rotateY(-45deg);
-webkit-transform-style:preserve-3d;'>
<div style='transform: rotateY(45deg); transform-style: preserve-3d;'>
<div style='transform: rotateY(-45deg); transform-style: preserve-3d;'>
<div id='child1'></div>
</div>
</div>
......@@ -1670,6 +1667,30 @@ TEST_F(MapCoordinatesTest, LocalToAbsoluteTransformFlattens) {
LayoutUnit::Epsilon());
}
TEST_F(MapCoordinatesTest, Transform3DWithOffset) {
// This is required to test 3d transforms.
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<style>
body { margin: 0; }
</style>
<div style="perspective: 400px; width: 0; height: 0">
<div>
<div style="height: 100px"></div>
<div style="transform-style: preserve-3d; transform: rotateY(0deg)">
<div id="target" style="width: 100px; height: 100px;
transform: translateZ(200px)">
</div>
</div>
</div>
</div>
)HTML");
auto* target = GetLayoutObjectByElementId("target");
EXPECT_EQ(FloatRect(0, 200, 200, 200),
MapLocalToAncestor(target, nullptr, FloatRect(0, 0, 100, 100)));
}
// This test verifies that the mapped location of a div within a scroller
// remains the same after scroll when ignoring scroll offset.
TEST_F(MapCoordinatesTest, IgnoreScrollOffset) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment