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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 0x1F110, 0x1F129, | 253 0x1F110, 0x1F129, |
254 0x1F130, 0x1F149, | 254 0x1F130, 0x1F149, |
255 0x1F150, 0x1F169, | 255 0x1F150, 0x1F169, |
256 0x1F170, 0x1F189, | 256 0x1F170, 0x1F189, |
257 0x1F200, 0x1F6FF | 257 0x1F200, 0x1F6FF |
258 }; | 258 }; |
259 | 259 |
260 return valueInIntervalList(cjkSymbolRanges, c); | 260 return valueInIntervalList(cjkSymbolRanges, c); |
261 } | 261 } |
262 | 262 |
263 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion) | 263 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus
tify) |
| 264 { |
| 265 unsigned count = 0; |
| 266 if (textJustify == TextJustifyDistribute) { |
| 267 count = length - 1; |
| 268 } else { |
| 269 if (direction == LTR) { |
| 270 for (size_t i = 0; i < length; ++i) { |
| 271 if (treatAsSpace(characters[i])) |
| 272 count++; |
| 273 } |
| 274 } else { |
| 275 for (size_t i = length; i > 0; --i) { |
| 276 if (treatAsSpace(characters[i - 1])) |
| 277 count++; |
| 278 } |
| 279 } |
| 280 } |
| 281 int lastCharacter = (direction == LTR) ? length - 1 : 0; |
| 282 isAfterExpansion = treatAsSpace(characters[lastCharacter]); |
| 283 |
| 284 return count; |
| 285 } |
| 286 |
| 287 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus
tify) |
264 { | 288 { |
265 unsigned count = 0; | 289 unsigned count = 0; |
266 if (direction == LTR) { | 290 if (direction == LTR) { |
267 for (size_t i = 0; i < length; ++i) { | |
268 if (treatAsSpace(characters[i])) { | |
269 count++; | |
270 isAfterExpansion = true; | |
271 } else { | |
272 isAfterExpansion = false; | |
273 } | |
274 } | |
275 } else { | |
276 for (size_t i = length; i > 0; --i) { | |
277 if (treatAsSpace(characters[i - 1])) { | |
278 count++; | |
279 isAfterExpansion = true; | |
280 } else { | |
281 isAfterExpansion = false; | |
282 } | |
283 } | |
284 } | |
285 return count; | |
286 } | |
287 | |
288 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion) | |
289 { | |
290 unsigned count = 0; | |
291 if (direction == LTR) { | |
292 for (size_t i = 0; i < length; ++i) { | 291 for (size_t i = 0; i < length; ++i) { |
293 UChar32 character = characters[i]; | 292 UChar32 character = characters[i]; |
294 if (treatAsSpace(character)) { | 293 if (treatAsSpace(character)) { |
295 count++; | 294 count++; |
296 isAfterExpansion = true; | 295 isAfterExpansion = true; |
297 continue; | 296 continue; |
298 } | 297 } |
299 if (U16_IS_LEAD(character) && i + 1 < length && U16_IS_TRAIL(charact
ers[i + 1])) { | 298 if (U16_IS_LEAD(character) && i + 1 < length && U16_IS_TRAIL(charact
ers[i + 1])) { |
300 character = U16_GET_SUPPLEMENTARY(character, characters[i + 1]); | 299 character = U16_GET_SUPPLEMENTARY(character, characters[i + 1]); |
301 i++; | 300 i++; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 { | 349 { |
351 return normalizeSpacesInternal(characters, length); | 350 return normalizeSpacesInternal(characters, length); |
352 } | 351 } |
353 | 352 |
354 String Character::normalizeSpaces(const UChar* characters, unsigned length) | 353 String Character::normalizeSpaces(const UChar* characters, unsigned length) |
355 { | 354 { |
356 return normalizeSpacesInternal(characters, length); | 355 return normalizeSpacesInternal(characters, length); |
357 } | 356 } |
358 | 357 |
359 } // namespace blink | 358 } // namespace blink |
OLD | NEW |