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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 2433933007: Fix opening App Menu after Bookmarks Drag (Closed)
Patch Set: Fix additional drag shutdown orders Created 4 years, 2 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/menu/menu_controller_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/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 delegate_->OnMenuClosed(internal::MenuControllerDelegate::NOTIFY_DELEGATE, 530 delegate_->OnMenuClosed(internal::MenuControllerDelegate::NOTIFY_DELEGATE,
531 selected->GetRootMenuItem(), accept_event_flags_); 531 selected->GetRootMenuItem(), accept_event_flags_);
532 // WARNING: the call to MenuClosed deletes us. 532 // WARNING: the call to MenuClosed deletes us.
533 return; 533 return;
534 } 534 }
535 535
536 // On Windows and Linux the destruction of this menu's Widget leads to the 536 // On Windows and Linux the destruction of this menu's Widget leads to the
537 // teardown of the platform specific drag-and-drop Widget. Do not shutdown 537 // teardown of the platform specific drag-and-drop Widget. Do not shutdown
538 // while dragging, leave the Widget hidden until drag-and-drop has completed, 538 // while dragging, leave the Widget hidden until drag-and-drop has completed,
539 // at which point all menus will be destroyed. 539 // at which point all menus will be destroyed.
540 //
541 // If |type| is EXIT_ALL we update the state of the menu to not showing. So
542 // that during the completion of a drag we are not incorrectly reporting the
543 // visual state.
540 if (!drag_in_progress_) 544 if (!drag_in_progress_)
541 ExitAsyncRun(); 545 ExitAsyncRun();
546 else if (type == EXIT_ALL)
547 showing_ = false;
542 } 548 }
543 549
544 void MenuController::AddNestedDelegate( 550 void MenuController::AddNestedDelegate(
545 internal::MenuControllerDelegate* delegate) { 551 internal::MenuControllerDelegate* delegate) {
546 delegate_stack_.push_back(std::make_pair(delegate, async_run_)); 552 delegate_stack_.push_back(std::make_pair(delegate, async_run_));
547 delegate_ = delegate; 553 delegate_ = delegate;
548 } 554 }
549 555
550 void MenuController::SetAsyncRun(bool is_async) { 556 void MenuController::SetAsyncRun(bool is_async) {
551 delegate_stack_.back().second = is_async; 557 delegate_stack_.back().second = is_async;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1020 }
1015 1021
1016 void MenuController::OnDragComplete(bool should_close) { 1022 void MenuController::OnDragComplete(bool should_close) {
1017 DCHECK(drag_in_progress_); 1023 DCHECK(drag_in_progress_);
1018 drag_in_progress_ = false; 1024 drag_in_progress_ = false;
1019 // During a drag, mouse events are processed directly by the widget, and not 1025 // During a drag, mouse events are processed directly by the widget, and not
1020 // sent to the MenuController. At drag completion, reset pressed state and 1026 // sent to the MenuController. At drag completion, reset pressed state and
1021 // the event target. 1027 // the event target.
1022 current_mouse_pressed_state_ = 0; 1028 current_mouse_pressed_state_ = 0;
1023 current_mouse_event_target_ = nullptr; 1029 current_mouse_event_target_ = nullptr;
1024 if (showing_ && should_close && GetActiveInstance() == this) { 1030
1025 CloseAllNestedMenus(); 1031 // Only attempt to close if the MenuHost said to.
1026 Cancel(EXIT_ALL); 1032 if (should_close) {
1027 } else if (async_run_) { 1033 if (showing_) {
1028 ExitAsyncRun(); 1034 // Close showing widgets.
1035 if (GetActiveInstance() == this) {
1036 CloseAllNestedMenus();
1037 Cancel(EXIT_ALL);
1038 }
1039 // The above may have deleted us. If not perform a full shutdown.
1040 if (GetActiveInstance() == this)
1041 ExitAsyncRun();
1042 } else if (exit_type_ == EXIT_ALL) {
1043 // We may have been canceled during the drag. If so we still need to fully
1044 // shutdown.
1045 ExitAsyncRun();
1046 }
1029 } 1047 }
1030 } 1048 }
1031 1049
1032 ui::PostDispatchAction MenuController::OnWillDispatchKeyEvent( 1050 ui::PostDispatchAction MenuController::OnWillDispatchKeyEvent(
1033 ui::KeyEvent* event) { 1051 ui::KeyEvent* event) {
1034 if (exit_type() == EXIT_ALL || exit_type() == EXIT_DESTROYED) { 1052 if (exit_type() == EXIT_ALL || exit_type() == EXIT_DESTROYED) {
1035 // If the event has arrived after the menu's exit type had changed but 1053 // If the event has arrived after the menu's exit type had changed but
1036 // before its message loop terminated, the event will continue its normal 1054 // before its message loop terminated, the event will continue its normal
1037 // propagation for the following reason: 1055 // propagation for the following reason:
1038 // If the user accepts a menu item in a nested menu, the menu item action is 1056 // If the user accepts a menu item in a nested menu, the menu item action is
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 if (hot_button_) 2730 if (hot_button_)
2713 hot_button_->SetHotTracked(false); 2731 hot_button_->SetHotTracked(false);
2714 hot_button_ = hot_button; 2732 hot_button_ = hot_button;
2715 if (hot_button) { 2733 if (hot_button) {
2716 hot_button->SetHotTracked(true); 2734 hot_button->SetHotTracked(true);
2717 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2735 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2718 } 2736 }
2719 } 2737 }
2720 2738
2721 } // namespace views 2739 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698