| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simp
lePath; } | 45 static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simp
lePath; } |
| 46 static CodePath characterRangeCodePath(const UChar*, unsigned len); | 46 static CodePath characterRangeCodePath(const UChar*, unsigned len); |
| 47 | 47 |
| 48 static bool isCJKIdeograph(UChar32); | 48 static bool isCJKIdeograph(UChar32); |
| 49 static bool isCJKIdeographOrSymbol(UChar32); | 49 static bool isCJKIdeographOrSymbol(UChar32); |
| 50 | 50 |
| 51 static unsigned expansionOpportunityCount(const LChar*, size_t length, TextD
irection, bool& isAfterExpansion); | 51 static unsigned expansionOpportunityCount(const LChar*, size_t length, TextD
irection, bool& isAfterExpansion); |
| 52 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion); | 52 static unsigned expansionOpportunityCount(const UChar*, size_t length, TextD
irection, bool& isAfterExpansion); |
| 53 | 53 |
| 54 static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n
' || c == noBreakSpace; } | 54 static bool treatAsSpace(UChar c) { return c == space || c == characterTabul
ation || c == newlineCharacter || c == noBreakSpace; } |
| 55 static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInC
omplexScript(c) || c == 0x200c || c == 0x200d; } | 55 static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInC
omplexScript(c) || c == 0x200c || c == 0x200d; } |
| 56 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20
|| (c >= 0x7F && c < 0xA0) || c == softHyphen || c == zeroWidthSpace || (c >= 0x
200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpa
ce || c == objectReplacementCharacter; } | 56 static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20
|| (c >= 0x7F && c < 0xA0) || c == softHyphen || c == zeroWidthSpace || (c >= 0x
200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpa
ce || c == objectReplacementCharacter; } |
| 57 static bool canReceiveTextEmphasis(UChar32); | 57 static bool canReceiveTextEmphasis(UChar32); |
| 58 | 58 |
| 59 static inline UChar normalizeSpaces(UChar character) | 59 static inline UChar normalizeSpaces(UChar character) |
| 60 { | 60 { |
| 61 if (treatAsSpace(character)) | 61 if (treatAsSpace(character)) |
| 62 return space; | 62 return space; |
| 63 | 63 |
| 64 if (treatAsZeroWidthSpace(character)) | 64 if (treatAsZeroWidthSpace(character)) |
| 65 return zeroWidthSpace; | 65 return zeroWidthSpace; |
| 66 | 66 |
| 67 return character; | 67 return character; |
| 68 } | 68 } |
| 69 | 69 |
| 70 static inline bool isNormalizedCanvasSpaceCharacter(UChar c) |
| 71 { |
| 72 // According to specification all space characters should be replaced wi
th 0x0020 space character. |
| 73 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canva
s-element.html#text-preparation-algorithm |
| 74 // The space characters according to specification are : U+0020, U+0009,
U+000A, U+000C, and U+000D. |
| 75 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-mi
crosyntaxes.html#space-character |
| 76 // This function returns true for 0x000B also, so that this is backward
compatible. |
| 77 // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.spac
e.collapse.space.html will fail |
| 78 return c == 0x0009 || (c >= 0x000A && c <= 0x000D); |
| 79 } |
| 80 |
| 70 static String normalizeSpaces(const LChar*, unsigned length); | 81 static String normalizeSpaces(const LChar*, unsigned length); |
| 71 static String normalizeSpaces(const UChar*, unsigned length); | 82 static String normalizeSpaces(const UChar*, unsigned length); |
| 72 | 83 |
| 73 private: | 84 private: |
| 74 Character(); | 85 Character(); |
| 75 }; | 86 }; |
| 76 | 87 |
| 77 } // namespace blink | 88 } // namespace blink |
| 78 | 89 |
| 79 #endif | 90 #endif |
| OLD | NEW |