| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); | 68 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); |
| 69 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE
xpansion) | 69 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE
xpansion) |
| 70 { | 70 { |
| 71 if (run.is8Bit()) | 71 if (run.is8Bit()) |
| 72 return expansionOpportunityCount(run.characters8(), run.length(), ru
n.direction(), isAfterExpansion, run.getTextJustify()); | 72 return expansionOpportunityCount(run.characters8(), run.length(), ru
n.direction(), isAfterExpansion, run.getTextJustify()); |
| 73 return expansionOpportunityCount(run.characters16(), run.length(), run.d
irection(), isAfterExpansion, run.getTextJustify()); | 73 return expansionOpportunityCount(run.characters16(), run.length(), run.d
irection(), isAfterExpansion, run.getTextJustify()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 static bool isUprightInMixedVertical(UChar32 character); | 76 static bool isUprightInMixedVertical(UChar32 character); |
| 77 | 77 |
| 78 static bool treatAsSpace(UChar c) | 78 static bool treatAsSpace(UChar32 c) |
| 79 { | 79 { |
| 80 return c == spaceCharacter | 80 return c == spaceCharacter |
| 81 || c == tabulationCharacter | 81 || c == tabulationCharacter |
| 82 || c == newlineCharacter | 82 || c == newlineCharacter |
| 83 || c == noBreakSpaceCharacter; | 83 || c == noBreakSpaceCharacter; |
| 84 } | 84 } |
| 85 static bool treatAsZeroWidthSpace(UChar c) | 85 static bool treatAsZeroWidthSpace(UChar32 c) |
| 86 { | 86 { |
| 87 return treatAsZeroWidthSpaceInComplexScript(c) | 87 return treatAsZeroWidthSpaceInComplexScript(c) |
| 88 || c == zeroWidthNonJoinerCharacter | 88 || c == zeroWidthNonJoinerCharacter |
| 89 || c == zeroWidthJoinerCharacter; | 89 || c == zeroWidthJoinerCharacter; |
| 90 } | 90 } |
| 91 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) | 91 static bool treatAsZeroWidthSpaceInComplexScript(UChar32 c) |
| 92 { | 92 { |
| 93 return c < 0x20 // ASCII Control Characters | 93 return c < 0x20 // ASCII Control Characters |
| 94 || (c >= 0x7F && c < 0xA0) // ASCII Delete .. No-break spaceCharacte
r | 94 || (c >= 0x7F && c < 0xA0) // ASCII Delete .. No-break spaceCharacte
r |
| 95 || c == softHyphenCharacter | 95 || c == softHyphenCharacter |
| 96 || c == zeroWidthSpaceCharacter | 96 || c == zeroWidthSpaceCharacter |
| 97 || (c >= leftToRightMarkCharacter && c <= rightToLeftMarkCharacter) | 97 || (c >= leftToRightMarkCharacter && c <= rightToLeftMarkCharacter) |
| 98 || (c >= leftToRightEmbedCharacter && c <= rightToLeftOverrideCharac
ter) | 98 || (c >= leftToRightEmbedCharacter && c <= rightToLeftOverrideCharac
ter) |
| 99 || c == zeroWidthNoBreakSpaceCharacter | 99 || c == zeroWidthNoBreakSpaceCharacter |
| 100 || c == objectReplacementCharacter; | 100 || c == objectReplacementCharacter; |
| 101 } | 101 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 112 static bool isEmojiModifierBase(UChar32); | 112 static bool isEmojiModifierBase(UChar32); |
| 113 static bool isEmojiKeycapBase(UChar32); | 113 static bool isEmojiKeycapBase(UChar32); |
| 114 static bool isRegionalIndicator(UChar32); | 114 static bool isRegionalIndicator(UChar32); |
| 115 static bool isModifier(UChar32 c) | 115 static bool isModifier(UChar32 c) |
| 116 { | 116 { |
| 117 return c >= 0x1F3FB && c <= 0x1F3FF; | 117 return c >= 0x1F3FB && c <= 0x1F3FF; |
| 118 } | 118 } |
| 119 | 119 |
| 120 static inline UChar normalizeSpaces(UChar character) | 120 static inline UChar normalizeSpaces(UChar character) |
| 121 { | 121 { |
| 122 |
| 122 if (treatAsSpace(character)) | 123 if (treatAsSpace(character)) |
| 123 return spaceCharacter; | 124 return spaceCharacter; |
| 124 | 125 |
| 125 if (treatAsZeroWidthSpace(character)) | 126 if (treatAsZeroWidthSpace(character)) |
| 126 return zeroWidthSpaceCharacter; | 127 return zeroWidthSpaceCharacter; |
| 127 | 128 |
| 128 return character; | 129 return character; |
| 129 } | 130 } |
| 130 | 131 |
| 131 static inline bool isNormalizedCanvasSpaceCharacter(UChar c) | 132 static inline bool isNormalizedCanvasSpaceCharacter(UChar32 c) |
| 132 { | 133 { |
| 133 // According to specification all space characters should be replaced wi
th 0x0020 space character. | 134 // According to specification all space characters should be replaced wi
th 0x0020 space character. |
| 134 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canva
s-element.html#text-preparation-algorithm | 135 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canva
s-element.html#text-preparation-algorithm |
| 135 // The space characters according to specification are : U+0020, U+0009,
U+000A, U+000C, and U+000D. | 136 // The space characters according to specification are : U+0020, U+0009,
U+000A, U+000C, and U+000D. |
| 136 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-mi
crosyntaxes.html#space-character | 137 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-mi
crosyntaxes.html#space-character |
| 137 // This function returns true for 0x000B also, so that this is backward
compatible. | 138 // This function returns true for 0x000B also, so that this is backward
compatible. |
| 138 // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.spac
e.collapse.space.html will fail | 139 // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.spac
e.collapse.space.html will fail |
| 139 return c == 0x0009 || (c >= 0x000A && c <= 0x000D); | 140 return c == 0x0009 || (c >= 0x000A && c <= 0x000D); |
| 140 } | 141 } |
| 141 | 142 |
| 142 static String normalizeSpaces(const LChar*, unsigned length); | 143 static String normalizeSpaces(const LChar*, unsigned length); |
| 143 static String normalizeSpaces(const UChar*, unsigned length); | 144 static String normalizeSpaces(const UChar*, unsigned length); |
| 144 | 145 |
| 145 static bool isCommonOrInheritedScript(UChar32); | 146 static bool isCommonOrInheritedScript(UChar32); |
| 146 }; | 147 }; |
| 147 | 148 |
| 148 } // namespace blink | 149 } // namespace blink |
| 149 | 150 |
| 150 #endif | 151 #endif |
| OLD | NEW |