Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2828)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 2096303003: [Mac][Material Design] Improve bookmark folder menu performance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/bookmarks/bookmark_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..de372e4be69481972d4eb0ab219e7b8eff142c8d 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,33 +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). Skip this check if |event| is nil (as
+ // documented in the header).
+ if (event && ![[button cell] isMouseReallyInside]) {
+ [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];
+ }
// During scrolling -mouseExitedButton: stops scrolling, so update the
// corresponding status field to reflect is has stopped.
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/bookmarks/bookmark_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698