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

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

Issue 777143002: Early return when the value of test-justify is distribute, and the length of line is 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « LayoutTests/fast/css3-text/css3-text-justify/text-justify-crash-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 0x1F200, 0x1F6FF 336 0x1F200, 0x1F6FF
337 }; 337 };
338 338
339 return valueInIntervalList(cjkSymbolRanges, c); 339 return valueInIntervalList(cjkSymbolRanges, c);
340 } 340 }
341 341
342 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify) 342 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify)
343 { 343 {
344 unsigned count = 0; 344 unsigned count = 0;
345 if (textJustify == TextJustifyDistribute) { 345 if (textJustify == TextJustifyDistribute) {
346 count = length - 1; 346 if (length == 0)
347 return 0;
348 int lastCharacter = (direction == LTR) ? length - 1 : 0;
349 isAfterExpansion = treatAsSpace(characters[lastCharacter]);
350 return length - 1;
kojii 2014/12/11 08:47:36 I jumped in from the mid of review discussions wit
351 }
352
353 if (direction == LTR) {
354 for (size_t i = 0; i < length; ++i) {
355 if (treatAsSpace(characters[i])) {
356 count++;
357 isAfterExpansion = true;
358 } else {
359 isAfterExpansion = false;
360 }
361 }
347 } else { 362 } else {
348 if (direction == LTR) { 363 for (size_t i = length; i > 0; --i) {
349 for (size_t i = 0; i < length; ++i) { 364 if (treatAsSpace(characters[i - 1])) {
350 if (treatAsSpace(characters[i])) 365 count++;
351 count++; 366 isAfterExpansion = true;
352 } 367 } else {
353 } else { 368 isAfterExpansion = false;
354 for (size_t i = length; i > 0; --i) {
355 if (treatAsSpace(characters[i - 1]))
356 count++;
357 } 369 }
358 } 370 }
359 } 371 }
360 int lastCharacter = (direction == LTR) ? length - 1 : 0;
361 isAfterExpansion = treatAsSpace(characters[lastCharacter]);
362 372
363 return count; 373 return count;
364 } 374 }
365 375
366 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify) 376 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify)
367 { 377 {
368 unsigned count = 0; 378 unsigned count = 0;
369 if (direction == LTR) { 379 if (direction == LTR) {
370 for (size_t i = 0; i < length; ++i) { 380 for (size_t i = 0; i < length; ++i) {
371 UChar32 character = characters[i]; 381 UChar32 character = characters[i];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 { 438 {
429 return normalizeSpacesInternal(characters, length); 439 return normalizeSpacesInternal(characters, length);
430 } 440 }
431 441
432 String Character::normalizeSpaces(const UChar* characters, unsigned length) 442 String Character::normalizeSpaces(const UChar* characters, unsigned length)
433 { 443 {
434 return normalizeSpacesInternal(characters, length); 444 return normalizeSpacesInternal(characters, length);
435 } 445 }
436 446
437 } // namespace blink 447 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css3-text/css3-text-justify/text-justify-crash-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698