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

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

Issue 2880623002: [ash-md] Fixed MenuButton focus appearing after dismissing menus. (Closed)
Patch Set: Reworked solution to use CustomButton::ShouldEnterHoveredState(). Created 3 years, 7 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 | ui/views/controls/button/menu_button_unittest.cc » ('j') | 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_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (increment_pressed_lock_called_) 373 if (increment_pressed_lock_called_)
374 *increment_pressed_lock_called_ = true; 374 *increment_pressed_lock_called_ = true;
375 should_disable_after_press_ = state() == STATE_DISABLED; 375 should_disable_after_press_ = state() == STATE_DISABLED;
376 if (state() != STATE_PRESSED) { 376 if (state() != STATE_PRESSED) {
377 if (snap_ink_drop_to_activated) 377 if (snap_ink_drop_to_activated)
378 GetInkDrop()->SnapToActivated(); 378 GetInkDrop()->SnapToActivated();
379 else 379 else
380 AnimateInkDrop(InkDropState::ACTIVATED, event); 380 AnimateInkDrop(InkDropState::ACTIVATED, event);
381 } 381 }
382 SetState(STATE_PRESSED); 382 SetState(STATE_PRESSED);
383 GetInkDrop()->SetHovered(false);
383 } 384 }
384 385
385 void MenuButton::DecrementPressedLocked() { 386 void MenuButton::DecrementPressedLocked() {
386 --pressed_lock_count_; 387 --pressed_lock_count_;
387 DCHECK_GE(pressed_lock_count_, 0); 388 DCHECK_GE(pressed_lock_count_, 0);
388 389
389 // If this was the last lock, manually reset state to the desired state. 390 // If this was the last lock, manually reset state to the desired state.
390 if (pressed_lock_count_ == 0) { 391 if (pressed_lock_count_ == 0) {
391 menu_closed_time_ = TimeTicks::Now(); 392 menu_closed_time_ = TimeTicks::Now();
392 ButtonState desired_state = STATE_NORMAL; 393 ButtonState desired_state = STATE_NORMAL;
393 if (should_disable_after_press_) { 394 if (should_disable_after_press_) {
394 desired_state = STATE_DISABLED; 395 desired_state = STATE_DISABLED;
395 should_disable_after_press_ = false; 396 should_disable_after_press_ = false;
396 } else if (ShouldEnterHoveredState()) { 397 } else if (ShouldEnterHoveredState()) {
397 desired_state = STATE_HOVERED; 398 desired_state = STATE_HOVERED;
399 GetInkDrop()->SetHovered(true);
398 } 400 }
399 SetState(desired_state); 401 SetState(desired_state);
400 // The widget may be null during shutdown. If so, it doesn't make sense to 402 // The widget may be null during shutdown. If so, it doesn't make sense to
401 // try to add an ink drop effect. 403 // try to add an ink drop effect.
402 if (GetWidget() && state() != STATE_PRESSED) 404 if (GetWidget() && state() != STATE_PRESSED)
403 AnimateInkDrop(InkDropState::DEACTIVATED, nullptr /* event */); 405 AnimateInkDrop(InkDropState::DEACTIVATED, nullptr /* event */);
404 } 406 }
405 } 407 }
406 408
407 int MenuButton::GetMaximumScreenXCoordinate() { 409 int MenuButton::GetMaximumScreenXCoordinate() {
408 if (!GetWidget()) { 410 if (!GetWidget()) {
409 NOTREACHED(); 411 NOTREACHED();
410 return 0; 412 return 0;
411 } 413 }
412 414
413 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 415 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
414 return monitor_bounds.right() - 1; 416 return monitor_bounds.right() - 1;
415 } 417 }
416 418
417 } // namespace views 419 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/menu_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698