Chromium Code Reviews| Index: ui/views/controls/button/custom_button.cc |
| diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc |
| index e8ce4a003e394c3ff8f5ae260888f8806ddf8b1c..e42e649d1efa8cf875e585916644ec5d910a75d7 100644 |
| --- a/ui/views/controls/button/custom_button.cc |
| +++ b/ui/views/controls/button/custom_button.cc |
| @@ -56,9 +56,8 @@ CustomButton* CustomButton::AsCustomButton(views::View* view) { |
| } |
| CustomButton::~CustomButton() { |
| - // InkDropDelegate needs to be destroyed by now since it may need to call |
| - // methods on |this| via InkDropHost. |
| - DCHECK(!ink_drop_delegate_); |
| + // |ink_drop_delegate_| is invalid here since it is owned, and destroyed by |
| + // descendant classes. |
|
Peter Kasting
2015/12/18 18:44:03
I wouldn't add this comment, since there's no reas
bruthig
2015/12/21 16:54:34
Done.
|
| } |
| void CustomButton::SetState(ButtonState state) { |
| @@ -143,8 +142,11 @@ const char* CustomButton::GetClassName() const { |
| bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { |
| if (state_ == STATE_DISABLED) |
| return true; |
| - if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) |
| + if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) { |
| SetState(STATE_PRESSED); |
| + if (ink_drop_delegate_) |
| + ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); |
| + } |
| if (request_focus_on_press_) |
| RequestFocus(); |
| if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { |
| @@ -342,7 +344,9 @@ CustomButton::CustomButton(ButtonListener* listener) |
| triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), |
| request_focus_on_press_(true), |
| ink_drop_delegate_(nullptr), |
| - notify_action_(NOTIFY_ON_RELEASE) { |
| + notify_action_(NOTIFY_ON_RELEASE), |
| + has_ink_drop_action_on_click_(false), |
| + ink_drop_action_on_click_(InkDropState::QUICK_ACTION) { |
| hover_animation_.reset(new gfx::ThrobAnimation(this)); |
| hover_animation_->SetSlideDuration(kHoverFadeDurationMs); |
| } |
| @@ -405,6 +409,18 @@ void CustomButton::OnBlur() { |
| SetState(STATE_NORMAL); |
| } |
| +void CustomButton::NotifyClick(const ui::Event& event) { |
| + if (ink_drop_delegate() && has_ink_drop_action_on_click_) |
| + ink_drop_delegate()->OnAction(ink_drop_action_on_click_); |
| + Button::NotifyClick(event); |
| +} |
| + |
| +void CustomButton::OnClickCanceled(const ui::Event& event) { |
| + if (ink_drop_delegate()) |
| + ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| + Button::OnClickCanceled(event); |
| +} |
| + |
| bool CustomButton::IsChildWidget() const { |
| return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); |
| } |