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 "ui/views/controls/textfield/textfield_views_model.h" | 5 #include "ui/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" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "ui/base/clipboard/clipboard.h" | 13 #include "ui/base/clipboard/clipboard.h" |
14 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 14 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
15 #include "ui/base/range/range.h" | 15 #include "ui/base/range/range.h" |
16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
18 #include "ui/gfx/render_text.h" | 18 #include "ui/gfx/render_text.h" |
19 #include "ui/views/controls/textfield/textfield.h" | 19 #include "ui/views/controls/textfield/textfield.h" |
20 #include "views/views_delegate.h" | 20 #include "ui/views/views_delegate.h" |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 | 23 |
24 namespace internal { | 24 namespace internal { |
25 | 25 |
26 // An edit object holds enough information/state to undo/redo the | 26 // An edit object holds enough information/state to undo/redo the |
27 // change. Two edits are merged when possible, for example, when | 27 // change. Two edits are merged when possible, for example, when |
28 // you type new characters in sequence. |Commit()| can be used to | 28 // you type new characters in sequence. |Commit()| can be used to |
29 // mark an edit as an independent edit and it shouldn't be merged. | 29 // mark an edit as an independent edit and it shouldn't be merged. |
30 // (For example, when you did undo/redo, or a text is appended via | 30 // (For example, when you did undo/redo, or a text is appended via |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 if (delete_from != delete_to) | 786 if (delete_from != delete_to) |
787 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); | 787 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); |
788 if (!new_text.empty()) | 788 if (!new_text.empty()) |
789 render_text_->SetText(text.insert(new_text_insert_at, new_text)); | 789 render_text_->SetText(text.insert(new_text_insert_at, new_text)); |
790 render_text_->SetCursorPosition(new_cursor_pos); | 790 render_text_->SetCursorPosition(new_cursor_pos); |
791 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). | 791 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). |
792 // This looks fine feature and we may want to do the same. | 792 // This looks fine feature and we may want to do the same. |
793 } | 793 } |
794 | 794 |
795 } // namespace views | 795 } // namespace views |
OLD | NEW |