Chromium Code Reviews| 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 |