diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 22:27:14 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 22:27:14 +0000 |
commit | 0b0f5cad9a96d77f1894d536e6fabf36eb41c341 (patch) | |
tree | 925d59fef5de22e4f246cd658104052258beb6e1 /chrome | |
parent | 2ff8b3133033d6130ea87df3ab2290a226c7bca7 (diff) | |
download | chromium_src-0b0f5cad9a96d77f1894d536e6fabf36eb41c341.zip chromium_src-0b0f5cad9a96d77f1894d536e6fabf36eb41c341.tar.gz chromium_src-0b0f5cad9a96d77f1894d536e6fabf36eb41c341.tar.bz2 |
Honor the select_all argument to AutocompleteEditViewMac::FocusLocation.
Calling -[NSWindow makeFirstResponder:] to give focus to the
AutocompleteTextField will select the entire contents of the field. If the
field is already focused and "select all" is not desired, avoid making this
call. If "select all" is desired, or if the field is not focused (regardless
of the value of select_all), the field will be focused and its entire contents
selected.
BUG=40322, 40682
TEST=With a profile primed so that "google.com" is the first suggestion when
typing "g" in the location bar, and no windows open, quickly press
command-N and begin typing "google" while the tab is being created.
Expect all of the entered characters to make it to the location bar. When
the bug occurs, the location bar in its entirety will be selected at some
point during or immediately following tab creation, which will cause
previously-typed text to be lost or the first autocomplete suggestion to
be chosen, and something like "ogle" or "google.com/ogle" to appear in
the location bar.
Review URL: http://codereview.chromium.org/1709010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index 0c97205..ad6e11b 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -884,10 +884,12 @@ void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { } void AutocompleteEditViewMac::FocusLocation(bool select_all) { - // TODO(pkasting): Figure out Mac's weird focus-handling and do the right - // thing here :( if ([field_ isEditable]) { - [[field_ window] makeFirstResponder:field_]; + // If the text field has a field editor, it's the first responder, meaning + // that it's already focused. makeFirstResponder: will select all, so only + // call it if this behavior is desired. + if (select_all || ![field_ currentEditor]) + [[field_ window] makeFirstResponder:field_]; DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); } } |