OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/rendering/TextRunConstructor.h" | 32 #include "core/rendering/TextRunConstructor.h" |
33 | 33 |
34 #include "core/rendering/RenderText.h" | 34 #include "core/rendering/RenderText.h" |
35 #include "core/rendering/style/RenderStyle.h" | 35 #include "core/rendering/style/RenderStyle.h" |
36 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | |
37 #include "platform/text/BidiTextRun.h" | 36 #include "platform/text/BidiTextRun.h" |
38 | 37 |
39 namespace blink { | 38 namespace blink { |
40 | 39 |
41 template <typename CharacterType> | 40 template <typename CharacterType> |
42 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion) | 41 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion) |
43 { | 42 { |
44 ASSERT(style); | 43 ASSERT(style); |
45 | 44 |
46 bool directionalOverride = style->rtlOrdering() == VisualOrder; | 45 bool directionalOverride = style->rtlOrdering() == VisualOrder; |
47 TextRun run(characters, length, 0, 0, expansion, direction, directionalOverr
ide); | 46 TextRun run(characters, length, 0, 0, expansion, direction, directionalOverr
ide); |
48 if (textRunNeedsRenderingContext(font)) | |
49 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); | |
50 | |
51 return run; | 47 return run; |
52 } | 48 } |
53 | 49 |
54 template <typename CharacterType> | 50 template <typename CharacterType> |
55 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion, TextRunFlags flags) | 51 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion, TextRunFlags flags) |
56 { | 52 { |
57 ASSERT(style); | 53 ASSERT(style); |
58 | 54 |
59 TextDirection textDirection = direction; | 55 TextDirection textDirection = direction; |
60 bool directionalOverride = style->rtlOrdering() == VisualOrder; | 56 bool directionalOverride = style->rtlOrdering() == VisualOrder; |
61 if (flags != DefaultTextRunFlags) { | 57 if (flags != DefaultTextRunFlags) { |
62 if (flags & RespectDirection) | 58 if (flags & RespectDirection) |
63 textDirection = style->direction(); | 59 textDirection = style->direction(); |
64 if (flags & RespectDirectionOverride) | 60 if (flags & RespectDirectionOverride) |
65 directionalOverride |= isOverride(style->unicodeBidi()); | 61 directionalOverride |= isOverride(style->unicodeBidi()); |
66 } | 62 } |
67 | 63 |
68 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalO
verride); | 64 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalO
verride); |
69 if (textRunNeedsRenderingContext(font)) | |
70 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); | |
71 | |
72 return run; | 65 return run; |
73 } | 66 } |
74 | 67 |
75 TextRun constructTextRun(RenderObject* context, const Font& font, const LChar* c
haracters, int length, RenderStyle* style, TextDirection direction, TextRun::Exp
ansionBehavior expansion) | 68 TextRun constructTextRun(RenderObject* context, const Font& font, const LChar* c
haracters, int length, RenderStyle* style, TextDirection direction, TextRun::Exp
ansionBehavior expansion) |
76 { | 69 { |
77 return constructTextRunInternal(context, font, characters, length, style, di
rection, expansion); | 70 return constructTextRunInternal(context, font, characters, length, style, di
rection, expansion); |
78 } | 71 } |
79 | 72 |
80 TextRun constructTextRun(RenderObject* context, const Font& font, const UChar* c
haracters, int length, RenderStyle* style, TextDirection direction, TextRun::Exp
ansionBehavior expansion) | 73 TextRun constructTextRun(RenderObject* context, const Font& font, const UChar* c
haracters, int length, RenderStyle* style, TextDirection direction, TextRun::Exp
ansionBehavior expansion) |
81 { | 74 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ASSERT(offset + length <= text->textLength()); | 111 ASSERT(offset + length <= text->textLength()); |
119 TextRun run = text->is8Bit() | 112 TextRun run = text->is8Bit() |
120 ? constructTextRunInternal(context, font, text->characters8() + offset,
length, style, LTR, expansion) | 113 ? constructTextRunInternal(context, font, text->characters8() + offset,
length, style, LTR, expansion) |
121 : constructTextRunInternal(context, font, text->characters16() + offset,
length, style, LTR, expansion); | 114 : constructTextRunInternal(context, font, text->characters16() + offset,
length, style, LTR, expansion); |
122 bool hasStrongDirectionality; | 115 bool hasStrongDirectionality; |
123 run.setDirection(directionForRun(run, hasStrongDirectionality)); | 116 run.setDirection(directionForRun(run, hasStrongDirectionality)); |
124 return run; | 117 return run; |
125 } | 118 } |
126 | 119 |
127 } // namespace blink | 120 } // namespace blink |
OLD | NEW |