Chromium Code Reviews| 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 (owner_needs_gesture_events()) { | |
| 830 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(), | |
| 831 owner()->GetNativeWindow()); | |
| 832 owner()->OnGestureEvent(event); | |
| 833 // Don't transfer events back if capture the GESTURE_END. Then the following | |
| 834 // gesture events on the shelf can be created correctly. | |
|
xiyuan
2017/05/26 23:13:37
Think it would be easier to understand if we renam
minch1
2017/06/01 16:42:28
Done.
| |
| 835 if (event->type() == ui::ET_GESTURE_END) | |
| 836 set_owner_needs_gesture_events(false); | |
| 837 } | |
| 838 #endif // !defined(OS_MACOSX) | |
| 826 } | 839 } |
| 827 | 840 |
| 828 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { | 841 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { |
| 829 if (event->type() == ui::ET_TOUCH_PRESSED) { | 842 if (event->type() == ui::ET_TOUCH_PRESSED) { |
| 830 MenuPart part = GetMenuPart(source, event->location()); | 843 MenuPart part = GetMenuPart(source, event->location()); |
| 831 if (part.type == MenuPart::NONE) { | 844 if (part.type == MenuPart::NONE) { |
| 832 RepostEventAndCancel(source, event); | 845 RepostEventAndCancel(source, event); |
| 833 event->SetHandled(); | 846 event->SetHandled(); |
| 834 } | 847 } |
| 835 } | 848 } |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 #endif | 1382 #endif |
| 1370 | 1383 |
| 1371 default: | 1384 default: |
| 1372 break; | 1385 break; |
| 1373 } | 1386 } |
| 1374 } | 1387 } |
| 1375 | 1388 |
| 1376 MenuController::MenuController(bool blocking, | 1389 MenuController::MenuController(bool blocking, |
| 1377 internal::MenuControllerDelegate* delegate) | 1390 internal::MenuControllerDelegate* delegate) |
| 1378 : blocking_run_(blocking), | 1391 : 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()), | 1392 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), |
| 1394 hot_button_(nullptr), | 1393 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_); | 1394 delegate_stack_.push_back(delegate_); |
| 1401 active_instance_ = this; | 1395 active_instance_ = this; |
| 1402 } | 1396 } |
| 1403 | 1397 |
| 1404 MenuController::~MenuController() { | 1398 MenuController::~MenuController() { |
| 1405 DCHECK(!showing_); | 1399 DCHECK(!showing_); |
| 1406 if (owner_) | 1400 if (owner_) |
| 1407 owner_->RemoveObserver(this); | 1401 owner_->RemoveObserver(this); |
| 1408 if (active_instance_ == this) | 1402 if (active_instance_ == this) |
| 1409 active_instance_ = NULL; | 1403 active_instance_ = NULL; |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2714 if (hot_button_) | 2708 if (hot_button_) |
| 2715 hot_button_->SetHotTracked(false); | 2709 hot_button_->SetHotTracked(false); |
| 2716 hot_button_ = hot_button; | 2710 hot_button_ = hot_button; |
| 2717 if (hot_button) { | 2711 if (hot_button) { |
| 2718 hot_button->SetHotTracked(true); | 2712 hot_button->SetHotTracked(true); |
| 2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 2713 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 2720 } | 2714 } |
| 2721 } | 2715 } |
| 2722 | 2716 |
| 2723 } // namespace views | 2717 } // namespace views |
| OLD | NEW |