summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/view.cc1
-rw-r--r--views/view_unittest.cc20
2 files changed, 21 insertions, 0 deletions
diff --git a/views/view.cc b/views/view.cc
index b06f5d3..7825804 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -1748,6 +1748,7 @@ void View::CreateLayer() {
layer_helper_->SetLayer(new ui::Layer(compositor));
layer()->set_bounds(gfx::Rect(offset.x(), offset.y(), width(), height()));
+ layer()->set_transform(GetTransform());
if (ancestor_with_layer)
ancestor_with_layer->layer()->Add(layer());
layer_helper_->set_bitmap_needs_updating(true);
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 7f3c4bb..58a8c7a 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -2579,6 +2579,26 @@ TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
EXPECT_EQ(2.0f, view->GetTransform().matrix()[0]);
}
+// Verifies a transform persists after removing/adding a view with a transform.
+TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
+ View* view = new View;
+ ui::Transform transform;
+ transform.SetScale(2.0f, 2.0f);
+ view->SetTransform(transform);
+ widget()->SetContentsView(view);
+ EXPECT_EQ(2.0f, view->GetTransform().matrix()[0]);
+ ASSERT_TRUE(view->layer() != NULL);
+ EXPECT_EQ(2.0f, view->layer()->transform().matrix()[0]);
+
+ View* parent = view->parent();
+ parent->RemoveChildView(view);
+ parent->AddChildView(view);
+
+ EXPECT_EQ(2.0f, view->GetTransform().matrix()[0]);
+ ASSERT_TRUE(view->layer() != NULL);
+ EXPECT_EQ(2.0f, view->layer()->transform().matrix()[0]);
+}
+
// Verifies that the complete bounds of a texture are updated if the texture
// needs to be refreshed and paint with a clip is invoked.
TEST_F(ViewLayerTest, PaintAll) {