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..4821462f076455a048414b56318713ab1a92dc63 100644 |
--- a/ui/gfx/compositor/layer_animation_observer.cc |
+++ b/ui/gfx/compositor/layer_animation_observer.cc |
@@ -11,14 +11,26 @@ namespace ui { |
//////////////////////////////////////////////////////////////////////////////// |
// LayerAnimationObserver |
+LayerAnimationObserver::LayerAnimationObserver() { |
+} |
+ |
+LayerAnimationObserver::~LayerAnimationObserver() { |
+ DetachFromAllSequences(); |
+} |
+ |
bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const { |
return false; |
} |
-LayerAnimationObserver::LayerAnimationObserver() { |
+void LayerAnimationObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
} |
-LayerAnimationObserver::~LayerAnimationObserver() { |
+void LayerAnimationObserver::OnDetachedFromSequence( |
+ LayerAnimationSequence* sequence) { |
+} |
+ |
+void LayerAnimationObserver::DetachFromAllSequences() { |
while (!attached_sequences_.empty()) { |
LayerAnimationSequence* sequence = *attached_sequences_.begin(); |
sequence->RemoveObserver(this); |
@@ -29,20 +41,21 @@ void LayerAnimationObserver::AttachedToSequence( |
LayerAnimationSequence* sequence) { |
DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end()); |
attached_sequences_.insert(sequence); |
+ OnAttachedToSequence(sequence); |
} |
void LayerAnimationObserver::DetachedFromSequence( |
LayerAnimationSequence* sequence) { |
if (attached_sequences_.find(sequence) != attached_sequences_.end()) |
attached_sequences_.erase(sequence); |
+ OnDetachedFromSequence(sequence); |
} |
//////////////////////////////////////////////////////////////////////////////// |
// ImplicitAnimationObserver |
ImplicitAnimationObserver::ImplicitAnimationObserver() |
- : active_(false), |
- animation_count_(0) { |
+ : active_(false) { |
} |
ImplicitAnimationObserver::~ImplicitAnimationObserver() {} |
@@ -52,26 +65,44 @@ void ImplicitAnimationObserver::SetActive(bool active) { |
CheckCompleted(); |
} |
+void ImplicitAnimationObserver::StopObservingImplicitAnimations() { |
+ SetActive(false); |
+ DetachFromAllSequences(); |
+} |
+ |
void ImplicitAnimationObserver::OnLayerAnimationEnded( |
- const LayerAnimationSequence* sequence) { |
- animation_count_--; |
+ LayerAnimationSequence* sequence) { |
+ sequence->RemoveObserver(this); |
+ DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
CheckCompleted(); |
} |
void ImplicitAnimationObserver::OnLayerAnimationAborted( |
- const LayerAnimationSequence* sequence) { |
- animation_count_--; |
+ LayerAnimationSequence* sequence) { |
+ sequence->RemoveObserver(this); |
+ DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
CheckCompleted(); |
} |
void ImplicitAnimationObserver::OnLayerAnimationScheduled( |
- const LayerAnimationSequence* sequence) { |
- animation_count_++; |
+ LayerAnimationSequence* sequence) { |
+} |
+ |
+void ImplicitAnimationObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
+} |
+ |
+void ImplicitAnimationObserver::OnDetachedFromSequence( |
+ LayerAnimationSequence* sequence) { |
+ DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
+ CheckCompleted(); |
} |
void ImplicitAnimationObserver::CheckCompleted() { |
- if (active_ && animation_count_ == 0) |
+ if (active_ && attached_sequences().empty()) { |
OnImplicitAnimationsCompleted(); |
+ active_ = false; |
+ } |
} |
} // namespace ui |