Chromium Code Reviews| Index: ui/views/controls/menu/menu_host.cc |
| diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc |
| index c6750a6e0cd51be18d9470a45969bed6b27c0e4c..d3d7b2dc680c3c7d49c25c7eeaecd86871d15646 100644 |
| --- a/ui/views/controls/menu/menu_host.cc |
| +++ b/ui/views/controls/menu/menu_host.cc |
| @@ -127,10 +127,20 @@ void MenuHost::InitMenuHost(Widget* parent, |
| menu_controller, submenu_, GetNativeView())); |
| #endif |
| + if (parent && !views::MenuController::DoCancel()) { |
|
xiyuan
2017/05/15 19:20:52
nit: Use |menu_controller| instance after making D
minch1
2017/05/16 22:13:39
Done.
|
| + owner_ = parent; |
| + TransferEvents(owner_, this); |
| + } |
| SetContentsView(contents_view); |
| ShowMenuHost(do_capture); |
| } |
| +void MenuHost::TransferEvents(Widget* source, Widget* target) { |
| + ui::GestureRecognizer::Get()->TransferEventsTo( |
| + source->GetNativeView(), target->GetNativeView(), |
| + ui::GestureRecognizer::ShouldCancelTouches::DontCancel); |
| +} |
| + |
| bool MenuHost::IsMenuHostVisible() { |
| return IsVisible(); |
| } |
| @@ -143,12 +153,18 @@ void MenuHost::ShowMenuHost(bool do_capture) { |
| if (do_capture) { |
| // Cancel existing touches, so we don't miss some touch release/cancel |
| // events due to the menu taking capture. |
| - ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr); |
| + if (views::MenuController::DoCancel()) |
| + ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr); |
| native_widget_private()->SetCapture(); |
| } |
| } |
| void MenuHost::HideMenuHost() { |
| + if (owner_ && !views::MenuController::DoCancel()) { |
| + TransferEvents(this, owner_); |
| + owner_ = NULL; |
| + views::MenuController::SetDoCancel(true); |
|
xiyuan
2017/05/15 19:20:52
Is this call necessary?
minch1
2017/05/15 22:16:34
Yes. I think this is necessary.
1. Press the shel
xiyuan
2017/05/15 22:41:10
That would be another reason to make |do_cancel_|
|
| + } |
| ignore_capture_lost_ = true; |
| ReleaseMenuHostCapture(); |
| Hide(); |