Index: ui/base/cocoa/base_view.mm |
diff --git a/ui/base/cocoa/base_view.mm b/ui/base/cocoa/base_view.mm |
index d5f89e89aadf8570a0872d8c3ae80d11a3d447a7..a40c2415f83354665e22188e823e364ac3fca67e 100644 |
--- a/ui/base/cocoa/base_view.mm |
+++ b/ui/base/cocoa/base_view.mm |
@@ -8,19 +8,19 @@ NSString* kViewDidBecomeFirstResponder = |
@"Chromium.kViewDidBecomeFirstResponder"; |
NSString* kSelectionDirection = @"Chromium.kSelectionDirection"; |
+const int kTrackingOptions = NSTrackingMouseMoved | |
+ NSTrackingMouseEnteredAndExited | |
+ NSTrackingActiveAlways; |
+ |
@implementation BaseView |
- (id)initWithFrame:(NSRect)frame { |
self = [super initWithFrame:frame]; |
if (self) { |
- trackingArea_ = |
- [[NSTrackingArea alloc] initWithRect:frame |
- options:NSTrackingMouseMoved | |
- NSTrackingMouseEnteredAndExited | |
- NSTrackingActiveInActiveApp | |
- NSTrackingInVisibleRect |
- owner:self |
- userInfo:nil]; |
+ trackingArea_ = [[NSTrackingArea alloc] initWithRect:frame |
Alexei Svitkine (slow)
2013/03/14 00:42:47
Could this just call [self refreshTrackingAreaSize
|
+ options:kTrackingOptions |
+ owner:self |
+ userInfo:nil]; |
[self addTrackingArea:trackingArea_]; |
} |
return self; |
@@ -143,4 +143,31 @@ NSString* kSelectionDirection = @"Chromium.kSelectionDirection"; |
return new_rect; |
} |
+- (void)refreshTrackingAreaSize { |
Alexei Svitkine (slow)
2013/03/14 00:42:47
Should this be called refreshTrackingAreaRect, sin
|
+ // 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. |
+ [self removeTrackingArea:trackingArea_]; |
+ [trackingArea_ release]; |
+ trackingArea_ = [[NSTrackingArea alloc] initWithRect:[self frame] |
+ options:kTrackingOptions |
+ owner:self |
+ userInfo:nil]; |
+ [self addTrackingArea:trackingArea_]; |
+} |
+ |
+- (void)setFrame:(NSRect)newRect { |
+ BOOL sizeChanged = !NSEqualSizes([self frame].size, newRect.size); |
+ [super setFrame:newRect]; |
+ |
+ // NB: -[NSView setFrame:] calls through -setFrameSize:. |
+ if (!sizeChanged) |
+ [self refreshTrackingAreaSize]; |
Alexei Svitkine (slow)
2013/03/14 00:42:47
So this is called because -[NSView setFrame:] does
|
+} |
+ |
+- (void)setFrameSize:(NSSize)newSize { |
+ [super setFrameSize:newSize]; |
+ [self refreshTrackingAreaSize]; |
+} |
+ |
@end |