Index: ui/gfx/compositor/layer_animation_observer.cc |
diff --git a/ui/gfx/compositor/layer_animation_observer.cc b/ui/gfx/compositor/layer_animation_observer.cc |
index 23217a57df6f23b50afdbdb0590d296832612f8b..cebd29c9224781fb80458b676fe1c527a8215ab5 100644 |
--- a/ui/gfx/compositor/layer_animation_observer.cc |
+++ b/ui/gfx/compositor/layer_animation_observer.cc |
@@ -11,10 +11,6 @@ namespace ui { |
//////////////////////////////////////////////////////////////////////////////// |
// LayerAnimationObserver |
-bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const { |
- return false; |
-} |
- |
LayerAnimationObserver::LayerAnimationObserver() { |
} |
@@ -25,6 +21,18 @@ LayerAnimationObserver::~LayerAnimationObserver() { |
} |
} |
+bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const { |
+ return false; |
+} |
+ |
+void LayerAnimationObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
+} |
+ |
+void LayerAnimationObserver::OnDetachedFromSequence( |
+ LayerAnimationSequence* sequence) { |
+} |
+ |
void LayerAnimationObserver::AttachedToSequence( |
LayerAnimationSequence* sequence) { |
DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end()); |
@@ -41,8 +49,7 @@ void LayerAnimationObserver::DetachedFromSequence( |
// ImplicitAnimationObserver |
ImplicitAnimationObserver::ImplicitAnimationObserver() |
- : active_(false), |
- animation_count_(0) { |
+ : active_(false) { |
} |
ImplicitAnimationObserver::~ImplicitAnimationObserver() {} |
@@ -54,24 +61,43 @@ void ImplicitAnimationObserver::SetActive(bool active) { |
void ImplicitAnimationObserver::OnLayerAnimationEnded( |
const LayerAnimationSequence* sequence) { |
- animation_count_--; |
+ unfinished_animations_.erase(sequence); |
CheckCompleted(); |
} |
void ImplicitAnimationObserver::OnLayerAnimationAborted( |
const LayerAnimationSequence* sequence) { |
- animation_count_--; |
+ unfinished_animations_.erase(sequence); |
CheckCompleted(); |
} |
void ImplicitAnimationObserver::OnLayerAnimationScheduled( |
const LayerAnimationSequence* sequence) { |
- animation_count_++; |
+ unfinished_animations_.insert(sequence); |
+} |
+ |
+void ImplicitAnimationObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
+ // If we're attached to a sequence that is already animating, we must add it |
+ // to the list now (because we've missed the AnimationScheduled notification). |
+ if (sequence->is_animating()) |
+ unfinished_animations_.insert(sequence); |
+} |
+ |
+void ImplicitAnimationObserver::OnDetachedFromSequence( |
+ LayerAnimationSequence* sequence) { |
+ // There is a chance that we were removed as an observer while an animation |
+ // was in progress. It is important that we remove this animation from the |
+ // list in this case, so we will attempt to remove the animation now. |
+ unfinished_animations_.erase(sequence); |
+ CheckCompleted(); |
} |
void ImplicitAnimationObserver::CheckCompleted() { |
- if (active_ && animation_count_ == 0) |
+ if (active_ && unfinished_animations_.empty()) { |
OnImplicitAnimationsCompleted(); |
+ active_ = false; |
+ } |
} |
} // namespace ui |