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

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

Issue 2250783002: Allow InkDropRipple to co-exist with highlight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove EmptyInkDropRipple 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/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/ink_drop_impl_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_impl.cc
diff --git a/ui/views/animation/ink_drop_impl.cc b/ui/views/animation/ink_drop_impl.cc
index fdc6b773cdfccae8b67a7bd01f15e0d8e20fa61f..9d65896d2848b73d939d963653480a669c01e7a9 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();
}
@@ -168,6 +171,7 @@ void InkDropImpl::DestroyInkDropHighlight() {
void InkDropImpl::AddRootLayerToHostIfNeeded() {
DCHECK(highlight_ || ink_drop_ripple_);
+ DCHECK(!root_layer_->children().empty());
if (!root_layer_added_to_host_) {
root_layer_added_to_host_ = true;
ink_drop_host_->AddInkDropLayer(root_layer_.get());
@@ -199,10 +203,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 (!IsHighlightFadingInOrVisible()) {
+ if (is_focused_)
+ HighlightAfterRippleTimerFired();
+ else if (is_hovered_)
+ StartHighlightAfterRippleTimer();
+ }
// TODO(bruthig): Investigate whether creating and destroying
// InkDropRipples is expensive and consider creating an
@@ -235,8 +241,11 @@ void InkDropImpl::SetHighlight(bool should_highlight,
if (should_highlight) {
CreateInkDropHighlight();
- if (highlight_ && !(ink_drop_ripple_ && ink_drop_ripple_->IsVisible()))
+ if (highlight_ &&
+ !(ink_drop_ripple_ && ink_drop_ripple_->IsVisible() &&
+ ink_drop_ripple_->OverridesHighlight())) {
highlight_->FadeIn(animation_duration);
+ }
} else {
highlight_->FadeOut(animation_duration, explode);
}
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/ink_drop_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698