Index: ui/compositor/layer_animator.cc |
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc |
index 4d063ecd6e94d2afd591b0569ed2bdf6aa90a509..b4afd2e0dfc30d31bbfaf65ac10880ba0deba818 100644 |
--- a/ui/compositor/layer_animator.cc |
+++ b/ui/compositor/layer_animator.cc |
@@ -115,6 +115,7 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { |
if (collection) |
collection->StopAnimator(this); |
} |
+ SwitchToLayer(delegate ? delegate->GetCcLayer() : nullptr); |
delegate_ = delegate; |
if (delegate_ && is_started_) { |
LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
@@ -123,6 +124,15 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { |
} |
} |
+void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { |
+ if (delegate_) { |
+ DCHECK(delegate_->GetCcLayer()); |
+ delegate_->GetCcLayer()->RemoveLayerAnimationEventObserver(this); |
+ } |
+ if (new_layer) |
+ new_layer->AddLayerAnimationEventObserver(this); |
+} |
+ |
void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { |
scoped_refptr<LayerAnimator> retain(this); |
OnScheduled(animation); |
@@ -850,6 +860,10 @@ LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() { |
return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL; |
} |
+void LayerAnimator::OnAnimationStarted(const cc::AnimationEvent& event) { |
+ OnThreadedAnimationStarted(event); |
+} |
+ |
LayerAnimator::RunningAnimation::RunningAnimation( |
const base::WeakPtr<LayerAnimationSequence>& sequence) |
: sequence_(sequence) { |