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

Side by Side Diff: ui/views/animation/ink_drop_impl.cc

Issue 2431493002: MD Buttons: Don't add layers for hidden -> hidden transitions. (Closed)
Patch Set: Additional test Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/animation/ink_drop_impl.h" 5 #include "ui/views/animation/ink_drop_impl.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/views/animation/ink_drop_highlight.h" 10 #include "ui/views/animation/ink_drop_highlight.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 DestroyInkDropHighlight(); 67 DestroyInkDropHighlight();
68 } 68 }
69 69
70 InkDropState InkDropImpl::GetTargetInkDropState() const { 70 InkDropState InkDropImpl::GetTargetInkDropState() const {
71 if (!ink_drop_ripple_) 71 if (!ink_drop_ripple_)
72 return InkDropState::HIDDEN; 72 return InkDropState::HIDDEN;
73 return ink_drop_ripple_->target_ink_drop_state(); 73 return ink_drop_ripple_->target_ink_drop_state();
74 } 74 }
75 75
76 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { 76 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) {
77 // Never animate hidden -> hidden, since that will add layers which may never
78 // be needed. Other same-state transitions may restart animations.
79 if (ink_drop_state == InkDropState::HIDDEN &&
80 GetTargetInkDropState() == InkDropState::HIDDEN)
81 return;
82
77 DestroyHiddenTargetedAnimations(); 83 DestroyHiddenTargetedAnimations();
78 if (!ink_drop_ripple_) 84 if (!ink_drop_ripple_)
79 CreateInkDropRipple(); 85 CreateInkDropRipple();
80 86
81 if (ink_drop_ripple_->OverridesHighlight()) { 87 if (ink_drop_ripple_->OverridesHighlight()) {
82 // When deactivating and the host is focused, snap back to the highlight 88 // When deactivating and the host is focused, snap back to the highlight
83 // state. (In the case of highlighting due to hover, we'll animate the 89 // state. (In the case of highlighting due to hover, we'll animate the
84 // highlight back in after a delay.) 90 // highlight back in after a delay.)
85 if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) { 91 if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) {
86 ink_drop_ripple_->HideImmediately(); 92 ink_drop_ripple_->HideImmediately();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 271 }
266 272
267 void InkDropImpl::HighlightAfterRippleTimerFired() { 273 void InkDropImpl::HighlightAfterRippleTimerFired() {
268 SetHighlight(true, base::TimeDelta::FromMilliseconds( 274 SetHighlight(true, base::TimeDelta::FromMilliseconds(
269 kHighlightFadeInAfterRippleDurationMs), 275 kHighlightFadeInAfterRippleDurationMs),
270 true); 276 true);
271 highlight_after_ripple_timer_.reset(); 277 highlight_after_ripple_timer_.reset();
272 } 278 }
273 279
274 } // namespace views 280 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698