| OLD | NEW |
| 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 771 } |
| 772 | 772 |
| 773 bool MenuController::OnMouseWheel(SubmenuView* source, | 773 bool MenuController::OnMouseWheel(SubmenuView* source, |
| 774 const ui::MouseWheelEvent& event) { | 774 const ui::MouseWheelEvent& event) { |
| 775 MenuPart part = GetMenuPart(source, event.location()); | 775 MenuPart part = GetMenuPart(source, event.location()); |
| 776 return part.submenu && part.submenu->OnMouseWheel(event); | 776 return part.submenu && part.submenu->OnMouseWheel(event); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void MenuController::OnGestureEvent(SubmenuView* source, | 779 void MenuController::OnGestureEvent(SubmenuView* source, |
| 780 ui::GestureEvent* event) { | 780 ui::GestureEvent* event) { |
| 781 #if !defined(OS_MACOSX) |
| 782 if (send_gesture_events_to_owner()) { |
| 783 DCHECK(owner()); |
| 784 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(), |
| 785 owner()->GetNativeWindow()); |
| 786 owner()->OnGestureEvent(event); |
| 787 // Reset |send_gesture_events_to_owner_| when the first gesture ends. |
| 788 if (event->type() == ui::ET_GESTURE_END) |
| 789 send_gesture_events_to_owner_ = false; |
| 790 return; |
| 791 } |
| 792 #endif // !defined(OS_MACOSX) |
| 793 |
| 781 MenuHostRootView* root_view = GetRootView(source, event->location()); | 794 MenuHostRootView* root_view = GetRootView(source, event->location()); |
| 782 if (root_view) { | 795 if (root_view) { |
| 783 // Reset hot-tracking if a different view is getting a touch event. | 796 // Reset hot-tracking if a different view is getting a touch event. |
| 784 ui::GestureEvent event_for_root(*event); | 797 ui::GestureEvent event_for_root(*event); |
| 785 ConvertLocatedEventForRootView(source, root_view, &event_for_root); | 798 ConvertLocatedEventForRootView(source, root_view, &event_for_root); |
| 786 View* view = | 799 View* view = |
| 787 root_view->GetEventHandlerForPoint(event_for_root.location()); | 800 root_view->GetEventHandlerForPoint(event_for_root.location()); |
| 788 Button* button = Button::AsButton(view); | 801 Button* button = Button::AsButton(view); |
| 789 if (hot_button_ && hot_button_ != button) | 802 if (hot_button_ && hot_button_ != button) |
| 790 SetHotTrackedButton(nullptr); | 803 SetHotTrackedButton(nullptr); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 part.type == MenuPart::MENU_ITEM) { | 835 part.type == MenuPart::MENU_ITEM) { |
| 823 // Move the selection to the parent menu so that the selection in the | 836 // Move the selection to the parent menu so that the selection in the |
| 824 // current menu is unset. Make sure the submenu remains open by sending the | 837 // current menu is unset. Make sure the submenu remains open by sending the |
| 825 // appropriate SetSelectionTypes flags. | 838 // appropriate SetSelectionTypes flags. |
| 826 SetSelection(part.menu->GetParentMenuItem(), | 839 SetSelection(part.menu->GetParentMenuItem(), |
| 827 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); | 840 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
| 828 event->StopPropagation(); | 841 event->StopPropagation(); |
| 829 } | 842 } |
| 830 | 843 |
| 831 if (event->stopped_propagation()) | 844 if (event->stopped_propagation()) |
| 832 return; | 845 return; |
| 833 | 846 |
| 834 if (!part.submenu) | 847 if (!part.submenu) |
| 835 return; | 848 return; |
| 836 part.submenu->OnGestureEvent(event); | 849 part.submenu->OnGestureEvent(event); |
| 837 } | 850 } |
| 838 | 851 |
| 839 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { | 852 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { |
| 840 if (event->type() == ui::ET_TOUCH_PRESSED) { | 853 if (event->type() == ui::ET_TOUCH_PRESSED) { |
| 841 MenuPart part = GetMenuPart(source, event->location()); | 854 MenuPart part = GetMenuPart(source, event->location()); |
| 842 if (part.type == MenuPart::NONE) { | 855 if (part.type == MenuPart::NONE) { |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 #endif | 1392 #endif |
| 1380 | 1393 |
| 1381 default: | 1394 default: |
| 1382 break; | 1395 break; |
| 1383 } | 1396 } |
| 1384 } | 1397 } |
| 1385 | 1398 |
| 1386 MenuController::MenuController(bool blocking, | 1399 MenuController::MenuController(bool blocking, |
| 1387 internal::MenuControllerDelegate* delegate) | 1400 internal::MenuControllerDelegate* delegate) |
| 1388 : blocking_run_(blocking), | 1401 : 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>()), | 1402 active_mouse_view_tracker_(base::MakeUnique<ViewTracker>()), |
| 1404 hot_button_(nullptr), | 1403 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_); | 1404 delegate_stack_.push_back(delegate_); |
| 1411 active_instance_ = this; | 1405 active_instance_ = this; |
| 1412 } | 1406 } |
| 1413 | 1407 |
| 1414 MenuController::~MenuController() { | 1408 MenuController::~MenuController() { |
| 1415 DCHECK(!showing_); | 1409 DCHECK(!showing_); |
| 1416 if (owner_) | 1410 if (owner_) |
| 1417 owner_->RemoveObserver(this); | 1411 owner_->RemoveObserver(this); |
| 1418 if (active_instance_ == this) | 1412 if (active_instance_ == this) |
| 1419 active_instance_ = NULL; | 1413 active_instance_ = NULL; |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 if (hot_button_) | 2704 if (hot_button_) |
| 2711 hot_button_->SetHotTracked(false); | 2705 hot_button_->SetHotTracked(false); |
| 2712 hot_button_ = hot_button; | 2706 hot_button_ = hot_button; |
| 2713 if (hot_button) { | 2707 if (hot_button) { |
| 2714 hot_button->SetHotTracked(true); | 2708 hot_button->SetHotTracked(true); |
| 2715 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 2709 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 2716 } | 2710 } |
| 2717 } | 2711 } |
| 2718 | 2712 |
| 2719 } // namespace views | 2713 } // namespace views |
| OLD | NEW |