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

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

Issue 2876203003: Make shelf item can be dragged when context menu is opened.
Patch Set: Fixed nit. Created 3 years, 4 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
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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // current menu is unset. Make sure the submenu remains open by sending the 824 // current menu is unset. Make sure the submenu remains open by sending the
825 // appropriate SetSelectionTypes flags. 825 // appropriate SetSelectionTypes flags.
826 SetSelection(part.menu->GetParentMenuItem(), 826 SetSelection(part.menu->GetParentMenuItem(),
827 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); 827 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
828 event->StopPropagation(); 828 event->StopPropagation();
829 } 829 }
830 830
831 if (event->stopped_propagation()) 831 if (event->stopped_propagation())
832 return; 832 return;
833 833
834 if (!part.submenu) 834 if (part.submenu) {
835 part.submenu->OnGestureEvent(event);
835 return; 836 return;
836 part.submenu->OnGestureEvent(event); 837 }
838
839 #if !defined(OS_MACOSX)
840 if (send_gesture_events_to_owner()) {
sadrul 2017/08/30 20:31:39 This should happen at the very beginning?
minch1 2017/08/31 23:21:02 Removed to the entry of OnGestureEvent, then we ca
841 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(),
842 owner()->GetNativeWindow());
843 owner()->OnGestureEvent(event);
844 // Reset |send_gesture_events_to_owner_| when the first gesture ends.
845 if (event->type() == ui::ET_GESTURE_END)
846 send_gesture_events_to_owner_ = false;
847 }
848 #endif // !defined(OS_MACOSX)
837 } 849 }
838 850
839 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { 851 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
840 if (event->type() == ui::ET_TOUCH_PRESSED) { 852 if (event->type() == ui::ET_TOUCH_PRESSED) {
841 MenuPart part = GetMenuPart(source, event->location()); 853 MenuPart part = GetMenuPart(source, event->location());
842 if (part.type == MenuPart::NONE) { 854 if (part.type == MenuPart::NONE) {
843 RepostEventAndCancel(source, event); 855 RepostEventAndCancel(source, event);
844 event->SetHandled(); 856 event->SetHandled();
845 } 857 }
846 } 858 }
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 #endif 1391 #endif
1380 1392
1381 default: 1393 default:
1382 break; 1394 break;
1383 } 1395 }
1384 } 1396 }
1385 1397
1386 MenuController::MenuController(bool blocking, 1398 MenuController::MenuController(bool blocking,
1387 internal::MenuControllerDelegate* delegate) 1399 internal::MenuControllerDelegate* delegate)
1388 : blocking_run_(blocking), 1400 : blocking_run_(blocking),
1389 showing_(false),
1390 exit_type_(EXIT_NONE),
1391 did_capture_(false),
1392 result_(NULL),
1393 accept_event_flags_(0),
1394 drop_target_(NULL),
1395 drop_position_(MenuDelegate::DROP_UNKNOWN),
1396 owner_(NULL),
1397 possible_drag_(false),
1398 drag_in_progress_(false),
1399 did_initiate_drag_(false),
1400 valid_drop_coordinates_(false),
1401 last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
1402 showing_submenu_(false),
1403 active_mouse_view_tracker_(base::MakeUnique<ViewTracker>()), 1401 active_mouse_view_tracker_(base::MakeUnique<ViewTracker>()),
1404 hot_button_(nullptr), 1402 delegate_(delegate) {
1405 delegate_(delegate),
1406 is_combobox_(false),
1407 item_selected_by_touch_(false),
1408 current_mouse_event_target_(nullptr),
1409 current_mouse_pressed_state_(0) {
1410 delegate_stack_.push_back(delegate_); 1403 delegate_stack_.push_back(delegate_);
1411 active_instance_ = this; 1404 active_instance_ = this;
1412 } 1405 }
1413 1406
1414 MenuController::~MenuController() { 1407 MenuController::~MenuController() {
1415 DCHECK(!showing_); 1408 DCHECK(!showing_);
1416 if (owner_) 1409 if (owner_)
1417 owner_->RemoveObserver(this); 1410 owner_->RemoveObserver(this);
1418 if (active_instance_ == this) 1411 if (active_instance_ == this)
1419 active_instance_ = NULL; 1412 active_instance_ = NULL;
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 if (hot_button_) 2703 if (hot_button_)
2711 hot_button_->SetHotTracked(false); 2704 hot_button_->SetHotTracked(false);
2712 hot_button_ = hot_button; 2705 hot_button_ = hot_button;
2713 if (hot_button) { 2706 if (hot_button) {
2714 hot_button->SetHotTracked(true); 2707 hot_button->SetHotTracked(true);
2715 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2708 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2716 } 2709 }
2717 } 2710 }
2718 2711
2719 } // namespace views 2712 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698