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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 2073753004: [Mac][Material Design] Improve bookmark folder menu performance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 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).
1386 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.
1387 [[button window] mouseLocationOutsideOfEventStream];
1388 currentMouseLocation = [button convertPoint:currentMouseLocation
1389 fromView:nil];
1390 if (!NSPointInRect(currentMouseLocation, [button bounds])) {
1391 [NSObject cancelPreviousPerformRequestsWithTarget:self];
1392 return;
1393 }
1394
1395 buttonThatMouseIsIn_ = button;
1396 [self setSelectedButtonByIndex:[self indexOfButton:button]];
1386 1397
1387 // Cancel a previous hover if needed. 1398 // Cancel a previous hover if needed.
1388 [NSObject cancelPreviousPerformRequestsWithTarget:self]; 1399 [NSObject cancelPreviousPerformRequestsWithTarget:self];
1389 1400
1390 // If already opened, then we exited but re-entered the button 1401 // If already opened, then we exited but re-entered the button
1391 // (without entering another button open), do nothing. 1402 // (without entering another button open), do nothing.
1392 if ([folderController_ parentButton] == sender) 1403 if ([folderController_ parentButton] == button)
1393 return; 1404 return;
1394 1405
1395 // If right click was done immediately on entering a button, then open the 1406 // 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. 1407 // folder without delay so that context menu appears over the folder menu.
1397 if ([event type] == NSRightMouseDown) 1408 if ([event type] == NSRightMouseDown)
1398 [self openBookmarkFolderFromButtonAndCloseOldOne:sender]; 1409 [self openBookmarkFolderFromButtonAndCloseOldOne:button];
1399 else 1410 else
1400 [self performSelector:@selector(openBookmarkFolderFromButtonAndCloseOldOne:) 1411 [self performSelector:@selector(openBookmarkFolderFromButtonAndCloseOldOne:)
1401 withObject:sender 1412 withObject:button
1402 afterDelay:bookmarks::kHoverOpenDelay 1413 afterDelay:bookmarks::kHoverOpenDelay
1403 inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]]; 1414 inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
1404 } 1415 }
1405 1416
1406 // Called from the BookmarkButton 1417 // Called from the BookmarkButton
1407 - (void)mouseExitedButton:(id)sender event:(NSEvent*)event { 1418 - (void)mouseExitedButton:(BookmarkButton*)button event:(NSEvent*)event {
1408 if (buttonThatMouseIsIn_ == sender) 1419 if (buttonThatMouseIsIn_ == button)
1409 buttonThatMouseIsIn_ = nil; 1420 buttonThatMouseIsIn_ = nil;
1410 [self setSelectedButtonByIndex:-1]; 1421 [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
1411 1422
1412 // During scrolling -mouseExitedButton: stops scrolling, so update the 1423 // During scrolling -mouseExitedButton: stops scrolling, so update the
1413 // corresponding status field to reflect is has stopped. 1424 // corresponding status field to reflect is has stopped.
1414 isScrolling_ = NO; 1425 isScrolling_ = NO;
1415 1426
1416 // Stop any timer about opening a new hover-open folder. 1427 // Stop any timer about opening a new hover-open folder.
1417 1428
1418 // Since a performSelector:withDelay: on self retains self, it is 1429 // Since a performSelector:withDelay: on self retains self, it is
1419 // possible that a cancelPreviousPerformRequestsWithTarget: reduces 1430 // possible that a cancelPreviousPerformRequestsWithTarget: reduces
1420 // the refcount to 0, releasing us. That's a bad thing to do while 1431 // 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 2091
2081 - (void)setIgnoreAnimations:(BOOL)ignore { 2092 - (void)setIgnoreAnimations:(BOOL)ignore {
2082 ignoreAnimations_ = ignore; 2093 ignoreAnimations_ = ignore;
2083 } 2094 }
2084 2095
2085 - (BookmarkButton*)buttonThatMouseIsIn { 2096 - (BookmarkButton*)buttonThatMouseIsIn {
2086 return buttonThatMouseIsIn_; 2097 return buttonThatMouseIsIn_;
2087 } 2098 }
2088 2099
2089 @end // BookmarkBarFolderController 2100 @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