| Index: ui/views/animation/ink_drop_ripple.cc
|
| diff --git a/ui/views/animation/ink_drop_ripple.cc b/ui/views/animation/ink_drop_ripple.cc
|
| index 06e38439bbe145737f01b123ec89bfc7f3e6ac74..d2784da20028c0e3aa192a29cb93e7cc46643f37 100644
|
| --- a/ui/views/animation/ink_drop_ripple.cc
|
| +++ b/ui/views/animation/ink_drop_ripple.cc
|
| @@ -55,13 +55,15 @@ void InkDropRipple::AnimateToState(InkDropState ink_drop_state) {
|
| // will get the target InkDropState when calling GetInkDropState().
|
| target_ink_drop_state_ = ink_drop_state;
|
|
|
| - if (old_ink_drop_state == InkDropState::HIDDEN &&
|
| - target_ink_drop_state_ != InkDropState::HIDDEN) {
|
| - GetRootLayer()->SetVisible(true);
|
| + if (GetRootLayer()) {
|
| + if (old_ink_drop_state == InkDropState::HIDDEN &&
|
| + target_ink_drop_state_ != InkDropState::HIDDEN) {
|
| + GetRootLayer()->SetVisible(true);
|
| + }
|
| +
|
| + AnimateStateChange(old_ink_drop_state, target_ink_drop_state_,
|
| + animation_observer);
|
| }
|
| -
|
| - AnimateStateChange(old_ink_drop_state, target_ink_drop_state_,
|
| - animation_observer);
|
| animation_observer->SetActive();
|
| // |this| may be deleted! |animation_observer| might synchronously call
|
| // AnimationEndedCallback which can delete |this|.
|
| @@ -79,11 +81,16 @@ void InkDropRipple::SnapToActivated() {
|
| base::Unretained(this), InkDropState::ACTIVATED),
|
| base::Bind(&InkDropRipple::AnimationEndedCallback,
|
| base::Unretained(this), InkDropState::ACTIVATED));
|
| - GetRootLayer()->SetVisible(true);
|
| + if (GetRootLayer())
|
| + GetRootLayer()->SetVisible(true);
|
| target_ink_drop_state_ = InkDropState::ACTIVATED;
|
| animation_observer->SetActive();
|
| }
|
|
|
| +bool InkDropRipple::IsVisible() {
|
| + return GetRootLayer() && GetRootLayer()->visible();
|
| +}
|
| +
|
| void InkDropRipple::HideImmediately() {
|
| AbortAllAnimations();
|
| SetStateToHidden();
|
| @@ -97,7 +104,8 @@ test::InkDropRippleTestApi* InkDropRipple::GetTestApi() {
|
| void InkDropRipple::AnimationStartedCallback(
|
| InkDropState ink_drop_state,
|
| const ui::CallbackLayerAnimationObserver& observer) {
|
| - observer_->AnimationStarted(ink_drop_state);
|
| + if (observer_)
|
| + observer_->AnimationStarted(ink_drop_state);
|
| }
|
|
|
| bool InkDropRipple::AnimationEndedCallback(
|
| @@ -105,11 +113,13 @@ bool InkDropRipple::AnimationEndedCallback(
|
| const ui::CallbackLayerAnimationObserver& observer) {
|
| if (ink_drop_state == InkDropState::HIDDEN)
|
| SetStateToHidden();
|
| - observer_->AnimationEnded(ink_drop_state,
|
| - observer.aborted_count()
|
| - ? InkDropAnimationEndedReason::PRE_EMPTED
|
| - : InkDropAnimationEndedReason::SUCCESS);
|
| - // |this| may be deleted!
|
| + if (observer_) {
|
| + observer_->AnimationEnded(ink_drop_state,
|
| + observer.aborted_count()
|
| + ? InkDropAnimationEndedReason::PRE_EMPTED
|
| + : InkDropAnimationEndedReason::SUCCESS);
|
| + // |this| may be deleted!
|
| + }
|
| return true;
|
| }
|
|
|
|
|