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_WIN_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_WIN_H_ |
6 #define UI_GFX_RENDER_TEXT_WIN_H_ | 6 #define UI_GFX_RENDER_TEXT_WIN_H_ |
7 | 7 |
8 #include <usp10.h> | 8 #include <usp10.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } // namespace internal | 57 } // namespace internal |
58 | 58 |
59 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. | 59 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. |
60 class RenderTextWin : public RenderText { | 60 class RenderTextWin : public RenderText { |
61 public: | 61 public: |
62 RenderTextWin(); | 62 RenderTextWin(); |
63 virtual ~RenderTextWin(); | 63 virtual ~RenderTextWin(); |
64 | 64 |
65 // Overridden from RenderText: | 65 // Overridden from RenderText: |
66 virtual Size GetStringSize() OVERRIDE; | 66 virtual Size GetStringSize() OVERRIDE; |
| 67 virtual Size GetMultilineTextSize() OVERRIDE; |
67 virtual int GetBaseline() OVERRIDE; | 68 virtual int GetBaseline() OVERRIDE; |
68 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; | 69 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
69 virtual std::vector<FontSpan> GetFontSpansForTesting() OVERRIDE; | 70 virtual std::vector<FontSpan> GetFontSpansForTesting() OVERRIDE; |
70 | 71 |
71 protected: | 72 protected: |
72 // Overridden from RenderText: | 73 // Overridden from RenderText: |
73 virtual SelectionModel AdjacentCharSelectionModel( | 74 virtual SelectionModel AdjacentCharSelectionModel( |
74 const SelectionModel& selection, | 75 const SelectionModel& selection, |
75 VisualCursorDirection direction) OVERRIDE; | 76 VisualCursorDirection direction) OVERRIDE; |
76 virtual SelectionModel AdjacentWordSelectionModel( | 77 virtual SelectionModel AdjacentWordSelectionModel( |
77 const SelectionModel& selection, | 78 const SelectionModel& selection, |
78 VisualCursorDirection direction) OVERRIDE; | 79 VisualCursorDirection direction) OVERRIDE; |
79 virtual ui::Range GetGlyphBounds(size_t index) OVERRIDE; | 80 virtual ui::Range GetGlyphBounds(size_t index) OVERRIDE; |
80 virtual std::vector<Rect> GetSubstringBounds(const ui::Range& range) OVERRIDE; | 81 virtual std::vector<Rect> GetSubstringBounds(const ui::Range& range) OVERRIDE; |
81 virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE; | 82 virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE; |
82 virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE; | 83 virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE; |
83 virtual bool IsCursorablePosition(size_t position) OVERRIDE; | 84 virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
84 virtual void ResetLayout() OVERRIDE; | 85 virtual void ResetLayout() OVERRIDE; |
85 virtual void EnsureLayout() OVERRIDE; | 86 virtual void EnsureLayout() OVERRIDE; |
86 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; | 87 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
87 | 88 |
88 private: | 89 private: |
89 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); | 90 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); |
| 91 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_MinWidth); |
| 92 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); |
90 | 93 |
91 void ItemizeLogicalText(); | 94 void ItemizeLogicalText(); |
92 void LayoutVisualText(); | 95 void LayoutVisualText(); |
93 void LayoutTextRun(internal::TextRun* run); | 96 void LayoutTextRun(internal::TextRun* run); |
94 | 97 |
95 // Helper function that calls |ScriptShape()| on the run, which has logic to | 98 // Helper function that calls |ScriptShape()| on the run, which has logic to |
96 // handle E_OUTOFMEMORY return codes. | 99 // handle E_OUTOFMEMORY return codes. |
97 HRESULT ShapeTextRunWithFont(internal::TextRun* run, const Font& font); | 100 HRESULT ShapeTextRunWithFont(internal::TextRun* run, const Font& font); |
98 | 101 |
99 // Returns the number of characters in |run| that have missing glyphs. | 102 // Returns the number of characters in |run| that have missing glyphs. |
(...skipping 15 matching lines...) Expand all Loading... |
115 | 118 |
116 // Cached map from font name to the last successful substitute font used. | 119 // Cached map from font name to the last successful substitute font used. |
117 // TODO(asvitkine): Move the caching logic to font_fallback_win.cc. | 120 // TODO(asvitkine): Move the caching logic to font_fallback_win.cc. |
118 static std::map<std::string, Font> successful_substitute_fonts_; | 121 static std::map<std::string, Font> successful_substitute_fonts_; |
119 | 122 |
120 SCRIPT_CONTROL script_control_; | 123 SCRIPT_CONTROL script_control_; |
121 SCRIPT_STATE script_state_; | 124 SCRIPT_STATE script_state_; |
122 | 125 |
123 ScopedVector<internal::TextRun> runs_; | 126 ScopedVector<internal::TextRun> runs_; |
124 Size string_size_; | 127 Size string_size_; |
| 128 Size multiline_string_size_; |
125 | 129 |
126 // A common vertical baseline for all the text runs. This is computed as the | 130 // A common vertical baseline for all the text runs. This is computed as the |
127 // largest baseline over all the runs' fonts. | 131 // largest baseline over all the runs' fonts. |
128 int common_baseline_; | 132 int common_baseline_; |
129 | 133 |
130 scoped_ptr<int[]> visual_to_logical_; | 134 scoped_ptr<int[]> visual_to_logical_; |
131 scoped_ptr<int[]> logical_to_visual_; | 135 scoped_ptr<int[]> logical_to_visual_; |
132 | 136 |
133 bool needs_layout_; | 137 bool needs_layout_; |
134 | 138 |
135 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); | 139 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); |
136 }; | 140 }; |
137 | 141 |
138 } // namespace gfx | 142 } // namespace gfx |
139 | 143 |
140 #endif // UI_GFX_RENDER_TEXT_WIN_H_ | 144 #endif // UI_GFX_RENDER_TEXT_WIN_H_ |
OLD | NEW |