diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 17:25:57 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 17:25:57 +0000 |
commit | 99f0c0818d6e612e6581f38bd0d53edceae44863 (patch) | |
tree | 826ebab8c995bd0ee4fc24028369c775f0ece31e /chrome/browser/cocoa/bookmark_bar_controller.mm | |
parent | b74538cf2eb1e4052422ba1c12ab3de21b5e3aeb (diff) | |
download | chromium_src-99f0c0818d6e612e6581f38bd0d53edceae44863.zip chromium_src-99f0c0818d6e612e6581f38bd0d53edceae44863.tar.gz chromium_src-99f0c0818d6e612e6581f38bd0d53edceae44863.tar.bz2 |
Crashes, bookmark text, menu hiding.
Make sure "bookmarks go here" text goes away when adding the 1st
bookmark (and comes back when deleting the last one).
When deleting the last item from an "off the side menu" (which would
cause the "off the side" chevron button to go away), close that menu.
Make sure the "off the side" button is deleted in the autorelease
pool, like all other buttons, in case "just one more" event is about to come in.
This is an attempt at fixing the top Mac browser crash.
BUG=43345,43501,43502
TEST=\
1)
New profile.
Open bookmark bar --> see "bookmarks go here"
Add bookmark --> text goes away
Delete bookmark --> text comes back.
2)
Add enough bookmarks so the "off the side" menu just barely appears.
Open the off the side menu, and right click --> delete the bookmark.
Expect to see the menu go away and the off-the-side button to go away.
Review URL: http://codereview.chromium.org/2025002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 596b651..446bfee 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -388,6 +388,12 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; if (bookmarkChildren > displayedButtonCount_) { [offTheSideButton_ setHidden:NO]; } else { + // If we just deleted the last item in an off-the-side menu so the + // button will be going away, make sure the menu goes away. + if (folderController_ && + ([folderController_ parentButton] == offTheSideButton_)) + [self closeAllBookmarkFolders]; + // (And hide the button, too.) [offTheSideButton_ setHidden:YES]; } } @@ -1537,12 +1543,19 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { [self openURL:node->GetURL() disposition:disposition]; } +// For the given root node of the bookmark bar, show or hide (as +// appropriate) the "no items" container (text which says "bookmarks +// go here"). +- (void)showOrHideNoItemContainerForNode:(const BookmarkNode*)node { + BOOL hideNoItemWarning = node->GetChildCount() > 0; + [[buttonView_ noItemContainer] setHidden:hideNoItemWarning]; +} + // TODO(jrg): write a "build bar" so there is a nice spot for things // like the contextual menu which is invoked when not over a // bookmark. On Safari that menu has a "new folder" option. - (void)addNodesToButtonList:(const BookmarkNode*)node { - BOOL hideNoItemWarning = node->GetChildCount() > 0; - [[buttonView_ noItemContainer] setHidden:hideNoItemWarning]; + [self showOrHideNoItemContainerForNode:node]; CGFloat maxViewX = NSMaxX([[self view] bounds]); int xOffset = 0; @@ -1640,6 +1653,10 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { [button setDraggable:NO]; otherBookmarksButton_.reset(button); + // Make sure this button, like all other BookmarkButtons, lives + // until the end of the current event loop. + [[button retain] autorelease]; + // Peg at right; keep same height as bar. [button setAutoresizingMask:(NSViewMinXMargin)]; [button setCell:cell]; @@ -1710,6 +1727,9 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { [oldController removeButton:oldIndex animate:NO]; [newController addButtonForNode:movedNode atIndex:newIndex]; } + // If we moved the only item on the "off the side" menu somewhere + // else, we may no longer need to show it. + [self configureOffTheSideButtonContentsAndVisibility]; } - (void)nodeAdded:(BookmarkModel*)model @@ -1718,6 +1738,9 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { id<BookmarkButtonControllerProtocol> newController = [self controllerForNode:newParent]; [newController addButtonForNode:newNode atIndex:newIndex]; + // If we go from 0 --> 1 bookmarks we may need to hide the + // "bookmarks go here" text container. + [self showOrHideNoItemContainerForNode:model->GetBookmarkBarNode()]; } - (void)nodeRemoved:(BookmarkModel*)model @@ -1727,6 +1750,12 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { id<BookmarkButtonControllerProtocol> parentController = [self controllerForNode:oldParent]; [parentController removeButton:index animate:YES]; + // If we go from 1 --> 0 bookmarks we may need to show the + // "bookmarks go here" text container. + [self showOrHideNoItemContainerForNode:model->GetBookmarkBarNode()]; + // If we deleted the only item on the "off the side" menu we no + // longer need to show it. + [self configureOffTheSideButtonContentsAndVisibility]; } // TODO(jrg): for now this is brute force. |