Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 switch (event->type()) { | 178 switch (event->type()) { |
| 179 case ui::ET_GESTURE_TAP_DOWN: | 179 case ui::ET_GESTURE_TAP_DOWN: |
| 180 ink_drop_state = views::InkDropState::ACTION_PENDING; | 180 ink_drop_state = views::InkDropState::ACTION_PENDING; |
| 181 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that | 181 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that |
| 182 // subsequent events for the gesture are sent to |this|. | 182 // subsequent events for the gesture are sent to |this|. |
| 183 event->SetHandled(); | 183 event->SetHandled(); |
| 184 break; | 184 break; |
| 185 case ui::ET_GESTURE_LONG_PRESS: | 185 case ui::ET_GESTURE_LONG_PRESS: |
| 186 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; | 186 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; |
| 187 break; | 187 break; |
| 188 case ui::ET_GESTURE_TAP: | |
| 189 ink_drop_state = views::InkDropState::QUICK_ACTION; | |
| 190 break; | |
| 191 case ui::ET_GESTURE_LONG_TAP: | 188 case ui::ET_GESTURE_LONG_TAP: |
| 192 ink_drop_state = views::InkDropState::SLOW_ACTION; | 189 ink_drop_state = views::InkDropState::SLOW_ACTION; |
| 193 break; | 190 break; |
| 191 case ui::ET_GESTURE_SCROLL_BEGIN: | |
| 194 case ui::ET_GESTURE_END: | 192 case ui::ET_GESTURE_END: |
| 195 case ui::ET_GESTURE_TAP_CANCEL: | |
| 196 ink_drop_state = views::InkDropState::HIDDEN; | 193 ink_drop_state = views::InkDropState::HIDDEN; |
| 197 break; | 194 break; |
| 198 default: | 195 default: |
| 199 return; | 196 return; |
| 200 } | 197 } |
| 198 | |
| 199 if (ink_drop_state == views::InkDropState::HIDDEN && | |
| 200 ink_drop_animation_controller_->WillAutoAnimateToHidden()) { | |
| 201 // Some InkDropStates automatically transition to the HIDDEN state so we | |
| 202 // don't make an explicit call. Explicitly animating to HIDDEN in this case | |
| 203 // would prematurely pre-empt these animations. | |
|
Peter Kasting
2015/11/11 22:07:21
Nit: I'd move this comment above the conditional,
bruthig
2015/11/12 18:30:30
Done.
| |
| 204 return; | |
| 205 } | |
| 201 ink_drop_animation_controller_->AnimateToState(ink_drop_state); | 206 ink_drop_animation_controller_->AnimateToState(ink_drop_state); |
| 202 } | 207 } |
| 203 | 208 |
| 204 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { | 209 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { |
| 205 CustomButton::GetAccessibleState(state); | 210 CustomButton::GetAccessibleState(state); |
| 206 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 211 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
| 207 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 212 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); |
| 208 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 213 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
| 209 } | 214 } |
| 210 | 215 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 return GetLocalBounds().CenterPoint(); | 361 return GetLocalBounds().CenterPoint(); |
| 357 } | 362 } |
| 358 | 363 |
| 359 void ToolbarButton::UpdateInkDropHoverState() { | 364 void ToolbarButton::UpdateInkDropHoverState() { |
| 360 ink_drop_animation_controller_->SetHovered(ShouldShowInkDropHover()); | 365 ink_drop_animation_controller_->SetHovered(ShouldShowInkDropHover()); |
| 361 } | 366 } |
| 362 | 367 |
| 363 const char* ToolbarButton::GetClassName() const { | 368 const char* ToolbarButton::GetClassName() const { |
| 364 return "ToolbarButton"; | 369 return "ToolbarButton"; |
| 365 } | 370 } |
| OLD | NEW |