Index: chrome/browser/ui/cocoa/website_settings/permission_selector_button.mm |
diff --git a/chrome/browser/ui/cocoa/website_settings/permission_selector_button.mm b/chrome/browser/ui/cocoa/website_settings/permission_selector_button.mm |
index 49520a43d3e209795a3da01696c3e62ca8e5d095..bfa304dd51fb19688b8ad92f58b713d84f6a7541 100644 |
--- a/chrome/browser/ui/cocoa/website_settings/permission_selector_button.mm |
+++ b/chrome/browser/ui/cocoa/website_settings/permission_selector_button.mm |
@@ -44,18 +44,18 @@ const CGFloat kPermissionButtonTitleRightPadding = 4; |
[self sizeToFit]; |
// Size the button to just fit the visible title - not all of its items. |
- [self setFrameSize:[self sizeForTitle:[self title]]]; |
+ [self setFrameSize:[PermissionSelectorButton sizeForTitle:[self title] |
+ forButton:self]]; |
} |
return self; |
} |
-// Determine the size of a popup button with the given title. |
-- (NSSize)sizeForTitle:(NSString*)title { |
- NSDictionary* textAttributes = @{NSFontAttributeName : [self font]}; |
++ (NSSize)sizeForTitle:(NSString*)title forButton:(NSButton*)button { |
groby-ooo-7-16
2014/04/18 18:18:18
If you can at all, I think I'd move that onto the
leng
2014/04/18 22:48:46
I'll move this to a shared location in a subsequen
|
+ NSDictionary* textAttributes = @{NSFontAttributeName : [button font]}; |
NSSize titleSize = [title sizeWithAttributes:textAttributes]; |
- NSRect frame = [self frame]; |
- NSRect titleRect = [[self cell] titleRectForBounds:frame]; |
+ NSRect frame = [button frame]; |
+ NSRect titleRect = [[button cell] titleRectForBounds:frame]; |
CGFloat width = titleSize.width + NSWidth(frame) - NSWidth(titleRect); |
return NSMakeSize(width + kPermissionButtonTitleRightPadding, |
@@ -70,7 +70,9 @@ const CGFloat kPermissionButtonTitleRightPadding = 4; |
static_cast<ContentSetting>([item tag]), |
defaultSetting, |
content_settings::SETTING_SOURCE_USER); |
- NSSize size = [self sizeForTitle:base::SysUTF16ToNSString(title)]; |
+ NSSize size = |
+ [PermissionSelectorButton sizeForTitle:base::SysUTF16ToNSString(title) |
+ forButton:self]; |
maxTitleWidth = std::max(maxTitleWidth, size.width); |
} |
return maxTitleWidth; |