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

Unified Diff: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm

Issue 165332: Mac: Make autocomplete popup track autocomplete field resizes. (Closed)
Patch Set: Oops, was unregistering for the wrong notification. Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index f2a33d8785e7039e5eb41ea93682fc34c33be9fb..1a0d35cdf95c141edc5f4a0c751d705d6d1773fb 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -190,6 +190,10 @@ NSAttributedString* AutocompletePopupViewMac::MatchText(
// Tell popup model via popup_view_ about the selected row.
- (void)select:sender;
+
+// Resize the popup when the field's window resizes.
+- (void)windowDidResize:(NSNotification*)notification;
+
@end
AutocompletePopupViewMac::AutocompletePopupViewMac(
@@ -241,6 +245,13 @@ void AutocompletePopupViewMac::CreatePopupIfNeeded() {
[matrix setTarget:matrix_target_];
[matrix setAction:@selector(select:)];
[popup_ setContentView:matrix];
+
+ // We need the popup to follow window resize.
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:matrix_target_
+ selector:@selector(windowDidResize:)
+ name:NSWindowDidResizeNotification
+ object:[field_ window]];
}
}
@@ -254,6 +265,11 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
NSMatrix* matrix = [popup_ contentView];
[matrix setTarget:nil];
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc removeObserver:matrix_target_
+ name:NSWindowDidResizeNotification
+ object:[field_ window]];
+
popup_.reset(nil);
return;
@@ -455,4 +471,14 @@ void AutocompletePopupViewMac::AcceptInput() {
popup_view_->AcceptInput();
}
+- (void)windowDidResize:(NSNotification*)notification {
+ DCHECK(popup_view_);
+
+ // TODO(shess): UpdatePopupAppearance() is called frequently, so it
+ // should be really cheap, but in this case we could probably make
+ // things even cheaper by refactoring between the popup-placement
+ // code and the matrix-population code.
+ popup_view_->UpdatePopupAppearance();
+}
+
@end
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698