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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/bookmarks/bookmark_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 return [[self folderTarget] pasteboardItemForDragOfButton:button]; 1366 return [[self folderTarget] pasteboardItemForDragOfButton:button];
1367 } 1367 }
1368 1368
1369 - (void)willBeginPasteboardDrag { 1369 - (void)willBeginPasteboardDrag {
1370 // Close our folder menu and submenus since we know we're going to be dragged. 1370 // Close our folder menu and submenus since we know we're going to be dragged.
1371 [self closeBookmarkFolder:self]; 1371 [self closeBookmarkFolder:self];
1372 } 1372 }
1373 1373
1374 // Called from BookmarkButton. 1374 // Called from BookmarkButton.
1375 // Unlike bookmark_bar_controller's version, we DO default to being enabled. 1375 // Unlike bookmark_bar_controller's version, we DO default to being enabled.
1376 - (void)mouseEnteredButton:(id)sender event:(NSEvent*)event { 1376 - (void)mouseEnteredButton:(BookmarkButton*)button event:(NSEvent*)event {
1377 // Prevent unnecessary button selection change while scrolling due to the 1377 // Prevent unnecessary button selection change while scrolling due to the
1378 // size changing that happens in -performOneScroll:. 1378 // size changing that happens in -performOneScroll:.
1379 if (isScrolling_) 1379 if (isScrolling_)
1380 return; 1380 return;
1381 1381
1382 [[NSCursor arrowCursor] set]; 1382 [[NSCursor arrowCursor] set];
1383 1383
1384 buttonThatMouseIsIn_ = sender; 1384 // Make sure the mouse is still within the button's bounds (it might not be if
1385 [self setSelectedButtonByIndex:[self indexOfButton:sender]]; 1385 // the mouse is moving quickly). Skip this check if |event| is nil (as
1386 // documented in the header).
1387 if (event && ![[button cell] isMouseReallyInside]) {
1388 [NSObject cancelPreviousPerformRequestsWithTarget:self];
1389 return;
1390 }
1391
1392 buttonThatMouseIsIn_ = button;
1393 [self setSelectedButtonByIndex:[self indexOfButton:button]];
1386 1394
1387 // Cancel a previous hover if needed. 1395 // Cancel a previous hover if needed.
1388 [NSObject cancelPreviousPerformRequestsWithTarget:self]; 1396 [NSObject cancelPreviousPerformRequestsWithTarget:self];
1389 1397
1390 // If already opened, then we exited but re-entered the button 1398 // If already opened, then we exited but re-entered the button
1391 // (without entering another button open), do nothing. 1399 // (without entering another button open), do nothing.
1392 if ([folderController_ parentButton] == sender) 1400 if ([folderController_ parentButton] == button)
1393 return; 1401 return;
1394 1402
1395 // If right click was done immediately on entering a button, then open the 1403 // If right click was done immediately on entering a button, then open the
1396 // folder without delay so that context menu appears over the folder menu. 1404 // folder without delay so that context menu appears over the folder menu.
1397 if ([event type] == NSRightMouseDown) 1405 if ([event type] == NSRightMouseDown)
1398 [self openBookmarkFolderFromButtonAndCloseOldOne:sender]; 1406 [self openBookmarkFolderFromButtonAndCloseOldOne:button];
1399 else 1407 else
1400 [self performSelector:@selector(openBookmarkFolderFromButtonAndCloseOldOne:) 1408 [self performSelector:@selector(openBookmarkFolderFromButtonAndCloseOldOne:)
1401 withObject:sender 1409 withObject:button
1402 afterDelay:bookmarks::kHoverOpenDelay 1410 afterDelay:bookmarks::kHoverOpenDelay
1403 inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]]; 1411 inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
1404 } 1412 }
1405 1413
1406 // Called from the BookmarkButton 1414 // Called from the BookmarkButton
1407 - (void)mouseExitedButton:(id)sender event:(NSEvent*)event { 1415 - (void)mouseExitedButton:(BookmarkButton*)button event:(NSEvent*)event {
1408 if (buttonThatMouseIsIn_ == sender) 1416 if (buttonThatMouseIsIn_ == button) {
1409 buttonThatMouseIsIn_ = nil; 1417 buttonThatMouseIsIn_ = nil;
1410 [self setSelectedButtonByIndex:-1]; 1418 [self setSelectedButtonByIndex:-1];
1419 }
1411 1420
1412 // During scrolling -mouseExitedButton: stops scrolling, so update the 1421 // During scrolling -mouseExitedButton: stops scrolling, so update the
1413 // corresponding status field to reflect is has stopped. 1422 // corresponding status field to reflect is has stopped.
1414 isScrolling_ = NO; 1423 isScrolling_ = NO;
1415 1424
1416 // Stop any timer about opening a new hover-open folder. 1425 // Stop any timer about opening a new hover-open folder.
1417 1426
1418 // Since a performSelector:withDelay: on self retains self, it is 1427 // Since a performSelector:withDelay: on self retains self, it is
1419 // possible that a cancelPreviousPerformRequestsWithTarget: reduces 1428 // possible that a cancelPreviousPerformRequestsWithTarget: reduces
1420 // the refcount to 0, releasing us. That's a bad thing to do while 1429 // the refcount to 0, releasing us. That's a bad thing to do while
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 2089
2081 - (void)setIgnoreAnimations:(BOOL)ignore { 2090 - (void)setIgnoreAnimations:(BOOL)ignore {
2082 ignoreAnimations_ = ignore; 2091 ignoreAnimations_ = ignore;
2083 } 2092 }
2084 2093
2085 - (BookmarkButton*)buttonThatMouseIsIn { 2094 - (BookmarkButton*)buttonThatMouseIsIn {
2086 return buttonThatMouseIsIn_; 2095 return buttonThatMouseIsIn_;
2087 } 2096 }
2088 2097
2089 @end // BookmarkBarFolderController 2098 @end // BookmarkBarFolderController
OLDNEW
« 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