OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_GFX_SELECTION_MODEL_H_ | 5 #ifndef UI_GFX_SELECTION_MODEL_H_ |
6 #define UI_GFX_SELECTION_MODEL_H_ | 6 #define UI_GFX_SELECTION_MODEL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Create a SelectionModel representing a selection (which may be empty). | 70 // Create a SelectionModel representing a selection (which may be empty). |
71 // The caret position is the end of the range. | 71 // The caret position is the end of the range. |
72 SelectionModel(const Range& selection, LogicalCursorDirection affinity); | 72 SelectionModel(const Range& selection, LogicalCursorDirection affinity); |
73 | 73 |
74 const Range& selection() const { return selection_; } | 74 const Range& selection() const { return selection_; } |
75 size_t caret_pos() const { return selection_.end(); } | 75 size_t caret_pos() const { return selection_.end(); } |
76 LogicalCursorDirection caret_affinity() const { return caret_affinity_; } | 76 LogicalCursorDirection caret_affinity() const { return caret_affinity_; } |
77 | 77 |
78 // WARNING: Generally the selection start should not be changed without | 78 // WARNING: Generally the selection start should not be changed without |
79 // considering the effect on the caret affinity. | 79 // considering the effect on the caret affinity. |
80 void set_selection_start(size_t pos) { selection_.set_start(pos); } | 80 void set_selection_start(uint32_t pos) { selection_.set_start(pos); } |
81 | 81 |
82 bool operator==(const SelectionModel& sel) const; | 82 bool operator==(const SelectionModel& sel) const; |
83 bool operator!=(const SelectionModel& sel) const { return !(*this == sel); } | 83 bool operator!=(const SelectionModel& sel) const { return !(*this == sel); } |
84 | 84 |
85 std::string ToString() const; | 85 std::string ToString() const; |
86 | 86 |
87 private: | 87 private: |
88 // Logical selection. The logical caret position is the end of the selection. | 88 // Logical selection. The logical caret position is the end of the selection. |
89 Range selection_; | 89 Range selection_; |
90 | 90 |
(...skipping 12 matching lines...) Expand all Loading... |
103 // 3 abc|FED abcFED| | 103 // 3 abc|FED abcFED| |
104 // 4 abcFE|D abcFE|D | 104 // 4 abcFE|D abcFE|D |
105 // 5 abcF|ED abcF|ED | 105 // 5 abcF|ED abcF|ED |
106 // 6 abc|FED abcFED| | 106 // 6 abc|FED abcFED| |
107 LogicalCursorDirection caret_affinity_; | 107 LogicalCursorDirection caret_affinity_; |
108 }; | 108 }; |
109 | 109 |
110 } // namespace gfx | 110 } // namespace gfx |
111 | 111 |
112 #endif // UI_GFX_SELECTION_MODEL_H_ | 112 #endif // UI_GFX_SELECTION_MODEL_H_ |
OLD | NEW |