Chromium Code Reviews| 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 "views/controls/textfield/textfield_views_model.h" | 5 #include "views/controls/textfield/textfield_views_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 AddOrMergeEditHistory(new InsertEdit(false, text, range.start())); | 604 AddOrMergeEditHistory(new InsertEdit(false, text, range.start())); |
| 605 render_text_->SetCursorPosition(range.end()); | 605 render_text_->SetCursorPosition(range.end()); |
| 606 ClearComposition(); | 606 ClearComposition(); |
| 607 if (delegate_) | 607 if (delegate_) |
| 608 delegate_->OnCompositionTextConfirmedOrCleared(); | 608 delegate_->OnCompositionTextConfirmedOrCleared(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void TextfieldViewsModel::CancelCompositionText() { | 611 void TextfieldViewsModel::CancelCompositionText() { |
| 612 DCHECK(HasCompositionText()); | 612 DCHECK(HasCompositionText()); |
| 613 ui::Range range = render_text_->GetCompositionRange(); | 613 ui::Range range = render_text_->GetCompositionRange(); |
| 614 ClearComposition(); | |
|
msw
2011/08/29 20:38:05
Why did you make this change?
I have a vague feeli
xji
2011/08/30 00:39:41
Inside SetCursorPosition(), we will need to get th
msw
2011/08/30 01:17:07
OK.
xji
2011/08/31 19:01:06
From suzhe
"The caller should make sure that the c
| |
| 614 string16 new_text = GetText(); | 615 string16 new_text = GetText(); |
| 615 render_text_->SetText(new_text.erase(range.start(), range.length())); | 616 render_text_->SetText(new_text.erase(range.start(), range.length())); |
| 616 render_text_->SetCursorPosition(range.start()); | 617 render_text_->SetCursorPosition(range.start()); |
| 617 ClearComposition(); | |
| 618 if (delegate_) | 618 if (delegate_) |
| 619 delegate_->OnCompositionTextConfirmedOrCleared(); | 619 delegate_->OnCompositionTextConfirmedOrCleared(); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void TextfieldViewsModel::ClearComposition() { | 622 void TextfieldViewsModel::ClearComposition() { |
| 623 render_text_->SetCompositionRange(ui::Range::InvalidRange()); | 623 render_text_->SetCompositionRange(ui::Range::InvalidRange()); |
| 624 } | 624 } |
| 625 | 625 |
| 626 void TextfieldViewsModel::GetCompositionTextRange(ui::Range* range) const { | 626 void TextfieldViewsModel::GetCompositionTextRange(ui::Range* range) const { |
| 627 *range = ui::Range(render_text_->GetCompositionRange()); | 627 *range = ui::Range(render_text_->GetCompositionRange()); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 if (delete_from != delete_to) | 775 if (delete_from != delete_to) |
| 776 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); | 776 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); |
| 777 if (!new_text.empty()) | 777 if (!new_text.empty()) |
| 778 render_text_->SetText(text.insert(new_text_insert_at, new_text)); | 778 render_text_->SetText(text.insert(new_text_insert_at, new_text)); |
| 779 render_text_->SetCursorPosition(new_cursor_pos); | 779 render_text_->SetCursorPosition(new_cursor_pos); |
| 780 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). | 780 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). |
| 781 // This looks fine feature and we may want to do the same. | 781 // This looks fine feature and we may want to do the same. |
| 782 } | 782 } |
| 783 | 783 |
| 784 } // namespace views | 784 } // namespace views |
| OLD | NEW |