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

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 comments. 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
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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 // current menu is unset. Make sure the submenu remains open by sending the 813 // current menu is unset. Make sure the submenu remains open by sending the
814 // appropriate SetSelectionTypes flags. 814 // appropriate SetSelectionTypes flags.
815 SetSelection(part.menu->GetParentMenuItem(), 815 SetSelection(part.menu->GetParentMenuItem(),
816 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); 816 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
817 event->StopPropagation(); 817 event->StopPropagation();
818 } 818 }
819 819
820 if (event->stopped_propagation()) 820 if (event->stopped_propagation())
821 return; 821 return;
822 822
823 if (!part.submenu) 823 if (part.submenu) {
824 part.submenu->OnGestureEvent(event);
824 return; 825 return;
825 part.submenu->OnGestureEvent(event); 826 }
827
828 #if defined(OS_CHROMEOS)
829 if (owner_needs_gesture_events()) {
830 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(),
831 owner()->GetNativeWindow());
832 owner()->OnGestureEvent(event);
833 }
834 #endif
826 } 835 }
827 836
828 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { 837 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
829 if (event->type() == ui::ET_TOUCH_PRESSED) { 838 if (event->type() == ui::ET_TOUCH_PRESSED) {
830 MenuPart part = GetMenuPart(source, event->location()); 839 MenuPart part = GetMenuPart(source, event->location());
831 if (part.type == MenuPart::NONE) { 840 if (part.type == MenuPart::NONE) {
832 RepostEventAndCancel(source, event); 841 RepostEventAndCancel(source, event);
833 event->SetHandled(); 842 event->SetHandled();
834 } 843 }
835 } 844 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 #endif 1378 #endif
1370 1379
1371 default: 1380 default:
1372 break; 1381 break;
1373 } 1382 }
1374 } 1383 }
1375 1384
1376 MenuController::MenuController(bool blocking, 1385 MenuController::MenuController(bool blocking,
1377 internal::MenuControllerDelegate* delegate) 1386 internal::MenuControllerDelegate* delegate)
1378 : blocking_run_(blocking), 1387 : blocking_run_(blocking),
1379 showing_(false),
1380 exit_type_(EXIT_NONE),
1381 did_capture_(false),
1382 result_(NULL),
1383 accept_event_flags_(0),
1384 drop_target_(NULL),
1385 drop_position_(MenuDelegate::DROP_UNKNOWN),
1386 owner_(NULL),
1387 possible_drag_(false),
1388 drag_in_progress_(false),
1389 did_initiate_drag_(false),
1390 valid_drop_coordinates_(false),
1391 last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
1392 showing_submenu_(false),
1393 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), 1388 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()),
1394 hot_button_(nullptr), 1389 delegate_(delegate) {
1395 delegate_(delegate),
1396 is_combobox_(false),
1397 item_selected_by_touch_(false),
1398 current_mouse_event_target_(nullptr),
1399 current_mouse_pressed_state_(0) {
1400 delegate_stack_.push_back(delegate_); 1390 delegate_stack_.push_back(delegate_);
1401 active_instance_ = this; 1391 active_instance_ = this;
1402 } 1392 }
1403 1393
1404 MenuController::~MenuController() { 1394 MenuController::~MenuController() {
1405 DCHECK(!showing_); 1395 DCHECK(!showing_);
1406 if (owner_) 1396 if (owner_)
1407 owner_->RemoveObserver(this); 1397 owner_->RemoveObserver(this);
1408 if (active_instance_ == this) 1398 if (active_instance_ == this)
1409 active_instance_ = NULL; 1399 active_instance_ = NULL;
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 if (hot_button_) 2704 if (hot_button_)
2715 hot_button_->SetHotTracked(false); 2705 hot_button_->SetHotTracked(false);
2716 hot_button_ = hot_button; 2706 hot_button_ = hot_button;
2717 if (hot_button) { 2707 if (hot_button) {
2718 hot_button->SetHotTracked(true); 2708 hot_button->SetHotTracked(true);
2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2709 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2720 } 2710 }
2721 } 2711 }
2722 2712
2723 } // namespace views 2713 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698