OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2007, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2007, 2011 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 , m_len(len) | 59 , m_len(len) |
60 , m_xpos(xpos) | 60 , m_xpos(xpos) |
61 , m_horizontalGlyphStretch(1) | 61 , m_horizontalGlyphStretch(1) |
62 , m_expansion(expansion) | 62 , m_expansion(expansion) |
63 , m_expansionBehavior(expansionBehavior) | 63 , m_expansionBehavior(expansionBehavior) |
64 , m_is8Bit(true) | 64 , m_is8Bit(true) |
65 , m_allowTabs(false) | 65 , m_allowTabs(false) |
66 , m_direction(direction) | 66 , m_direction(direction) |
67 , m_directionalOverride(directionalOverride) | 67 , m_directionalOverride(directionalOverride) |
68 , m_characterScanForCodePath(characterScanForCodePath) | 68 , m_characterScanForCodePath(characterScanForCodePath) |
| 69 , m_useComplexCodePath(false) |
69 , m_disableSpacing(false) | 70 , m_disableSpacing(false) |
70 , m_tabSize(0) | 71 , m_tabSize(0) |
71 , m_normalizeSpace(false) | 72 , m_normalizeSpace(false) |
72 { | 73 { |
73 m_data.characters8 = c; | 74 m_data.characters8 = c; |
74 } | 75 } |
75 | 76 |
76 TextRun(const UChar* c, unsigned len, float xpos = 0, float expansion = 0, E
xpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpan
sion, TextDirection direction = LTR, bool directionalOverride = false, bool char
acterScanForCodePath = true) | 77 TextRun(const UChar* c, unsigned len, float xpos = 0, float expansion = 0, E
xpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpan
sion, TextDirection direction = LTR, bool directionalOverride = false, bool char
acterScanForCodePath = true) |
77 : m_charactersLength(len) | 78 : m_charactersLength(len) |
78 , m_len(len) | 79 , m_len(len) |
79 , m_xpos(xpos) | 80 , m_xpos(xpos) |
80 , m_horizontalGlyphStretch(1) | 81 , m_horizontalGlyphStretch(1) |
81 , m_expansion(expansion) | 82 , m_expansion(expansion) |
82 , m_expansionBehavior(expansionBehavior) | 83 , m_expansionBehavior(expansionBehavior) |
83 , m_is8Bit(false) | 84 , m_is8Bit(false) |
84 , m_allowTabs(false) | 85 , m_allowTabs(false) |
85 , m_direction(direction) | 86 , m_direction(direction) |
86 , m_directionalOverride(directionalOverride) | 87 , m_directionalOverride(directionalOverride) |
87 , m_characterScanForCodePath(characterScanForCodePath) | 88 , m_characterScanForCodePath(characterScanForCodePath) |
| 89 , m_useComplexCodePath(false) |
88 , m_disableSpacing(false) | 90 , m_disableSpacing(false) |
89 , m_tabSize(0) | 91 , m_tabSize(0) |
90 , m_normalizeSpace(false) | 92 , m_normalizeSpace(false) |
91 { | 93 { |
92 m_data.characters16 = c; | 94 m_data.characters16 = c; |
93 } | 95 } |
94 | 96 |
95 TextRun(const String& string, float xpos = 0, float expansion = 0, Expansion
Behavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, Te
xtDirection direction = LTR, bool directionalOverride = false, bool characterSca
nForCodePath = true, bool normalizeSpace = false) | 97 TextRun(const String& string, float xpos = 0, float expansion = 0, Expansion
Behavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, Te
xtDirection direction = LTR, bool directionalOverride = false, bool characterSca
nForCodePath = true, bool normalizeSpace = false) |
96 : m_charactersLength(string.length()) | 98 : m_charactersLength(string.length()) |
97 , m_len(string.length()) | 99 , m_len(string.length()) |
98 , m_xpos(xpos) | 100 , m_xpos(xpos) |
99 , m_horizontalGlyphStretch(1) | 101 , m_horizontalGlyphStretch(1) |
100 , m_expansion(expansion) | 102 , m_expansion(expansion) |
101 , m_expansionBehavior(expansionBehavior) | 103 , m_expansionBehavior(expansionBehavior) |
102 , m_allowTabs(false) | 104 , m_allowTabs(false) |
103 , m_direction(direction) | 105 , m_direction(direction) |
104 , m_directionalOverride(directionalOverride) | 106 , m_directionalOverride(directionalOverride) |
105 , m_characterScanForCodePath(characterScanForCodePath) | 107 , m_characterScanForCodePath(characterScanForCodePath) |
| 108 , m_useComplexCodePath(false) |
106 , m_disableSpacing(false) | 109 , m_disableSpacing(false) |
107 , m_tabSize(0) | 110 , m_tabSize(0) |
108 , m_normalizeSpace(normalizeSpace) | 111 , m_normalizeSpace(normalizeSpace) |
109 { | 112 { |
110 if (!m_charactersLength) { | 113 if (!m_charactersLength) { |
111 m_is8Bit = true; | 114 m_is8Bit = true; |
112 m_data.characters8 = 0; | 115 m_data.characters8 = 0; |
113 } else if (string.is8Bit()) { | 116 } else if (string.is8Bit()) { |
114 m_data.characters8 = string.characters8(); | 117 m_data.characters8 = string.characters8(); |
115 m_is8Bit = true; | 118 m_is8Bit = true; |
116 } else { | 119 } else { |
117 m_data.characters16 = string.characters16(); | 120 m_data.characters16 = string.characters16(); |
118 m_is8Bit = false; | 121 m_is8Bit = false; |
119 } | 122 } |
120 } | 123 } |
121 | 124 |
122 TextRun(const StringView& string, float xpos = 0, float expansion = 0, Expan
sionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion
, TextDirection direction = LTR, bool directionalOverride = false, bool characte
rScanForCodePath = true, bool normalizeSpace = false) | 125 TextRun(const StringView& string, float xpos = 0, float expansion = 0, Expan
sionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion
, TextDirection direction = LTR, bool directionalOverride = false, bool characte
rScanForCodePath = true, bool normalizeSpace = false) |
123 : m_charactersLength(string.length()) | 126 : m_charactersLength(string.length()) |
124 , m_len(string.length()) | 127 , m_len(string.length()) |
125 , m_xpos(xpos) | 128 , m_xpos(xpos) |
126 , m_horizontalGlyphStretch(1) | 129 , m_horizontalGlyphStretch(1) |
127 , m_expansion(expansion) | 130 , m_expansion(expansion) |
128 , m_expansionBehavior(expansionBehavior) | 131 , m_expansionBehavior(expansionBehavior) |
129 , m_allowTabs(false) | 132 , m_allowTabs(false) |
130 , m_direction(direction) | 133 , m_direction(direction) |
131 , m_directionalOverride(directionalOverride) | 134 , m_directionalOverride(directionalOverride) |
132 , m_characterScanForCodePath(characterScanForCodePath) | 135 , m_characterScanForCodePath(characterScanForCodePath) |
| 136 , m_useComplexCodePath(false) |
133 , m_disableSpacing(false) | 137 , m_disableSpacing(false) |
134 , m_tabSize(0) | 138 , m_tabSize(0) |
135 , m_normalizeSpace(normalizeSpace) | 139 , m_normalizeSpace(normalizeSpace) |
136 { | 140 { |
137 if (!m_charactersLength) { | 141 if (!m_charactersLength) { |
138 m_is8Bit = true; | 142 m_is8Bit = true; |
139 m_data.characters8 = 0; | 143 m_data.characters8 = 0; |
140 } else if (string.is8Bit()) { | 144 } else if (string.is8Bit()) { |
141 m_data.characters8 = string.characters8(); | 145 m_data.characters8 = string.characters8(); |
142 m_is8Bit = true; | 146 m_is8Bit = true; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 float xPos() const { return m_xpos; } | 193 float xPos() const { return m_xpos; } |
190 void setXPos(float xPos) { m_xpos = xPos; } | 194 void setXPos(float xPos) { m_xpos = xPos; } |
191 float expansion() const { return m_expansion; } | 195 float expansion() const { return m_expansion; } |
192 bool allowsLeadingExpansion() const { return m_expansionBehavior & AllowLead
ingExpansion; } | 196 bool allowsLeadingExpansion() const { return m_expansionBehavior & AllowLead
ingExpansion; } |
193 bool allowsTrailingExpansion() const { return m_expansionBehavior & AllowTra
ilingExpansion; } | 197 bool allowsTrailingExpansion() const { return m_expansionBehavior & AllowTra
ilingExpansion; } |
194 TextDirection direction() const { return static_cast<TextDirection>(m_direct
ion); } | 198 TextDirection direction() const { return static_cast<TextDirection>(m_direct
ion); } |
195 bool rtl() const { return m_direction == RTL; } | 199 bool rtl() const { return m_direction == RTL; } |
196 bool ltr() const { return m_direction == LTR; } | 200 bool ltr() const { return m_direction == LTR; } |
197 bool directionalOverride() const { return m_directionalOverride; } | 201 bool directionalOverride() const { return m_directionalOverride; } |
198 bool characterScanForCodePath() const { return m_characterScanForCodePath; } | 202 bool characterScanForCodePath() const { return m_characterScanForCodePath; } |
| 203 bool useComplexCodePath() const { return m_useComplexCodePath; } |
199 bool spacingDisabled() const { return m_disableSpacing; } | 204 bool spacingDisabled() const { return m_disableSpacing; } |
200 | 205 |
201 void disableSpacing() { m_disableSpacing = true; } | 206 void disableSpacing() { m_disableSpacing = true; } |
202 void setDirection(TextDirection direction) { m_direction = direction; } | 207 void setDirection(TextDirection direction) { m_direction = direction; } |
203 void setDirectionalOverride(bool override) { m_directionalOverride = overrid
e; } | 208 void setDirectionalOverride(bool override) { m_directionalOverride = overrid
e; } |
204 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s
can; } | 209 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s
can; } |
| 210 void setUseComplexCodePath(bool useComplex) { m_useComplexCodePath = useComp
lex; } |
205 | 211 |
206 class RenderingContext : public RefCounted<RenderingContext> { | 212 class RenderingContext : public RefCounted<RenderingContext> { |
207 public: | 213 public: |
208 virtual ~RenderingContext() { } | 214 virtual ~RenderingContext() { } |
209 | 215 |
210 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Wid
thIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& adv
anceLength) = 0; | 216 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Wid
thIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& adv
anceLength) = 0; |
211 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl
eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; | 217 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl
eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; |
212 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& c
harsConsumed, Glyph& glyphId) const = 0; | 218 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& c
harsConsumed, Glyph& glyphId) const = 0; |
213 }; | 219 }; |
214 | 220 |
(...skipping 14 matching lines...) Expand all Loading... |
229 float m_xpos; | 235 float m_xpos; |
230 float m_horizontalGlyphStretch; | 236 float m_horizontalGlyphStretch; |
231 | 237 |
232 float m_expansion; | 238 float m_expansion; |
233 ExpansionBehavior m_expansionBehavior : 2; | 239 ExpansionBehavior m_expansionBehavior : 2; |
234 unsigned m_is8Bit : 1; | 240 unsigned m_is8Bit : 1; |
235 unsigned m_allowTabs : 1; | 241 unsigned m_allowTabs : 1; |
236 unsigned m_direction : 1; | 242 unsigned m_direction : 1; |
237 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. | 243 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. |
238 unsigned m_characterScanForCodePath : 1; | 244 unsigned m_characterScanForCodePath : 1; |
| 245 unsigned m_useComplexCodePath : 1; |
239 unsigned m_disableSpacing : 1; | 246 unsigned m_disableSpacing : 1; |
240 unsigned m_tabSize; | 247 unsigned m_tabSize; |
241 bool m_normalizeSpace; | 248 bool m_normalizeSpace; |
242 RefPtr<RenderingContext> m_renderingContext; | 249 RefPtr<RenderingContext> m_renderingContext; |
243 }; | 250 }; |
244 | 251 |
245 inline void TextRun::setTabSize(bool allow, unsigned size) | 252 inline void TextRun::setTabSize(bool allow, unsigned size) |
246 { | 253 { |
247 m_allowTabs = allow; | 254 m_allowTabs = allow; |
248 m_tabSize = size; | 255 m_tabSize = size; |
249 } | 256 } |
250 | 257 |
251 // Container for parameters needed to paint TextRun. | 258 // Container for parameters needed to paint TextRun. |
252 struct TextRunPaintInfo { | 259 struct TextRunPaintInfo { |
253 explicit TextRunPaintInfo(const TextRun& r) | 260 explicit TextRunPaintInfo(const TextRun& r) |
254 : run(r) | 261 : run(r) |
255 , from(0) | 262 , from(0) |
256 , to(r.length()) | 263 , to(r.length()) |
257 { | 264 { |
258 } | 265 } |
259 | 266 |
260 const TextRun& run; | 267 const TextRun& run; |
261 int from; | 268 int from; |
262 int to; | 269 int to; |
263 FloatRect bounds; | 270 FloatRect bounds; |
264 }; | 271 }; |
265 | 272 |
266 } | 273 } |
267 #endif | 274 #endif |
OLD | NEW |