| 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_animation_observer.h" | 5 #include "ui/compositor/layer_animation_observer.h" |
| 6 | 6 |
| 7 #include "ui/compositor/layer_animation_sequence.h" | 7 #include "ui/compositor/layer_animation_sequence.h" |
| 8 | 8 |
| 9 namespace ui { | 9 namespace ui { |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (attached_sequences_.find(sequence) != attached_sequences_.end()) | 49 if (attached_sequences_.find(sequence) != attached_sequences_.end()) |
| 50 attached_sequences_.erase(sequence); | 50 attached_sequences_.erase(sequence); |
| 51 if (send_notification) | 51 if (send_notification) |
| 52 OnDetachedFromSequence(sequence); | 52 OnDetachedFromSequence(sequence); |
| 53 } | 53 } |
| 54 | 54 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
| 56 // ImplicitAnimationObserver | 56 // ImplicitAnimationObserver |
| 57 | 57 |
| 58 ImplicitAnimationObserver::ImplicitAnimationObserver() | 58 ImplicitAnimationObserver::ImplicitAnimationObserver() |
| 59 : active_(false) { | 59 : active_(false), |
| 60 destroyed_(NULL) { |
| 60 } | 61 } |
| 61 | 62 |
| 62 ImplicitAnimationObserver::~ImplicitAnimationObserver() {} | 63 ImplicitAnimationObserver::~ImplicitAnimationObserver() { |
| 64 if (destroyed_) |
| 65 *destroyed_ = true; |
| 66 } |
| 63 | 67 |
| 64 void ImplicitAnimationObserver::SetActive(bool active) { | 68 void ImplicitAnimationObserver::SetActive(bool active) { |
| 65 active_ = active; | 69 active_ = active; |
| 66 CheckCompleted(); | 70 CheckCompleted(); |
| 67 } | 71 } |
| 68 | 72 |
| 69 void ImplicitAnimationObserver::StopObservingImplicitAnimations() { | 73 void ImplicitAnimationObserver::StopObservingImplicitAnimations() { |
| 70 SetActive(false); | 74 SetActive(false); |
| 71 StopObserving(); | 75 StopObserving(); |
| 72 } | 76 } |
| 73 | 77 |
| 74 void ImplicitAnimationObserver::OnLayerAnimationEnded( | 78 void ImplicitAnimationObserver::OnLayerAnimationEnded( |
| 75 LayerAnimationSequence* sequence) { | 79 LayerAnimationSequence* sequence) { |
| 80 bool destroyed = false; |
| 81 destroyed_ = &destroyed; |
| 76 sequence->RemoveObserver(this); | 82 sequence->RemoveObserver(this); |
| 83 if (destroyed) |
| 84 return; |
| 85 destroyed_ = NULL; |
| 77 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | 86 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
| 78 CheckCompleted(); | 87 CheckCompleted(); |
| 79 } | 88 } |
| 80 | 89 |
| 81 void ImplicitAnimationObserver::OnLayerAnimationAborted( | 90 void ImplicitAnimationObserver::OnLayerAnimationAborted( |
| 82 LayerAnimationSequence* sequence) { | 91 LayerAnimationSequence* sequence) { |
| 83 sequence->RemoveObserver(this); | 92 sequence->RemoveObserver(this); |
| 84 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | 93 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
| 85 CheckCompleted(); | 94 CheckCompleted(); |
| 86 } | 95 } |
| 87 | 96 |
| 88 void ImplicitAnimationObserver::OnLayerAnimationScheduled( | 97 void ImplicitAnimationObserver::OnLayerAnimationScheduled( |
| 89 LayerAnimationSequence* sequence) { | 98 LayerAnimationSequence* sequence) { |
| 90 } | 99 } |
| 91 | 100 |
| 92 void ImplicitAnimationObserver::OnAttachedToSequence( | 101 void ImplicitAnimationObserver::OnAttachedToSequence( |
| 93 LayerAnimationSequence* sequence) { | 102 LayerAnimationSequence* sequence) { |
| 94 } | 103 } |
| 95 | 104 |
| 96 void ImplicitAnimationObserver::OnDetachedFromSequence( | 105 void ImplicitAnimationObserver::OnDetachedFromSequence( |
| 97 LayerAnimationSequence* sequence) { | 106 LayerAnimationSequence* sequence) { |
| 98 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | 107 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
| 99 CheckCompleted(); | 108 CheckCompleted(); |
| 100 } | 109 } |
| 101 | 110 |
| 102 void ImplicitAnimationObserver::CheckCompleted() { | 111 void ImplicitAnimationObserver::CheckCompleted() { |
| 103 if (active_ && attached_sequences().empty()) { | 112 if (active_ && attached_sequences().empty()) { |
| 113 active_ = false; |
| 104 OnImplicitAnimationsCompleted(); | 114 OnImplicitAnimationsCompleted(); |
| 105 active_ = false; | |
| 106 } | 115 } |
| 107 } | 116 } |
| 108 | 117 |
| 109 } // namespace ui | 118 } // namespace ui |
| OLD | NEW |