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