| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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/layout/TextRunConstructor.h" | 32 #include "core/layout/TextRunConstructor.h" |
| 33 | 33 |
| 34 #include "core/layout/LayoutText.h" |
| 34 #include "core/layout/style/LayoutStyle.h" | 35 #include "core/layout/style/LayoutStyle.h" |
| 35 #include "core/rendering/RenderText.h" | |
| 36 #include "platform/text/BidiTextRun.h" | 36 #include "platform/text/BidiTextRun.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 template <typename CharacterType> | 40 template <typename CharacterType> |
| 41 static inline TextRun constructTextRunInternal(LayoutObject* context, const Font
& font, const CharacterType* characters, int length, const LayoutStyle& style, T
extDirection direction) | 41 static inline TextRun constructTextRunInternal(LayoutObject* context, const Font
& font, const CharacterType* characters, int length, const LayoutStyle& style, T
extDirection direction) |
| 42 { | 42 { |
| 43 TextRun::ExpansionBehavior expansion = TextRun::AllowTrailingExpansion | Tex
tRun::ForbidLeadingExpansion; | 43 TextRun::ExpansionBehavior expansion = TextRun::AllowTrailingExpansion | Tex
tRun::ForbidLeadingExpansion; |
| 44 bool directionalOverride = style.rtlOrdering() == VisualOrder; | 44 bool directionalOverride = style.rtlOrdering() == VisualOrder; |
| 45 TextRun run(characters, length, 0, 0, expansion, direction, directionalOverr
ide); | 45 TextRun run(characters, length, 0, 0, expansion, direction, directionalOverr
ide); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 TextRun constructTextRun(LayoutObject* context, const Font& font, const LChar* c
haracters, int length, const LayoutStyle& style, TextDirection direction) | 66 TextRun constructTextRun(LayoutObject* context, const Font& font, const LChar* c
haracters, int length, const LayoutStyle& style, TextDirection direction) |
| 67 { | 67 { |
| 68 return constructTextRunInternal(context, font, characters, length, style, di
rection); | 68 return constructTextRunInternal(context, font, characters, length, style, di
rection); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TextRun constructTextRun(LayoutObject* context, const Font& font, const UChar* c
haracters, int length, const LayoutStyle& style, TextDirection direction) | 71 TextRun constructTextRun(LayoutObject* context, const Font& font, const UChar* c
haracters, int length, const LayoutStyle& style, TextDirection direction) |
| 72 { | 72 { |
| 73 return constructTextRunInternal(context, font, characters, length, style, di
rection); | 73 return constructTextRunInternal(context, font, characters, length, style, di
rection); |
| 74 } | 74 } |
| 75 | 75 |
| 76 TextRun constructTextRun(LayoutObject* context, const Font& font, const RenderTe
xt* text, const LayoutStyle& style, TextDirection direction) | 76 TextRun constructTextRun(LayoutObject* context, const Font& font, const LayoutTe
xt* text, const LayoutStyle& style, TextDirection direction) |
| 77 { | 77 { |
| 78 if (text->is8Bit()) | 78 if (text->is8Bit()) |
| 79 return constructTextRunInternal(context, font, text->characters8(), text
->textLength(), style, direction); | 79 return constructTextRunInternal(context, font, text->characters8(), text
->textLength(), style, direction); |
| 80 return constructTextRunInternal(context, font, text->characters16(), text->t
extLength(), style, direction); | 80 return constructTextRunInternal(context, font, text->characters16(), text->t
extLength(), style, direction); |
| 81 } | 81 } |
| 82 | 82 |
| 83 TextRun constructTextRun(LayoutObject* context, const Font& font, const RenderTe
xt* text, unsigned offset, unsigned length, const LayoutStyle& style, TextDirect
ion direction) | 83 TextRun constructTextRun(LayoutObject* context, const Font& font, const LayoutTe
xt* text, unsigned offset, unsigned length, const LayoutStyle& style, TextDirect
ion direction) |
| 84 { | 84 { |
| 85 ASSERT(offset + length <= text->textLength()); | 85 ASSERT(offset + length <= text->textLength()); |
| 86 if (text->is8Bit()) | 86 if (text->is8Bit()) |
| 87 return constructTextRunInternal(context, font, text->characters8() + off
set, length, style, direction); | 87 return constructTextRunInternal(context, font, text->characters8() + off
set, length, style, direction); |
| 88 return constructTextRunInternal(context, font, text->characters16() + offset
, length, style, direction); | 88 return constructTextRunInternal(context, font, text->characters16() + offset
, length, style, direction); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TextRun constructTextRun(LayoutObject* context, const Font& font, const String&
string, const LayoutStyle& style, TextDirection direction, TextRunFlags flags) | 91 TextRun constructTextRun(LayoutObject* context, const Font& font, const String&
string, const LayoutStyle& style, TextDirection direction, TextRunFlags flags) |
| 92 { | 92 { |
| 93 unsigned length = string.length(); | 93 unsigned length = string.length(); |
| 94 if (!length) | 94 if (!length) |
| 95 return constructTextRunInternal(context, font, static_cast<const LChar*>
(0), length, style, direction, flags); | 95 return constructTextRunInternal(context, font, static_cast<const LChar*>
(0), length, style, direction, flags); |
| 96 if (string.is8Bit()) | 96 if (string.is8Bit()) |
| 97 return constructTextRunInternal(context, font, string.characters8(), len
gth, style, direction, flags); | 97 return constructTextRunInternal(context, font, string.characters8(), len
gth, style, direction, flags); |
| 98 return constructTextRunInternal(context, font, string.characters16(), length
, style, direction, flags); | 98 return constructTextRunInternal(context, font, string.characters16(), length
, style, direction, flags); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TextRun constructTextRun(LayoutObject* context, const Font& font, const String&
string, const LayoutStyle& style, TextRunFlags flags) | 101 TextRun constructTextRun(LayoutObject* context, const Font& font, const String&
string, const LayoutStyle& style, TextRunFlags flags) |
| 102 { | 102 { |
| 103 bool hasStrongDirectionality; | 103 bool hasStrongDirectionality; |
| 104 return constructTextRun(context, font, string, style, determineDirectionalit
y(string, hasStrongDirectionality), flags); | 104 return constructTextRun(context, font, string, style, determineDirectionalit
y(string, hasStrongDirectionality), flags); |
| 105 } | 105 } |
| 106 | 106 |
| 107 TextRun constructTextRun(LayoutObject* context, const Font& font, const RenderTe
xt* text, unsigned offset, unsigned length, const LayoutStyle& style) | 107 TextRun constructTextRun(LayoutObject* context, const Font& font, const LayoutTe
xt* text, unsigned offset, unsigned length, const LayoutStyle& style) |
| 108 { | 108 { |
| 109 ASSERT(offset + length <= text->textLength()); | 109 ASSERT(offset + length <= text->textLength()); |
| 110 TextRun run = text->is8Bit() | 110 TextRun run = text->is8Bit() |
| 111 ? constructTextRunInternal(context, font, text->characters8() + offset,
length, style, LTR) | 111 ? constructTextRunInternal(context, font, text->characters8() + offset,
length, style, LTR) |
| 112 : constructTextRunInternal(context, font, text->characters16() + offset,
length, style, LTR); | 112 : constructTextRunInternal(context, font, text->characters16() + offset,
length, style, LTR); |
| 113 bool hasStrongDirectionality; | 113 bool hasStrongDirectionality; |
| 114 run.setDirection(directionForRun(run, hasStrongDirectionality)); | 114 run.setDirection(directionForRun(run, hasStrongDirectionality)); |
| 115 return run; | 115 return run; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |