| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/autocomplete/autocomplete_edit_view_views.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_views.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 views::TextRange new_sel; | 478 views::TextRange new_sel; |
| 479 textfield_->GetSelectedRange(&new_sel); | 479 textfield_->GetSelectedRange(&new_sel); |
| 480 | 480 |
| 481 size_t length = GetTextLength(); | 481 size_t length = GetTextLength(); |
| 482 bool at_end_of_edit = (new_sel.start() == length && new_sel.end() == length); | 482 bool at_end_of_edit = (new_sel.start() == length && new_sel.end() == length); |
| 483 | 483 |
| 484 // See if the text or selection have changed since OnBeforePossibleChange(). | 484 // See if the text or selection have changed since OnBeforePossibleChange(). |
| 485 std::wstring new_text = GetText(); | 485 std::wstring new_text = GetText(); |
| 486 text_changed_ = (new_text != text_before_change_); | 486 text_changed_ = (new_text != text_before_change_); |
| 487 bool selection_differs = !sel_before_change_.Equals(new_sel); | 487 bool selection_differs = !sel_before_change_.HasSameSelectionWith(new_sel); |
| 488 | 488 |
| 489 // When the user has deleted text, we don't allow inline autocomplete. Make | 489 // When the user has deleted text, we don't allow inline autocomplete. Make |
| 490 // sure to not flag cases like selecting part of the text and then pasting | 490 // sure to not flag cases like selecting part of the text and then pasting |
| 491 // (or typing) the prefix of that selection. (We detect these by making | 491 // (or typing) the prefix of that selection. (We detect these by making |
| 492 // sure the caret, which should be after any insertion, hasn't moved | 492 // sure the caret, which should be after any insertion, hasn't moved |
| 493 // forward of the old selection start.) | 493 // forward of the old selection start.) |
| 494 bool just_deleted_text = | 494 bool just_deleted_text = |
| 495 (text_before_change_.length() > new_text.length()) && | 495 (text_before_change_.length() > new_text.length()) && |
| 496 (new_sel.start() <= sel_before_change_.GetMin()); | 496 (new_sel.start() <= sel_before_change_.GetMin()); |
| 497 | 497 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 string16 AutocompleteEditViewViews::GetSelectedText() const { | 627 string16 AutocompleteEditViewViews::GetSelectedText() const { |
| 628 // TODO(oshima): Support instant, IME. | 628 // TODO(oshima): Support instant, IME. |
| 629 return textfield_->GetSelectedText(); | 629 return textfield_->GetSelectedText(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) { | 632 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) { |
| 633 const views::TextRange range(caret, end); | 633 const views::TextRange range(caret, end); |
| 634 textfield_->SelectRange(range); | 634 textfield_->SelectRange(range); |
| 635 } | 635 } |
| OLD | NEW |