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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 0x1F110, 0x1F129, | 254 0x1F110, 0x1F129, |
255 0x1F130, 0x1F149, | 255 0x1F130, 0x1F149, |
256 0x1F150, 0x1F169, | 256 0x1F150, 0x1F169, |
257 0x1F170, 0x1F189, | 257 0x1F170, 0x1F189, |
258 0x1F200, 0x1F6FF | 258 0x1F200, 0x1F6FF |
259 }; | 259 }; |
260 | 260 |
261 return valueInIntervalList(cjkSymbolRanges, c); | 261 return valueInIntervalList(cjkSymbolRanges, c); |
262 } | 262 } |
263 | 263 |
264 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion) | 264 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion, const TextJustifyStore te
xtJustify) |
265 { | 265 { |
266 unsigned count = 0; | 266 unsigned count = 0; |
267 if (direction == LTR) { | 267 if (textJustify == TextJustifyDistribute) { |
268 for (size_t i = 0; i < length; ++i) { | 268 count = length - 1; |
269 if (treatAsSpace(characters[i])) { | 269 } else { |
270 count++; | 270 if (direction == LTR) { |
271 isAfterExpansion = true; | 271 for (size_t i = 0; i < length; ++i) { |
272 } else { | 272 if (treatAsSpace(characters[i])) |
273 isAfterExpansion = false; | 273 count++; |
274 } | 274 } |
275 } | 275 } else { |
276 } else { | 276 for (size_t i = length; i > 0; --i) { |
277 for (size_t i = length; i > 0; --i) { | 277 if (treatAsSpace(characters[i - 1])) |
278 if (treatAsSpace(characters[i - 1])) { | 278 count++; |
279 count++; | |
280 isAfterExpansion = true; | |
281 } else { | |
282 isAfterExpansion = false; | |
283 } | 279 } |
284 } | 280 } |
285 } | 281 } |
| 282 int lastCharacter = (direction == LTR) ? length - 1 : 0; |
| 283 isAfterExpansion = treatAsSpace(characters[lastCharacter]); |
| 284 |
286 return count; | 285 return count; |
287 } | 286 } |
288 | 287 |
289 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion) | 288 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le
ngth, TextDirection direction, bool& isAfterExpansion, const TextJustifyStore te
xtJustify) |
290 { | 289 { |
291 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId
eographsInComplexText(); | 290 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId
eographsInComplexText(); |
292 unsigned count = 0; | 291 unsigned count = 0; |
293 if (direction == LTR) { | 292 if (direction == LTR) { |
294 for (size_t i = 0; i < length; ++i) { | 293 for (size_t i = 0; i < length; ++i) { |
295 UChar32 character = characters[i]; | 294 UChar32 character = characters[i]; |
296 if (treatAsSpace(character)) { | 295 if (treatAsSpace(character)) { |
297 count++; | 296 count++; |
298 isAfterExpansion = true; | 297 isAfterExpansion = true; |
299 continue; | 298 continue; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 { | 365 { |
367 return normalizeSpacesInternal(characters, length); | 366 return normalizeSpacesInternal(characters, length); |
368 } | 367 } |
369 | 368 |
370 String Character::normalizeSpaces(const UChar* characters, unsigned length) | 369 String Character::normalizeSpaces(const UChar* characters, unsigned length) |
371 { | 370 { |
372 return normalizeSpacesInternal(characters, length); | 371 return normalizeSpacesInternal(characters, length); |
373 } | 372 } |
374 | 373 |
375 } // namespace blink | 374 } // namespace blink |
OLD | NEW |