Chromium Code Reviews| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 void OmniboxEditModel::Revert() { | 365 void OmniboxEditModel::Revert() { |
| 366 SetInputInProgress(false); | 366 SetInputInProgress(false); |
| 367 input_.Clear(); | 367 input_.Clear(); |
| 368 paste_state_ = NONE; | 368 paste_state_ = NONE; |
| 369 InternalSetUserText(base::string16()); | 369 InternalSetUserText(base::string16()); |
| 370 keyword_.clear(); | 370 keyword_.clear(); |
| 371 is_keyword_hint_ = false; | 371 is_keyword_hint_ = false; |
| 372 has_temporary_text_ = false; | 372 has_temporary_text_ = false; |
| 373 size_t start, end; | 373 size_t start, end; |
| 374 view_->GetSelectionBounds(&start, &end); | 374 view_->GetSelectionBounds(&start, &end); |
| 375 view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, false); | 375 // First home cursor, so view of text is scrolled to left, then correct it. |
|
Peter Kasting
2017/05/25 23:19:19
Nit: This helps, but I'd probably expand the comme
Kevin Bailey
2017/05/26 13:58:05
Done.
| |
| 376 view_->SetWindowTextAndCaretPos( | 376 view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, true); |
| 377 permanent_text_, std::min(permanent_text_.length(), start), false, true); | 377 view_->SetCaretPos(std::min(permanent_text_.length(), start)); |
| 378 client_->OnRevert(); | 378 client_->OnRevert(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, | 381 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, |
| 382 bool prevent_inline_autocomplete) { | 382 bool prevent_inline_autocomplete) { |
| 383 const base::string16 input_text = MaybePrependKeyword(user_text_); | 383 const base::string16 input_text = MaybePrependKeyword(user_text_); |
| 384 | 384 |
| 385 size_t start, cursor_position; | 385 size_t start, cursor_position; |
| 386 view_->GetSelectionBounds(&start, &cursor_position); | 386 view_->GetSelectionBounds(&start, &cursor_position); |
| 387 | 387 |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 // Update state and notify view if the omnibox has focus and the caret | 1388 // Update state and notify view if the omnibox has focus and the caret |
| 1389 // visibility changed. | 1389 // visibility changed. |
| 1390 const bool was_caret_visible = is_caret_visible(); | 1390 const bool was_caret_visible = is_caret_visible(); |
| 1391 focus_state_ = state; | 1391 focus_state_ = state; |
| 1392 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1392 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1393 is_caret_visible() != was_caret_visible) | 1393 is_caret_visible() != was_caret_visible) |
| 1394 view_->ApplyCaretVisibility(); | 1394 view_->ApplyCaretVisibility(); |
| 1395 | 1395 |
| 1396 client_->OnFocusChanged(focus_state_, reason); | 1396 client_->OnFocusChanged(focus_state_, reason); |
| 1397 } | 1397 } |
| OLD | NEW |