Chromium Code Reviews| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm |
| index ee57e655b4a680d03f0d40b87e8830b30e9575d0..a3bef22f2846f9052f356e330e56fae769935d40 100644 |
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm |
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm |
| @@ -1373,7 +1373,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { |
| // Called from BookmarkButton. |
| // Unlike bookmark_bar_controller's version, we DO default to being enabled. |
| -- (void)mouseEnteredButton:(id)sender event:(NSEvent*)event { |
| +- (void)mouseEnteredButton:(BookmarkButton*)button event:(NSEvent*)event { |
| // Prevent unnecessary button selection change while scrolling due to the |
| // size changing that happens in -performOneScroll:. |
| if (isScrolling_) |
| @@ -1381,31 +1381,42 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { |
| [[NSCursor arrowCursor] set]; |
| - buttonThatMouseIsIn_ = sender; |
| - [self setSelectedButtonByIndex:[self indexOfButton:sender]]; |
| + // Make sure the mouse is still within the button's bounds (it might not be if |
| + // the mouse is moving quickly). |
| + NSPoint currentMouseLocation = |
|
tapted
2016/06/17 05:00:42
Does [[button cell] isMouseReallyInside] do the jo
shrike
2016/06/21 23:25:20
Yes, thank you.
|
| + [[button window] mouseLocationOutsideOfEventStream]; |
| + currentMouseLocation = [button convertPoint:currentMouseLocation |
| + fromView:nil]; |
| + if (!NSPointInRect(currentMouseLocation, [button bounds])) { |
| + [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
| + return; |
| + } |
| + |
| + buttonThatMouseIsIn_ = button; |
| + [self setSelectedButtonByIndex:[self indexOfButton:button]]; |
| // Cancel a previous hover if needed. |
| [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
| // If already opened, then we exited but re-entered the button |
| // (without entering another button open), do nothing. |
| - if ([folderController_ parentButton] == sender) |
| + if ([folderController_ parentButton] == button) |
| return; |
| // If right click was done immediately on entering a button, then open the |
| // folder without delay so that context menu appears over the folder menu. |
| if ([event type] == NSRightMouseDown) |
| - [self openBookmarkFolderFromButtonAndCloseOldOne:sender]; |
| + [self openBookmarkFolderFromButtonAndCloseOldOne:button]; |
| else |
| [self performSelector:@selector(openBookmarkFolderFromButtonAndCloseOldOne:) |
| - withObject:sender |
| + withObject:button |
| afterDelay:bookmarks::kHoverOpenDelay |
| inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]]; |
| } |
| // Called from the BookmarkButton |
| -- (void)mouseExitedButton:(id)sender event:(NSEvent*)event { |
| - if (buttonThatMouseIsIn_ == sender) |
| +- (void)mouseExitedButton:(BookmarkButton*)button event:(NSEvent*)event { |
| + if (buttonThatMouseIsIn_ == button) |
| buttonThatMouseIsIn_ = nil; |
| [self setSelectedButtonByIndex:-1]; |
|
tapted
2016/06/17 05:00:42
There's an indenting bug here - this line is inden
shrike
2016/06/21 23:25:20
It doesn't look like it. It happened in 2011, and
|