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

Unified Diff: ui/base/cocoa/base_view.mm

Issue 941543002: Mac: Speculative fix for tracking area crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bgv
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/cocoa/base_view.mm
diff --git a/ui/base/cocoa/base_view.mm b/ui/base/cocoa/base_view.mm
index b37b6789435d8a6da2698e72d63b1779adba2957..cb25a02444180f512340896ef1d93708f08d18ce 100644
--- a/ui/base/cocoa/base_view.mm
+++ b/ui/base/cocoa/base_view.mm
@@ -8,12 +8,34 @@ NSString* kViewDidBecomeFirstResponder =
@"Chromium.kViewDidBecomeFirstResponder";
NSString* kSelectionDirection = @"Chromium.kSelectionDirection";
-const int kTrackingOptions = NSTrackingMouseMoved |
- NSTrackingMouseEnteredAndExited |
- NSTrackingActiveAlways;
-
@implementation BaseView
+- (instancetype)initWithFrame:(NSRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ [self initBaseView];
+ }
+ return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder*)decoder {
+ if ((self = [super initWithCoder:decoder])) {
+ [self initBaseView];
+ }
+ return self;
+}
+
+- (void)initBaseView {
+ trackingArea_.reset(
+ [[CrTrackingArea alloc] initWithRect:NSZeroRect
+ options:NSTrackingMouseMoved |
+ NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveAlways |
+ NSTrackingInVisibleRect
+ owner:self
+ userInfo:nil]);
+ [self addTrackingArea:trackingArea_.get()];
+}
+
- (void)dealloc {
if (trackingArea_.get())
[self removeTrackingArea:trackingArea_.get()];
@@ -138,19 +160,4 @@ const int kTrackingOptions = NSTrackingMouseMoved |
return new_rect;
}
-- (void)updateTrackingAreas {
- [super updateTrackingAreas];
Nico 2015/02/24 21:00:18 Could we set a flag in dealloc and not add a new t
Andre 2015/02/24 21:20:46 I thought about that, but ended up not being confi
-
- // NSTrackingInVisibleRect doesn't work correctly with Lion's window resizing,
- // http://crbug.com/176725 / http://openradar.appspot.com/radar?id=2773401 .
- // Tear down old tracking area and create a new one as workaround.
- if (trackingArea_.get())
- [self removeTrackingArea:trackingArea_.get()];
- trackingArea_.reset([[CrTrackingArea alloc] initWithRect:[self bounds]
- options:kTrackingOptions
- owner:self
- userInfo:nil]);
- [self addTrackingArea:trackingArea_.get()];
-}
-
@end
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698