Index: chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm |
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm |
index 1a26bdce55fedb4bd2f3309a49f58cfd79a41cb1..31aebc1891f9c377e50c562949059d52d151144d 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm |
@@ -18,6 +18,12 @@ const CGFloat kMaxLabelWidth = |
} // namespace |
+@interface AutofillBubbleController () |
+ |
+// Update the current message, keeping arrow location in place. |
+- (void)updateMessage:(NSString*)message display:(BOOL)display; |
+ |
+@end |
@implementation AutofillBubbleController |
@@ -51,19 +57,9 @@ const CGFloat kMaxLabelWidth = |
[label_ setEditable:NO]; |
[label_ setBordered:NO]; |
[label_ setDrawsBackground:NO]; |
- [label_ setStringValue:message]; |
- NSRect labelFrame = NSMakeRect(inset.width, inset.height, 0, 0); |
- labelFrame.size = [[label_ cell] cellSizeForBounds: |
- NSMakeRect(0, 0, kMaxLabelWidth, CGFLOAT_MAX)]; |
- [label_ setFrame:labelFrame]; |
[[self bubble] addSubview:label_]; |
- NSRect windowFrame = [[self window] frame]; |
- windowFrame.size = NSMakeSize( |
- NSMaxX([label_ frame]), |
- NSHeight([label_ frame]) + info_bubble::kBubbleArrowHeight); |
- windowFrame = NSInsetRect(windowFrame, -inset.width, -inset.height); |
- [[self window] setFrame:windowFrame display:NO]; |
+ [self updateMessage:message display:NO]; |
} |
return self; |
} |
@@ -72,4 +68,32 @@ const CGFloat kMaxLabelWidth = |
return kMaxLabelWidth + 2 * inset_.width; |
} |
+- (void)setMessage:(NSString*)message { |
+ if ([[label_ stringValue] isEqualToString:message]) |
+ return; |
+ [self updateMessage:message display:YES]; |
+} |
+ |
+- (void)updateMessage:(NSString*)message display:(BOOL)display { |
+ [label_ setStringValue:message]; |
+ |
+ NSRect labelFrame = NSMakeRect(inset_.width, inset_.height, 0, 0); |
+ labelFrame.size = [[label_ cell] cellSizeForBounds: |
+ NSMakeRect(0, 0, kMaxLabelWidth, CGFLOAT_MAX)]; |
+ [label_ setFrame:labelFrame]; |
+ |
+ // Update window's size, but ensure the origin is maintained so that the arrow |
+ // still points at the same location. |
+ NSRect windowFrame = [[self window] frame]; |
+ NSPoint origin = windowFrame.origin; |
+ origin.y += NSHeight(windowFrame); |
+ windowFrame.size = NSMakeSize( |
+ NSMaxX([label_ frame]), |
+ NSHeight([label_ frame]) + info_bubble::kBubbleArrowHeight); |
+ windowFrame = NSInsetRect(windowFrame, -inset_.width, -inset_.height); |
+ origin.y -= NSHeight(windowFrame); |
+ windowFrame.origin = origin; |
+ [[self window] setFrame:windowFrame display:display]; |
+} |
+ |
@end |