| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 static bool isCJKIdeograph(UChar32); | 54 static bool isCJKIdeograph(UChar32); |
| 55 static bool isCJKIdeographOrSymbol(UChar32); | 55 static bool isCJKIdeographOrSymbol(UChar32); |
| 56 | 56 |
| 57 static unsigned expansionOpportunityCount(const LChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); | 57 static unsigned expansionOpportunityCount(const LChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); |
| 58 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); | 58 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion, const TextJustify); |
| 59 | 59 |
| 60 static bool shouldIgnoreRotation(UChar32 character); | 60 static bool shouldIgnoreRotation(UChar32 character); |
| 61 | 61 |
| 62 static bool treatAsSpace(UChar c) | 62 static bool treatAsSpace(UChar c) |
| 63 { | 63 { |
| 64 return c == space | 64 return c == spaceCharacter |
| 65 || c == characterTabulation | 65 || c == tabulationCharacter |
| 66 || c == newlineCharacter | 66 || c == newlineCharacter |
| 67 || c == noBreakSpace; | 67 || c == noBreakSpaceCharacter; |
| 68 } | 68 } |
| 69 static bool treatAsZeroWidthSpace(UChar c) | 69 static bool treatAsZeroWidthSpace(UChar c) |
| 70 { | 70 { |
| 71 return treatAsZeroWidthSpaceInComplexScript(c) | 71 return treatAsZeroWidthSpaceInComplexScript(c) |
| 72 || c == zeroWidthNonJoiner | 72 || c == zeroWidthNonJoinerCharacter |
| 73 || c == zeroWidthJoiner; | 73 || c == zeroWidthJoinerCharacter; |
| 74 } | 74 } |
| 75 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) | 75 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) |
| 76 { | 76 { |
| 77 return c < 0x20 // ASCII Control Characters | 77 return c < 0x20 // ASCII Control Characters |
| 78 || (c >= 0x7F && c < 0xA0) // ASCII Delete .. No-break space | 78 || (c >= 0x7F && c < 0xA0) // ASCII Delete .. No-break spaceCharacte
r |
| 79 || c == softHyphen | 79 || c == softHyphenCharacter |
| 80 || c == zeroWidthSpace | 80 || c == zeroWidthSpaceCharacter |
| 81 || (c >= leftToRightMark && c <= rightToLeftMark) | 81 || (c >= leftToRightMarkCharacter && c <= rightToLeftMarkCharacter) |
| 82 || (c >= leftToRightEmbed && c <= rightToLeftOverride) | 82 || (c >= leftToRightEmbedCharacter && c <= rightToLeftOverrideCharac
ter) |
| 83 || c == zeroWidthNoBreakSpace | 83 || c == zeroWidthNoBreakSpaceCharacter |
| 84 || c == objectReplacementCharacter; | 84 || c == objectReplacementCharacter; |
| 85 } | 85 } |
| 86 static bool canReceiveTextEmphasis(UChar32); | 86 static bool canReceiveTextEmphasis(UChar32); |
| 87 | 87 |
| 88 static inline UChar normalizeSpaces(UChar character) | 88 static inline UChar normalizeSpaces(UChar character) |
| 89 { | 89 { |
| 90 if (treatAsSpace(character)) | 90 if (treatAsSpace(character)) |
| 91 return space; | 91 return spaceCharacter; |
| 92 | 92 |
| 93 if (treatAsZeroWidthSpace(character)) | 93 if (treatAsZeroWidthSpace(character)) |
| 94 return zeroWidthSpace; | 94 return zeroWidthSpaceCharacter; |
| 95 | 95 |
| 96 return character; | 96 return character; |
| 97 } | 97 } |
| 98 | 98 |
| 99 static inline bool isNormalizedCanvasSpaceCharacter(UChar c) | 99 static inline bool isNormalizedCanvasSpaceCharacter(UChar c) |
| 100 { | 100 { |
| 101 // According to specification all space characters should be replaced wi
th 0x0020 space character. | 101 // According to specification all space characters should be replaced wi
th 0x0020 space character. |
| 102 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canva
s-element.html#text-preparation-algorithm | 102 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canva
s-element.html#text-preparation-algorithm |
| 103 // The space characters according to specification are : U+0020, U+0009,
U+000A, U+000C, and U+000D. | 103 // The space characters according to specification are : U+0020, U+0009,
U+000A, U+000C, and U+000D. |
| 104 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-mi
crosyntaxes.html#space-character | 104 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-mi
crosyntaxes.html#space-character |
| 105 // This function returns true for 0x000B also, so that this is backward
compatible. | 105 // This function returns true for 0x000B also, so that this is backward
compatible. |
| 106 // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.spac
e.collapse.space.html will fail | 106 // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.spac
e.collapse.space.html will fail |
| 107 return c == 0x0009 || (c >= 0x000A && c <= 0x000D); | 107 return c == 0x0009 || (c >= 0x000A && c <= 0x000D); |
| 108 } | 108 } |
| 109 | 109 |
| 110 static String normalizeSpaces(const LChar*, unsigned length); | 110 static String normalizeSpaces(const LChar*, unsigned length); |
| 111 static String normalizeSpaces(const UChar*, unsigned length); | 111 static String normalizeSpaces(const UChar*, unsigned length); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 Character(); | 114 Character(); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace blink | 117 } // namespace blink |
| 118 | 118 |
| 119 #endif | 119 #endif |
| OLD | NEW |