Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: ui/views/animation/ink_drop_ripple.cc

Issue 2340993002: Tweaks to "Allow InkDropRipple to co-exist with highlight or not exist at all." (Closed)
Patch Set: Fixed InkDropImplTest.HighlightCanExistWithoutRipple. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/animation/ink_drop_ripple.h ('k') | ui/views/animation/ink_drop_ripple_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « ui/views/animation/ink_drop_ripple.h ('k') | ui/views/animation/ink_drop_ripple_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698