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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 CheckCompleted(); | 113 CheckCompleted(); |
114 } | 114 } |
115 | 115 |
116 void ImplicitAnimationObserver::CheckCompleted() { | 116 void ImplicitAnimationObserver::CheckCompleted() { |
117 if (active_ && attached_sequences().empty()) { | 117 if (active_ && attached_sequences().empty()) { |
118 active_ = false; | 118 active_ = false; |
119 OnImplicitAnimationsCompleted(); | 119 OnImplicitAnimationsCompleted(); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
| 123 //////////////////////////////////////////////////////////////////////////////// |
| 124 // AnimationFinishedObserver |
| 125 |
| 126 AnimationFinishedObserver::AnimationFinishedObserver( |
| 127 base::Callback<void(void)> &callback) |
| 128 : callback_(callback), |
| 129 sequences_attached_(0), |
| 130 sequences_completed_(0), |
| 131 paused_(false) { |
| 132 } |
| 133 |
| 134 AnimationFinishedObserver::~AnimationFinishedObserver() { |
| 135 } |
| 136 |
| 137 void AnimationFinishedObserver::Pause() { |
| 138 paused_ = true; |
| 139 } |
| 140 |
| 141 void AnimationFinishedObserver::Unpause() { |
| 142 if (!paused_) |
| 143 return; |
| 144 paused_ = false; |
| 145 if (sequences_completed_ == sequences_attached_) { |
| 146 callback_.Run(); |
| 147 delete this; |
| 148 } |
| 149 } |
| 150 |
| 151 void AnimationFinishedObserver::OnLayerAnimationEnded( |
| 152 ui::LayerAnimationSequence* seq) { |
| 153 sequences_completed_++; |
| 154 if ((sequences_completed_ == sequences_attached_) && !paused_) { |
| 155 callback_.Run(); |
| 156 delete this; |
| 157 } |
| 158 } |
| 159 |
| 160 void AnimationFinishedObserver::OnLayerAnimationAborted( |
| 161 ui::LayerAnimationSequence* seq) { |
| 162 sequences_completed_++; |
| 163 if ((sequences_completed_ == sequences_attached_) && !paused_) |
| 164 delete this; |
| 165 } |
| 166 |
| 167 void AnimationFinishedObserver::OnAttachedToSequence( |
| 168 LayerAnimationSequence* sequence) { |
| 169 LayerAnimationObserver::OnAttachedToSequence(sequence); |
| 170 sequences_attached_++; |
| 171 } |
| 172 |
| 173 //////////////////////////////////////////////////////////////////////////////// |
| 174 // AnimationAbortedObserver |
| 175 |
| 176 AnimationAbortedObserver::AnimationAbortedObserver( |
| 177 base::Callback<void(void)> &callback) |
| 178 : callback_(callback), |
| 179 sequences_attached_(0), |
| 180 sequences_completed_(0), |
| 181 aborted_(false) { |
| 182 } |
| 183 |
| 184 AnimationAbortedObserver::~AnimationAbortedObserver() { |
| 185 if (sequences_completed_ != sequences_attached_) { |
| 186 if (aborted_) |
| 187 callback_.Run(); |
| 188 } |
| 189 } |
| 190 |
| 191 void AnimationAbortedObserver::Pause() { |
| 192 paused_ = true; |
| 193 } |
| 194 |
| 195 void AnimationAbortedObserver::Unpause() { |
| 196 if (!paused_) |
| 197 return; |
| 198 paused_ = false; |
| 199 if (sequences_completed_ == sequences_attached_) { |
| 200 if (aborted_) |
| 201 callback_.Run(); |
| 202 delete this; |
| 203 } |
| 204 } |
| 205 |
| 206 void AnimationAbortedObserver::OnLayerAnimationEnded( |
| 207 ui::LayerAnimationSequence* seq) { |
| 208 sequences_completed_++; |
| 209 if ((sequences_completed_ == sequences_attached_) && !paused_) { |
| 210 if (aborted_) |
| 211 callback_.Run(); |
| 212 delete this; |
| 213 } |
| 214 } |
| 215 |
| 216 void AnimationAbortedObserver::OnLayerAnimationAborted( |
| 217 ui::LayerAnimationSequence* seq) { |
| 218 aborted_ = true; |
| 219 sequences_completed_++; |
| 220 if ((sequences_completed_ == sequences_attached_) && !paused_) { |
| 221 callback_.Run(); |
| 222 delete this; |
| 223 } |
| 224 } |
| 225 |
| 226 void AnimationAbortedObserver::OnAttachedToSequence( |
| 227 LayerAnimationSequence* sequence) { |
| 228 LayerAnimationObserver::OnAttachedToSequence(sequence); |
| 229 sequences_attached_++; |
| 230 } |
| 231 |
123 } // namespace ui | 232 } // namespace ui |
OLD | NEW |