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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_disableSpacing(false) | 69 , m_disableSpacing(false) |
70 , m_tabSize(0) | 70 , m_tabSize(0) |
71 , m_spaceNormalize(false) | |
71 { | 72 { |
72 m_data.characters8 = c; | 73 m_data.characters8 = c; |
73 } | 74 } |
74 | 75 |
75 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) | 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) |
76 : m_charactersLength(len) | 77 : m_charactersLength(len) |
77 , m_len(len) | 78 , m_len(len) |
78 , m_xpos(xpos) | 79 , m_xpos(xpos) |
79 , m_horizontalGlyphStretch(1) | 80 , m_horizontalGlyphStretch(1) |
80 , m_expansion(expansion) | 81 , m_expansion(expansion) |
81 , m_expansionBehavior(expansionBehavior) | 82 , m_expansionBehavior(expansionBehavior) |
82 , m_is8Bit(false) | 83 , m_is8Bit(false) |
83 , m_allowTabs(false) | 84 , m_allowTabs(false) |
84 , m_direction(direction) | 85 , m_direction(direction) |
85 , m_directionalOverride(directionalOverride) | 86 , m_directionalOverride(directionalOverride) |
86 , m_characterScanForCodePath(characterScanForCodePath) | 87 , m_characterScanForCodePath(characterScanForCodePath) |
87 , m_disableSpacing(false) | 88 , m_disableSpacing(false) |
88 , m_tabSize(0) | 89 , m_tabSize(0) |
90 , m_spaceNormalize(false) | |
89 { | 91 { |
90 m_data.characters16 = c; | 92 m_data.characters16 = c; |
91 } | 93 } |
92 | 94 |
93 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) | 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 spaceNormalize = false) |
94 : m_charactersLength(string.length()) | 96 : m_charactersLength(string.length()) |
95 , m_len(string.length()) | 97 , m_len(string.length()) |
96 , m_xpos(xpos) | 98 , m_xpos(xpos) |
97 , m_horizontalGlyphStretch(1) | 99 , m_horizontalGlyphStretch(1) |
98 , m_expansion(expansion) | 100 , m_expansion(expansion) |
99 , m_expansionBehavior(expansionBehavior) | 101 , m_expansionBehavior(expansionBehavior) |
100 , m_allowTabs(false) | 102 , m_allowTabs(false) |
101 , m_direction(direction) | 103 , m_direction(direction) |
102 , m_directionalOverride(directionalOverride) | 104 , m_directionalOverride(directionalOverride) |
103 , m_characterScanForCodePath(characterScanForCodePath) | 105 , m_characterScanForCodePath(characterScanForCodePath) |
104 , m_disableSpacing(false) | 106 , m_disableSpacing(false) |
105 , m_tabSize(0) | 107 , m_tabSize(0) |
108 , m_spaceNormalize(spaceNormalize) | |
106 { | 109 { |
107 if (!m_charactersLength) { | 110 if (!m_charactersLength) { |
108 m_is8Bit = true; | 111 m_is8Bit = true; |
109 m_data.characters8 = 0; | 112 m_data.characters8 = 0; |
110 } else if (string.is8Bit()) { | 113 } else if (string.is8Bit()) { |
111 m_data.characters8 = string.characters8(); | 114 m_data.characters8 = string.characters8(); |
112 m_is8Bit = true; | 115 m_is8Bit = true; |
113 } else { | 116 } else { |
114 m_data.characters16 = string.characters16(); | 117 m_data.characters16 = string.characters16(); |
115 m_is8Bit = false; | 118 m_is8Bit = false; |
116 } | 119 } |
117 } | 120 } |
118 | 121 |
119 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) | 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 spaceNormalize = false) |
120 : m_charactersLength(string.length()) | 123 : m_charactersLength(string.length()) |
121 , m_len(string.length()) | 124 , m_len(string.length()) |
122 , m_xpos(xpos) | 125 , m_xpos(xpos) |
123 , m_horizontalGlyphStretch(1) | 126 , m_horizontalGlyphStretch(1) |
124 , m_expansion(expansion) | 127 , m_expansion(expansion) |
125 , m_expansionBehavior(expansionBehavior) | 128 , m_expansionBehavior(expansionBehavior) |
126 , m_allowTabs(false) | 129 , m_allowTabs(false) |
127 , m_direction(direction) | 130 , m_direction(direction) |
128 , m_directionalOverride(directionalOverride) | 131 , m_directionalOverride(directionalOverride) |
129 , m_characterScanForCodePath(characterScanForCodePath) | 132 , m_characterScanForCodePath(characterScanForCodePath) |
130 , m_disableSpacing(false) | 133 , m_disableSpacing(false) |
131 , m_tabSize(0) | 134 , m_tabSize(0) |
135 , m_spaceNormalize(spaceNormalize) | |
132 { | 136 { |
133 if (!m_charactersLength) { | 137 if (!m_charactersLength) { |
134 m_is8Bit = true; | 138 m_is8Bit = true; |
135 m_data.characters8 = 0; | 139 m_data.characters8 = 0; |
136 } else if (string.is8Bit()) { | 140 } else if (string.is8Bit()) { |
137 m_data.characters8 = string.characters8(); | 141 m_data.characters8 = string.characters8(); |
138 m_is8Bit = true; | 142 m_is8Bit = true; |
139 } else { | 143 } else { |
140 m_data.characters16 = string.characters16(); | 144 m_data.characters16 = string.characters16(); |
141 m_is8Bit = false; | 145 m_is8Bit = false; |
(...skipping 18 matching lines...) Expand all Loading... | |
160 const LChar* data8(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; } | 164 const LChar* data8(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; } |
161 const UChar* data16(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; } | 165 const UChar* data16(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; } |
162 | 166 |
163 const LChar* characters8() const { ASSERT(is8Bit()); return m_data.character s8; } | 167 const LChar* characters8() const { ASSERT(is8Bit()); return m_data.character s8; } |
164 const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.charact ers16; } | 168 const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.charact ers16; } |
165 | 169 |
166 bool is8Bit() const { return m_is8Bit; } | 170 bool is8Bit() const { return m_is8Bit; } |
167 int length() const { return m_len; } | 171 int length() const { return m_len; } |
168 int charactersLength() const { return m_charactersLength; } | 172 int charactersLength() const { return m_charactersLength; } |
169 | 173 |
174 bool isSpaceNormalize() const { return m_spaceNormalize; } | |
eae
2014/09/16 00:46:34
bool normalizeSpace()
void setNormalizeSpace
h.joshi
2014/09/16 05:48:11
Done.
| |
175 void setSpaceNormalize(bool spaceNormalize) { m_spaceNormalize = spaceNormal ize; } | |
176 | |
170 void setText(const LChar* c, unsigned len) { m_data.characters8 = c; m_len = len; m_is8Bit = true;} | 177 void setText(const LChar* c, unsigned len) { m_data.characters8 = c; m_len = len; m_is8Bit = true;} |
171 void setText(const UChar* c, unsigned len) { m_data.characters16 = c; m_len = len; m_is8Bit = false;} | 178 void setText(const UChar* c, unsigned len) { m_data.characters16 = c; m_len = len; m_is8Bit = false;} |
172 void setText(const String&); | 179 void setText(const String&); |
173 void setCharactersLength(unsigned charactersLength) { m_charactersLength = c haractersLength; } | 180 void setCharactersLength(unsigned charactersLength) { m_charactersLength = c haractersLength; } |
174 | 181 |
175 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; } | 182 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; } |
176 void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = sca le; } | 183 void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = sca le; } |
177 | 184 |
178 bool allowTabs() const { return m_allowTabs; } | 185 bool allowTabs() const { return m_allowTabs; } |
179 unsigned tabSize() const { return m_tabSize; } | 186 unsigned tabSize() const { return m_tabSize; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 | 231 |
225 float m_expansion; | 232 float m_expansion; |
226 ExpansionBehavior m_expansionBehavior : 2; | 233 ExpansionBehavior m_expansionBehavior : 2; |
227 unsigned m_is8Bit : 1; | 234 unsigned m_is8Bit : 1; |
228 unsigned m_allowTabs : 1; | 235 unsigned m_allowTabs : 1; |
229 unsigned m_direction : 1; | 236 unsigned m_direction : 1; |
230 unsigned m_directionalOverride : 1; // Was this direction set by an override character. | 237 unsigned m_directionalOverride : 1; // Was this direction set by an override character. |
231 unsigned m_characterScanForCodePath : 1; | 238 unsigned m_characterScanForCodePath : 1; |
232 unsigned m_disableSpacing : 1; | 239 unsigned m_disableSpacing : 1; |
233 unsigned m_tabSize; | 240 unsigned m_tabSize; |
241 bool m_spaceNormalize; | |
234 RefPtr<RenderingContext> m_renderingContext; | 242 RefPtr<RenderingContext> m_renderingContext; |
235 }; | 243 }; |
236 | 244 |
237 inline void TextRun::setTabSize(bool allow, unsigned size) | 245 inline void TextRun::setTabSize(bool allow, unsigned size) |
238 { | 246 { |
239 m_allowTabs = allow; | 247 m_allowTabs = allow; |
240 m_tabSize = size; | 248 m_tabSize = size; |
241 } | 249 } |
242 | 250 |
243 // Container for parameters needed to paint TextRun. | 251 // Container for parameters needed to paint TextRun. |
244 struct TextRunPaintInfo { | 252 struct TextRunPaintInfo { |
245 explicit TextRunPaintInfo(const TextRun& r) | 253 explicit TextRunPaintInfo(const TextRun& r) |
246 : run(r) | 254 : run(r) |
247 , from(0) | 255 , from(0) |
248 , to(r.length()) | 256 , to(r.length()) |
249 { | 257 { |
250 } | 258 } |
251 | 259 |
252 const TextRun& run; | 260 const TextRun& run; |
253 int from; | 261 int from; |
254 int to; | 262 int to; |
255 FloatRect bounds; | 263 FloatRect bounds; |
256 }; | 264 }; |
257 | 265 |
258 } | 266 } |
259 #endif | 267 #endif |
OLD | NEW |