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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 626 base::string16 TextfieldModel::GetTextFromRange(const gfx::Range& range) const { |
627 if (range.IsValid() && range.GetMin() < text().length()) | 627 return render_text_->GetTextFromRange(range); |
628 return text().substr(range.GetMin(), range.length()); | |
629 return base::string16(); | |
630 } | 628 } |
631 | 629 |
632 void TextfieldModel::GetTextRange(gfx::Range* range) const { | 630 void TextfieldModel::GetTextRange(gfx::Range* range) const { |
633 *range = gfx::Range(0, text().length()); | 631 *range = gfx::Range(0, text().length()); |
634 } | 632 } |
635 | 633 |
636 void TextfieldModel::SetCompositionText( | 634 void TextfieldModel::SetCompositionText( |
637 const ui::CompositionText& composition) { | 635 const ui::CompositionText& composition) { |
638 if (HasCompositionText()) | 636 if (HasCompositionText()) |
639 CancelCompositionText(); | 637 CancelCompositionText(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 render_text_->SetCursorPosition(new_cursor_pos); | 851 render_text_->SetCursorPosition(new_cursor_pos); |
854 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). | 852 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). |
855 } | 853 } |
856 | 854 |
857 // static | 855 // static |
858 void TextfieldModel::ClearKillBuffer() { | 856 void TextfieldModel::ClearKillBuffer() { |
859 SetKillBuffer(base::string16()); | 857 SetKillBuffer(base::string16()); |
860 } | 858 } |
861 | 859 |
862 } // namespace views | 860 } // namespace views |
OLD | NEW |