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