OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/omnibox/browser/omnibox_edit_model.h" | 5 #include "components/omnibox/browser/omnibox_edit_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 autocomplete_controller()->ResetSession(); | 356 autocomplete_controller()->ResetSession(); |
357 } | 357 } |
358 | 358 |
359 controller_->OnInputInProgress(in_progress); | 359 controller_->OnInputInProgress(in_progress); |
360 | 360 |
361 if (user_input_in_progress_ || !in_revert_) | 361 if (user_input_in_progress_ || !in_revert_) |
362 client_->OnInputStateChanged(); | 362 client_->OnInputStateChanged(); |
363 } | 363 } |
364 | 364 |
365 void OmniboxEditModel::Revert() { | 365 void OmniboxEditModel::Revert() { |
366 bool user_input_was_in_progress = user_input_in_progress_; | |
366 SetInputInProgress(false); | 367 SetInputInProgress(false); |
367 input_.Clear(); | 368 input_.Clear(); |
368 paste_state_ = NONE; | 369 paste_state_ = NONE; |
369 InternalSetUserText(base::string16()); | 370 InternalSetUserText(base::string16()); |
370 keyword_.clear(); | 371 keyword_.clear(); |
371 is_keyword_hint_ = false; | 372 is_keyword_hint_ = false; |
372 has_temporary_text_ = false; | 373 has_temporary_text_ = false; |
373 view_->SetWindowTextAndCaretPos(permanent_text_, | 374 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
| |
374 has_focus() ? permanent_text_.length() : 0, | 375 view_->SetWindowTextAndCaretPos(permanent_text_, permanent_text_.length(), |
375 false, true); | 376 false, true); |
377 } else { | |
378 size_t start, end; | |
379 view_->GetSelectionBounds(&start, &end); | |
380 view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, true); | |
381 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
| |
382 } | |
376 client_->OnRevert(); | 383 client_->OnRevert(); |
377 } | 384 } |
378 | 385 |
379 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, | 386 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, |
380 bool prevent_inline_autocomplete) { | 387 bool prevent_inline_autocomplete) { |
381 const base::string16 input_text = MaybePrependKeyword(user_text_); | 388 const base::string16 input_text = MaybePrependKeyword(user_text_); |
382 | 389 |
383 size_t start, cursor_position; | 390 size_t start, cursor_position; |
384 view_->GetSelectionBounds(&start, &cursor_position); | 391 view_->GetSelectionBounds(&start, &cursor_position); |
385 | 392 |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 // Update state and notify view if the omnibox has focus and the caret | 1393 // Update state and notify view if the omnibox has focus and the caret |
1387 // visibility changed. | 1394 // visibility changed. |
1388 const bool was_caret_visible = is_caret_visible(); | 1395 const bool was_caret_visible = is_caret_visible(); |
1389 focus_state_ = state; | 1396 focus_state_ = state; |
1390 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1397 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1391 is_caret_visible() != was_caret_visible) | 1398 is_caret_visible() != was_caret_visible) |
1392 view_->ApplyCaretVisibility(); | 1399 view_->ApplyCaretVisibility(); |
1393 | 1400 |
1394 client_->OnFocusChanged(focus_state_, reason); | 1401 client_->OnFocusChanged(focus_state_, reason); |
1395 } | 1402 } |
OLD | NEW |