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

Side by Side Diff: ui/views/controls/menu/menu_runner_impl_cocoa.mm

Issue 2450903002: MacViews: Clear mouse handler when showing context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" 5 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h"
6 6
7 #include "base/mac/sdk_forward_declarations.h" 7 #include "base/mac/sdk_forward_declarations.h"
8 #import "ui/base/cocoa/menu_controller.h" 8 #import "ui/base/cocoa/menu_controller.h"
9 #include "ui/base/models/menu_model.h" 9 #include "ui/base/models/menu_model.h"
10 #include "ui/events/base_event_utils.h" 10 #include "ui/events/base_event_utils.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 MenuButton* button, 121 MenuButton* button,
122 const gfx::Rect& bounds, 122 const gfx::Rect& bounds,
123 MenuAnchorPosition anchor, 123 MenuAnchorPosition anchor,
124 int32_t run_types) { 124 int32_t run_types) {
125 DCHECK(run_types & kNativeRunTypes); 125 DCHECK(run_types & kNativeRunTypes);
126 DCHECK(!IsRunning()); 126 DCHECK(!IsRunning());
127 DCHECK(parent); 127 DCHECK(parent);
128 closing_event_time_ = base::TimeTicks(); 128 closing_event_time_ = base::TimeTicks();
129 running_ = true; 129 running_ = true;
130 130
131 // If we are shown on mouse press, we will eat the subsequent mouse down and
132 // the parent widget will not be able to reset its state (it might have mouse
133 // capture from the mouse down). So we clear its state here.
134 if (parent && parent->GetRootView())
tapted 2016/10/26 02:15:31 above there's a DCHECK(parent), so there's no need
135 parent->GetRootView()->SetMouseHandler(nullptr);
tapted 2016/10/26 02:15:31 This is just copied from menu_controller.cc - can
themblsha 2016/10/26 15:49:14 The fragment in browser.cc is from 2016, and it's
136
131 if (run_types & MenuRunner::CONTEXT_MENU) { 137 if (run_types & MenuRunner::CONTEXT_MENU) {
132 [NSMenu popUpContextMenu:[menu_controller_ menu] 138 [NSMenu popUpContextMenu:[menu_controller_ menu]
133 withEvent:[NSApp currentEvent] 139 withEvent:[NSApp currentEvent]
134 forView:parent->GetNativeView()]; 140 forView:parent->GetNativeView()];
135 } else if (run_types & MenuRunner::COMBOBOX) { 141 } else if (run_types & MenuRunner::COMBOBOX) {
136 NSMenuItem* checked_item = FirstCheckedItem(menu_controller_); 142 NSMenuItem* checked_item = FirstCheckedItem(menu_controller_);
137 base::scoped_nsobject<NSView> anchor_view( 143 base::scoped_nsobject<NSView> anchor_view(
138 CreateMenuAnchorView(parent->GetNativeWindow(), bounds, checked_item)); 144 CreateMenuAnchorView(parent->GetNativeWindow(), bounds, checked_item));
139 NSMenu* menu = [menu_controller_ menu]; 145 NSMenu* menu = [menu_controller_ menu];
140 [menu setMinimumWidth:bounds.width() + kNativeCheckmarkWidth]; 146 [menu setMinimumWidth:bounds.width() + kNativeCheckmarkWidth];
(...skipping 22 matching lines...) Expand all
163 169
164 base::TimeTicks MenuRunnerImplCocoa::GetClosingEventTime() const { 170 base::TimeTicks MenuRunnerImplCocoa::GetClosingEventTime() const {
165 return closing_event_time_; 171 return closing_event_time_;
166 } 172 }
167 173
168 MenuRunnerImplCocoa::~MenuRunnerImplCocoa() { 174 MenuRunnerImplCocoa::~MenuRunnerImplCocoa() {
169 } 175 }
170 176
171 } // namespace internal 177 } // namespace internal
172 } // namespace views 178 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698