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 <set> | 7 #include <set> |
| 8 | 8 |
| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 277 } |
| 278 | 278 |
| 279 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent, | 279 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent, |
| 280 MenuButton* button, | 280 MenuButton* button, |
| 281 const gfx::Rect& bounds, | 281 const gfx::Rect& bounds, |
| 282 MenuItemView::AnchorPosition anchor, | 282 MenuItemView::AnchorPosition anchor, |
| 283 int32 types) { | 283 int32 types) { |
| 284 // The parent of the nested menu will have created a DisplayChangeListener, so | 284 // The parent of the nested menu will have created a DisplayChangeListener, so |
| 285 // we avoid creating a DisplayChangeListener if nested. Drop menus are | 285 // we avoid creating a DisplayChangeListener if nested. Drop menus are |
| 286 // transient, so we don't cancel in that case. | 286 // transient, so we don't cancel in that case. |
| 287 if ((types & (IS_NESTED | FOR_DROP)) == 0) { | 287 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent != NULL) { |
|
Ben Goodger (Google)
2013/03/11 16:10:07
nit && parent
Jun Mukai
2013/03/11 16:42:29
Done.
| |
| 288 display_change_listener_.reset( | 288 display_change_listener_.reset( |
| 289 internal::DisplayChangeListener::Create(parent, this)); | 289 internal::DisplayChangeListener::Create(parent, this)); |
| 290 } | 290 } |
| 291 if ((types & MenuRunner::CONTEXT_MENU) && | 291 if ((types & MenuRunner::CONTEXT_MENU) && |
| 292 parent && | 292 parent && |
| 293 parent->GetCurrentEvent() && | 293 parent->GetCurrentEvent() && |
| 294 !MenuItemView::IsBubble(anchor)) | 294 !MenuItemView::IsBubble(anchor)) |
| 295 anchor = parent->GetCurrentEvent()->IsGestureEvent() ? | 295 anchor = parent->GetCurrentEvent()->IsGestureEvent() ? |
| 296 MenuItemView::BOTTOMCENTER : MenuItemView::TOPLEFT; | 296 MenuItemView::BOTTOMCENTER : MenuItemView::TOPLEFT; |
| 297 | 297 |
| 298 return holder_->RunMenuAt(parent, button, bounds, anchor, types); | 298 return holder_->RunMenuAt(parent, button, bounds, anchor, types); |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool MenuRunner::IsRunning() const { | 301 bool MenuRunner::IsRunning() const { |
| 302 return holder_->running(); | 302 return holder_->running(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void MenuRunner::Cancel() { | 305 void MenuRunner::Cancel() { |
| 306 holder_->Cancel(); | 306 holder_->Cancel(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace views | 309 } // namespace views |
| OLD | NEW |