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 view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, true); |
Peter Kasting
2017/05/18 18:38:34
Nit: I didn't mention this before, but this deserv
Kevin Bailey
2017/05/18 19:48:17
Done.
| |
376 view_->SetWindowTextAndCaretPos( | 376 view_->SetCaretPos(std::min(permanent_text_.length(), start)); |
Peter Kasting
2017/05/18 18:38:34
Should we use SetCaretPos() first, then SetWindowT
Kevin Bailey
2017/05/18 19:48:17
Ya, RenderText apparently won't update with just a
| |
377 permanent_text_, std::min(permanent_text_.length(), start), false, true); | |
378 client_->OnRevert(); | 377 client_->OnRevert(); |
379 } | 378 } |
380 | 379 |
381 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, | 380 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, |
382 bool prevent_inline_autocomplete) { | 381 bool prevent_inline_autocomplete) { |
383 const base::string16 input_text = MaybePrependKeyword(user_text_); | 382 const base::string16 input_text = MaybePrependKeyword(user_text_); |
384 | 383 |
385 size_t start, cursor_position; | 384 size_t start, cursor_position; |
386 view_->GetSelectionBounds(&start, &cursor_position); | 385 view_->GetSelectionBounds(&start, &cursor_position); |
387 | 386 |
(...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 | 1387 // Update state and notify view if the omnibox has focus and the caret |
1389 // visibility changed. | 1388 // visibility changed. |
1390 const bool was_caret_visible = is_caret_visible(); | 1389 const bool was_caret_visible = is_caret_visible(); |
1391 focus_state_ = state; | 1390 focus_state_ = state; |
1392 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1391 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1393 is_caret_visible() != was_caret_visible) | 1392 is_caret_visible() != was_caret_visible) |
1394 view_->ApplyCaretVisibility(); | 1393 view_->ApplyCaretVisibility(); |
1395 | 1394 |
1396 client_->OnFocusChanged(focus_state_, reason); | 1395 client_->OnFocusChanged(focus_state_, reason); |
1397 } | 1396 } |
OLD | NEW |