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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_controller.mm

Issue 3158031: Try to fix top crasher.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller.mm » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/bookmark_bar_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
6 #include "app/l10n_util_mac.h" 6 #include "app/l10n_util_mac.h"
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 bookmarks::kBookmarkHorizontalPadding; 1366 bookmarks::kBookmarkHorizontalPadding;
1367 1367
1368 // As a result of pasting or dragging, the bar may now have more buttons 1368 // As a result of pasting or dragging, the bar may now have more buttons
1369 // than will fit so remove any which overflow. They will be shown in 1369 // than will fit so remove any which overflow. They will be shown in
1370 // the off-the-side folder. 1370 // the off-the-side folder.
1371 while (displayedButtonCount_ > 0) { 1371 while (displayedButtonCount_ > 0) {
1372 BookmarkButton* button = [buttons_ lastObject]; 1372 BookmarkButton* button = [buttons_ lastObject];
1373 if (NSMaxX([button frame]) < maxViewX) 1373 if (NSMaxX([button frame]) < maxViewX)
1374 break; 1374 break;
1375 [buttons_ removeLastObject]; 1375 [buttons_ removeLastObject];
1376 [button setDelegate:nil];
1376 [button removeFromSuperview]; 1377 [button removeFromSuperview];
1377 --displayedButtonCount_; 1378 --displayedButtonCount_;
1378 } 1379 }
1379 1380
1380 // As a result of cutting, deleting and dragging, the bar may now have room 1381 // As a result of cutting, deleting and dragging, the bar may now have room
1381 // for more buttons. 1382 // for more buttons.
1382 int xOffset = displayedButtonCount_ > 0 ? 1383 int xOffset = displayedButtonCount_ > 0 ?
1383 NSMaxX([[buttons_ lastObject] frame]) + 1384 NSMaxX([[buttons_ lastObject] frame]) +
1384 bookmarks::kBookmarkHorizontalPadding : 0; 1385 bookmarks::kBookmarkHorizontalPadding : 0;
1385 for (int i = displayedButtonCount_; i < barCount; ++i) { 1386 for (int i = displayedButtonCount_; i < barCount; ++i) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 return folderTarget_.get(); 1434 return folderTarget_.get();
1434 } 1435 }
1435 1436
1436 - (int)displayedButtonCount { 1437 - (int)displayedButtonCount {
1437 return displayedButtonCount_; 1438 return displayedButtonCount_;
1438 } 1439 }
1439 1440
1440 // Delete all buttons (bookmarks, chevron, "other bookmarks") from the 1441 // Delete all buttons (bookmarks, chevron, "other bookmarks") from the
1441 // bookmark bar; reset knowledge of bookmarks. 1442 // bookmark bar; reset knowledge of bookmarks.
1442 - (void)clearBookmarkBar { 1443 - (void)clearBookmarkBar {
1443 [buttons_ makeObjectsPerformSelector:@selector(removeFromSuperview)]; 1444 for (BookmarkButton* button in buttons_.get()) {
1445 [button setDelegate:nil];
1446 [button removeFromSuperview];
1447 }
1444 [buttons_ removeAllObjects]; 1448 [buttons_ removeAllObjects];
1445 [self clearMenuTagMap]; 1449 [self clearMenuTagMap];
1446 displayedButtonCount_ = 0; 1450 displayedButtonCount_ = 0;
1447 1451
1448 // Make sure there are no stale pointers in the pasteboard. This 1452 // Make sure there are no stale pointers in the pasteboard. This
1449 // can be important if a bookmark is deleted (via bookmark sync) 1453 // can be important if a bookmark is deleted (via bookmark sync)
1450 // while in the middle of a drag. The "drag completed" code 1454 // while in the middle of a drag. The "drag completed" code
1451 // (e.g. [BookmarkBarView performDragOperationForBookmarkButton:]) is 1455 // (e.g. [BookmarkBarView performDragOperationForBookmarkButton:]) is
1452 // careful enough to bail if there is no data found at "drop" time. 1456 // careful enough to bail if there is no data found at "drop" time.
1453 // 1457 //
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 BookmarkButton* oldButton = [buttons_ objectAtIndex:buttonIndex]; 2376 BookmarkButton* oldButton = [buttons_ objectAtIndex:buttonIndex];
2373 if (oldButton == [folderController_ parentButton]) { 2377 if (oldButton == [folderController_ parentButton]) {
2374 // If we are deleting a button whose folder is currently open, close it! 2378 // If we are deleting a button whose folder is currently open, close it!
2375 [self closeAllBookmarkFolders]; 2379 [self closeAllBookmarkFolders];
2376 } 2380 }
2377 NSRect poofFrame = [oldButton bounds]; 2381 NSRect poofFrame = [oldButton bounds];
2378 NSPoint poofPoint = NSMakePoint(NSMidX(poofFrame), NSMidY(poofFrame)); 2382 NSPoint poofPoint = NSMakePoint(NSMidX(poofFrame), NSMidY(poofFrame));
2379 poofPoint = [oldButton convertPoint:poofPoint toView:nil]; 2383 poofPoint = [oldButton convertPoint:poofPoint toView:nil];
2380 poofPoint = [[oldButton window] convertBaseToScreen:poofPoint]; 2384 poofPoint = [[oldButton window] convertBaseToScreen:poofPoint];
2381 NSRect oldFrame = [oldButton frame]; 2385 NSRect oldFrame = [oldButton frame];
2386 [oldButton setDelegate:nil];
2382 [oldButton removeFromSuperview]; 2387 [oldButton removeFromSuperview];
2383 if (animate && !ignoreAnimations_ && [self isVisible]) 2388 if (animate && !ignoreAnimations_ && [self isVisible])
2384 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint, 2389 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint,
2385 NSZeroSize, nil, nil, nil); 2390 NSZeroSize, nil, nil, nil);
2386 CGFloat xOffset = NSWidth(oldFrame) + bookmarks::kBookmarkHorizontalPadding; 2391 CGFloat xOffset = NSWidth(oldFrame) + bookmarks::kBookmarkHorizontalPadding;
2387 [buttons_ removeObjectAtIndex:buttonIndex]; 2392 [buttons_ removeObjectAtIndex:buttonIndex];
2388 NSUInteger buttonCount = [buttons_ count]; 2393 NSUInteger buttonCount = [buttons_ count];
2389 for (NSUInteger i = buttonIndex; i < buttonCount; ++i) { 2394 for (NSUInteger i = buttonIndex; i < buttonCount; ++i) {
2390 BookmarkButton* button = [buttons_ objectAtIndex:i]; 2395 BookmarkButton* button = [buttons_ objectAtIndex:i];
2391 NSRect buttonFrame = [button frame]; 2396 NSRect buttonFrame = [button frame];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 // to minimize touching the object passed in (likely a mock). 2437 // to minimize touching the object passed in (likely a mock).
2433 - (void)setButtonContextMenu:(id)menu { 2438 - (void)setButtonContextMenu:(id)menu {
2434 buttonContextMenu_ = menu; 2439 buttonContextMenu_ = menu;
2435 } 2440 }
2436 2441
2437 - (void)setIgnoreAnimations:(BOOL)ignore { 2442 - (void)setIgnoreAnimations:(BOOL)ignore {
2438 ignoreAnimations_ = ignore; 2443 ignoreAnimations_ = ignore;
2439 } 2444 }
2440 2445
2441 @end 2446 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698