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

Unified Diff: components/omnibox/browser/omnibox_edit_model.cc

Issue 2860503004: [omnibox] Home cursor, then restore, on revert (Closed)
Patch Set: Preserve cursor and scroll to left, restore test Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/omnibox_edit_model.cc
diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc
index 4c3a2782776335c03ee4aca6c61f16876b685e55..9b5d6abf41b298317759b5a4719fa4663524e640 100644
--- a/components/omnibox/browser/omnibox_edit_model.cc
+++ b/components/omnibox/browser/omnibox_edit_model.cc
@@ -363,6 +363,7 @@ void OmniboxEditModel::SetInputInProgress(bool in_progress) {
}
void OmniboxEditModel::Revert() {
+ bool user_input_was_in_progress = user_input_in_progress_;
SetInputInProgress(false);
input_.Clear();
paste_state_ = NONE;
@@ -370,9 +371,15 @@ void OmniboxEditModel::Revert() {
keyword_.clear();
is_keyword_hint_ = false;
has_temporary_text_ = false;
- view_->SetWindowTextAndCaretPos(permanent_text_,
- has_focus() ? permanent_text_.length() : 0,
- false, true);
+ if (has_focus() && user_input_was_in_progress) {
Peter Kasting 2017/05/15 23:51:23 Do we even need this distinction anymore? I'm won
Kevin Bailey 2017/05/16 01:01:01 I don't know all the cases that Revert() is called
Peter Kasting 2017/05/16 05:53:53 There are several, but not so many that you couldn
Kevin Bailey 2017/05/17 01:53:54 I said 'cases', not 'places'. :) I looked through
+ view_->SetWindowTextAndCaretPos(permanent_text_, permanent_text_.length(),
+ false, true);
+ } else {
+ size_t start, end;
+ view_->GetSelectionBounds(&start, &end);
+ view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, true);
+ view_->SetWindowTextAndCaretPos(permanent_text_, start, false, true);
Peter Kasting 2017/05/16 05:53:53 Even if you don't plumb full facilities for updati
Kevin Bailey 2017/05/17 01:53:54 Ya, exposing SetCursorPosition() wouldn't be too h
Peter Kasting 2017/05/17 02:44:14 Sure.
Kevin Bailey 2017/05/17 03:57:52 I was thinking we wanted to notify when the cursor
Peter Kasting 2017/05/17 03:59:21 Correctnesswise it's fine. My concern is that it
+ }
client_->OnRevert();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698