From e017e07f7b7390b24c36b123cd1310ae15cd904e Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Fri, 28 Aug 2009 17:35:24 +0000 Subject: [Mac] Don't eat tab if tab-to-search hint not visible. http://crbug.com/20284 TEST=Type "test text". You should see "Type to search" hint. TAB should take you into the content view. Unfortunately, there are other unrelated bugs around the tab sequencing, so this only works with NTP on a new window. Hit TAB twice and you should start tabbing between thumbnails. Review URL: http://codereview.chromium.org/180010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24741 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/autocomplete/autocomplete_edit_view_mac.h | 7 ++++--- .../browser/autocomplete/autocomplete_edit_view_mac.mm | 17 +++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h index aac879b..0c0cb2b 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h @@ -112,10 +112,11 @@ class AutocompleteEditViewMac : public AutocompleteEditView { // Called when the user attempts to paste into |field_|. void OnPaste(); - void AcceptInput(WindowOpenDisposition disposition, bool for_drop); + // Checks if a keyword search is possible and forwards to |model_| + // if so. Returns true if the tab should be eaten. + bool OnTabPressed(); - // Forwards to |model_| when user hits Tab. - void AcceptKeyword(); + void AcceptInput(WindowOpenDisposition disposition, bool for_drop); // Helper for LocationBarViewMac. Selects all in |field_|. void FocusLocation(); diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index d115c88..9ca8a6b 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -622,6 +622,14 @@ void AutocompleteEditViewMac::OnPaste() { OnAfterPossibleChange(); } +bool AutocompleteEditViewMac::OnTabPressed() { + if (model_->is_keyword_hint() && !model_->keyword().empty()) { + model_->AcceptKeyword(); + return true; + } + return false; +} + bool AutocompleteEditViewMac::IsPopupOpen() const { return popup_view_->IsOpen(); } @@ -635,10 +643,6 @@ void AutocompleteEditViewMac::AcceptInput( model_->AcceptInput(disposition, for_drop); } -void AutocompleteEditViewMac::AcceptKeyword() { - model_->AcceptKeyword(); -} - void AutocompleteEditViewMac::FocusLocation() { [[field_ window] makeFirstResponder:field_]; DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); @@ -725,8 +729,9 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { } if (cmd == @selector(insertTab:)) { - edit_view_->AcceptKeyword(); - return YES; + if (edit_view_->OnTabPressed()) { + return YES; + } } // |-noop:| is sent when the user presses Cmd+Return. Override the no-op -- cgit v1.1