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

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

Issue 2499523003: Add ink drop masking to TrayBackgroundView (Closed)
Patch Set: Addressed review comments Created 4 years, 1 month 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
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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 this, animation_duration, explode); 568 this, animation_duration, explode);
569 case InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE: 569 case InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE:
570 return base::MakeUnique<ShowHighlightOnRippleVisibleState>( 570 return base::MakeUnique<ShowHighlightOnRippleVisibleState>(
571 this, animation_duration, explode); 571 this, animation_duration, explode);
572 } 572 }
573 // Required for some compilers. 573 // Required for some compilers.
574 NOTREACHED(); 574 NOTREACHED();
575 return nullptr; 575 return nullptr;
576 } 576 }
577 577
578 InkDropImpl::InkDropImpl(InkDropHost* ink_drop_host) 578 InkDropImpl::InkDropImpl(InkDropHost* ink_drop_host, const gfx::Size& host_size)
579 : ink_drop_host_(ink_drop_host), 579 : ink_drop_host_(ink_drop_host),
580 root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)), 580 root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)),
581 root_layer_added_to_host_(false), 581 root_layer_added_to_host_(false),
582 show_highlight_on_hover_(true), 582 show_highlight_on_hover_(true),
583 show_highlight_on_focus_(false), 583 show_highlight_on_focus_(false),
584 is_hovered_(false), 584 is_hovered_(false),
585 is_focused_(false), 585 is_focused_(false),
586 exiting_highlight_state_(false), 586 exiting_highlight_state_(false),
587 destroying_(false) { 587 destroying_(false) {
588 root_layer_->SetBounds(gfx::Rect(host_size));
588 SetAutoHighlightMode(AutoHighlightMode::NONE); 589 SetAutoHighlightMode(AutoHighlightMode::NONE);
589 root_layer_->set_name("InkDropImpl:RootLayer"); 590 root_layer_->set_name("InkDropImpl:RootLayer");
590 } 591 }
591 592
592 InkDropImpl::~InkDropImpl() { 593 InkDropImpl::~InkDropImpl() {
593 destroying_ = true; 594 destroying_ = true;
594 // Setting a no-op state prevents animations from being triggered on a null 595 // Setting a no-op state prevents animations from being triggered on a null
595 // |ink_drop_ripple_| as a side effect of the tear down. 596 // |ink_drop_ripple_| as a side effect of the tear down.
596 SetHighlightState(base::MakeUnique<DestroyingHighlightState>()); 597 SetHighlightState(base::MakeUnique<DestroyingHighlightState>());
597 598
(...skipping 15 matching lines...) Expand all
613 614
614 void InkDropImpl::SetAutoHighlightMode(AutoHighlightMode auto_highlight_mode) { 615 void InkDropImpl::SetAutoHighlightMode(AutoHighlightMode auto_highlight_mode) {
615 // Exit the current state completely first in case state tear down accesses 616 // Exit the current state completely first in case state tear down accesses
616 // the current |highlight_state_factory_| instance. 617 // the current |highlight_state_factory_| instance.
617 ExitHighlightState(); 618 ExitHighlightState();
618 highlight_state_factory_ = 619 highlight_state_factory_ =
619 base::MakeUnique<HighlightStateFactory>(auto_highlight_mode, this); 620 base::MakeUnique<HighlightStateFactory>(auto_highlight_mode, this);
620 SetHighlightState(highlight_state_factory_->CreateStartState()); 621 SetHighlightState(highlight_state_factory_->CreateStartState());
621 } 622 }
622 623
624 void InkDropImpl::HostSizeChanged(const gfx::Size& new_size) {
625 // |root_layer_| should fill the entire host because it affects the clipping
626 // when a mask layer is applied to it. This will not affect clipping if no
627 // mask layer is set.
628 root_layer_->SetBounds(gfx::Rect(new_size));
629 }
630
623 InkDropState InkDropImpl::GetTargetInkDropState() const { 631 InkDropState InkDropImpl::GetTargetInkDropState() const {
624 if (!ink_drop_ripple_) 632 if (!ink_drop_ripple_)
625 return InkDropState::HIDDEN; 633 return InkDropState::HIDDEN;
626 return ink_drop_ripple_->target_ink_drop_state(); 634 return ink_drop_ripple_->target_ink_drop_state();
627 } 635 }
628 636
629 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { 637 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) {
630 // Never animate hidden -> hidden, since that will add layers which may never 638 // Never animate hidden -> hidden, since that will add layers which may never
631 // be needed. Other same-state transitions may restart animations. 639 // be needed. Other same-state transitions may restart animations.
632 if (ink_drop_state == InkDropState::HIDDEN && 640 if (ink_drop_state == InkDropState::HIDDEN &&
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 "within a call to " 811 "within a call to "
804 "HighlightState::Exit()."; 812 "HighlightState::Exit().";
805 if (highlight_state_) { 813 if (highlight_state_) {
806 base::AutoReset<bool> exit_guard(&exiting_highlight_state_, true); 814 base::AutoReset<bool> exit_guard(&exiting_highlight_state_, true);
807 highlight_state_->Exit(); 815 highlight_state_->Exit();
808 } 816 }
809 highlight_state_ = nullptr; 817 highlight_state_ = nullptr;
810 } 818 }
811 819
812 } // namespace views 820 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698