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_LINUX_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_LINUX_H_ |
6 #define UI_GFX_RENDER_TEXT_LINUX_H_ | 6 #define UI_GFX_RENDER_TEXT_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <pango/pango.h> | 9 #include <pango/pango.h> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 bool insert_mode) OVERRIDE; | 32 bool insert_mode) OVERRIDE; |
33 | 33 |
34 protected: | 34 protected: |
35 // Overridden from RenderText: | 35 // Overridden from RenderText: |
36 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, | 36 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, |
37 BreakType break_type) OVERRIDE; | 37 BreakType break_type) OVERRIDE; |
38 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, | 38 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, |
39 BreakType break_type) OVERRIDE; | 39 BreakType break_type) OVERRIDE; |
40 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; | 40 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; |
41 virtual SelectionModel RightEndSelectionModel() OVERRIDE; | 41 virtual SelectionModel RightEndSelectionModel() OVERRIDE; |
42 virtual size_t GetIndexOfPreviousGrapheme(size_t position) OVERRIDE; | 42 virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
43 | 43 |
44 private: | 44 private: |
45 enum RelativeLogicalPosition { | 45 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; |
46 PREVIOUS, | |
47 NEXT | |
48 }; | |
49 | |
50 // Get the logical start index of the next grapheme after |position|. | |
51 size_t GetIndexOfNextGrapheme(size_t position); | |
52 | 46 |
53 // Returns the run that contains |position|. Return NULL if not found. | 47 // Returns the run that contains |position|. Return NULL if not found. |
54 GSList* GetRunContainingPosition(size_t position) const; | 48 GSList* GetRunContainingPosition(size_t position) const; |
55 | 49 |
56 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of | 50 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of |
57 // next grapheme in the text if |pos| is NEXT, otherwise, returns the index of | 51 // next grapheme in the text if |next| is true, otherwise, returns the index |
58 // previous grapheme. Returns 0 if there is no previous grapheme, and returns | 52 // of previous grapheme. Returns 0 if there is no previous grapheme, and |
59 // the |text_| length if there is no next grapheme. | 53 // returns the |text_| length if there is no next grapheme. |
60 size_t Utf8IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, | 54 size_t Utf8IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, |
61 RelativeLogicalPosition pos) const; | 55 bool next) const; |
62 size_t Utf16IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, | 56 size_t Utf16IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, |
63 RelativeLogicalPosition pos) const; | 57 bool next) const; |
64 | 58 |
65 // Given a |run|, returns the SelectionModel that contains the logical first | 59 // Given a |run|, returns the SelectionModel that contains the logical first |
66 // or last caret position inside (not at a boundary of) the run. | 60 // or last caret position inside (not at a boundary of) the run. |
67 // The returned value represents a cursor/caret position without a selection. | 61 // The returned value represents a cursor/caret position without a selection. |
68 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; | 62 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; |
69 SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; | 63 SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; |
70 | 64 |
71 // Get the selection model visually left or right of |current| by one | 65 // Get the selection model visually left or right of |current| by one |
72 // grapheme. | 66 // grapheme. |
73 // The returned value represents a cursor/caret position without a selection. | 67 // The returned value represents a cursor/caret position without a selection. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 const char* layout_text_; | 109 const char* layout_text_; |
116 // The text length. | 110 // The text length. |
117 size_t layout_text_len_; | 111 size_t layout_text_len_; |
118 | 112 |
119 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); | 113 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); |
120 }; | 114 }; |
121 | 115 |
122 } // namespace gfx; | 116 } // namespace gfx; |
123 | 117 |
124 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ | 118 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ |
OLD | NEW |