Index: ui/compositor/layer_animator.cc |
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc |
index a6fcd7da224a9652803421f4f82ce9ab0ebd958e..506901850a49a24cf7c627f65396ea10c5529a90 100644 |
--- a/ui/compositor/layer_animator.cc |
+++ b/ui/compositor/layer_animator.cc |
@@ -45,6 +45,39 @@ ui::AnimationContainer* GetAnimationContainer() { |
return container; |
} |
+class SuccessCallbackAnimationObserver : public LayerAnimationObserver { |
+ public: |
+ SuccessCallbackAnimationObserver(base::Closure callback) |
+ : callback_(callback), |
+ attached_(0) { |
+ } |
+ |
+ virtual void OnLayerAnimationEnded(LayerAnimationSequence* sequence) { |
+ callback_.Run(); |
+ callback_.Reset(); |
+ } |
+ |
+ virtual void OnLayerAnimationAborted( |
+ LayerAnimationSequence* sequence) {} |
+ |
+ virtual void OnLayerAnimationScheduled( |
+ LayerAnimationSequence* sequence) {} |
+ |
+ private: |
+ virtual void OnAttachedToSequence(LayerAnimationSequence* sequence) { |
+ attached_++; |
+ } |
+ |
+ virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence) { |
+ attached_--; |
+ if (attached_ == 0) |
+ delete this; |
+ } |
+ |
+ base::Closure callback_; |
+ int attached_; |
Daniel Erat
2012/11/27 18:32:11
nit: rename to num_attached_sequences_ or somethin
Ian Vollick
2012/11/27 18:35:07
DISALLOW_COPY_AND_ASSIGN
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
Done.
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
Done.
|
+}; |
+ |
} // namespace |
// static |
@@ -258,6 +291,29 @@ void LayerAnimator::SchedulePauseForProperties( |
properties_to_pause, duration))); |
} |
+void LayerAnimator::ScheduleSuccessCallbackForProperties( |
+ 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( |
Daniel Erat
2012/11/27 18:32:11
pause?
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
We create PauseElement (one that does not change a
|
+ 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); |
+} |
+ |
Daniel Erat
2012/11/27 18:32:11
nit: delete extra blank line
Denis Kuznetsov (DE-MUC)
2012/11/27 18:46:59
Done.
|
+ |
bool LayerAnimator::IsAnimatingProperty( |
LayerAnimationElement::AnimatableProperty property) const { |
for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin(); |
@@ -540,7 +596,7 @@ void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) { |
if (!weak_sequence_ptr) |
return; |
- ProgressAnimation(sequence, sequence->duration()); |
+ ProgressAnimationToEnd(sequence); |
if (!weak_sequence_ptr) |
return; |