Chromium Code Reviews| Index: chrome/browser/ui/cocoa/gradient_button_cell.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/gradient_button_cell.mm (revision 68678) |
| +++ chrome/browser/ui/cocoa/gradient_button_cell.mm (working copy) |
| @@ -28,6 +28,7 @@ |
| innerPath:(NSBezierPath**)returnInnerPath |
| clipPath:(NSBezierPath**)returnClipPath; |
| +- (void)updateTrackingAreas; |
| @end |
| @@ -320,21 +321,16 @@ |
| if (showOnly) { |
| if (trackingArea_.get()) { |
| [self setShowsBorderOnlyWhileMouseInside:NO]; |
| - [[self controlView] removeTrackingArea:trackingArea_]; |
| } |
| - trackingArea_.reset([[NSTrackingArea alloc] |
| - initWithRect:[[self controlView] |
| - bounds] |
| - options:(NSTrackingMouseEnteredAndExited | |
| - NSTrackingActiveInActiveApp) |
| - owner:self |
| - userInfo:nil]); |
| - [[self controlView] addTrackingArea:trackingArea_]; |
| + [self updateTrackingAreas]; |
| } else { |
| if (trackingArea_) { |
| [[self controlView] removeTrackingArea:trackingArea_]; |
| trackingArea_.reset(nil); |
| - isMouseInside_ = NO; |
| + if (isMouseInside_) { |
| + isMouseInside_ = NO; |
| + [[self controlView] setNeedsDisplay:YES]; |
| + } |
| } |
| } |
| } |
| @@ -716,4 +712,45 @@ |
| return boundingPath; |
| } |
| +- (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView |
| +{ |
|
mrossetti
2010/12/10 18:12:49
Move brace up to end of previous line.
Leib
2010/12/13 17:32:00
Done.
|
| + [super resetCursorRect:cellFrame inView:controlView]; |
| + if (trackingArea_) { |
|
mrossetti
2010/12/10 18:12:49
Note that braces are optional for single-line if b
Leib
2010/12/13 17:32:00
Done.
|
| + [self updateTrackingAreas]; |
| + } |
| +} |
| + |
| +- (void)updateTrackingAreas |
| +{ |
|
mrossetti
2010/12/10 18:12:49
Brace up to previous line.
Leib
2010/12/13 17:32:00
Done.
|
| + BOOL mouseInView = NO; |
| + NSView *controlView = [self controlView]; |
|
mrossetti
2010/12/10 18:12:49
Asterisks precede the space in Chromium.
Leib
2010/12/13 17:32:00
Done.
|
| + NSWindow *window = [controlView window]; |
|
mrossetti
2010/12/10 18:12:49
Move asterisk to before the space.
Leib
2010/12/13 17:32:00
Done.
|
| + NSRect bounds = [controlView bounds]; |
| + if (window) { |
| + NSPoint mousePoint = [window mouseLocationOutsideOfEventStream]; |
| + mousePoint = [controlView convertPointFromBase:mousePoint]; |
| + mouseInView = [controlView mouse:mousePoint inRect:bounds]; |
| + } |
| + |
| + if (trackingArea_.get()) { |
| + [controlView removeTrackingArea:trackingArea_]; |
| + } |
| + |
| + NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | |
| + NSTrackingActiveInActiveApp; |
| + if (mouseInView) { |
| + options |= NSTrackingAssumeInside; |
| + } |
| + |
| + trackingArea_.reset([[NSTrackingArea alloc] |
| + initWithRect:bounds |
| + options:options |
| + owner:self |
| + userInfo:nil]); |
| + if (isMouseInside_ != mouseInView) { |
| + isMouseInside_ = mouseInView; |
| + [controlView setNeedsDisplay:YES]; |
| + } |
| +} |
| + |
| @end |