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 24 matching lines...) Expand all Loading... | |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 class FloatPoint; | 37 class FloatPoint; |
38 class Font; | 38 class Font; |
39 class GraphicsContext; | 39 class GraphicsContext; |
40 class GlyphBuffer; | 40 class GlyphBuffer; |
41 class SimpleFontData; | 41 class SimpleFontData; |
42 struct GlyphData; | 42 struct GlyphData; |
43 struct WidthIterator; | 43 struct WidthIterator; |
44 | 44 |
45 enum TextJustify { | |
46 TextJustifyAuto = 0x0, | |
leviw_travelin_and_unemployed
2014/11/05 23:23:39
You actually don't need to set these values.
| |
47 TextJustifyNone = 0x1, | |
48 TextJustifyInterWord = 0x2, | |
49 TextJustifyDistribute = 0x3 | |
50 }; | |
51 | |
52 typedef unsigned TextJustifyStore; | |
leviw_travelin_and_unemployed
2014/11/05 23:23:39
You don't need this. Look at how RenderObject hand
| |
53 | |
45 class PLATFORM_EXPORT TextRun { | 54 class PLATFORM_EXPORT TextRun { |
46 WTF_MAKE_FAST_ALLOCATED; | 55 WTF_MAKE_FAST_ALLOCATED; |
47 public: | 56 public: |
48 enum ExpansionBehaviorFlags { | 57 enum ExpansionBehaviorFlags { |
49 ForbidTrailingExpansion = 0 << 0, | 58 ForbidTrailingExpansion = 0 << 0, |
50 AllowTrailingExpansion = 1 << 0, | 59 AllowTrailingExpansion = 1 << 0, |
51 ForbidLeadingExpansion = 0 << 1, | 60 ForbidLeadingExpansion = 0 << 1, |
52 AllowLeadingExpansion = 1 << 1, | 61 AllowLeadingExpansion = 1 << 1, |
53 }; | 62 }; |
54 | 63 |
55 typedef unsigned ExpansionBehavior; | 64 typedef unsigned ExpansionBehavior; |
56 | 65 |
57 TextRun(const LChar* 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) | 66 TextRun(const LChar* 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) |
58 : m_charactersLength(len) | 67 : m_charactersLength(len) |
59 , m_len(len) | 68 , m_len(len) |
60 , m_xpos(xpos) | 69 , m_xpos(xpos) |
61 , m_horizontalGlyphStretch(1) | 70 , m_horizontalGlyphStretch(1) |
62 , m_expansion(expansion) | 71 , m_expansion(expansion) |
63 , m_expansionBehavior(expansionBehavior) | 72 , m_expansionBehavior(expansionBehavior) |
64 , m_is8Bit(true) | 73 , m_is8Bit(true) |
65 , m_allowTabs(false) | 74 , m_allowTabs(false) |
66 , m_direction(direction) | 75 , m_direction(direction) |
67 , m_directionalOverride(directionalOverride) | 76 , m_directionalOverride(directionalOverride) |
68 , m_characterScanForCodePath(characterScanForCodePath) | 77 , m_characterScanForCodePath(characterScanForCodePath) |
69 , m_disableSpacing(false) | 78 , m_disableSpacing(false) |
79 , m_textJustifyStore(TextJustifyAuto) | |
70 , m_tabSize(0) | 80 , m_tabSize(0) |
71 { | 81 { |
72 m_data.characters8 = c; | 82 m_data.characters8 = c; |
73 } | 83 } |
74 | 84 |
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) | 85 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) | 86 : m_charactersLength(len) |
77 , m_len(len) | 87 , m_len(len) |
78 , m_xpos(xpos) | 88 , m_xpos(xpos) |
79 , m_horizontalGlyphStretch(1) | 89 , m_horizontalGlyphStretch(1) |
80 , m_expansion(expansion) | 90 , m_expansion(expansion) |
81 , m_expansionBehavior(expansionBehavior) | 91 , m_expansionBehavior(expansionBehavior) |
82 , m_is8Bit(false) | 92 , m_is8Bit(false) |
83 , m_allowTabs(false) | 93 , m_allowTabs(false) |
84 , m_direction(direction) | 94 , m_direction(direction) |
85 , m_directionalOverride(directionalOverride) | 95 , m_directionalOverride(directionalOverride) |
86 , m_characterScanForCodePath(characterScanForCodePath) | 96 , m_characterScanForCodePath(characterScanForCodePath) |
87 , m_disableSpacing(false) | 97 , m_disableSpacing(false) |
98 , m_textJustifyStore(TextJustifyAuto) | |
88 , m_tabSize(0) | 99 , m_tabSize(0) |
89 { | 100 { |
90 m_data.characters16 = c; | 101 m_data.characters16 = c; |
91 } | 102 } |
92 | 103 |
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) | 104 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) |
94 : m_charactersLength(string.length()) | 105 : m_charactersLength(string.length()) |
95 , m_len(string.length()) | 106 , m_len(string.length()) |
96 , m_xpos(xpos) | 107 , m_xpos(xpos) |
97 , m_horizontalGlyphStretch(1) | 108 , m_horizontalGlyphStretch(1) |
98 , m_expansion(expansion) | 109 , m_expansion(expansion) |
99 , m_expansionBehavior(expansionBehavior) | 110 , m_expansionBehavior(expansionBehavior) |
100 , m_allowTabs(false) | 111 , m_allowTabs(false) |
101 , m_direction(direction) | 112 , m_direction(direction) |
102 , m_directionalOverride(directionalOverride) | 113 , m_directionalOverride(directionalOverride) |
103 , m_characterScanForCodePath(characterScanForCodePath) | 114 , m_characterScanForCodePath(characterScanForCodePath) |
104 , m_disableSpacing(false) | 115 , m_disableSpacing(false) |
116 , m_textJustifyStore(TextJustifyAuto) | |
105 , m_tabSize(0) | 117 , m_tabSize(0) |
106 { | 118 { |
107 if (!m_charactersLength) { | 119 if (!m_charactersLength) { |
108 m_is8Bit = true; | 120 m_is8Bit = true; |
109 m_data.characters8 = 0; | 121 m_data.characters8 = 0; |
110 } else if (string.is8Bit()) { | 122 } else if (string.is8Bit()) { |
111 m_data.characters8 = string.characters8(); | 123 m_data.characters8 = string.characters8(); |
112 m_is8Bit = true; | 124 m_is8Bit = true; |
113 } else { | 125 } else { |
114 m_data.characters16 = string.characters16(); | 126 m_data.characters16 = string.characters16(); |
115 m_is8Bit = false; | 127 m_is8Bit = false; |
116 } | 128 } |
117 } | 129 } |
118 | 130 |
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) | 131 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) |
120 : m_charactersLength(string.length()) | 132 : m_charactersLength(string.length()) |
121 , m_len(string.length()) | 133 , m_len(string.length()) |
122 , m_xpos(xpos) | 134 , m_xpos(xpos) |
123 , m_horizontalGlyphStretch(1) | 135 , m_horizontalGlyphStretch(1) |
124 , m_expansion(expansion) | 136 , m_expansion(expansion) |
125 , m_expansionBehavior(expansionBehavior) | 137 , m_expansionBehavior(expansionBehavior) |
126 , m_allowTabs(false) | 138 , m_allowTabs(false) |
127 , m_direction(direction) | 139 , m_direction(direction) |
128 , m_directionalOverride(directionalOverride) | 140 , m_directionalOverride(directionalOverride) |
129 , m_characterScanForCodePath(characterScanForCodePath) | 141 , m_characterScanForCodePath(characterScanForCodePath) |
130 , m_disableSpacing(false) | 142 , m_disableSpacing(false) |
143 , m_textJustifyStore(TextJustifyAuto) | |
131 , m_tabSize(0) | 144 , m_tabSize(0) |
132 { | 145 { |
133 if (!m_charactersLength) { | 146 if (!m_charactersLength) { |
134 m_is8Bit = true; | 147 m_is8Bit = true; |
135 m_data.characters8 = 0; | 148 m_data.characters8 = 0; |
136 } else if (string.is8Bit()) { | 149 } else if (string.is8Bit()) { |
137 m_data.characters8 = string.characters8(); | 150 m_data.characters8 = string.characters8(); |
138 m_is8Bit = true; | 151 m_is8Bit = true; |
139 } else { | 152 } else { |
140 m_data.characters16 = string.characters16(); | 153 m_data.characters16 = string.characters16(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 bool ltr() const { return m_direction == LTR; } | 202 bool ltr() const { return m_direction == LTR; } |
190 bool directionalOverride() const { return m_directionalOverride; } | 203 bool directionalOverride() const { return m_directionalOverride; } |
191 bool characterScanForCodePath() const { return m_characterScanForCodePath; } | 204 bool characterScanForCodePath() const { return m_characterScanForCodePath; } |
192 bool spacingDisabled() const { return m_disableSpacing; } | 205 bool spacingDisabled() const { return m_disableSpacing; } |
193 | 206 |
194 void disableSpacing() { m_disableSpacing = true; } | 207 void disableSpacing() { m_disableSpacing = true; } |
195 void setDirection(TextDirection direction) { m_direction = direction; } | 208 void setDirection(TextDirection direction) { m_direction = direction; } |
196 void setDirectionalOverride(bool override) { m_directionalOverride = overrid e; } | 209 void setDirectionalOverride(bool override) { m_directionalOverride = overrid e; } |
197 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s can; } | 210 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s can; } |
198 | 211 |
212 void setTextJustifyStore(TextJustifyStore textJustify) { m_textJustifyStore = textJustify; } | |
213 TextJustifyStore textJustifyStore() const { return m_textJustifyStore; } | |
leviw_travelin_and_unemployed
2014/11/05 23:23:39
How about just textJustify()/setTextJustify?
| |
214 | |
199 class RenderingContext : public RefCounted<RenderingContext> { | 215 class RenderingContext : public RefCounted<RenderingContext> { |
200 public: | 216 public: |
201 virtual ~RenderingContext() { } | 217 virtual ~RenderingContext() { } |
202 | 218 |
203 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Wid thIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& adv anceLength) = 0; | 219 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Wid thIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& adv anceLength) = 0; |
204 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; | 220 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; |
205 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& c harsConsumed, Glyph& glyphId) const = 0; | 221 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& c harsConsumed, Glyph& glyphId) const = 0; |
206 }; | 222 }; |
207 | 223 |
208 RenderingContext* renderingContext() const { return m_renderingContext.get() ; } | 224 RenderingContext* renderingContext() const { return m_renderingContext.get() ; } |
(...skipping 14 matching lines...) Expand all Loading... | |
223 float m_horizontalGlyphStretch; | 239 float m_horizontalGlyphStretch; |
224 | 240 |
225 float m_expansion; | 241 float m_expansion; |
226 ExpansionBehavior m_expansionBehavior : 2; | 242 ExpansionBehavior m_expansionBehavior : 2; |
227 unsigned m_is8Bit : 1; | 243 unsigned m_is8Bit : 1; |
228 unsigned m_allowTabs : 1; | 244 unsigned m_allowTabs : 1; |
229 unsigned m_direction : 1; | 245 unsigned m_direction : 1; |
230 unsigned m_directionalOverride : 1; // Was this direction set by an override character. | 246 unsigned m_directionalOverride : 1; // Was this direction set by an override character. |
231 unsigned m_characterScanForCodePath : 1; | 247 unsigned m_characterScanForCodePath : 1; |
232 unsigned m_disableSpacing : 1; | 248 unsigned m_disableSpacing : 1; |
249 unsigned m_textJustifyStore : 2; | |
leviw_travelin_and_unemployed
2014/11/05 23:23:39
How about just "m_textJustify"?
| |
233 unsigned m_tabSize; | 250 unsigned m_tabSize; |
234 RefPtr<RenderingContext> m_renderingContext; | 251 RefPtr<RenderingContext> m_renderingContext; |
235 }; | 252 }; |
236 | 253 |
237 inline void TextRun::setTabSize(bool allow, unsigned size) | 254 inline void TextRun::setTabSize(bool allow, unsigned size) |
238 { | 255 { |
239 m_allowTabs = allow; | 256 m_allowTabs = allow; |
240 m_tabSize = size; | 257 m_tabSize = size; |
241 } | 258 } |
242 | 259 |
243 // Container for parameters needed to paint TextRun. | 260 // Container for parameters needed to paint TextRun. |
244 struct TextRunPaintInfo { | 261 struct TextRunPaintInfo { |
245 explicit TextRunPaintInfo(const TextRun& r) | 262 explicit TextRunPaintInfo(const TextRun& r) |
246 : run(r) | 263 : run(r) |
247 , from(0) | 264 , from(0) |
248 , to(r.length()) | 265 , to(r.length()) |
249 { | 266 { |
250 } | 267 } |
251 | 268 |
252 const TextRun& run; | 269 const TextRun& run; |
253 int from; | 270 int from; |
254 int to; | 271 int to; |
255 FloatRect bounds; | 272 FloatRect bounds; |
256 }; | 273 }; |
257 | 274 |
258 } | 275 } |
259 #endif | 276 #endif |
OLD | NEW |