Chromium Code Reviews| Index: ui/compositor/layer_animator.cc |
| diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc |
| index a6fcd7da224a9652803421f4f82ce9ab0ebd958e..cc58b3efc102e3c024d6a068ce71151fdc2ebb9b 100644 |
| --- a/ui/compositor/layer_animator.cc |
| +++ b/ui/compositor/layer_animator.cc |
| @@ -45,6 +45,41 @@ ui::AnimationContainer* GetAnimationContainer() { |
| return container; |
| } |
| +class SuccessCallbackAnimationObserver : public LayerAnimationObserver { |
| + public: |
| + SuccessCallbackAnimationObserver(base::Closure callback) |
| + : callback_(callback), |
| + num_attached_sequences_(0) { |
| + } |
| + |
| + virtual void OnLayerAnimationEnded(LayerAnimationSequence* sequence) { |
|
Daniel Erat
2012/11/27 19:03:27
nit: add OVERRIDE to all overridden methods, along
Denis Kuznetsov (DE-MUC)
2012/11/28 15:41:46
Done.
|
| + callback_.Run(); |
| + callback_.Reset(); |
| + } |
| + |
| + virtual void OnLayerAnimationAborted( |
| + LayerAnimationSequence* sequence) {} |
| + |
| + virtual void OnLayerAnimationScheduled( |
| + LayerAnimationSequence* sequence) {} |
| + |
| + private: |
| + virtual void OnAttachedToSequence(LayerAnimationSequence* sequence) { |
| + num_attached_sequences_++; |
| + } |
| + |
| + virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence) { |
| + num_attached_sequences_--; |
| + if (num_attached_sequences_ == 0) |
| + delete this; |
| + } |
| + |
| + base::Closure callback_; |
| + int num_attached_sequences_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SuccessCallbackAnimationObserver); |
| +}; |
| + |
| } // namespace |
| // static |
| @@ -258,6 +293,28 @@ void LayerAnimator::SchedulePauseForProperties( |
| properties_to_pause, duration))); |
| } |
| +void LayerAnimator::SetCompletionCallbackForProperties( |
| + base::Closure& callback, |
| + LayerAnimationElement::AnimatableProperty property, |
| + ...) { |
| + ui::LayerAnimationElement::AnimatableProperties properties_to_pause; |
| + va_list marker; |
| + va_start(marker, property); |
| + for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) { |
| + properties_to_pause.insert( |
| + static_cast<LayerAnimationElement::AnimatableProperty>(p)); |
| + } |
| + va_end(marker); |
| + |
| + ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
| + ui::LayerAnimationElement::CreatePauseElement( |
| + properties_to_pause, base::TimeDelta())); |
| + |
| + sequence->AddObserver(new SuccessCallbackAnimationObserver(callback)); |
| + |
| + ScheduleAnimation(sequence); |
| +} |
| + |
| bool LayerAnimator::IsAnimatingProperty( |
| LayerAnimationElement::AnimatableProperty property) const { |
| for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin(); |
| @@ -540,7 +597,7 @@ void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) { |
| if (!weak_sequence_ptr) |
| return; |
| - ProgressAnimation(sequence, sequence->duration()); |
| + ProgressAnimationToEnd(sequence); |
| if (!weak_sequence_ptr) |
| return; |