| 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_host.h" | 5 #include "ui/views/controls/menu/menu_host.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "ui/gfx/path.h" | 8 #include "ui/gfx/path.h" |
| 9 #include "ui/native_theme/native_theme.h" | 9 #include "ui/native_theme/native_theme.h" |
| 10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 | 24 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 26 // MenuHost, public: | 26 // MenuHost, public: |
| 27 | 27 |
| 28 MenuHost::MenuHost(SubmenuView* submenu) | 28 MenuHost::MenuHost(SubmenuView* submenu) |
| 29 : submenu_(submenu), | 29 : submenu_(submenu), |
| 30 destroying_(false), | 30 destroying_(false), |
| 31 ignore_capture_lost_(false) { | 31 ignore_capture_lost_(false) { |
| 32 set_auto_release_capture(false); |
| 32 } | 33 } |
| 33 | 34 |
| 34 MenuHost::~MenuHost() { | 35 MenuHost::~MenuHost() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 void MenuHost::InitMenuHost(Widget* parent, | 38 void MenuHost::InitMenuHost(Widget* parent, |
| 38 const gfx::Rect& bounds, | 39 const gfx::Rect& bounds, |
| 39 View* contents_view, | 40 View* contents_view, |
| 40 bool do_capture) { | 41 bool do_capture) { |
| 41 TRACE_EVENT0("views", "MenuHost::InitMenuHost"); | 42 TRACE_EVENT0("views", "MenuHost::InitMenuHost"); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 native_widget_private()->ReleaseCapture(); | 103 native_widget_private()->ReleaseCapture(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
| 106 // MenuHost, Widget overrides: | 107 // MenuHost, Widget overrides: |
| 107 | 108 |
| 108 internal::RootView* MenuHost::CreateRootView() { | 109 internal::RootView* MenuHost::CreateRootView() { |
| 109 return new MenuHostRootView(this, submenu_); | 110 return new MenuHostRootView(this, submenu_); |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool MenuHost::ShouldReleaseCaptureOnMouseReleased() const { | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 void MenuHost::OnMouseCaptureLost() { | 113 void MenuHost::OnMouseCaptureLost() { |
| 117 if (destroying_ || ignore_capture_lost_) | 114 if (destroying_ || ignore_capture_lost_) |
| 118 return; | 115 return; |
| 119 MenuController* menu_controller = | 116 MenuController* menu_controller = |
| 120 submenu_->GetMenuItem()->GetMenuController(); | 117 submenu_->GetMenuItem()->GetMenuController(); |
| 121 if (menu_controller && !menu_controller->drag_in_progress()) | 118 if (menu_controller && !menu_controller->drag_in_progress()) |
| 122 menu_controller->CancelAll(); | 119 menu_controller->CancelAll(); |
| 123 Widget::OnMouseCaptureLost(); | 120 Widget::OnMouseCaptureLost(); |
| 124 } | 121 } |
| 125 | 122 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 if (destroying_) | 134 if (destroying_) |
| 138 return; | 135 return; |
| 139 | 136 |
| 140 MenuController* menu_controller = | 137 MenuController* menu_controller = |
| 141 submenu_->GetMenuItem()->GetMenuController(); | 138 submenu_->GetMenuItem()->GetMenuController(); |
| 142 if (menu_controller && !menu_controller->drag_in_progress()) | 139 if (menu_controller && !menu_controller->drag_in_progress()) |
| 143 menu_controller->CancelAll(); | 140 menu_controller->CancelAll(); |
| 144 } | 141 } |
| 145 | 142 |
| 146 } // namespace views | 143 } // namespace views |
| OLD | NEW |