Chromium Code Reviews| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 } | 343 } |
| 344 | 344 |
| 345 - (int)buttonCount { | 345 - (int)buttonCount { |
| 346 return [[self buttons] count]; | 346 return [[self buttons] count]; |
| 347 } | 347 } |
| 348 | 348 |
| 349 - (BookmarkButton*)parentButton { | 349 - (BookmarkButton*)parentButton { |
| 350 return parentButton_.get(); | 350 return parentButton_.get(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 - (void)offsetFolderMenuWindow:(NSSize)offset { | |
| 354 NSWindow* window = [self window]; | |
| 355 NSRect windowFrame = [window frame]; | |
| 356 windowFrame.origin.x -= offset.width; | |
| 357 windowFrame.origin.y += offset.height; // Yes, in the opposite direction! | |
| 358 [window setFrame:windowFrame display:YES]; | |
| 359 [folderController_ offsetFolderMenuWindow:offset]; | |
| 360 } | |
| 361 | |
| 362 - (void)reconfigureMenu { | 353 - (void)reconfigureMenu { |
| 363 [NSObject cancelPreviousPerformRequestsWithTarget:self]; | 354 [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
| 364 for (BookmarkButton* button in buttons_.get()) { | 355 for (BookmarkButton* button in buttons_.get()) { |
| 365 [button setDelegate:nil]; | 356 [button setDelegate:nil]; |
| 366 [button removeFromSuperview]; | 357 [button removeFromSuperview]; |
| 367 } | 358 } |
| 368 [buttons_ removeAllObjects]; | 359 [buttons_ removeAllObjects]; |
| 369 [self configureWindow]; | 360 [self configureWindow]; |
| 370 } | 361 } |
| 371 | 362 |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1924 | 1915 |
| 1925 [oldButton setDelegate:nil]; | 1916 [oldButton setDelegate:nil]; |
| 1926 [oldButton removeFromSuperview]; | 1917 [oldButton removeFromSuperview]; |
| 1927 [buttons_ removeObjectAtIndex:buttonIndex]; | 1918 [buttons_ removeObjectAtIndex:buttonIndex]; |
| 1928 for (NSInteger i = 0; i < buttonIndex; ++i) { | 1919 for (NSInteger i = 0; i < buttonIndex; ++i) { |
| 1929 BookmarkButton* button = [buttons_ objectAtIndex:i]; | 1920 BookmarkButton* button = [buttons_ objectAtIndex:i]; |
| 1930 NSRect buttonFrame = [button frame]; | 1921 NSRect buttonFrame = [button frame]; |
| 1931 buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; | 1922 buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
| 1932 [button setFrame:buttonFrame]; | 1923 [button setFrame:buttonFrame]; |
| 1933 } | 1924 } |
| 1934 // Search for and adjust submenus, if necessary. | 1925 |
| 1935 NSInteger buttonCount = [buttons_ count]; | 1926 NSInteger buttonCount = [buttons_ count]; |
| 1936 if (buttonCount) { | 1927 if (buttonCount == 0) { |
| 1937 BookmarkButton* subButton = [folderController_ parentButton]; | 1928 if (parentButton_ != [barController_ otherBookmarksButton]) { |
| 1938 for (NSButton* aButton in buttons_.get()) { | 1929 // If all nodes have been removed from this folder then add in the |
| 1939 // If this button is showing its menu then we need to move the menu, too. | 1930 // 'empty' placeholder button except for "Other bookmarks" folder |
|
Alexei Svitkine (slow)
2014/09/26 15:14:37
Are you sure we never need to do this?
What if yo
Gaja
2014/09/27 05:56:33
Oh, I did not test this case, I will check the beh
| |
| 1940 if (aButton == subButton) | 1931 // as we are going to hide it. |
| 1941 [folderController_ | 1932 NSRect buttonFrame = |
| 1942 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; | 1933 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); |
|
Gaja
2014/09/25 09:00:39
@asvitkine,
This CL is to remove only the above 'i
| |
| 1934 BookmarkButton* button = [self makeButtonForNode:nil | |
| 1935 frame:buttonFrame]; | |
|
Alexei Svitkine (slow)
2014/09/26 15:14:37
Nit: Align :'s or wrap after =.
Gaja
2014/09/27 05:56:33
Acknowledged.
| |
| 1936 [buttons_ addObject:button]; | |
| 1937 [folderView_ addSubview:button]; | |
| 1938 buttonCount = 1; | |
|
Alexei Svitkine (slow)
2014/09/26 15:14:37
Shouldn't this block call [self adjustWindowForBut
Gaja
2014/09/27 05:56:33
I think we don't need this line. Here is my analys
| |
| 1943 } | 1939 } |
| 1944 } else if (parentButton_ != [barController_ otherBookmarksButton]) { | 1940 else { |
|
Alexei Svitkine (slow)
2014/09/26 15:14:37
Nit: Put on previous line.
Gaja
2014/09/27 05:56:33
Acknowledged.
| |
| 1945 // If all nodes have been removed from this folder then add in the | 1941 // buttonCount will be 0 if "Other bookmarks" folder is empty, so close |
| 1946 // 'empty' placeholder button except for "Other bookmarks" folder | 1942 // the folder before hiding it. |
| 1947 // as we are going to hide it. | 1943 [barController_ closeBookmarkFolder:nil]; |
| 1948 NSRect buttonFrame = | 1944 } |
| 1949 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); | 1945 } else if (buttonCount > 0) |
|
Alexei Svitkine (slow)
2014/09/26 15:14:37
Nit: {}'s
Gaja
2014/09/27 05:56:33
Acknowledged.
| |
| 1950 BookmarkButton* button = [self makeButtonForNode:nil | 1946 [self adjustWindowForButtonCount:buttonCount]; |
| 1951 frame:buttonFrame]; | |
| 1952 [buttons_ addObject:button]; | |
| 1953 [folderView_ addSubview:button]; | |
| 1954 buttonCount = 1; | |
| 1955 } | |
| 1956 | |
| 1957 // buttonCount will be 0 if "Other bookmarks" folder is empty, so close | |
| 1958 // the folder before hiding it. | |
| 1959 if (buttonCount == 0) | |
| 1960 [barController_ closeBookmarkFolder:nil]; | |
| 1961 else if (buttonCount > 0) | |
| 1962 [self adjustWindowForButtonCount:buttonCount]; | |
| 1963 | 1947 |
| 1964 if (animate && !ignoreAnimations_) | 1948 if (animate && !ignoreAnimations_) |
| 1965 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint, | 1949 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint, |
| 1966 NSZeroSize, nil, nil, nil); | 1950 NSZeroSize, nil, nil, nil); |
| 1967 } | 1951 } |
| 1968 | 1952 |
| 1969 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 1953 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 1970 (const BookmarkNode*)node { | 1954 (const BookmarkNode*)node { |
| 1971 // See if we are holding this node, otherwise see if it is in our | 1955 // See if we are holding this node, otherwise see if it is in our |
| 1972 // hierarchy of visible folder menus. | 1956 // hierarchy of visible folder menus. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2003 | 1987 |
| 2004 - (void)setIgnoreAnimations:(BOOL)ignore { | 1988 - (void)setIgnoreAnimations:(BOOL)ignore { |
| 2005 ignoreAnimations_ = ignore; | 1989 ignoreAnimations_ = ignore; |
| 2006 } | 1990 } |
| 2007 | 1991 |
| 2008 - (BookmarkButton*)buttonThatMouseIsIn { | 1992 - (BookmarkButton*)buttonThatMouseIsIn { |
| 2009 return buttonThatMouseIsIn_; | 1993 return buttonThatMouseIsIn_; |
| 2010 } | 1994 } |
| 2011 | 1995 |
| 2012 @end // BookmarkBarFolderController | 1996 @end // BookmarkBarFolderController |
| OLD | NEW |