| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/cocoa/hover_button.h" | 5 #import "ui/base/cocoa/hover_button.h" |
| 6 | 6 |
| 7 @implementation HoverButton | 7 @implementation HoverButton |
| 8 | 8 |
| 9 @synthesize hoverState = hoverState_; | 9 @synthesize hoverState = hoverState_; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 if (trackingArea_.get()) | 37 if (trackingArea_.get()) |
| 38 self.hoverState = kHoverStateNone; | 38 self.hoverState = kHoverStateNone; |
| 39 } | 39 } |
| 40 | 40 |
| 41 - (void)mouseDown:(NSEvent*)theEvent { | 41 - (void)mouseDown:(NSEvent*)theEvent { |
| 42 self.hoverState = kHoverStateMouseDown; | 42 self.hoverState = kHoverStateMouseDown; |
| 43 // The hover button needs to hold onto itself here for a bit. Otherwise, | 43 // The hover button needs to hold onto itself here for a bit. Otherwise, |
| 44 // it can be freed while |super mouseDown:| is in its loop, and the | 44 // it can be freed while |super mouseDown:| is in its loop, and the |
| 45 // |checkImageState| call will crash. | 45 // |checkImageState| call will crash. |
| 46 // http://crbug.com/28220 | 46 // http://crbug.com/28220 |
| 47 scoped_nsobject<HoverButton> myself([self retain]); | 47 base::scoped_nsobject<HoverButton> myself([self retain]); |
| 48 | 48 |
| 49 [super mouseDown:theEvent]; | 49 [super mouseDown:theEvent]; |
| 50 // We need to check the image state after the mouseDown event loop finishes. | 50 // We need to check the image state after the mouseDown event loop finishes. |
| 51 // It's possible that we won't get a mouseExited event if the button was | 51 // It's possible that we won't get a mouseExited event if the button was |
| 52 // moved under the mouse during tab resize, instead of the mouse moving over | 52 // moved under the mouse during tab resize, instead of the mouse moving over |
| 53 // the button. | 53 // the button. |
| 54 // http://crbug.com/31279 | 54 // http://crbug.com/31279 |
| 55 [self checkImageState]; | 55 [self checkImageState]; |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? | 99 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? |
| 100 kHoverStateMouseOver : kHoverStateNone; | 100 kHoverStateMouseOver : kHoverStateNone; |
| 101 } | 101 } |
| 102 | 102 |
| 103 - (void)setHoverState:(HoverState)state { | 103 - (void)setHoverState:(HoverState)state { |
| 104 hoverState_ = state; | 104 hoverState_ = state; |
| 105 [self setNeedsDisplay:YES]; | 105 [self setNeedsDisplay:YES]; |
| 106 } | 106 } |
| 107 | 107 |
| 108 @end | 108 @end |
| OLD | NEW |