diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 02:35:21 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 02:35:21 +0000 |
commit | 9365e0553abbefbb54cd6f82586f2a1c4790e522 (patch) | |
tree | 268ff60546a1a07db40903959efa88caaf60cd0f | |
parent | 6dba9a4428541b520adaad72a60414e1ef0488bb (diff) | |
download | chromium_src-9365e0553abbefbb54cd6f82586f2a1c4790e522.zip chromium_src-9365e0553abbefbb54cd6f82586f2a1c4790e522.tar.gz chromium_src-9365e0553abbefbb54cd6f82586f2a1c4790e522.tar.bz2 |
Pasting on a folder now puts the pasted bookmark item in the folder as the last bookmark within the folder. Bringing up a contextual menu on an open bookmark bar folder no longer closes the folder.
BUG=32064
TEST=1) Copy a bookmark item. Using the contextual menu, paste the bookmark item just copied onto the top of a folder in the bookmark bar. Open that folder and verify that the pasted item appears as the last bookmark therein. 2) Copy a bookmark item. Pop open a bookmark bar folder which itself contains a folder. Paste the bookmark item onto the top of that subfolder. Verify that the subfolder now contains the pasted bookmark item as its last bookmark. 3) Pop open a bookmark folder. Bring up the contextual menu on that folder. Verify that the folder window is not automatically closed when the contextual menu is presented.
Review URL: http://codereview.chromium.org/1732029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46032 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 7ab6095..130a97a 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -504,13 +504,16 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; switch ([event type]) { case NSLeftMouseDown: case NSRightMouseDown: - // If a click in my window and NOT in the bookmark bar, - // then is a click outside. Clicks directly on the bookmarks bar are - // counted as "outside" as well, because they should close bookmark folder - // menus as well. + // If the click is in my window but NOT in the bookmark bar, consider + // it a click 'outside'. Clicks directly on an active button (i.e. one + // that is a folder and for which its folder menu is showing) are 'in'. + // All other clicks on the bookmarks bar are counted as 'outside' + // because they should close any open bookmark folder menu. if (eventWindow == myWindow) { NSView* hitView = [[eventWindow contentView] hitTest:[event locationInWindow]]; + if (hitView == [folderController_ parentButton]) + return NO; if (![hitView isDescendantOf:[self view]] || hitView == buttonView_) return YES; } @@ -1301,22 +1304,20 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { } // Paste the copied node immediately after the node for which the context -// menu has been presented. +// menu has been presented if the node is a non-folder bookmark, otherwise +// past at the end of the folder node. - (IBAction)pasteBookmark:(id)sender { const BookmarkNode* node = [self nodeFromMenuItem:sender]; if (node) { - const BookmarkNode* parent = node->GetParent(); - // Pasting into the bar but not onto any element in the bar causes the - // pasted node to be placed at the right end of the bar. int index = -1; - if (node == bookmarkModel_->GetBookmarkBarNode()) { - parent = node; - } else { + if (node != bookmarkModel_->GetBookmarkBarNode() && !node->is_folder()) { + const BookmarkNode* parent = node->GetParent(); index = parent->IndexOfChild(node) + 1; if (index > parent->GetChildCount()) index = -1; + node = parent; } - bookmark_utils::PasteFromClipboard(bookmarkModel_, parent, index); + bookmark_utils::PasteFromClipboard(bookmarkModel_, node, index); } } |