| 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/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 Loading... |
| 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_MACOSX) |
| 829 if (send_gesture_events_to_owner()) { |
| 830 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(), |
| 831 owner()->GetNativeWindow()); |
| 832 owner()->OnGestureEvent(event); |
| 833 // Reset |send_gesture_events_to_owner_| when the first gesture ends. |
| 834 if (event->type() == ui::ET_GESTURE_END) |
| 835 send_gesture_events_to_owner_ = false; |
| 836 } |
| 837 #endif // !defined(OS_MACOSX) |
| 826 } | 838 } |
| 827 | 839 |
| 828 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { | 840 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { |
| 829 if (event->type() == ui::ET_TOUCH_PRESSED) { | 841 if (event->type() == ui::ET_TOUCH_PRESSED) { |
| 830 MenuPart part = GetMenuPart(source, event->location()); | 842 MenuPart part = GetMenuPart(source, event->location()); |
| 831 if (part.type == MenuPart::NONE) { | 843 if (part.type == MenuPart::NONE) { |
| 832 RepostEventAndCancel(source, event); | 844 RepostEventAndCancel(source, event); |
| 833 event->SetHandled(); | 845 event->SetHandled(); |
| 834 } | 846 } |
| 835 } | 847 } |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 #endif | 1381 #endif |
| 1370 | 1382 |
| 1371 default: | 1383 default: |
| 1372 break; | 1384 break; |
| 1373 } | 1385 } |
| 1374 } | 1386 } |
| 1375 | 1387 |
| 1376 MenuController::MenuController(bool blocking, | 1388 MenuController::MenuController(bool blocking, |
| 1377 internal::MenuControllerDelegate* delegate) | 1389 internal::MenuControllerDelegate* delegate) |
| 1378 : blocking_run_(blocking), | 1390 : 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_tracker_(base::MakeUnique<ViewTracker>()), | 1391 active_mouse_view_tracker_(base::MakeUnique<ViewTracker>()), |
| 1394 hot_button_(nullptr), | 1392 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_); | 1393 delegate_stack_.push_back(delegate_); |
| 1401 active_instance_ = this; | 1394 active_instance_ = this; |
| 1402 } | 1395 } |
| 1403 | 1396 |
| 1404 MenuController::~MenuController() { | 1397 MenuController::~MenuController() { |
| 1405 DCHECK(!showing_); | 1398 DCHECK(!showing_); |
| 1406 if (owner_) | 1399 if (owner_) |
| 1407 owner_->RemoveObserver(this); | 1400 owner_->RemoveObserver(this); |
| 1408 if (active_instance_ == this) | 1401 if (active_instance_ == this) |
| 1409 active_instance_ = NULL; | 1402 active_instance_ = NULL; |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2703 if (hot_button_) | 2696 if (hot_button_) |
| 2704 hot_button_->SetHotTracked(false); | 2697 hot_button_->SetHotTracked(false); |
| 2705 hot_button_ = hot_button; | 2698 hot_button_ = hot_button; |
| 2706 if (hot_button) { | 2699 if (hot_button) { |
| 2707 hot_button->SetHotTracked(true); | 2700 hot_button->SetHotTracked(true); |
| 2708 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 2701 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 2709 } | 2702 } |
| 2710 } | 2703 } |
| 2711 | 2704 |
| 2712 } // namespace views | 2705 } // namespace views |
| OLD | NEW |