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

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

Issue 5966006: Hitting Tab should always move cursor to end of omnibox text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build. Created 9 years, 11 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
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_win.h ('k') | chrome/browser/browser_focus_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_edit_view_win.cc
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 89d8f55aa4ddbd75ee875eae2d48c3452f012211..cca0d08d2cea6113d943c90067f2ec8038cac25d 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -924,6 +924,12 @@ void AutocompleteEditViewWin::SetInstantSuggestion(const string16& suggestion) {
NOTREACHED();
}
+string16 AutocompleteEditViewWin::GetInstantSuggestion() const {
+ // On Windows, we shows the suggestion in LocationBarView.
+ NOTREACHED();
+ return string16();
+}
+
int AutocompleteEditViewWin::TextWidth() const {
return WidthNeededToDisplay(GetText());
}
@@ -946,13 +952,6 @@ views::View* AutocompleteEditViewWin::AddToView(views::View* parent) {
return host;
}
-bool AutocompleteEditViewWin::CommitInstantSuggestion(
- const string16& typed_text,
- const string16& suggested_text) {
- model_->FinalizeInstantQuery(typed_text, suggested_text);
- return true;
-}
-
void AutocompleteEditViewWin::PasteAndGo(const string16& text) {
if (CanPasteAndGo(text))
model_->PasteAndGo();
@@ -1848,7 +1847,7 @@ bool AutocompleteEditViewWin::OnKeyDownOnlyWritable(TCHAR key,
GetSel(selection);
return (selection.cpMin == selection.cpMax) &&
(selection.cpMin == GetTextLength()) &&
- controller_->OnCommitSuggestedText(GetText());
+ controller_->OnCommitSuggestedText(true);
}
case VK_RETURN:
@@ -1977,8 +1976,13 @@ bool AutocompleteEditViewWin::OnKeyDownOnlyWritable(TCHAR key,
// Accept the keyword.
ScopedFreeze freeze(this, GetTextObjectModel());
model_->AcceptKeyword();
+ } else if (!IsCaretAtEnd()) {
+ ScopedFreeze freeze(this, GetTextObjectModel());
+ OnBeforePossibleChange();
+ PlaceCaretAt(GetTextLength());
+ OnAfterPossibleChange();
} else {
- controller_->OnCommitSuggestedText(GetText());
+ controller_->OnCommitSuggestedText(true);
}
return true;
}
@@ -2568,3 +2572,10 @@ int AutocompleteEditViewWin::WidthNeededToDisplay(
// PosFromChar(i) might return 0 when i is greater than 1.
return font_.GetStringWidth(text) + GetHorizontalMargin();
}
+
+bool AutocompleteEditViewWin::IsCaretAtEnd() const {
+ long length = GetTextLength();
+ CHARRANGE sel;
+ GetSelection(sel);
+ return sel.cpMin == sel.cpMax && sel.cpMin == length;
+}
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_win.h ('k') | chrome/browser/browser_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698