Chromium Code Reviews| Index: ui/views/animation/flood_fill_ink_drop_ripple.cc |
| diff --git a/ui/views/animation/flood_fill_ink_drop_ripple.cc b/ui/views/animation/flood_fill_ink_drop_ripple.cc |
| index 10459d8c956d81588dbb6497b2631fd6b9415ffe..060d83208143aa5ae4b4c9c489103b336c64a3c6 100644 |
| --- a/ui/views/animation/flood_fill_ink_drop_ripple.cc |
| +++ b/ui/views/animation/flood_fill_ink_drop_ripple.cc |
| @@ -215,11 +215,10 @@ void FloodFillInkDropRipple::AnimateStateChange( |
| GetAnimationDuration(ACTION_PENDING_FADE_IN), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| gfx::Tween::EASE_IN, animation_observer); |
| - AnimateToOpacity(visible_opacity_, |
| - GetAnimationDuration(ACTION_PENDING_TRANSFORM) - |
| - GetAnimationDuration(ACTION_PENDING_FADE_IN), |
| - ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| - gfx::Tween::EASE_IN, animation_observer); |
| + PauseOpacityAnimation(GetAnimationDuration(ACTION_PENDING_TRANSFORM) - |
| + GetAnimationDuration(ACTION_PENDING_FADE_IN), |
| + ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| + animation_observer); |
| AnimateToTransform(GetMaxSizeTargetTransform(), |
| GetAnimationDuration(ACTION_PENDING_TRANSFORM), |
| @@ -260,6 +259,20 @@ void FloodFillInkDropRipple::AnimateStateChange( |
| gfx::Tween::EASE_IN_OUT, animation_observer); |
| break; |
| case InkDropState::ACTIVATED: { |
| + if (old_ink_drop_state == InkDropState::ACTION_PENDING) { |
| + // The final state of pending animation is the same as the final state |
|
bruthig
2017/01/05 20:20:39
Can this be confirmed/enforced by a test?
mohsen
2017/01/06 19:48:06
Done.
|
| + // of activated animation. We only need to enqueue a zero-length pause |
| + // so that animation observers are notified in order. |
|
bruthig
2017/01/05 20:20:39
Can this be confirmed/enforced by a test?
mohsen
2017/01/06 19:48:06
Done.
|
| + PauseOpacityAnimation( |
| + base::TimeDelta(), |
| + ui::LayerAnimator::PreemptionStrategy::ENQUEUE_NEW_ANIMATION, |
| + animation_observer); |
| + PauseTransformAnimation( |
| + base::TimeDelta(), |
| + ui::LayerAnimator::PreemptionStrategy::ENQUEUE_NEW_ANIMATION, |
| + animation_observer); |
| + break; |
| + } |
| AnimateToOpacity(visible_opacity_, |
| GetAnimationDuration(ACTIVATED_FADE_IN), |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| @@ -313,6 +326,27 @@ void FloodFillInkDropRipple::AnimateToTransform( |
| animator->StartAnimation(sequence); |
| } |
| +void FloodFillInkDropRipple::PauseTransformAnimation( |
| + base::TimeDelta duration, |
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| + ui::LayerAnimationObserver* observer) { |
| + ui::LayerAnimator* animator = painted_layer_.GetAnimator(); |
| + ui::ScopedLayerAnimationSettings animation(animator); |
| + animation.SetPreemptionStrategy(preemption_strategy); |
| + |
| + std::unique_ptr<ui::LayerAnimationElement> element = |
| + ui::LayerAnimationElement::CreatePauseElement( |
| + ui::LayerAnimationElement::TRANSFORM, duration); |
| + |
| + ui::LayerAnimationSequence* sequence = |
| + new ui::LayerAnimationSequence(std::move(element)); |
| + |
| + if (observer) |
| + sequence->AddObserver(observer); |
| + |
| + animator->StartAnimation(sequence); |
| +} |
| + |
| void FloodFillInkDropRipple::SetOpacity(float opacity) { |
| root_layer_.SetOpacity(opacity); |
| } |
| @@ -338,6 +372,27 @@ void FloodFillInkDropRipple::AnimateToOpacity( |
| animator->StartAnimation(animation_sequence); |
| } |
| +void FloodFillInkDropRipple::PauseOpacityAnimation( |
| + base::TimeDelta duration, |
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| + ui::LayerAnimationObserver* observer) { |
| + ui::LayerAnimator* animator = root_layer_.GetAnimator(); |
| + ui::ScopedLayerAnimationSettings animation(animator); |
| + animation.SetPreemptionStrategy(preemption_strategy); |
| + |
| + std::unique_ptr<ui::LayerAnimationElement> element = |
| + ui::LayerAnimationElement::CreatePauseElement( |
| + ui::LayerAnimationElement::OPACITY, duration); |
| + |
| + ui::LayerAnimationSequence* sequence = |
| + new ui::LayerAnimationSequence(std::move(element)); |
| + |
| + if (observer) |
| + sequence->AddObserver(observer); |
| + |
| + animator->StartAnimation(sequence); |
| +} |
| + |
| gfx::Transform FloodFillInkDropRipple::CalculateTransform( |
| float target_radius) const { |
| const float target_scale = target_radius / circle_layer_delegate_.radius(); |