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_runner.h" | 5 #include "ui/views/controls/menu/menu_runner.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ui/views/controls/menu/menu_runner_handler.h" | 9 #include "ui/views/controls/menu/menu_runner_handler.h" |
| 10 #include "ui/views/controls/menu/menu_runner_impl.h" | 10 #include "ui/views/controls/menu/menu_runner_impl.h" |
| 11 #include "ui/views/widget/widget.h" | |
| 11 | 12 |
| 12 namespace views { | 13 namespace views { |
| 13 | 14 |
| 14 MenuRunner::MenuRunner(ui::MenuModel* menu_model, int32_t run_types) | 15 MenuRunner::MenuRunner(ui::MenuModel* menu_model, int32_t run_types) |
| 15 : run_types_(run_types), | 16 : run_types_(run_types), |
| 16 impl_(internal::MenuRunnerImplInterface::Create(menu_model, run_types)) {} | 17 impl_(internal::MenuRunnerImplInterface::Create(menu_model, run_types)) {} |
| 17 | 18 |
| 18 MenuRunner::MenuRunner(MenuItemView* menu_view, int32_t run_types) | 19 MenuRunner::MenuRunner(MenuItemView* menu_view, int32_t run_types) |
| 19 : run_types_(run_types), impl_(new internal::MenuRunnerImpl(menu_view)) {} | 20 : run_types_(run_types), impl_(new internal::MenuRunnerImpl(menu_view)) {} |
| 20 | 21 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 49 break; | 50 break; |
| 50 case ui::MENU_SOURCE_TOUCH: | 51 case ui::MENU_SOURCE_TOUCH: |
| 51 case ui::MENU_SOURCE_TOUCH_EDIT_MENU: | 52 case ui::MENU_SOURCE_TOUCH_EDIT_MENU: |
| 52 anchor = MENU_ANCHOR_BOTTOMCENTER; | 53 anchor = MENU_ANCHOR_BOTTOMCENTER; |
| 53 break; | 54 break; |
| 54 default: | 55 default: |
| 55 break; | 56 break; |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 | 59 |
| 60 // If we are shown on mouse press, we will eat the subsequent mouse down and | |
| 61 // the parent widget will not be able to reset its state (it might have mouse | |
| 62 // capture from the mouse down). So we clear its state here. | |
| 63 if (parent && parent->GetRootView()) | |
|
sky
2016/10/26 17:46:11
Can you clarify why you need need to move this her
themblsha
2016/10/27 15:05:28
As tapted suggested in his first comment, this see
| |
| 64 parent->GetRootView()->SetMouseHandler(nullptr); | |
| 65 | |
| 59 return impl_->RunMenuAt(parent, button, bounds, anchor, run_types_); | 66 return impl_->RunMenuAt(parent, button, bounds, anchor, run_types_); |
| 60 } | 67 } |
| 61 | 68 |
| 62 bool MenuRunner::IsRunning() const { | 69 bool MenuRunner::IsRunning() const { |
| 63 return impl_->IsRunning(); | 70 return impl_->IsRunning(); |
| 64 } | 71 } |
| 65 | 72 |
| 66 void MenuRunner::Cancel() { | 73 void MenuRunner::Cancel() { |
| 67 impl_->Cancel(); | 74 impl_->Cancel(); |
| 68 } | 75 } |
| 69 | 76 |
| 70 base::TimeTicks MenuRunner::closing_event_time() const { | 77 base::TimeTicks MenuRunner::closing_event_time() const { |
| 71 return impl_->GetClosingEventTime(); | 78 return impl_->GetClosingEventTime(); |
| 72 } | 79 } |
| 73 | 80 |
| 74 void MenuRunner::SetRunnerHandler( | 81 void MenuRunner::SetRunnerHandler( |
| 75 std::unique_ptr<MenuRunnerHandler> runner_handler) { | 82 std::unique_ptr<MenuRunnerHandler> runner_handler) { |
| 76 runner_handler_ = std::move(runner_handler); | 83 runner_handler_ = std::move(runner_handler); |
| 77 } | 84 } |
| 78 | 85 |
| 79 } // namespace views | 86 } // namespace views |
| OLD | NEW |