summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 21:02:59 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 21:02:59 +0000
commit1b5ae94c2073e4041696a1f693fcf3e6f908a0f7 (patch)
tree462d41179ce4c2c8751a5817a497a11acd05a043
parent5249c471780ef5973118ae62c8e157e59bbb18f6 (diff)
downloadchromium_src-1b5ae94c2073e4041696a1f693fcf3e6f908a0f7.zip
chromium_src-1b5ae94c2073e4041696a1f693fcf3e6f908a0f7.tar.gz
chromium_src-1b5ae94c2073e4041696a1f693fcf3e6f908a0f7.tar.bz2
[Mac] If the clear all button is wider then the content view, size up the bubble to fit.
Also fix the button leak that was in here. BUG=43950 TEST=see bug Review URL: http://codereview.chromium.org/1996017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47069 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller.mm22
1 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
index eb7df32..9fa9d0e 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
@@ -289,20 +289,34 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
const ContentSettingBubbleModel::BubbleContent& content =
contentSettingBubbleModel_->bubble_content();
NSRect containerFrame = [contentsContainer_ frame];
- NSRect frame = NSMakeRect(0, 0, containerFrame.size.width, kGeoLabelHeight);
+ NSRect frame = NSMakeRect(0, 0, NSWidth(containerFrame), kGeoLabelHeight);
// "Clear" button.
if (!content.clear_link.empty()) {
NSRect buttonFrame = NSMakeRect(0, 0,
- containerFrame.size.width,
+ NSWidth(containerFrame),
kGeoClearButtonHeight);
- NSButton* button = [[NSButton alloc] initWithFrame:buttonFrame];
+ scoped_nsobject<NSButton> button([[NSButton alloc]
+ initWithFrame:buttonFrame]);
[button setTitle:base::SysUTF8ToNSString(content.clear_link)];
[button setTarget:self];
[button setAction:@selector(clearGeolocationForCurrentHost:)];
[button setBezelStyle:NSRoundRectBezelStyle];
SetControlSize(button, NSSmallControlSize);
[button sizeToFit];
+
+ // If the button is wider than the container, widen the window.
+ CGFloat buttonWidth = NSWidth([button frame]);
+ if (buttonWidth > NSWidth(containerFrame)) {
+ NSRect windowFrame = [[self window] frame];
+ windowFrame.size.width += buttonWidth - NSWidth(containerFrame);
+ [[self window] setFrame:windowFrame display:NO];
+ // Fetch the updated sizes.
+ containerFrame = [contentsContainer_ frame];
+ frame = NSMakeRect(0, 0, NSWidth(containerFrame), kGeoLabelHeight);
+ }
+
+ // Add the button.
[contentsContainer_ addSubview:button];
frame.origin.y = NSMaxY([button frame]) + kGeoPadding;
@@ -343,7 +357,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
// Resize container to fit its subviews, and window to fit the container.
NSRect windowFrame = [[self window] frame];
- windowFrame.size.height += containerHeight - containerFrame.size.height;
+ windowFrame.size.height += containerHeight - NSHeight(containerFrame);
[[self window] setFrame:windowFrame display:NO];
containerFrame.size.height = containerHeight;
[contentsContainer_ setFrame:containerFrame];