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

Side by Side Diff: ui/views/controls/button/menu_button.cc

Issue 2299443002: Update MenuButton closing time for async (Closed)
Patch Set: Created 4 years, 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/controls/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 listener_->OnMenuButtonClicked(this, menu_position, event); 138 listener_->OnMenuButtonClicked(this, menu_position, event);
139 139
140 if (destroyed) { 140 if (destroyed) {
141 // The menu was deleted while showing. Don't attempt any processing. 141 // The menu was deleted while showing. Don't attempt any processing.
142 return false; 142 return false;
143 } 143 }
144 144
145 increment_pressed_lock_called_ = nullptr; 145 increment_pressed_lock_called_ = nullptr;
146 destroyed_flag_ = nullptr; 146 destroyed_flag_ = nullptr;
147 147
148 menu_closed_time_ = TimeTicks::Now();
149
150 if (!increment_pressed_lock_called && pressed_lock_count_ == 0) { 148 if (!increment_pressed_lock_called && pressed_lock_count_ == 0) {
151 AnimateInkDrop(InkDropState::ACTION_TRIGGERED, 149 AnimateInkDrop(InkDropState::ACTION_TRIGGERED,
152 ui::LocatedEvent::FromIfValid(event)); 150 ui::LocatedEvent::FromIfValid(event));
153 } 151 }
154 152
155 // We must return false here so that the RootView does not get stuck 153 // We must return false here so that the RootView does not get stuck
156 // sending all mouse pressed events to us instead of the appropriate 154 // sending all mouse pressed events to us instead of the appropriate
157 // target. 155 // target.
158 return false; 156 return false;
159 } 157 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 378 }
381 SetState(STATE_PRESSED); 379 SetState(STATE_PRESSED);
382 } 380 }
383 381
384 void MenuButton::DecrementPressedLocked() { 382 void MenuButton::DecrementPressedLocked() {
385 --pressed_lock_count_; 383 --pressed_lock_count_;
386 DCHECK_GE(pressed_lock_count_, 0); 384 DCHECK_GE(pressed_lock_count_, 0);
387 385
388 // If this was the last lock, manually reset state to the desired state. 386 // If this was the last lock, manually reset state to the desired state.
389 if (pressed_lock_count_ == 0) { 387 if (pressed_lock_count_ == 0) {
388 menu_closed_time_ = TimeTicks::Now();
390 ButtonState desired_state = STATE_NORMAL; 389 ButtonState desired_state = STATE_NORMAL;
391 if (should_disable_after_press_) { 390 if (should_disable_after_press_) {
392 desired_state = STATE_DISABLED; 391 desired_state = STATE_DISABLED;
393 should_disable_after_press_ = false; 392 should_disable_after_press_ = false;
394 } else if (ShouldEnterHoveredState()) { 393 } else if (ShouldEnterHoveredState()) {
395 desired_state = STATE_HOVERED; 394 desired_state = STATE_HOVERED;
396 } 395 }
397 SetState(desired_state); 396 SetState(desired_state);
398 // The widget may be null during shutdown. If so, it doesn't make sense to 397 // The widget may be null during shutdown. If so, it doesn't make sense to
399 // try to add an ink drop effect. 398 // try to add an ink drop effect.
400 if (GetWidget() && state() != STATE_PRESSED) 399 if (GetWidget() && state() != STATE_PRESSED)
401 AnimateInkDrop(InkDropState::DEACTIVATED, nullptr /* event */); 400 AnimateInkDrop(InkDropState::DEACTIVATED, nullptr /* event */);
402 } 401 }
403 } 402 }
404 403
405 int MenuButton::GetMaximumScreenXCoordinate() { 404 int MenuButton::GetMaximumScreenXCoordinate() {
406 if (!GetWidget()) { 405 if (!GetWidget()) {
407 NOTREACHED(); 406 NOTREACHED();
408 return 0; 407 return 0;
409 } 408 }
410 409
411 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 410 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
412 return monitor_bounds.right() - 1; 411 return monitor_bounds.right() - 1;
413 } 412 }
414 413
415 } // namespace views 414 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698