| 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 19 matching lines...) Expand all Loading... |
| 30 #include "platform/heap/Heap.h" | 30 #include "platform/heap/Heap.h" |
| 31 #include "platform/text/TextDirection.h" | 31 #include "platform/text/TextDirection.h" |
| 32 #include "platform/text/TextPath.h" | 32 #include "platform/text/TextPath.h" |
| 33 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 34 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 35 | 35 |
| 36 class SkTextBlob; | 36 class SkTextBlob; |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 enum TextJustify { |
| 41 TextJustifyAuto = 0x0, |
| 42 TextJustifyNone = 0x1, |
| 43 TextJustifyInterWord = 0x2, |
| 44 TextJustifyDistribute = 0x3 |
| 45 }; |
| 46 |
| 40 class PLATFORM_EXPORT TextRun { | 47 class PLATFORM_EXPORT TextRun { |
| 41 WTF_MAKE_FAST_ALLOCATED; | 48 WTF_MAKE_FAST_ALLOCATED; |
| 42 public: | 49 public: |
| 43 enum ExpansionBehaviorFlags { | 50 enum ExpansionBehaviorFlags { |
| 44 ForbidTrailingExpansion = 0 << 0, | 51 ForbidTrailingExpansion = 0 << 0, |
| 45 AllowTrailingExpansion = 1 << 0, | 52 AllowTrailingExpansion = 1 << 0, |
| 46 ForbidLeadingExpansion = 0 << 1, | 53 ForbidLeadingExpansion = 0 << 1, |
| 47 AllowLeadingExpansion = 1 << 1, | 54 AllowLeadingExpansion = 1 << 1, |
| 48 }; | 55 }; |
| 49 | 56 |
| 50 typedef unsigned ExpansionBehavior; | 57 typedef unsigned ExpansionBehavior; |
| 51 | 58 |
| 52 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) | 59 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) |
| 53 : m_charactersLength(len) | 60 : m_charactersLength(len) |
| 54 , m_len(len) | 61 , m_len(len) |
| 55 , m_xpos(xpos) | 62 , m_xpos(xpos) |
| 56 , m_horizontalGlyphStretch(1) | 63 , m_horizontalGlyphStretch(1) |
| 57 , m_expansion(expansion) | 64 , m_expansion(expansion) |
| 58 , m_expansionBehavior(expansionBehavior) | 65 , m_expansionBehavior(expansionBehavior) |
| 59 , m_is8Bit(true) | 66 , m_is8Bit(true) |
| 60 , m_allowTabs(false) | 67 , m_allowTabs(false) |
| 61 , m_direction(direction) | 68 , m_direction(direction) |
| 62 , m_directionalOverride(directionalOverride) | 69 , m_directionalOverride(directionalOverride) |
| 63 , m_characterScanForCodePath(characterScanForCodePath) | 70 , m_characterScanForCodePath(characterScanForCodePath) |
| 64 , m_useComplexCodePath(false) | 71 , m_useComplexCodePath(false) |
| 65 , m_disableSpacing(false) | 72 , m_disableSpacing(false) |
| 73 , m_textJustify(TextJustifyAuto) |
| 66 , m_tabSize(0) | 74 , m_tabSize(0) |
| 67 , m_normalizeSpace(false) | 75 , m_normalizeSpace(false) |
| 68 { | 76 { |
| 69 m_data.characters8 = c; | 77 m_data.characters8 = c; |
| 70 } | 78 } |
| 71 | 79 |
| 72 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) | 80 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) |
| 73 : m_charactersLength(len) | 81 : m_charactersLength(len) |
| 74 , m_len(len) | 82 , m_len(len) |
| 75 , m_xpos(xpos) | 83 , m_xpos(xpos) |
| 76 , m_horizontalGlyphStretch(1) | 84 , m_horizontalGlyphStretch(1) |
| 77 , m_expansion(expansion) | 85 , m_expansion(expansion) |
| 78 , m_expansionBehavior(expansionBehavior) | 86 , m_expansionBehavior(expansionBehavior) |
| 79 , m_is8Bit(false) | 87 , m_is8Bit(false) |
| 80 , m_allowTabs(false) | 88 , m_allowTabs(false) |
| 81 , m_direction(direction) | 89 , m_direction(direction) |
| 82 , m_directionalOverride(directionalOverride) | 90 , m_directionalOverride(directionalOverride) |
| 83 , m_characterScanForCodePath(characterScanForCodePath) | 91 , m_characterScanForCodePath(characterScanForCodePath) |
| 84 , m_useComplexCodePath(false) | 92 , m_useComplexCodePath(false) |
| 85 , m_disableSpacing(false) | 93 , m_disableSpacing(false) |
| 94 , m_textJustify(TextJustifyAuto) |
| 86 , m_tabSize(0) | 95 , m_tabSize(0) |
| 87 , m_normalizeSpace(false) | 96 , m_normalizeSpace(false) |
| 88 { | 97 { |
| 89 m_data.characters16 = c; | 98 m_data.characters16 = c; |
| 90 } | 99 } |
| 91 | 100 |
| 92 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, bool normalizeSpace = false) | 101 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, bool normalizeSpace = false) |
| 93 : m_charactersLength(string.length()) | 102 : m_charactersLength(string.length()) |
| 94 , m_len(string.length()) | 103 , m_len(string.length()) |
| 95 , m_xpos(xpos) | 104 , m_xpos(xpos) |
| 96 , m_horizontalGlyphStretch(1) | 105 , m_horizontalGlyphStretch(1) |
| 97 , m_expansion(expansion) | 106 , m_expansion(expansion) |
| 98 , m_expansionBehavior(expansionBehavior) | 107 , m_expansionBehavior(expansionBehavior) |
| 99 , m_allowTabs(false) | 108 , m_allowTabs(false) |
| 100 , m_direction(direction) | 109 , m_direction(direction) |
| 101 , m_directionalOverride(directionalOverride) | 110 , m_directionalOverride(directionalOverride) |
| 102 , m_characterScanForCodePath(characterScanForCodePath) | 111 , m_characterScanForCodePath(characterScanForCodePath) |
| 103 , m_useComplexCodePath(false) | 112 , m_useComplexCodePath(false) |
| 104 , m_disableSpacing(false) | 113 , m_disableSpacing(false) |
| 114 , m_textJustify(TextJustifyAuto) |
| 105 , m_tabSize(0) | 115 , m_tabSize(0) |
| 106 , m_normalizeSpace(normalizeSpace) | 116 , m_normalizeSpace(normalizeSpace) |
| 107 { | 117 { |
| 108 if (!m_charactersLength) { | 118 if (!m_charactersLength) { |
| 109 m_is8Bit = true; | 119 m_is8Bit = true; |
| 110 m_data.characters8 = 0; | 120 m_data.characters8 = 0; |
| 111 } else if (string.is8Bit()) { | 121 } else if (string.is8Bit()) { |
| 112 m_data.characters8 = string.characters8(); | 122 m_data.characters8 = string.characters8(); |
| 113 m_is8Bit = true; | 123 m_is8Bit = true; |
| 114 } else { | 124 } else { |
| 115 m_data.characters16 = string.characters16(); | 125 m_data.characters16 = string.characters16(); |
| 116 m_is8Bit = false; | 126 m_is8Bit = false; |
| 117 } | 127 } |
| 118 } | 128 } |
| 119 | 129 |
| 120 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, bool normalizeSpace = false) | 130 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, bool normalizeSpace = false) |
| 121 : m_charactersLength(string.length()) | 131 : m_charactersLength(string.length()) |
| 122 , m_len(string.length()) | 132 , m_len(string.length()) |
| 123 , m_xpos(xpos) | 133 , m_xpos(xpos) |
| 124 , m_horizontalGlyphStretch(1) | 134 , m_horizontalGlyphStretch(1) |
| 125 , m_expansion(expansion) | 135 , m_expansion(expansion) |
| 126 , m_expansionBehavior(expansionBehavior) | 136 , m_expansionBehavior(expansionBehavior) |
| 127 , m_allowTabs(false) | 137 , m_allowTabs(false) |
| 128 , m_direction(direction) | 138 , m_direction(direction) |
| 129 , m_directionalOverride(directionalOverride) | 139 , m_directionalOverride(directionalOverride) |
| 130 , m_characterScanForCodePath(characterScanForCodePath) | 140 , m_characterScanForCodePath(characterScanForCodePath) |
| 131 , m_useComplexCodePath(false) | 141 , m_useComplexCodePath(false) |
| 132 , m_disableSpacing(false) | 142 , m_disableSpacing(false) |
| 143 , m_textJustify(TextJustifyAuto) |
| 133 , m_tabSize(0) | 144 , m_tabSize(0) |
| 134 , m_normalizeSpace(normalizeSpace) | 145 , m_normalizeSpace(normalizeSpace) |
| 135 { | 146 { |
| 136 if (!m_charactersLength) { | 147 if (!m_charactersLength) { |
| 137 m_is8Bit = true; | 148 m_is8Bit = true; |
| 138 m_data.characters8 = 0; | 149 m_data.characters8 = 0; |
| 139 } else if (string.is8Bit()) { | 150 } else if (string.is8Bit()) { |
| 140 m_data.characters8 = string.characters8(); | 151 m_data.characters8 = string.characters8(); |
| 141 m_is8Bit = true; | 152 m_is8Bit = true; |
| 142 } else { | 153 } else { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool characterScanForCodePath() const { return m_characterScanForCodePath; } | 208 bool characterScanForCodePath() const { return m_characterScanForCodePath; } |
| 198 bool useComplexCodePath() const { return m_useComplexCodePath; } | 209 bool useComplexCodePath() const { return m_useComplexCodePath; } |
| 199 bool spacingDisabled() const { return m_disableSpacing; } | 210 bool spacingDisabled() const { return m_disableSpacing; } |
| 200 | 211 |
| 201 void disableSpacing() { m_disableSpacing = true; } | 212 void disableSpacing() { m_disableSpacing = true; } |
| 202 void setDirection(TextDirection direction) { m_direction = direction; } | 213 void setDirection(TextDirection direction) { m_direction = direction; } |
| 203 void setDirectionalOverride(bool override) { m_directionalOverride = overrid
e; } | 214 void setDirectionalOverride(bool override) { m_directionalOverride = overrid
e; } |
| 204 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s
can; } | 215 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s
can; } |
| 205 void setUseComplexCodePath(bool useComplex) { m_useComplexCodePath = useComp
lex; } | 216 void setUseComplexCodePath(bool useComplex) { m_useComplexCodePath = useComp
lex; } |
| 206 | 217 |
| 218 void setTextJustify(TextJustify textJustify) { m_textJustify = static_cast<u
nsigned>(textJustify); } |
| 219 TextJustify textJustify() const { return static_cast<TextJustify>(m_textJust
ify); } |
| 220 |
| 207 class RenderingContext : public RefCounted<RenderingContext> { | 221 class RenderingContext : public RefCounted<RenderingContext> { |
| 208 public: | 222 public: |
| 209 virtual ~RenderingContext() { } | 223 virtual ~RenderingContext() { } |
| 210 }; | 224 }; |
| 211 | 225 |
| 212 RenderingContext* renderingContext() const { return m_renderingContext.get()
; } | 226 RenderingContext* renderingContext() const { return m_renderingContext.get()
; } |
| 213 void setRenderingContext(PassRefPtr<RenderingContext> context) { m_rendering
Context = context; } | 227 void setRenderingContext(PassRefPtr<RenderingContext> context) { m_rendering
Context = context; } |
| 214 | 228 |
| 215 private: | 229 private: |
| 216 union { | 230 union { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 | 242 |
| 229 float m_expansion; | 243 float m_expansion; |
| 230 ExpansionBehavior m_expansionBehavior : 2; | 244 ExpansionBehavior m_expansionBehavior : 2; |
| 231 unsigned m_is8Bit : 1; | 245 unsigned m_is8Bit : 1; |
| 232 unsigned m_allowTabs : 1; | 246 unsigned m_allowTabs : 1; |
| 233 unsigned m_direction : 1; | 247 unsigned m_direction : 1; |
| 234 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. | 248 unsigned m_directionalOverride : 1; // Was this direction set by an override
character. |
| 235 unsigned m_characterScanForCodePath : 1; | 249 unsigned m_characterScanForCodePath : 1; |
| 236 unsigned m_useComplexCodePath : 1; | 250 unsigned m_useComplexCodePath : 1; |
| 237 unsigned m_disableSpacing : 1; | 251 unsigned m_disableSpacing : 1; |
| 252 unsigned m_textJustify : 2; |
| 238 unsigned m_tabSize; | 253 unsigned m_tabSize; |
| 239 bool m_normalizeSpace; | 254 bool m_normalizeSpace; |
| 240 RefPtr<RenderingContext> m_renderingContext; | 255 RefPtr<RenderingContext> m_renderingContext; |
| 241 }; | 256 }; |
| 242 | 257 |
| 243 inline void TextRun::setTabSize(bool allow, unsigned size) | 258 inline void TextRun::setTabSize(bool allow, unsigned size) |
| 244 { | 259 { |
| 245 m_allowTabs = allow; | 260 m_allowTabs = allow; |
| 246 m_tabSize = size; | 261 m_tabSize = size; |
| 247 } | 262 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 260 | 275 |
| 261 const TextRun& run; | 276 const TextRun& run; |
| 262 int from; | 277 int from; |
| 263 int to; | 278 int to; |
| 264 FloatRect bounds; | 279 FloatRect bounds; |
| 265 RefPtr<const SkTextBlob>* cachedTextBlob; | 280 RefPtr<const SkTextBlob>* cachedTextBlob; |
| 266 }; | 281 }; |
| 267 | 282 |
| 268 } | 283 } |
| 269 #endif | 284 #endif |
| OLD | NEW |