diff options
-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 |