OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All |
3 * rights reserved. | 3 * rights reserved. |
4 * Copyright (C) 2005 Alexey Proskuryakov. | 4 * Copyright (C) 2005 Alexey Proskuryakov. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return true; | 144 return true; |
145 | 145 |
146 // Halfwidth katakana letters. | 146 // Halfwidth katakana letters. |
147 if (character >= 0xFF66 && character <= 0xFF9D && character != 0xFF70) | 147 if (character >= 0xFF66 && character <= 0xFF9D && character != 0xFF70) |
148 return true; | 148 return true; |
149 | 149 |
150 return false; | 150 return false; |
151 } | 151 } |
152 | 152 |
153 bool IsSmallKanaLetter(UChar character) { | 153 bool IsSmallKanaLetter(UChar character) { |
154 ASSERT(IsKanaLetter(character)); | 154 DCHECK(IsKanaLetter(character)); |
155 | 155 |
156 switch (character) { | 156 switch (character) { |
157 case 0x3041: // HIRAGANA LETTER SMALL A | 157 case 0x3041: // HIRAGANA LETTER SMALL A |
158 case 0x3043: // HIRAGANA LETTER SMALL I | 158 case 0x3043: // HIRAGANA LETTER SMALL I |
159 case 0x3045: // HIRAGANA LETTER SMALL U | 159 case 0x3045: // HIRAGANA LETTER SMALL U |
160 case 0x3047: // HIRAGANA LETTER SMALL E | 160 case 0x3047: // HIRAGANA LETTER SMALL E |
161 case 0x3049: // HIRAGANA LETTER SMALL O | 161 case 0x3049: // HIRAGANA LETTER SMALL O |
162 case 0x3063: // HIRAGANA LETTER SMALL TU | 162 case 0x3063: // HIRAGANA LETTER SMALL TU |
163 case 0x3083: // HIRAGANA LETTER SMALL YA | 163 case 0x3083: // HIRAGANA LETTER SMALL YA |
164 case 0x3085: // HIRAGANA LETTER SMALL YU | 164 case 0x3085: // HIRAGANA LETTER SMALL YU |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 case 0xFF6C: // HALFWIDTH KATAKANA LETTER SMALL YA | 202 case 0xFF6C: // HALFWIDTH KATAKANA LETTER SMALL YA |
203 case 0xFF6D: // HALFWIDTH KATAKANA LETTER SMALL YU | 203 case 0xFF6D: // HALFWIDTH KATAKANA LETTER SMALL YU |
204 case 0xFF6E: // HALFWIDTH KATAKANA LETTER SMALL YO | 204 case 0xFF6E: // HALFWIDTH KATAKANA LETTER SMALL YO |
205 case 0xFF6F: // HALFWIDTH KATAKANA LETTER SMALL TU | 205 case 0xFF6F: // HALFWIDTH KATAKANA LETTER SMALL TU |
206 return true; | 206 return true; |
207 } | 207 } |
208 return false; | 208 return false; |
209 } | 209 } |
210 | 210 |
211 static inline VoicedSoundMarkType ComposedVoicedSoundMark(UChar character) { | 211 static inline VoicedSoundMarkType ComposedVoicedSoundMark(UChar character) { |
212 ASSERT(IsKanaLetter(character)); | 212 DCHECK(IsKanaLetter(character)); |
213 | 213 |
214 switch (character) { | 214 switch (character) { |
215 case 0x304C: // HIRAGANA LETTER GA | 215 case 0x304C: // HIRAGANA LETTER GA |
216 case 0x304E: // HIRAGANA LETTER GI | 216 case 0x304E: // HIRAGANA LETTER GI |
217 case 0x3050: // HIRAGANA LETTER GU | 217 case 0x3050: // HIRAGANA LETTER GU |
218 case 0x3052: // HIRAGANA LETTER GE | 218 case 0x3052: // HIRAGANA LETTER GE |
219 case 0x3054: // HIRAGANA LETTER GO | 219 case 0x3054: // HIRAGANA LETTER GO |
220 case 0x3056: // HIRAGANA LETTER ZA | 220 case 0x3056: // HIRAGANA LETTER ZA |
221 case 0x3058: // HIRAGANA LETTER ZI | 221 case 0x3058: // HIRAGANA LETTER ZI |
222 case 0x305A: // HIRAGANA LETTER ZU | 222 case 0x305A: // HIRAGANA LETTER ZU |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 for (unsigned i = 0; i < length; ++i) { | 288 for (unsigned i = 0; i < length; ++i) { |
289 if (IsKanaLetter(pattern[i])) | 289 if (IsKanaLetter(pattern[i])) |
290 return true; | 290 return true; |
291 } | 291 } |
292 return false; | 292 return false; |
293 } | 293 } |
294 | 294 |
295 void NormalizeCharactersIntoNFCForm(const UChar* characters, | 295 void NormalizeCharactersIntoNFCForm(const UChar* characters, |
296 unsigned length, | 296 unsigned length, |
297 Vector<UChar>& buffer) { | 297 Vector<UChar>& buffer) { |
298 ASSERT(length); | 298 DCHECK(length); |
299 | 299 |
300 buffer.Resize(length); | 300 buffer.Resize(length); |
301 | 301 |
302 UErrorCode status = U_ZERO_ERROR; | 302 UErrorCode status = U_ZERO_ERROR; |
303 size_t buffer_size = unorm_normalize(characters, length, UNORM_NFC, 0, | 303 size_t buffer_size = unorm_normalize(characters, length, UNORM_NFC, 0, |
304 buffer.Data(), length, &status); | 304 buffer.Data(), length, &status); |
305 ASSERT(status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING || | 305 DCHECK(status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING || |
306 status == U_BUFFER_OVERFLOW_ERROR); | 306 status == U_BUFFER_OVERFLOW_ERROR); |
307 ASSERT(buffer_size); | 307 DCHECK(buffer_size); |
308 | 308 |
309 buffer.Resize(buffer_size); | 309 buffer.Resize(buffer_size); |
310 | 310 |
311 if (status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING) | 311 if (status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING) |
312 return; | 312 return; |
313 | 313 |
314 status = U_ZERO_ERROR; | 314 status = U_ZERO_ERROR; |
315 unorm_normalize(characters, length, UNORM_NFC, 0, buffer.Data(), buffer_size, | 315 unorm_normalize(characters, length, UNORM_NFC, 0, buffer.Data(), buffer_size, |
316 &status); | 316 &status); |
317 ASSERT(status == U_STRING_NOT_TERMINATED_WARNING); | 317 DCHECK_EQ(status, U_STRING_NOT_TERMINATED_WARNING); |
318 } | 318 } |
319 | 319 |
320 // This function returns kNotFound if |first| and |second| contain different | 320 // This function returns kNotFound if |first| and |second| contain different |
321 // Kana letters. If |first| and |second| contain the same Kana letter then | 321 // Kana letters. If |first| and |second| contain the same Kana letter then |
322 // function returns offset in characters from |first|. | 322 // function returns offset in characters from |first|. |
323 // Pointers to both strings increase simultaneously so so it is possible to use | 323 // Pointers to both strings increase simultaneously so so it is possible to use |
324 // one offset value. | 324 // one offset value. |
325 static inline size_t CompareKanaLetterAndComposedVoicedSoundMarks( | 325 static inline size_t CompareKanaLetterAndComposedVoicedSoundMarks( |
326 const UChar* first, | 326 const UChar* first, |
327 const UChar* first_end, | 327 const UChar* first_end, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 if (offset == kNotFound) | 424 if (offset == kNotFound) |
425 return false; | 425 return false; |
426 | 426 |
427 // Update values of |a| and |b| after comparing. | 427 // Update values of |a| and |b| after comparing. |
428 a += offset; | 428 a += offset; |
429 b += offset; | 429 b += offset; |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 } // namespace blink | 433 } // namespace blink |
OLD | NEW |