OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 child->parent_->Remove(child); | 157 child->parent_->Remove(child); |
158 child->parent_ = this; | 158 child->parent_ = this; |
159 children_.push_back(child); | 159 children_.push_back(child); |
160 cc_layer_->AddChild(child->cc_layer_); | 160 cc_layer_->AddChild(child->cc_layer_); |
161 child->OnDeviceScaleFactorChanged(device_scale_factor_); | 161 child->OnDeviceScaleFactorChanged(device_scale_factor_); |
162 if (GetCompositor()) | 162 if (GetCompositor()) |
163 child->SendPendingThreadedAnimations(); | 163 child->SendPendingThreadedAnimations(); |
164 } | 164 } |
165 | 165 |
166 void Layer::Remove(Layer* child) { | 166 void Layer::Remove(Layer* child) { |
| 167 // Current bounds are used to calculate offsets when layers are reparented. |
| 168 // Stop (and complete) an ongoing animation to update the bounds immediately. |
| 169 if (child->GetAnimator()) { |
| 170 child->GetAnimator()->StopAnimatingProperty( |
| 171 ui::LayerAnimationElement::BOUNDS); |
| 172 } |
167 std::vector<Layer*>::iterator i = | 173 std::vector<Layer*>::iterator i = |
168 std::find(children_.begin(), children_.end(), child); | 174 std::find(children_.begin(), children_.end(), child); |
169 DCHECK(i != children_.end()); | 175 DCHECK(i != children_.end()); |
170 children_.erase(i); | 176 children_.erase(i); |
171 child->parent_ = NULL; | 177 child->parent_ = NULL; |
172 child->cc_layer_->RemoveFromParent(); | 178 child->cc_layer_->RemoveFromParent(); |
173 } | 179 } |
174 | 180 |
175 void Layer::StackAtTop(Layer* child) { | 181 void Layer::StackAtTop(Layer* child) { |
176 if (children_.size() <= 1 || child == children_.back()) | 182 if (children_.size() <= 1 || child == children_.back()) |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 963 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
958 } | 964 } |
959 | 965 |
960 void Layer::RecomputePosition() { | 966 void Layer::RecomputePosition() { |
961 cc_layer_->SetPosition(gfx::ScalePoint( | 967 cc_layer_->SetPosition(gfx::ScalePoint( |
962 gfx::PointF(bounds_.x(), bounds_.y()), | 968 gfx::PointF(bounds_.x(), bounds_.y()), |
963 device_scale_factor_)); | 969 device_scale_factor_)); |
964 } | 970 } |
965 | 971 |
966 } // namespace ui | 972 } // namespace ui |
OLD | NEW |