| Index: ui/compositor/layer_animator.cc
|
| diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
|
| index a6fcd7da224a9652803421f4f82ce9ab0ebd958e..eec2dfb9e6f3f5d8c43609a55bc65d49edc71a6f 100644
|
| --- a/ui/compositor/layer_animator.cc
|
| +++ b/ui/compositor/layer_animator.cc
|
| @@ -45,6 +45,43 @@ ui::AnimationContainer* GetAnimationContainer() {
|
| return container;
|
| }
|
|
|
| +class SuccessCallbackAnimationObserver : public LayerAnimationObserver {
|
| + public:
|
| + SuccessCallbackAnimationObserver(base::Closure callback)
|
| + : callback_(callback),
|
| + num_attached_sequences_(0) {
|
| + }
|
| +
|
| + // LayerAnimationObserver overrides:
|
| + virtual void OnLayerAnimationEnded(
|
| + LayerAnimationSequence* sequence) OVERRIDE {
|
| + callback_.Run();
|
| + callback_.Reset();
|
| + }
|
| +
|
| + virtual void OnLayerAnimationAborted(
|
| + LayerAnimationSequence* sequence) OVERRIDE {}
|
| +
|
| + virtual void OnLayerAnimationScheduled(
|
| + LayerAnimationSequence* sequence) OVERRIDE {}
|
| +
|
| + 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 +295,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 +599,7 @@ void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) {
|
| if (!weak_sequence_ptr)
|
| return;
|
|
|
| - ProgressAnimation(sequence, sequence->duration());
|
| + ProgressAnimationToEnd(sequence);
|
| if (!weak_sequence_ptr)
|
| return;
|
|
|
|
|