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

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

Issue 191723003: Nukes USE_AURA ifdefs from views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 9 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 | Annotate | Revision Log
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"
11 #include "ui/native_theme/native_theme.h" 11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/controls/menu/menu_controller.h" 12 #include "ui/views/controls/menu/menu_controller.h"
13 #include "ui/views/controls/menu/menu_host_root_view.h" 13 #include "ui/views/controls/menu/menu_host_root_view.h"
14 #include "ui/views/controls/menu/menu_item_view.h" 14 #include "ui/views/controls/menu/menu_item_view.h"
15 #include "ui/views/controls/menu/menu_scroll_view_container.h" 15 #include "ui/views/controls/menu/menu_scroll_view_container.h"
16 #include "ui/views/controls/menu/submenu_view.h" 16 #include "ui/views/controls/menu/submenu_view.h"
17 #include "ui/views/corewm/shadow_types.h"
17 #include "ui/views/round_rect_painter.h" 18 #include "ui/views/round_rect_painter.h"
18 #include "ui/views/widget/native_widget_private.h" 19 #include "ui/views/widget/native_widget_private.h"
19 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
20 21
21 #if defined(USE_AURA)
22 #include "ui/views/corewm/shadow_types.h"
23 #endif
24
25 namespace views { 22 namespace views {
26 23
27 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
28 // MenuHost, public: 25 // MenuHost, public:
29 26
30 MenuHost::MenuHost(SubmenuView* submenu) 27 MenuHost::MenuHost(SubmenuView* submenu)
31 : submenu_(submenu), 28 : submenu_(submenu),
32 destroying_(false), 29 destroying_(false),
33 ignore_capture_lost_(false) { 30 ignore_capture_lost_(false) {
34 set_auto_release_capture(false); 31 set_auto_release_capture(false);
(...skipping 15 matching lines...) Expand all
50 bool bubble_border = submenu_->GetScrollViewContainer() && 47 bool bubble_border = submenu_->GetScrollViewContainer() &&
51 submenu_->GetScrollViewContainer()->HasBubbleBorder(); 48 submenu_->GetScrollViewContainer()->HasBubbleBorder();
52 params.has_dropshadow = !bubble_border; 49 params.has_dropshadow = !bubble_border;
53 params.opacity = (bubble_border || rounded_border) ? 50 params.opacity = (bubble_border || rounded_border) ?
54 Widget::InitParams::TRANSLUCENT_WINDOW : 51 Widget::InitParams::TRANSLUCENT_WINDOW :
55 Widget::InitParams::OPAQUE_WINDOW; 52 Widget::InitParams::OPAQUE_WINDOW;
56 params.parent = parent ? parent->GetNativeView() : NULL; 53 params.parent = parent ? parent->GetNativeView() : NULL;
57 params.bounds = bounds; 54 params.bounds = bounds;
58 Init(params); 55 Init(params);
59 56
60 #if defined(USE_AURA)
61 if (bubble_border) 57 if (bubble_border)
62 SetShadowType(GetNativeView(), views::corewm::SHADOW_TYPE_NONE); 58 SetShadowType(GetNativeView(), views::corewm::SHADOW_TYPE_NONE);
63 #endif
64 59
65 SetContentsView(contents_view); 60 SetContentsView(contents_view);
66 if (bubble_border || rounded_border) 61 if (bubble_border || rounded_border)
67 SetOpacity(0); 62 SetOpacity(0);
68 ShowMenuHost(do_capture); 63 ShowMenuHost(do_capture);
69 } 64 }
70 65
71 bool MenuHost::IsMenuHostVisible() { 66 bool MenuHost::IsMenuHostVisible() {
72 return IsVisible(); 67 return IsVisible();
73 } 68 }
74 69
75 void MenuHost::ShowMenuHost(bool do_capture) { 70 void MenuHost::ShowMenuHost(bool do_capture) {
76 // Doing a capture may make us get capture lost. Ignore it while we're in the 71 // Doing a capture may make us get capture lost. Ignore it while we're in the
77 // process of showing. 72 // process of showing.
78 base::AutoReset<bool> reseter(&ignore_capture_lost_, true); 73 base::AutoReset<bool> reseter(&ignore_capture_lost_, true);
79 ShowInactive(); 74 ShowInactive();
80 if (do_capture) { 75 if (do_capture) {
81 #if defined(USE_AURA)
82 // Cancel existing touches, so we don't miss some touch release/cancel 76 // Cancel existing touches, so we don't miss some touch release/cancel
83 // events due to the menu taking capture. 77 // events due to the menu taking capture.
84 ui::GestureRecognizer::Get()->TransferEventsTo(GetNativeWindow(), NULL); 78 ui::GestureRecognizer::Get()->TransferEventsTo(GetNativeWindow(), NULL);
85 #endif // USE_AURA
86 native_widget_private()->SetCapture(); 79 native_widget_private()->SetCapture();
87 } 80 }
88 } 81 }
89 82
90 void MenuHost::HideMenuHost() { 83 void MenuHost::HideMenuHost() {
91 ignore_capture_lost_ = true; 84 ignore_capture_lost_ = true;
92 ReleaseMenuHostCapture(); 85 ReleaseMenuHostCapture();
93 Hide(); 86 Hide();
94 ignore_capture_lost_ = false; 87 ignore_capture_lost_ = false;
95 } 88 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (destroying_) 134 if (destroying_)
142 return; 135 return;
143 136
144 MenuController* menu_controller = 137 MenuController* menu_controller =
145 submenu_->GetMenuItem()->GetMenuController(); 138 submenu_->GetMenuItem()->GetMenuController();
146 if (menu_controller && !menu_controller->drag_in_progress()) 139 if (menu_controller && !menu_controller->drag_in_progress())
147 menu_controller->CancelAll(); 140 menu_controller->CancelAll();
148 } 141 }
149 142
150 } // namespace views 143 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698