diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 19:51:59 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 19:51:59 +0000 |
commit | 2c02986320e4de786b306499b6f2c64751f54d04 (patch) | |
tree | d8ca70af09a2908bde1d172a487f302362100e08 /chrome | |
parent | 4f876793cc6abebb436545a4e8934cd1a5c3d80e (diff) | |
download | chromium_src-2c02986320e4de786b306499b6f2c64751f54d04.zip chromium_src-2c02986320e4de786b306499b6f2c64751f54d04.tar.gz chromium_src-2c02986320e4de786b306499b6f2c64751f54d04.tar.bz2 |
[Mac] Remove guard on FocusLocation() in autocomplete field.
Reapplies http://codereview.chromium.org/149492 . That version was
accidentally calling this code as part of the class implementation,
which caused the code to receive the "done editing" notification,
which caused the code to drop the popup...
This version stops using FocusLocation() internally, instead messaging
field_ directly.
http://crbug.com/12246
TEST=Type some stuff in address bar. Popup should popup with suggestions. With cursor still in bar, Command-l should select all.
Review URL: http://codereview.chromium.org/155537
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.h | 2 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 17 |
2 files changed, 7 insertions, 12 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h index 6c7ccfb..9b22412 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h @@ -100,7 +100,7 @@ class AutocompleteEditViewMac : public AutocompleteEditView { void AcceptInput(WindowOpenDisposition disposition, bool for_drop); - // Helper for LocationBarBridge. + // Helper for LocationBarViewMac. Selects all in |field_|. void FocusLocation(); private: diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index 6f8f6c8..2c541c8 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -223,9 +223,7 @@ void AutocompleteEditViewMac::Update( // store existing state before anyone tries to setup the new // state. Anyhow, it would look something like this. #if 0 - FocusLocation(); - - // Must restore directly to evade model_->has_focus() guard. + [[field_ window] makeFirstResponder:field_]; [[field_ currentEditor] setSelectedRange:state->selection]; #endif } @@ -295,7 +293,9 @@ void AutocompleteEditViewMac::SetSelectedRange(const NSRange range) { if (model_->has_focus()) { // TODO(shess): If |model_| thinks we have focus, this should not // be necessary. Try to convert to DCHECK(IsFirstResponder()). - FocusLocation(); + if (![field_ currentEditor]) { + [[field_ window] makeFirstResponder:field_]; + } // TODO(shess): What if it didn't get first responder, and there is // no field editor? This will do nothing. Well, at least it won't @@ -549,13 +549,8 @@ void AutocompleteEditViewMac::AcceptInput( } void AutocompleteEditViewMac::FocusLocation() { - // -makeFirstResponder: will select the entire field_. If we're - // already firstResponder, it's likely that we want to retain the - // current selection. - if (![field_ currentEditor]) { - [[field_ window] makeFirstResponder:field_]; - DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); - } + [[field_ window] makeFirstResponder:field_]; + DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); } @implementation AutocompleteFieldDelegate |