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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <iosfwd> | 9 #include <string> |
10 | 10 |
11 #include "ui/base/range/range.h" | 11 #include "ui/base/range/range.h" |
12 #include "ui/base/ui_export.h" | 12 #include "ui/base/ui_export.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 | 15 |
16 // VisualCursorDirection and LogicalCursorDirection represent directions of | 16 // VisualCursorDirection and LogicalCursorDirection represent directions of |
17 // motion of the cursor in BiDi text. The combinations that make sense are: | 17 // motion of the cursor in BiDi text. The combinations that make sense are: |
18 // | 18 // |
19 // base::i18n::TextDirection VisualCursorDirection LogicalCursorDirection | 19 // base::i18n::TextDirection VisualCursorDirection LogicalCursorDirection |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // The caret position is the end of the range. | 70 // The caret position is the end of the range. |
71 SelectionModel(ui::Range selection, LogicalCursorDirection affinity); | 71 SelectionModel(ui::Range selection, LogicalCursorDirection affinity); |
72 | 72 |
73 const ui::Range& selection() const { return selection_; } | 73 const ui::Range& selection() const { return selection_; } |
74 size_t caret_pos() const { return selection_.end(); } | 74 size_t caret_pos() const { return selection_.end(); } |
75 LogicalCursorDirection caret_affinity() const { return caret_affinity_; } | 75 LogicalCursorDirection caret_affinity() const { return caret_affinity_; } |
76 | 76 |
77 bool operator==(const SelectionModel& sel) const; | 77 bool operator==(const SelectionModel& sel) const; |
78 bool operator!=(const SelectionModel& sel) { return !(*this == sel); } | 78 bool operator!=(const SelectionModel& sel) { return !(*this == sel); } |
79 | 79 |
| 80 std::string ToString() const; |
| 81 |
80 private: | 82 private: |
81 friend class RenderText; | 83 friend class RenderText; |
82 | 84 |
83 // TODO(benrg): Generally the selection start should not be changed without | 85 // TODO(benrg): Generally the selection start should not be changed without |
84 // considering the effect on the caret affinity. This setter is exposed only | 86 // considering the effect on the caret affinity. This setter is exposed only |
85 // to RenderText to discourage misuse, and should probably be removed. | 87 // to RenderText to discourage misuse, and should probably be removed. |
86 void set_selection_start(size_t pos) { selection_.set_start(pos); } | 88 void set_selection_start(size_t pos) { selection_.set_start(pos); } |
87 | 89 |
88 // Logical selection. The logical caret position is the end of the selection. | 90 // Logical selection. The logical caret position is the end of the selection. |
89 ui::Range selection_; | 91 ui::Range selection_; |
(...skipping 10 matching lines...) Expand all Loading... |
100 // 0 |abcFED |abcFED | 102 // 0 |abcFED |abcFED |
101 // 1 a|bcFED a|bcFED | 103 // 1 a|bcFED a|bcFED |
102 // 2 ab|cFED ab|cFED | 104 // 2 ab|cFED ab|cFED |
103 // 3 abc|FED abcFED| | 105 // 3 abc|FED abcFED| |
104 // 4 abcFE|D abcFE|D | 106 // 4 abcFE|D abcFE|D |
105 // 5 abcF|ED abcF|ED | 107 // 5 abcF|ED abcF|ED |
106 // 6 abc|FED abcFED| | 108 // 6 abc|FED abcFED| |
107 LogicalCursorDirection caret_affinity_; | 109 LogicalCursorDirection caret_affinity_; |
108 }; | 110 }; |
109 | 111 |
110 UI_EXPORT std::ostream& operator<<(std::ostream& out, | |
111 const SelectionModel& sel); | |
112 | |
113 } // namespace gfx | 112 } // namespace gfx |
114 | 113 |
115 #endif // UI_GFX_SELECTION_MODEL_H_ | 114 #endif // UI_GFX_SELECTION_MODEL_H_ |
OLD | NEW |