| 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 size_t position) { | 616 size_t position) { |
| 617 if (HasCompositionText()) | 617 if (HasCompositionText()) |
| 618 CancelCompositionText(); | 618 CancelCompositionText(); |
| 619 ExecuteAndRecordReplace(DO_NOT_MERGE, | 619 ExecuteAndRecordReplace(DO_NOT_MERGE, |
| 620 GetCursorPosition(), | 620 GetCursorPosition(), |
| 621 position + new_text.length(), | 621 position + new_text.length(), |
| 622 new_text, | 622 new_text, |
| 623 position); | 623 position); |
| 624 } | 624 } |
| 625 | 625 |
| 626 base::string16 TextfieldModel::GetTextFromRange(const gfx::Range& range) const { | |
| 627 if (range.IsValid() && range.GetMin() < text().length()) | |
| 628 return text().substr(range.GetMin(), range.length()); | |
| 629 return base::string16(); | |
| 630 } | |
| 631 | |
| 632 void TextfieldModel::GetTextRange(gfx::Range* range) const { | 626 void TextfieldModel::GetTextRange(gfx::Range* range) const { |
| 633 *range = gfx::Range(0, text().length()); | 627 *range = gfx::Range(0, text().length()); |
| 634 } | 628 } |
| 635 | 629 |
| 636 void TextfieldModel::SetCompositionText( | 630 void TextfieldModel::SetCompositionText( |
| 637 const ui::CompositionText& composition) { | 631 const ui::CompositionText& composition) { |
| 638 if (HasCompositionText()) | 632 if (HasCompositionText()) |
| 639 CancelCompositionText(); | 633 CancelCompositionText(); |
| 640 else if (HasSelection()) | 634 else if (HasSelection()) |
| 641 DeleteSelection(); | 635 DeleteSelection(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 render_text_->SetCursorPosition(new_cursor_pos); | 847 render_text_->SetCursorPosition(new_cursor_pos); |
| 854 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). | 848 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). |
| 855 } | 849 } |
| 856 | 850 |
| 857 // static | 851 // static |
| 858 void TextfieldModel::ClearKillBuffer() { | 852 void TextfieldModel::ClearKillBuffer() { |
| 859 SetKillBuffer(base::string16()); | 853 SetKillBuffer(base::string16()); |
| 860 } | 854 } |
| 861 | 855 |
| 862 } // namespace views | 856 } // namespace views |
| OLD | NEW |