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 #ifndef UI_GFX_RENDER_TEXT_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_H_ |
| 6 #define UI_GFX_RENDER_TEXT_H_ | 6 #define UI_GFX_RENDER_TEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 CaretPlacement caret_placement() const { return caret_placement_; } | 114 CaretPlacement caret_placement() const { return caret_placement_; } |
| 115 void set_caret_placement(CaretPlacement placement) { | 115 void set_caret_placement(CaretPlacement placement) { |
| 116 caret_placement_ = placement; | 116 caret_placement_ = placement; |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool Equals(const SelectionModel& sel) const; | 119 bool Equals(const SelectionModel& sel) const; |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 void Init(size_t start, size_t end, size_t pos, CaretPlacement status); | 122 void Init(size_t start, size_t end, size_t pos, CaretPlacement status); |
| 123 | 123 |
| 124 // Logical selection start. If there is non-empty selection, the selection | 124 // Logical selection start. If there is non-empty selection, if |
| 125 // always starts visually at the leading edge of the selection_start. So, we | 125 // selection_start_ is less than selection_end_, the selection starts visually |
| 126 // do not need extra information for visual selection bounding. | 126 // at the leading edge of the selection_start_. If selection_start_ is greater |
| 127 // than selection_end_, the selection starts visually at the trailing edge of | |
| 128 // selection_start_'s previous grapheme. So, we do not need extra information | |
|
msw
2011/08/19 23:16:59
Is that true? Isn't it always leading the selectio
xji
2011/08/22 23:57:28
The above example wont show any difference.
But th
msw
2011/08/23 08:01:01
Ok, I think I understand and it seems that you are
| |
| 129 // for visual bounding. | |
| 127 size_t selection_start_; | 130 size_t selection_start_; |
| 128 | 131 |
| 129 // The logical cursor position that next character will be inserted into. | 132 // The logical cursor position that next character will be inserted into. |
| 130 // It is also the end of the selection. | 133 // It is also the end of the selection. |
| 131 size_t selection_end_; | 134 size_t selection_end_; |
| 132 | 135 |
| 133 // The following two fields are used to guide cursor visual position. | 136 // The following two fields are used to guide cursor visual position. |
| 134 // The index of the character that cursor is visually attached to. | 137 // The index of the character that cursor is visually attached to. |
| 135 size_t caret_pos_; | 138 size_t caret_pos_; |
| 136 // The visual placement of the cursor, relative to its associated character. | 139 // The visual placement of the cursor, relative to its associated character. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 | 294 |
| 292 // Clear out |style_ranges_|. | 295 // Clear out |style_ranges_|. |
| 293 void ClearStyleRanges(); | 296 void ClearStyleRanges(); |
| 294 | 297 |
| 295 bool IsPositionAtWordSelectionBoundary(size_t pos); | 298 bool IsPositionAtWordSelectionBoundary(size_t pos); |
| 296 | 299 |
| 297 // Update the cached bounds and display offset to ensure that the current | 300 // Update the cached bounds and display offset to ensure that the current |
| 298 // cursor is within the visible display area. | 301 // cursor is within the visible display area. |
| 299 void UpdateCachedBoundsAndOffset(); | 302 void UpdateCachedBoundsAndOffset(); |
| 300 | 303 |
| 304 // Returns the selection model of selection_start_. | |
| 305 // The returned value represents a cursor/caret position without a selection. | |
| 306 SelectionModel GetSelectionModelForSelectionStart(); | |
| 307 | |
| 301 // Logical UTF-16 string data to be drawn. | 308 // Logical UTF-16 string data to be drawn. |
| 302 string16 text_; | 309 string16 text_; |
| 303 | 310 |
| 304 // Logical selection range and visual cursor position. | 311 // Logical selection range and visual cursor position. |
| 305 SelectionModel selection_model_; | 312 SelectionModel selection_model_; |
| 306 | 313 |
| 307 // The cached cursor bounds; get these bounds with GetUpdatedCursorBounds. | 314 // The cached cursor bounds; get these bounds with GetUpdatedCursorBounds. |
| 308 Rect cursor_bounds_; | 315 Rect cursor_bounds_; |
| 309 | 316 |
| 310 // The cursor visibility and insert mode. | 317 // The cursor visibility and insert mode. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 332 // SetCursorPosition, SetSelectionModel, Font related style change, and other | 339 // SetCursorPosition, SetSelectionModel, Font related style change, and other |
| 333 // operations that adjust the visible text bounds. | 340 // operations that adjust the visible text bounds. |
| 334 bool cached_bounds_and_offset_valid_; | 341 bool cached_bounds_and_offset_valid_; |
| 335 | 342 |
| 336 DISALLOW_COPY_AND_ASSIGN(RenderText); | 343 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 337 }; | 344 }; |
| 338 | 345 |
| 339 } // namespace gfx | 346 } // namespace gfx |
| 340 | 347 |
| 341 #endif // UI_GFX_RENDER_TEXT_H_ | 348 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |