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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 2090003002: MacViews: Explicitly release mouse capture in BridgedNativeWidget::OnWindowWillClose(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | ui/views/widget/widget_unittest.cc » ('J')
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/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // For other teardown flows (e.g. Widget::WIDGET_OWNS_NATIVE_WIDGET or 359 // For other teardown flows (e.g. Widget::WIDGET_OWNS_NATIVE_WIDGET or
360 // Widget::CloseNow()) the delegate must first be cleared to avoid AppKit 360 // Widget::CloseNow()) the delegate must first be cleared to avoid AppKit
361 // calling back into the bridge. This means OnWindowWillClose() needs to be 361 // calling back into the bridge. This means OnWindowWillClose() needs to be
362 // invoked manually, which is done below. 362 // invoked manually, which is done below.
363 // Note that if the window has children it can't be closed until the 363 // Note that if the window has children it can't be closed until the
364 // children are gone, but removing child windows calls into AppKit for the 364 // children are gone, but removing child windows calls into AppKit for the
365 // parent window, so the delegate must be cleared first. 365 // parent window, so the delegate must be cleared first.
366 [window_ setDelegate:nil]; 366 [window_ setDelegate:nil];
367 close_window = true; 367 close_window = true;
368 } 368 }
369 369 // If we have capture, we'll get a OnMouseCaptureLost callback, which can
tapted 2016/06/23 02:26:28 nit: it's generally good to avoid "we". (there's e
karandeepb 2016/06/23 07:58:32 Done.
370 // lead to a use after free crash. Hence explicitly release capture. See
371 // crbug.com/622201.
372 ReleaseCapture();
tapted 2016/06/23 02:26:28 DesktopNativeWidgetAura does it in OnHostClosed, w
karandeepb 2016/06/23 07:58:32 Yes Widget::OnMouseCaptureLost is invoked for aura
karandeepb 2016/06/24 05:34:36 Done.
370 RemoveOrDestroyChildren(); 373 RemoveOrDestroyChildren();
371 DCHECK(child_windows_.empty()); 374 DCHECK(child_windows_.empty());
372 SetFocusManager(nullptr); 375 SetFocusManager(nullptr);
373 SetRootView(nullptr); 376 SetRootView(nullptr);
374 DestroyCompositor(); 377 DestroyCompositor();
375 378
376 if (close_window) { 379 if (close_window) {
377 OnWindowWillClose(); 380 OnWindowWillClose();
378 [window_ close]; 381 [window_ close];
379 } 382 }
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1348 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1346 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1349 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1347 // changes. Previously we tried adding an NSView and removing it, but for some 1350 // changes. Previously we tried adding an NSView and removing it, but for some
1348 // reason it required reposting the mouse-down event, and didn't always work. 1351 // reason it required reposting the mouse-down event, and didn't always work.
1349 // Calling the below seems to be an effective solution. 1352 // Calling the below seems to be an effective solution.
1350 [window_ setMovableByWindowBackground:NO]; 1353 [window_ setMovableByWindowBackground:NO];
1351 [window_ setMovableByWindowBackground:YES]; 1354 [window_ setMovableByWindowBackground:YES];
1352 } 1355 }
1353 1356
1354 } // namespace views 1357 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | ui/views/widget/widget_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698