summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 00:48:13 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 00:48:13 +0000
commit6e699a7f5208640ecf1f9a81ec6e819704d9df13 (patch)
treefabdcbbcb3a8cebaa7bb7c136fc945ad1587f658
parent6db2c41353ea0d4f148e5a50d74b49510a631777 (diff)
downloadchromium_src-6e699a7f5208640ecf1f9a81ec6e819704d9df13.zip
chromium_src-6e699a7f5208640ecf1f9a81ec6e819704d9df13.tar.gz
chromium_src-6e699a7f5208640ecf1f9a81ec6e819704d9df13.tar.bz2
Don't clip bookmark bar icons with no name
BUG=44265 TEST=change some bookmark titles to "" and note that the icons are not clipped Review URL: http://codereview.chromium.org/3549011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61458 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm2
-rw-r--r--chrome/browser/cocoa/bookmark_button_cell.mm20
2 files changed, 10 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index 0c7ec9d..664309b 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -1885,7 +1885,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
for (BookmarkButton* button in buttons_.get()) {
const BookmarkNode* cellnode = [button bookmarkNode];
if (cellnode == node) {
- [[button cell] setBookmarkCellText:nil
+ [[button cell] setBookmarkCellText:[button title]
image:[self favIconForNode:node]];
// Adding an image means we might need more room for the
// bookmark. Test for it by growing the button (if needed)
diff --git a/chrome/browser/cocoa/bookmark_button_cell.mm b/chrome/browser/cocoa/bookmark_button_cell.mm
index 368f34f..55d9e87 100644
--- a/chrome/browser/cocoa/bookmark_button_cell.mm
+++ b/chrome/browser/cocoa/bookmark_button_cell.mm
@@ -76,6 +76,7 @@
[self setButtonType:NSMomentaryPushInButton];
[self setBezelStyle:NSShadowlessSquareBezelStyle];
[self setShowsBorderOnlyWhileMouseInside:YES];
+ [self setControlSize:NSSmallControlSize];
[self setAlignment:NSLeftTextAlignment];
[self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[self setWraps:NO];
@@ -98,11 +99,9 @@
- (NSSize)cellSizeForBounds:(NSRect)aRect {
NSSize size = [super cellSizeForBounds:aRect];
- // See comments in setBookmarkCellText:image: about squeezing
- // buttons with no title.
- if ([[self title] length]) {
- size.width += 2;
- }
+ // Cocoa seems to slightly underestimate how much space we need, so we
+ // compensate here to avoid a clipped rendering.
+ size.width += 2;
size.height += 4;
return size;
}
@@ -113,18 +112,17 @@
withString:@" "];
title = [title stringByReplacingOccurrencesOfString:@"\r"
withString:@" "];
- // If no title squeeze things tight with a NSMiniControlSize.
- // Else make them small and place the image on the left.
+ // If there is no title, squeeze things tight by displaying only the image; by
+ // default, Cocoa leaves extra space in an attempt to display an empty title.
if ([title length]) {
[self setImagePosition:NSImageLeft];
- [self setControlSize:NSSmallControlSize];
+ [self setTitle:title];
} else {
- [self setControlSize:NSMiniControlSize];
+ [self setImagePosition:NSImageOnly];
}
+
if (image)
[self setImage:image];
- if (title)
- [self setTitle:title];
}
- (void)setBookmarkNode:(const BookmarkNode*)node {