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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 ui::MENU_SOURCE_KEYBOARD); | 1210 ui::MENU_SOURCE_KEYBOARD); |
| 1211 } | 1211 } |
| 1212 break; | 1212 break; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 default: | 1215 default: |
| 1216 break; | 1216 break; |
| 1217 } | 1217 } |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 MenuController::MenuController(ui::NativeTheme* theme, | 1220 MenuController::MenuController(bool blocking, |
| 1221 bool blocking, | |
| 1222 internal::MenuControllerDelegate* delegate) | 1221 internal::MenuControllerDelegate* delegate) |
| 1223 : blocking_run_(blocking), | 1222 : blocking_run_(blocking), |
| 1224 showing_(false), | 1223 showing_(false), |
| 1225 exit_type_(EXIT_NONE), | 1224 exit_type_(EXIT_NONE), |
| 1226 did_capture_(false), | 1225 did_capture_(false), |
| 1227 result_(NULL), | 1226 result_(NULL), |
| 1228 accept_event_flags_(0), | 1227 accept_event_flags_(0), |
| 1229 drop_target_(NULL), | 1228 drop_target_(NULL), |
| 1230 drop_position_(MenuDelegate::DROP_UNKNOWN), | 1229 drop_position_(MenuDelegate::DROP_UNKNOWN), |
| 1231 owner_(NULL), | 1230 owner_(NULL), |
| 1232 possible_drag_(false), | 1231 possible_drag_(false), |
| 1233 drag_in_progress_(false), | 1232 drag_in_progress_(false), |
| 1234 did_initiate_drag_(false), | 1233 did_initiate_drag_(false), |
| 1235 valid_drop_coordinates_(false), | 1234 valid_drop_coordinates_(false), |
| 1236 last_drop_operation_(MenuDelegate::DROP_UNKNOWN), | 1235 last_drop_operation_(MenuDelegate::DROP_UNKNOWN), |
| 1237 showing_submenu_(false), | 1236 showing_submenu_(false), |
| 1238 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), | 1237 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), |
| 1239 delegate_(delegate), | 1238 delegate_(delegate), |
| 1240 message_loop_depth_(0), | 1239 message_loop_depth_(0), |
| 1241 menu_config_(theme), | |
| 1242 closing_event_time_(base::TimeDelta()), | 1240 closing_event_time_(base::TimeDelta()), |
| 1243 menu_start_time_(base::TimeTicks()), | 1241 menu_start_time_(base::TimeTicks()), |
| 1244 is_combobox_(false), | 1242 is_combobox_(false), |
| 1245 item_selected_by_touch_(false), | 1243 item_selected_by_touch_(false), |
| 1246 current_mouse_event_target_(nullptr), | 1244 current_mouse_event_target_(nullptr), |
| 1247 current_mouse_pressed_state_(0), | 1245 current_mouse_pressed_state_(0), |
| 1248 message_loop_(MenuMessageLoop::Create()) { | 1246 message_loop_(MenuMessageLoop::Create()) { |
| 1249 active_instance_ = this; | 1247 active_instance_ = this; |
| 1250 } | 1248 } |
| 1251 | 1249 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1726 | 1724 |
| 1727 void MenuController::BuildMenuItemPath(MenuItemView* item, | 1725 void MenuController::BuildMenuItemPath(MenuItemView* item, |
| 1728 std::vector<MenuItemView*>* path) { | 1726 std::vector<MenuItemView*>* path) { |
| 1729 if (!item) | 1727 if (!item) |
| 1730 return; | 1728 return; |
| 1731 BuildMenuItemPath(item->GetParentMenuItem(), path); | 1729 BuildMenuItemPath(item->GetParentMenuItem(), path); |
| 1732 path->push_back(item); | 1730 path->push_back(item); |
| 1733 } | 1731 } |
| 1734 | 1732 |
| 1735 void MenuController::StartShowTimer() { | 1733 void MenuController::StartShowTimer() { |
| 1734 static MenuConfig* menu_config = nullptr; | |
|
sky
2015/11/17 18:22:24
I don't like the static here. Can you get the menu
Evan Stade
2015/11/17 18:54:33
I'm not sure what you meant by root item, but I th
| |
| 1735 if (!menu_config) | |
| 1736 menu_config = new MenuConfig(nullptr); | |
| 1736 show_timer_.Start(FROM_HERE, | 1737 show_timer_.Start(FROM_HERE, |
| 1737 TimeDelta::FromMilliseconds(menu_config_.show_delay), | 1738 TimeDelta::FromMilliseconds(menu_config->show_delay), |
| 1738 this, &MenuController::CommitPendingSelection); | 1739 this, &MenuController::CommitPendingSelection); |
| 1739 } | 1740 } |
| 1740 | 1741 |
| 1741 void MenuController::StopShowTimer() { | 1742 void MenuController::StopShowTimer() { |
| 1742 show_timer_.Stop(); | 1743 show_timer_.Stop(); |
| 1743 } | 1744 } |
| 1744 | 1745 |
| 1745 void MenuController::StartCancelAllTimer() { | 1746 void MenuController::StartCancelAllTimer() { |
| 1746 cancel_all_timer_.Start(FROM_HERE, | 1747 cancel_all_timer_.Start(FROM_HERE, |
| 1747 TimeDelta::FromMilliseconds(kCloseOnExitTime), | 1748 TimeDelta::FromMilliseconds(kCloseOnExitTime), |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2486 } | 2487 } |
| 2487 } | 2488 } |
| 2488 | 2489 |
| 2489 gfx::Screen* MenuController::GetScreen() { | 2490 gfx::Screen* MenuController::GetScreen() { |
| 2490 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2491 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2491 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2492 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2492 : gfx::Screen::GetNativeScreen(); | 2493 : gfx::Screen::GetNativeScreen(); |
| 2493 } | 2494 } |
| 2494 | 2495 |
| 2495 } // namespace views | 2496 } // namespace views |
| OLD | NEW |