OLD | NEW |
---|---|
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 "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1930 NSRect buttonFrame = [button frame]; | 1930 NSRect buttonFrame = [button frame]; |
1931 buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; | 1931 buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
1932 [button setFrame:buttonFrame]; | 1932 [button setFrame:buttonFrame]; |
1933 } | 1933 } |
1934 // Search for and adjust submenus, if necessary. | 1934 // Search for and adjust submenus, if necessary. |
1935 NSInteger buttonCount = [buttons_ count]; | 1935 NSInteger buttonCount = [buttons_ count]; |
1936 if (buttonCount) { | 1936 if (buttonCount) { |
1937 BookmarkButton* subButton = [folderController_ parentButton]; | 1937 BookmarkButton* subButton = [folderController_ parentButton]; |
1938 for (NSButton* aButton in buttons_.get()) { | 1938 for (NSButton* aButton in buttons_.get()) { |
1939 // If this button is showing its menu then we need to move the menu, too. | 1939 // If this button is showing its menu then we need to move the menu, too. |
1940 if (aButton == subButton) | 1940 if (aButton == subButton) { |
1941 [folderController_ | 1941 NSInteger targetIndex = [buttons_ indexOfObject:aButton]; |
Alexei Svitkine (slow)
2014/10/06 15:37:30
This results in O(n^2) behavior, since -indexOfObj
Gaja
2014/10/07 04:39:12
Done. Making use of an index variable by increment
| |
1942 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; | 1942 if ((targetIndex + 1) > buttonIndex) { |
Alexei Svitkine (slow)
2014/10/06 15:37:30
Can you add a comment explaining this?
Maybe if y
Gaja
2014/10/07 04:39:12
Done. I have added it to existing comment above.
| |
1943 [folderController_ offsetFolderMenuWindow:NSMakeSize(0.0, | |
1944 bookmarks::kBookmarkFolderButtonHeight)]; | |
1945 } | |
1946 } | |
1943 } | 1947 } |
1944 } else if (parentButton_ != [barController_ otherBookmarksButton]) { | 1948 } else if (parentButton_ != [barController_ otherBookmarksButton]) { |
1945 // If all nodes have been removed from this folder then add in the | 1949 // If all nodes have been removed from this folder then add in the |
1946 // 'empty' placeholder button except for "Other bookmarks" folder | 1950 // 'empty' placeholder button except for "Other bookmarks" folder |
1947 // as we are going to hide it. | 1951 // as we are going to hide it. |
1948 NSRect buttonFrame = | 1952 NSRect buttonFrame = |
1949 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); | 1953 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); |
1950 BookmarkButton* button = [self makeButtonForNode:nil | 1954 BookmarkButton* button = [self makeButtonForNode:nil |
1951 frame:buttonFrame]; | 1955 frame:buttonFrame]; |
1952 [buttons_ addObject:button]; | 1956 [buttons_ addObject:button]; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2003 | 2007 |
2004 - (void)setIgnoreAnimations:(BOOL)ignore { | 2008 - (void)setIgnoreAnimations:(BOOL)ignore { |
2005 ignoreAnimations_ = ignore; | 2009 ignoreAnimations_ = ignore; |
2006 } | 2010 } |
2007 | 2011 |
2008 - (BookmarkButton*)buttonThatMouseIsIn { | 2012 - (BookmarkButton*)buttonThatMouseIsIn { |
2009 return buttonThatMouseIsIn_; | 2013 return buttonThatMouseIsIn_; |
2010 } | 2014 } |
2011 | 2015 |
2012 @end // BookmarkBarFolderController | 2016 @end // BookmarkBarFolderController |
OLD | NEW |