Chromium Code Reviews| Index: ui/views/animation/ink_drop_impl.cc |
| diff --git a/ui/views/animation/ink_drop_impl.cc b/ui/views/animation/ink_drop_impl.cc |
| index fdc6b773cdfccae8b67a7bd01f15e0d8e20fa61f..3872270680aeef4a56453c392dd8d190203a9bf0 100644 |
| --- a/ui/views/animation/ink_drop_impl.cc |
| +++ b/ui/views/animation/ink_drop_impl.cc |
| @@ -78,19 +78,21 @@ void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { |
| if (!ink_drop_ripple_) |
| CreateInkDropRipple(); |
| - // When deactivating and the host is focused, snap back to the highlight |
| - // state. (In the case of highlighting due to hover, we'll animate the |
| - // highlight back in after a delay.) |
| - if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) { |
| - ink_drop_ripple_->HideImmediately(); |
| - SetHighlight(true, base::TimeDelta(), false); |
| - return; |
| - } |
| - |
| - if (ink_drop_state != views::InkDropState::HIDDEN) { |
| - SetHighlight(false, base::TimeDelta::FromMilliseconds( |
| - kHighlightFadeOutBeforeRippleDurationMs), |
| - true); |
| + if (ink_drop_ripple_->OverridesHighlight()) { |
| + // When deactivating and the host is focused, snap back to the highlight |
| + // state. (In the case of highlighting due to hover, we'll animate the |
| + // highlight back in after a delay.) |
| + if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) { |
| + ink_drop_ripple_->HideImmediately(); |
| + SetHighlight(true, base::TimeDelta(), false); |
| + return; |
| + } |
| + |
| + if (ink_drop_state != views::InkDropState::HIDDEN) { |
| + SetHighlight(false, base::TimeDelta::FromMilliseconds( |
| + kHighlightFadeOutBeforeRippleDurationMs), |
| + true); |
| + } |
| } |
| ink_drop_ripple_->AnimateToState(ink_drop_state); |
| @@ -101,7 +103,8 @@ void InkDropImpl::SnapToActivated() { |
| if (!ink_drop_ripple_) |
| CreateInkDropRipple(); |
| - SetHighlight(false, base::TimeDelta(), false); |
| + if (ink_drop_ripple_->OverridesHighlight()) |
| + SetHighlight(false, base::TimeDelta(), false); |
| ink_drop_ripple_->SnapToActivated(); |
| } |
| @@ -133,15 +136,18 @@ void InkDropImpl::DestroyHiddenTargetedAnimations() { |
| void InkDropImpl::CreateInkDropRipple() { |
| DestroyInkDropRipple(); |
| ink_drop_ripple_ = ink_drop_host_->CreateInkDropRipple(); |
| - ink_drop_ripple_->set_observer(this); |
| - root_layer_->Add(ink_drop_ripple_->GetRootLayer()); |
| + if (ink_drop_ripple_->GetRootLayer()) { |
| + ink_drop_ripple_->set_observer(this); |
| + root_layer_->Add(ink_drop_ripple_->GetRootLayer()); |
| + } |
| AddRootLayerToHostIfNeeded(); |
| } |
| void InkDropImpl::DestroyInkDropRipple() { |
| if (!ink_drop_ripple_) |
| return; |
| - root_layer_->Remove(ink_drop_ripple_->GetRootLayer()); |
| + if (ink_drop_ripple_->GetRootLayer()) |
| + root_layer_->Remove(ink_drop_ripple_->GetRootLayer()); |
| ink_drop_ripple_.reset(); |
| RemoveRootLayerFromHostIfNeeded(); |
| } |
| @@ -199,10 +205,12 @@ void InkDropImpl::AnimationEnded(InkDropState ink_drop_state, |
| } else if (ink_drop_state == views::InkDropState::HIDDEN) { |
| // Re-highlight, as necessary. For hover, there's a delay; for focus, jump |
| // straight into the animation. |
| - if (is_focused_) |
| - HighlightAfterRippleTimerFired(); |
| - else if (is_hovered_) |
| - StartHighlightAfterRippleTimer(); |
| + if (ink_drop_ripple_->OverridesHighlight()) { |
|
bruthig
2016/08/25 17:45:29
I'm wondering if this should check |ink_drop_highl
Evan Stade
2016/08/26 23:36:15
Done.
|
| + if (is_focused_) |
| + HighlightAfterRippleTimerFired(); |
| + else if (is_hovered_) |
| + StartHighlightAfterRippleTimer(); |
| + } |
| // TODO(bruthig): Investigate whether creating and destroying |
| // InkDropRipples is expensive and consider creating an |