Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1249)

Side by Side Diff: ui/views/controls/menu/menu_host.cc

Issue 378333003: Allow menus to stay open during a child view's drag and drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/events/gestures/gesture_recognizer.h" 9 #include "ui/events/gestures/gesture_recognizer.h"
10 #include "ui/gfx/path.h" 10 #include "ui/gfx/path.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 internal::RootView* MenuHost::CreateRootView() { 104 internal::RootView* MenuHost::CreateRootView() {
105 return new MenuHostRootView(this, submenu_); 105 return new MenuHostRootView(this, submenu_);
106 } 106 }
107 107
108 void MenuHost::OnMouseCaptureLost() { 108 void MenuHost::OnMouseCaptureLost() {
109 if (destroying_ || ignore_capture_lost_) 109 if (destroying_ || ignore_capture_lost_)
110 return; 110 return;
111 MenuController* menu_controller = 111 MenuController* menu_controller =
112 submenu_->GetMenuItem()->GetMenuController(); 112 submenu_->GetMenuItem()->GetMenuController();
113 if (menu_controller && !menu_controller->drag_in_progress()) 113 if (menu_controller &&
114 !menu_controller->drag_in_progress() &&
115 !dragged_view()) {
sky 2014/07/11 17:45:33 Document why we check dragged_view(). I also midly
Devlin 2014/07/11 18:43:51 If we forward a OnDragWillStart() down to MenuCont
sky 2014/07/11 19:15:20 Yes, I believe you are right.
114 menu_controller->CancelAll(); 116 menu_controller->CancelAll();
117 }
115 Widget::OnMouseCaptureLost(); 118 Widget::OnMouseCaptureLost();
116 } 119 }
117 120
118 void MenuHost::OnNativeWidgetDestroyed() { 121 void MenuHost::OnNativeWidgetDestroyed() {
119 if (!destroying_) { 122 if (!destroying_) {
120 // We weren't explicitly told to destroy ourselves, which means the menu was 123 // We weren't explicitly told to destroy ourselves, which means the menu was
121 // deleted out from under us (the window we're parented to was closed). Tell 124 // deleted out from under us (the window we're parented to was closed). Tell
122 // the SubmenuView to drop references to us. 125 // the SubmenuView to drop references to us.
123 submenu_->MenuHostDestroyed(); 126 submenu_->MenuHostDestroyed();
124 } 127 }
125 Widget::OnNativeWidgetDestroyed(); 128 Widget::OnNativeWidgetDestroyed();
126 } 129 }
127 130
128 void MenuHost::OnOwnerClosing() { 131 void MenuHost::OnOwnerClosing() {
129 if (destroying_) 132 if (destroying_)
130 return; 133 return;
131 134
132 MenuController* menu_controller = 135 MenuController* menu_controller =
133 submenu_->GetMenuItem()->GetMenuController(); 136 submenu_->GetMenuItem()->GetMenuController();
134 if (menu_controller && !menu_controller->drag_in_progress()) 137 if (menu_controller && !menu_controller->drag_in_progress())
135 menu_controller->CancelAll(); 138 menu_controller->CancelAll();
136 } 139 }
137 140
141 void MenuHost::OnDragComplete() {
142 // During a view's drag, we may have lost the capture. Reset it so that we
sky 2014/07/11 17:45:33 Add a delegate method as to what should happen whe
Devlin 2014/07/11 18:43:51 Done. However, this has a side-effect: other drag
sky 2014/07/11 19:15:20 Good point. I don't believe the bookmark code does
Devlin 2014/07/11 20:28:15 Tentatively done (see comment on new patch set).
143 // get OnMouseCaptureLost events.
144 native_widget_private()->SetCapture();
145 }
146
138 } // namespace views 147 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698