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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 8 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
Index: chrome/browser/autocomplete/autocomplete_edit.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete_edit.cc (revision 80563)
+++ chrome/browser/autocomplete/autocomplete_edit.cc (working copy)
@@ -382,6 +382,8 @@
void AutocompleteEditModel::StartAutocomplete(
bool has_selected_text,
bool prevent_inline_autocomplete) const {
+ ResetCurrentMatchKeywordMode();
Peter Kasting 2011/04/07 20:19:21 Your CL must be missing some locally modified file
+
bool keyword_is_selected = KeywordIsSelected();
popup_->SetHoveredLine(AutocompletePopupModel::kNoMatch);
// We don't explicitly clear AutocompletePopupModel::manually_selected_match,
@@ -548,30 +550,65 @@
bool AutocompleteEditModel::AcceptKeyword() {
DCHECK(is_keyword_hint_ && !keyword_.empty());
- view_->OnBeforePossibleChange();
- view_->SetWindowTextAndCaretPos(string16(), 0);
+ autocomplete_controller_->Stop(false);
is_keyword_hint_ = false;
- view_->OnAfterPossibleChange();
- just_deleted_text_ = false; // OnAfterPossibleChange() erroneously sets this
- // since the edit contents have disappeared. It
- // doesn't really matter, but we clear it to be
- // consistent.
+
+ if (popup_->selected_line() != AutocompletePopupModel::kNoMatch) {
+ AutocompleteMatch match = CurrentMatch();
+
+ match.keyword->is_keyword_mode = true;
+ popup_->view()->InvalidateLine(popup_->selected_line());
+ }
+
+ view_->SetUserText(string16(), string16(), false);
+
UserMetrics::RecordAction(UserMetricsAction("AcceptedKeywordHint"), profile_);
return true;
}
void AutocompleteEditModel::ClearKeyword(const string16& visible_text) {
- view_->OnBeforePossibleChange();
+ autocomplete_controller_->Stop(false);
+ ResetCurrentMatchKeywordMode();
+
const string16 window_text(keyword_ + visible_text);
- view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length());
- keyword_.clear();
- is_keyword_hint_ = false;
- view_->OnAfterPossibleChange();
- just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this
- // since the edit contents have actually grown
- // longer.
+
+ // Only reset the result if the edit text has changed since the
+ // keyword was accepted.
+ if (just_deleted_text_) {
+ view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length());
+ keyword_.clear();
+ is_keyword_hint_ = false;
+ view_->OnAfterPossibleChange();
+ just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this
+ // since the edit contents have actually grown
+ // longer.
+ } else {
+ view_->SetUserText(window_text, window_text, false);
+
+ if (visible_text.size() != 0) {
Peter Kasting 2011/04/07 20:19:21 Nit: Shorter: is_keyword_hint_ = visible_text.emp
+ is_keyword_hint_ = false;
+ keyword_.clear();
+ } else {
+ is_keyword_hint_ = true;
+ }
+
+ OnChanged();
+ }
}
+void AutocompleteEditModel::ResetCurrentMatchKeywordMode() const {
+ if (popup_->selected_line() != AutocompletePopupModel::kNoMatch) {
+ AutocompleteMatch match;
+ InfoForCurrentSelection(&match, NULL);
+
+ if (match.keyword.get() && match.keyword->is_keyword_hint &&
+ match.keyword->is_keyword_mode) {
+ match.keyword->is_keyword_mode = false;
+ popup_->view()->InvalidateLine(popup_->selected_line());
+ }
+ }
+}
+
const AutocompleteResult& AutocompleteEditModel::result() const {
return autocomplete_controller_->result();
}
@@ -668,6 +705,14 @@
} else {
// The popup is open, so the user should be able to interact with it
// normally.
+ if (popup_->selected_line() != AutocompletePopupModel::kNoMatch) {
+ AutocompleteMatch match = CurrentMatch();
+
+ if (match.keyword.get() && match.keyword->is_keyword_hint &&
+ match.keyword->is_keyword_mode)
+ ClearKeyword(string16());
+ }
+
popup_->Move(count);
}
}
@@ -853,8 +898,12 @@
// can be many of these as a user types an initial series of characters,
// the OS DNS cache could suffer eviction problems for minimal gain.
- is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword);
+ if (match->keyword.get()) {
+ is_keyword_hint = match->keyword->is_keyword_hint;
+ keyword = match->keyword->text;
+ }
}
+
popup_->OnResultChanged();
OnPopupDataChanged(inline_autocomplete_text, NULL, keyword,
is_keyword_hint);
@@ -998,7 +1047,8 @@
TRIM_LEADING, &keyword);
// Only allow exact keyword match if |keyword| represents a keyword hint.
- return keyword.length() && popup_->GetKeywordForText(keyword, &keyword);
+ return keyword.length() &&
+ autocomplete_controller_->GetKeywordForText(keyword, &keyword);
}
// static

Powered by Google App Engine
This is Rietveld 408576698