Chromium Code Reviews| Index: ui/views/animation/ink_drop_animation_controller_impl.cc |
| diff --git a/ui/views/animation/ink_drop_animation_controller_impl.cc b/ui/views/animation/ink_drop_animation_controller_impl.cc |
| index 0e885df1c2cf66a1e77ec84e49dcfe5d2b7898c2..c277761e8b8e35616382da8b6c8d0dff905e5dbc 100644 |
| --- a/ui/views/animation/ink_drop_animation_controller_impl.cc |
| +++ b/ui/views/animation/ink_drop_animation_controller_impl.cc |
| @@ -81,8 +81,7 @@ bool InkDropAnimationControllerImpl::IsVisible() const { |
| void InkDropAnimationControllerImpl::AnimateToState( |
| InkDropState ink_drop_state) { |
| - if (!ink_drop_animation_) |
| - CreateInkDropAnimation(); |
| + EnsureInkDropAnimation(); |
| // The InkDropAnimationObserver::InkDropAnimationEnded() callback needs to |
| // know if it is safe to destroy the |ink_drop_animation_| and it is not safe |
| @@ -117,14 +116,13 @@ bool InkDropAnimationControllerImpl::IsHovered() const { |
| return hover_ && hover_->IsVisible(); |
| } |
| -gfx::Size InkDropAnimationControllerImpl::GetInkDropLargeSize() const { |
| - return ink_drop_large_size_; |
| -} |
| - |
| void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& large_size, |
| int large_corner_radius, |
| const gfx::Size& small_size, |
| int small_corner_radius) { |
| + CHECK(!ink_drop_animation_); |
| + CHECK(!hover_); |
|
sadrul
2016/02/10 23:26:49
D versions?
Evan Stade
2016/02/11 00:13:25
ah yes, thanks, meant to DCHECK. CHECK was just fo
|
| + |
| // TODO(bruthig): Fix the ink drop animations to work for non-square sizes. |
| DCHECK_EQ(large_size.width(), large_size.height()) |
| << "The ink drop animation does not currently support non-square sizes."; |
| @@ -134,9 +132,6 @@ void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& large_size, |
| ink_drop_large_corner_radius_ = large_corner_radius; |
| ink_drop_small_size_ = small_size; |
| ink_drop_small_corner_radius_ = small_corner_radius; |
| - |
| - DestroyInkDropAnimation(); |
| - DestroyInkDropHover(); |
| } |
| void InkDropAnimationControllerImpl::SetInkDropCenter( |
| @@ -148,12 +143,16 @@ void InkDropAnimationControllerImpl::SetInkDropCenter( |
| hover_->SetCenterPoint(ink_drop_center_); |
| } |
| -void InkDropAnimationControllerImpl::CreateInkDropAnimation() { |
| +void InkDropAnimationControllerImpl::EnsureInkDropAnimation() { |
| + SkColor color = ink_drop_host_->GetInkDropBaseColor(); |
| + if (ink_drop_animation_ && ink_drop_animation_->GetColor() == color) |
| + return; |
| + |
| DestroyInkDropAnimation(); |
| ink_drop_animation_.reset(new SquareInkDropAnimation( |
| - ink_drop_large_size_, ink_drop_large_corner_radius_, ink_drop_small_size_, |
| - ink_drop_small_corner_radius_)); |
| + color, ink_drop_large_size_, ink_drop_large_corner_radius_, |
| + ink_drop_small_size_, ink_drop_small_corner_radius_)); |
| ink_drop_animation_->AddObserver(this); |
| ink_drop_animation_->SetCenterPoint(ink_drop_center_); |
| @@ -168,11 +167,16 @@ void InkDropAnimationControllerImpl::DestroyInkDropAnimation() { |
| ink_drop_animation_.reset(); |
| } |
| -void InkDropAnimationControllerImpl::CreateInkDropHover() { |
| +void InkDropAnimationControllerImpl::EnsureInkDropHover() { |
| + SkColor color = ink_drop_host_->GetInkDropBaseColor(); |
| + if (hover_ && hover_->GetColor() == color) |
| + return; |
| + |
| DestroyInkDropHover(); |
| - hover_.reset( |
| - new InkDropHover(ink_drop_small_size_, ink_drop_small_corner_radius_)); |
| + hover_.reset(new InkDropHover(ink_drop_host_->GetInkDropBaseColor(), |
| + ink_drop_small_size_, |
| + ink_drop_small_corner_radius_)); |
| hover_->SetCenterPoint(ink_drop_center_); |
| root_layer_->Add(hover_->layer()); |
| } |
| @@ -219,11 +223,9 @@ void InkDropAnimationControllerImpl::SetHoveredInternal( |
| return; |
| if (is_hovered) { |
| - if (!hover_) |
| - CreateInkDropHover(); |
| - if (!IsVisible()) { |
| + EnsureInkDropHover(); |
| + if (!IsVisible()) |
| hover_->FadeIn(animation_duration); |
| - } |
| } else { |
| hover_->FadeOut(animation_duration); |
| } |