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_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 #include <vector> | 10 #include <vector> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; | 44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
45 | 45 |
46 private: | 46 private: |
47 virtual size_t IndexOfAdjacentGrapheme( | 47 virtual size_t IndexOfAdjacentGrapheme( |
48 size_t index, | 48 size_t index, |
49 LogicalCursorDirection direction) OVERRIDE; | 49 LogicalCursorDirection direction) OVERRIDE; |
50 | 50 |
51 // Returns the run that contains |position|. Return NULL if not found. | 51 // Returns the run that contains |position|. Return NULL if not found. |
52 GSList* GetRunContainingPosition(size_t position) const; | 52 GSList* GetRunContainingPosition(size_t position) const; |
53 | 53 |
54 // Given |utf8_index_of_current_grapheme|, returns the UTF-8 index of the | 54 // Given |layout_index_of_current_grapheme|, returns the layout (UTF-8) index |
55 // |next| or previous grapheme in logical order. Returns 0 if there is no | 55 // of the |next| or previous grapheme in logical order. Returns 0 if there is |
56 // previous grapheme, or the |text_| length if there is no next grapheme. | 56 // no previous grapheme, or the |text_| length if there is no next grapheme. |
57 size_t Utf8IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, | 57 size_t LayoutIndexOfAdjacentGrapheme(size_t layout_index_of_current_grapheme, |
58 LogicalCursorDirection direction) const; | 58 LogicalCursorDirection direction) const; |
59 | 59 |
60 // Given a |run|, returns the SelectionModel that contains the logical first | 60 // Given a |run|, returns the SelectionModel that contains the logical first |
61 // or last caret position inside (not at a boundary of) the run. | 61 // or last caret position inside (not at a boundary of) the run. |
62 // The returned value represents a cursor/caret position without a selection. | 62 // The returned value represents a cursor/caret position without a selection. |
63 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; | 63 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; |
64 SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; | 64 SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; |
65 | 65 |
66 // Unref |layout_| and |pango_line_|. Set them to NULL. | 66 // Unref |layout_| and |pango_line_|. Set them to NULL. |
67 void ResetLayout(); | 67 void ResetLayout(); |
68 | 68 |
69 // Setup pango attribute: foreground, background, font, strike. | 69 // Setup pango attribute: foreground, background, font, strike. |
70 void SetupPangoAttributes(PangoLayout* layout); | 70 void SetupPangoAttributes(PangoLayout* layout); |
71 | 71 |
72 // Append one pango attribute |pango_attr| into pango attribute list |attrs|. | 72 // Append one pango attribute |pango_attr| into pango attribute list |attrs|. |
73 void AppendPangoAttribute(size_t start, | 73 void AppendPangoAttribute(size_t start, |
74 size_t end, | 74 size_t end, |
75 PangoAttribute* pango_attr, | 75 PangoAttribute* pango_attr, |
76 PangoAttrList* attrs); | 76 PangoAttrList* attrs); |
77 | 77 |
78 size_t Utf16IndexToUtf8Index(size_t index) const; | 78 // Convert between indices into text() and indices into |layout_text_|. |
79 size_t Utf8IndexToUtf16Index(size_t index) const; | 79 size_t TextIndexToLayoutIndex(size_t index) const; |
| 80 size_t LayoutIndexToTextIndex(size_t index) const; |
80 | 81 |
81 // Calculate the visual bounds containing the logical substring within |from| | 82 // Calculate the visual bounds containing the logical substring within |from| |
82 // to |to|. | 83 // to |to|. |
83 std::vector<Rect> CalculateSubstringBounds(size_t from, size_t to); | 84 std::vector<Rect> CalculateSubstringBounds(size_t from, size_t to); |
84 | 85 |
85 // Get the visual bounds of the logical selection. | 86 // Get the visual bounds of the logical selection. |
86 std::vector<Rect> GetSelectionBounds(); | 87 std::vector<Rect> GetSelectionBounds(); |
87 | 88 |
88 // Pango Layout. | 89 // Pango Layout. |
89 PangoLayout* layout_; | 90 PangoLayout* layout_; |
(...skipping 12 matching lines...) Expand all Loading... |
102 const char* layout_text_; | 103 const char* layout_text_; |
103 // The text length. | 104 // The text length. |
104 size_t layout_text_len_; | 105 size_t layout_text_len_; |
105 | 106 |
106 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); | 107 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); |
107 }; | 108 }; |
108 | 109 |
109 } // namespace gfx | 110 } // namespace gfx |
110 | 111 |
111 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ | 112 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ |
OLD | NEW |