Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_runner_impl.h" | 5 #include "ui/views/controls/menu/menu_runner_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/native_theme/native_theme.h" | 8 #include "ui/native_theme/native_theme.h" |
| 9 #include "ui/views/controls/button/menu_button.h" | 9 #include "ui/views/controls/button/menu_button.h" |
| 10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 running_ = true; | 115 running_ = true; |
| 116 for_drop_ = (run_types & MenuRunner::FOR_DROP) != 0; | 116 for_drop_ = (run_types & MenuRunner::FOR_DROP) != 0; |
| 117 bool has_mnemonics = (run_types & MenuRunner::HAS_MNEMONICS) != 0; | 117 bool has_mnemonics = (run_types & MenuRunner::HAS_MNEMONICS) != 0; |
| 118 owns_controller_ = false; | 118 owns_controller_ = false; |
| 119 if (!controller) { | 119 if (!controller) { |
| 120 // No menus are showing, show one. | 120 // No menus are showing, show one. |
| 121 controller = new MenuController(!for_drop_, this); | 121 controller = new MenuController(!for_drop_, this); |
| 122 owns_controller_ = true; | 122 owns_controller_ = true; |
| 123 } | 123 } |
| 124 controller->set_is_combobox((run_types & MenuRunner::COMBOBOX) != 0); | 124 controller->set_is_combobox((run_types & MenuRunner::COMBOBOX) != 0); |
| 125 if (run_types & MenuRunner::FIXED_ANCHOR) { | |
|
xiyuan
2017/05/12 20:24:57
We probably should make ShelfView to call set_canc
| |
| 126 controller->set_cancel_active_touches(false); | |
| 127 } | |
| 125 controller_ = controller->AsWeakPtr(); | 128 controller_ = controller->AsWeakPtr(); |
| 126 menu_->set_controller(controller_.get()); | 129 menu_->set_controller(controller_.get()); |
| 127 menu_->PrepareForRun(owns_controller_, | 130 menu_->PrepareForRun(owns_controller_, |
| 128 has_mnemonics, | 131 has_mnemonics, |
| 129 !for_drop_ && ShouldShowMnemonics(button)); | 132 !for_drop_ && ShouldShowMnemonics(button)); |
| 130 | 133 |
| 131 controller->Run(parent, button, menu_, bounds, anchor, | 134 controller->Run(parent, button, menu_, bounds, anchor, |
| 132 (run_types & MenuRunner::CONTEXT_MENU) != 0, | 135 (run_types & MenuRunner::CONTEXT_MENU) != 0, |
| 133 (run_types & MenuRunner::NESTED_DRAG) != 0); | 136 (run_types & MenuRunner::NESTED_DRAG) != 0); |
| 134 } | 137 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 #if defined(OS_WIN) | 199 #if defined(OS_WIN) |
| 197 // This is only needed on Windows. | 200 // This is only needed on Windows. |
| 198 if (!show_mnemonics) | 201 if (!show_mnemonics) |
| 199 show_mnemonics = ui::win::IsAltPressed(); | 202 show_mnemonics = ui::win::IsAltPressed(); |
| 200 #endif | 203 #endif |
| 201 return show_mnemonics; | 204 return show_mnemonics; |
| 202 } | 205 } |
| 203 | 206 |
| 204 } // namespace internal | 207 } // namespace internal |
| 205 } // namespace views | 208 } // namespace views |
| OLD | NEW |