Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/platform/fonts/Character.h

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code changes to correct Test Expectation Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 == characterSpace
65 || c == characterTabulation 65 || c == characterTabulation
66 || c == newlineCharacter 66 || c == characterNewline
67 || c == noBreakSpace; 67 || c == characterNoBreakSpace;
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 == characterZeroWidthNonJoiner
73 || c == zeroWidthJoiner; 73 || c == characterZeroWidthJoiner;
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 characterSpac e
79 || c == softHyphen 79 || c == characterSoftHyphen
80 || c == zeroWidthSpace 80 || c == characterZeroWidthSpace
81 || (c >= leftToRightMark && c <= rightToLeftMark) 81 || (c >= characterLeftToRightMark && c <= characterRightToLeftMark)
82 || (c >= leftToRightEmbed && c <= rightToLeftOverride) 82 || (c >= characterLeftToRightEmbed && c <= characterRightToLeftOverr ide)
83 || c == zeroWidthNoBreakSpace 83 || c == characterZeroWidthNoBreakSpace
84 || c == objectReplacementCharacter; 84 || c == characterObjectReplacement;
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 characterSpace;
92 92
93 if (treatAsZeroWidthSpace(character)) 93 if (treatAsZeroWidthSpace(character))
94 return zeroWidthSpace; 94 return characterZeroWidthSpace;
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 characterSpace characters should be re placed with 0x0020 space character.
jsbell 2015/05/05 17:29:53 This comment change is incorrect.
h.joshi 2015/05/11 07:06:32 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698