| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield_model.h" | 5 #include "ui/views/controls/textfield/textfield_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 size_t position) { | 609 size_t position) { |
| 610 if (HasCompositionText()) | 610 if (HasCompositionText()) |
| 611 CancelCompositionText(); | 611 CancelCompositionText(); |
| 612 ExecuteAndRecordReplace(DO_NOT_MERGE, | 612 ExecuteAndRecordReplace(DO_NOT_MERGE, |
| 613 GetCursorPosition(), | 613 GetCursorPosition(), |
| 614 position + new_text.length(), | 614 position + new_text.length(), |
| 615 new_text, | 615 new_text, |
| 616 position); | 616 position); |
| 617 } | 617 } |
| 618 | 618 |
| 619 base::string16 TextfieldModel::GetTextFromRange(const gfx::Range& range) const { | |
| 620 if (range.IsValid() && range.GetMin() < text().length()) | |
| 621 return text().substr(range.GetMin(), range.length()); | |
| 622 return base::string16(); | |
| 623 } | |
| 624 | |
| 625 void TextfieldModel::GetTextRange(gfx::Range* range) const { | 619 void TextfieldModel::GetTextRange(gfx::Range* range) const { |
| 626 *range = gfx::Range(0, text().length()); | 620 *range = gfx::Range(0, text().length()); |
| 627 } | 621 } |
| 628 | 622 |
| 629 void TextfieldModel::SetCompositionText( | 623 void TextfieldModel::SetCompositionText( |
| 630 const ui::CompositionText& composition) { | 624 const ui::CompositionText& composition) { |
| 631 if (HasCompositionText()) | 625 if (HasCompositionText()) |
| 632 CancelCompositionText(); | 626 CancelCompositionText(); |
| 633 else if (HasSelection()) | 627 else if (HasSelection()) |
| 634 DeleteSelection(); | 628 DeleteSelection(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 render_text_->SetCursorPosition(new_cursor_pos); | 840 render_text_->SetCursorPosition(new_cursor_pos); |
| 847 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). | 841 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). |
| 848 } | 842 } |
| 849 | 843 |
| 850 // static | 844 // static |
| 851 void TextfieldModel::ClearKillBuffer() { | 845 void TextfieldModel::ClearKillBuffer() { |
| 852 SetKillBuffer(base::string16()); | 846 SetKillBuffer(base::string16()); |
| 853 } | 847 } |
| 854 | 848 |
| 855 } // namespace views | 849 } // namespace views |
| OLD | NEW |