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