| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 , m_expansion(expansion) | 68 , m_expansion(expansion) |
| 69 , m_expansionBehavior(expansionBehavior) | 69 , m_expansionBehavior(expansionBehavior) |
| 70 , m_is8Bit(true) | 70 , m_is8Bit(true) |
| 71 , m_allowTabs(false) | 71 , m_allowTabs(false) |
| 72 , m_direction(direction) | 72 , m_direction(direction) |
| 73 , m_directionalOverride(directionalOverride) | 73 , m_directionalOverride(directionalOverride) |
| 74 , m_characterScanForCodePath(characterScanForCodePath) | 74 , m_characterScanForCodePath(characterScanForCodePath) |
| 75 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) | 75 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) |
| 76 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) | 76 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) |
| 77 , m_disableSpacing(false) | 77 , m_disableSpacing(false) |
| 78 , m_distributeJustification(false) |
| 78 , m_tabSize(0) | 79 , m_tabSize(0) |
| 79 { | 80 { |
| 80 m_data.characters8 = c; | 81 m_data.characters8 = c; |
| 81 } | 82 } |
| 82 | 83 |
| 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, RoundingHacks roundingHacks = RunRounding | WordRou
nding) | 84 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, RoundingHacks roundingHacks = RunRounding | WordRou
nding) |
| 84 : m_charactersLength(len) | 85 : m_charactersLength(len) |
| 85 , m_len(len) | 86 , m_len(len) |
| 86 , m_xpos(xpos) | 87 , m_xpos(xpos) |
| 87 , m_horizontalGlyphStretch(1) | 88 , m_horizontalGlyphStretch(1) |
| 88 , m_expansion(expansion) | 89 , m_expansion(expansion) |
| 89 , m_expansionBehavior(expansionBehavior) | 90 , m_expansionBehavior(expansionBehavior) |
| 90 , m_is8Bit(false) | 91 , m_is8Bit(false) |
| 91 , m_allowTabs(false) | 92 , m_allowTabs(false) |
| 92 , m_direction(direction) | 93 , m_direction(direction) |
| 93 , m_directionalOverride(directionalOverride) | 94 , m_directionalOverride(directionalOverride) |
| 94 , m_characterScanForCodePath(characterScanForCodePath) | 95 , m_characterScanForCodePath(characterScanForCodePath) |
| 95 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) | 96 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) |
| 96 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) | 97 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) |
| 97 , m_disableSpacing(false) | 98 , m_disableSpacing(false) |
| 99 , m_distributeJustification(false) |
| 98 , m_tabSize(0) | 100 , m_tabSize(0) |
| 99 { | 101 { |
| 100 m_data.characters16 = c; | 102 m_data.characters16 = c; |
| 101 } | 103 } |
| 102 | 104 |
| 103 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, RoundingHacks roundingHacks = RunRounding | WordRounding) | 105 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, RoundingHacks roundingHacks = RunRounding | WordRounding) |
| 104 : m_charactersLength(string.length()) | 106 : m_charactersLength(string.length()) |
| 105 , m_len(string.length()) | 107 , m_len(string.length()) |
| 106 , m_xpos(xpos) | 108 , m_xpos(xpos) |
| 107 , m_horizontalGlyphStretch(1) | 109 , m_horizontalGlyphStretch(1) |
| 108 , m_expansion(expansion) | 110 , m_expansion(expansion) |
| 109 , m_expansionBehavior(expansionBehavior) | 111 , m_expansionBehavior(expansionBehavior) |
| 110 , m_allowTabs(false) | 112 , m_allowTabs(false) |
| 111 , m_direction(direction) | 113 , m_direction(direction) |
| 112 , m_directionalOverride(directionalOverride) | 114 , m_directionalOverride(directionalOverride) |
| 113 , m_characterScanForCodePath(characterScanForCodePath) | 115 , m_characterScanForCodePath(characterScanForCodePath) |
| 114 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) | 116 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) |
| 115 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) | 117 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) |
| 116 , m_disableSpacing(false) | 118 , m_disableSpacing(false) |
| 119 , m_distributeJustification(false) |
| 117 , m_tabSize(0) | 120 , m_tabSize(0) |
| 118 { | 121 { |
| 119 if (!m_charactersLength) { | 122 if (!m_charactersLength) { |
| 120 m_is8Bit = true; | 123 m_is8Bit = true; |
| 121 m_data.characters8 = 0; | 124 m_data.characters8 = 0; |
| 122 } else if (string.is8Bit()) { | 125 } else if (string.is8Bit()) { |
| 123 m_data.characters8 = string.characters8(); | 126 m_data.characters8 = string.characters8(); |
| 124 m_is8Bit = true; | 127 m_is8Bit = true; |
| 125 } else { | 128 } else { |
| 126 m_data.characters16 = string.characters16(); | 129 m_data.characters16 = string.characters16(); |
| 127 m_is8Bit = false; | 130 m_is8Bit = false; |
| 128 } | 131 } |
| 129 } | 132 } |
| 130 | 133 |
| 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, RoundingHacks roundingHacks = RunRounding | WordRoundin
g) | 134 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, RoundingHacks roundingHacks = RunRounding | WordRoundin
g) |
| 132 : m_charactersLength(string.length()) | 135 : m_charactersLength(string.length()) |
| 133 , m_len(string.length()) | 136 , m_len(string.length()) |
| 134 , m_xpos(xpos) | 137 , m_xpos(xpos) |
| 135 , m_horizontalGlyphStretch(1) | 138 , m_horizontalGlyphStretch(1) |
| 136 , m_expansion(expansion) | 139 , m_expansion(expansion) |
| 137 , m_expansionBehavior(expansionBehavior) | 140 , m_expansionBehavior(expansionBehavior) |
| 138 , m_allowTabs(false) | 141 , m_allowTabs(false) |
| 139 , m_direction(direction) | 142 , m_direction(direction) |
| 140 , m_directionalOverride(directionalOverride) | 143 , m_directionalOverride(directionalOverride) |
| 141 , m_characterScanForCodePath(characterScanForCodePath) | 144 , m_characterScanForCodePath(characterScanForCodePath) |
| 142 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) | 145 , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHa
cks) |
| 143 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) | 146 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRounding
Hacks) |
| 144 , m_disableSpacing(false) | 147 , m_disableSpacing(false) |
| 148 , m_distributeJustification(false) |
| 145 , m_tabSize(0) | 149 , m_tabSize(0) |
| 146 { | 150 { |
| 147 if (!m_charactersLength) { | 151 if (!m_charactersLength) { |
| 148 m_is8Bit = true; | 152 m_is8Bit = true; |
| 149 m_data.characters8 = 0; | 153 m_data.characters8 = 0; |
| 150 } else if (string.is8Bit()) { | 154 } else if (string.is8Bit()) { |
| 151 m_data.characters8 = string.characters8(); | 155 m_data.characters8 = string.characters8(); |
| 152 m_is8Bit = true; | 156 m_is8Bit = true; |
| 153 } else { | 157 } else { |
| 154 m_data.characters16 = string.characters16(); | 158 m_data.characters16 = string.characters16(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; } | 193 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; } |
| 190 void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = sca
le; } | 194 void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = sca
le; } |
| 191 | 195 |
| 192 bool allowTabs() const { return m_allowTabs; } | 196 bool allowTabs() const { return m_allowTabs; } |
| 193 unsigned tabSize() const { return m_tabSize; } | 197 unsigned tabSize() const { return m_tabSize; } |
| 194 void setTabSize(bool, unsigned); | 198 void setTabSize(bool, unsigned); |
| 195 | 199 |
| 196 float xPos() const { return m_xpos; } | 200 float xPos() const { return m_xpos; } |
| 197 void setXPos(float xPos) { m_xpos = xPos; } | 201 void setXPos(float xPos) { m_xpos = xPos; } |
| 198 float expansion() const { return m_expansion; } | 202 float expansion() const { return m_expansion; } |
| 203 bool isDistributeJustification() const { return m_distributeJustification; } |
| 204 void setDistributeJustification(bool distributeJustification) { m_distribute
Justification = distributeJustification; } |
| 199 bool allowsLeadingExpansion() const { return m_expansionBehavior & AllowLead
ingExpansion; } | 205 bool allowsLeadingExpansion() const { return m_expansionBehavior & AllowLead
ingExpansion; } |
| 200 bool allowsTrailingExpansion() const { return m_expansionBehavior & AllowTra
ilingExpansion; } | 206 bool allowsTrailingExpansion() const { return m_expansionBehavior & AllowTra
ilingExpansion; } |
| 201 TextDirection direction() const { return static_cast<TextDirection>(m_direct
ion); } | 207 TextDirection direction() const { return static_cast<TextDirection>(m_direct
ion); } |
| 202 bool rtl() const { return m_direction == RTL; } | 208 bool rtl() const { return m_direction == RTL; } |
| 203 bool ltr() const { return m_direction == LTR; } | 209 bool ltr() const { return m_direction == LTR; } |
| 204 bool directionalOverride() const { return m_directionalOverride; } | 210 bool directionalOverride() const { return m_directionalOverride; } |
| 205 bool characterScanForCodePath() const { return m_characterScanForCodePath; } | 211 bool characterScanForCodePath() const { return m_characterScanForCodePath; } |
| 206 bool applyRunRounding() const { return m_applyRunRounding; } | 212 bool applyRunRounding() const { return m_applyRunRounding; } |
| 207 bool applyWordRounding() const { return m_applyWordRounding; } | 213 bool applyWordRounding() const { return m_applyWordRounding; } |
| 208 bool spacingDisabled() const { return m_disableSpacing; } | 214 bool spacingDisabled() const { return m_disableSpacing; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 float m_expansion; | 253 float m_expansion; |
| 248 ExpansionBehavior m_expansionBehavior : 2; | 254 ExpansionBehavior m_expansionBehavior : 2; |
| 249 unsigned m_is8Bit : 1; | 255 unsigned m_is8Bit : 1; |
| 250 unsigned m_allowTabs : 1; | 256 unsigned m_allowTabs : 1; |
| 251 unsigned m_direction : 1; | 257 unsigned m_direction : 1; |
| 252 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. | 258 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. |
| 253 unsigned m_characterScanForCodePath : 1; | 259 unsigned m_characterScanForCodePath : 1; |
| 254 unsigned m_applyRunRounding : 1; | 260 unsigned m_applyRunRounding : 1; |
| 255 unsigned m_applyWordRounding : 1; | 261 unsigned m_applyWordRounding : 1; |
| 256 unsigned m_disableSpacing : 1; | 262 unsigned m_disableSpacing : 1; |
| 263 unsigned m_distributeJustification : 1; |
| 257 unsigned m_tabSize; | 264 unsigned m_tabSize; |
| 258 RefPtr<RenderingContext> m_renderingContext; | 265 RefPtr<RenderingContext> m_renderingContext; |
| 259 }; | 266 }; |
| 260 | 267 |
| 261 inline void TextRun::setTabSize(bool allow, unsigned size) | 268 inline void TextRun::setTabSize(bool allow, unsigned size) |
| 262 { | 269 { |
| 263 m_allowTabs = allow; | 270 m_allowTabs = allow; |
| 264 m_tabSize = size; | 271 m_tabSize = size; |
| 265 } | 272 } |
| 266 | 273 |
| 267 // Container for parameters needed to paint TextRun. | 274 // Container for parameters needed to paint TextRun. |
| 268 struct TextRunPaintInfo { | 275 struct TextRunPaintInfo { |
| 269 explicit TextRunPaintInfo(const TextRun& r) | 276 explicit TextRunPaintInfo(const TextRun& r) |
| 270 : run(r) | 277 : run(r) |
| 271 , from(0) | 278 , from(0) |
| 272 , to(r.length()) | 279 , to(r.length()) |
| 273 { | 280 { |
| 274 } | 281 } |
| 275 | 282 |
| 276 const TextRun& run; | 283 const TextRun& run; |
| 277 int from; | 284 int from; |
| 278 int to; | 285 int to; |
| 279 FloatRect bounds; | 286 FloatRect bounds; |
| 280 }; | 287 }; |
| 281 | 288 |
| 282 } | 289 } |
| 283 #endif | 290 #endif |
| OLD | NEW |