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

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: With test case 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 0x1F150, 0x1F169, 334 0x1F150, 0x1F169,
335 0x1F170, 0x1F189, 335 0x1F170, 0x1F189,
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 if (length == 0) {
345 isAfterExpansion = false;
kojii 2014/12/05 06:23:22 Why do we need to set |isAfterExpansion = false| h
dw.im 2014/12/05 07:16:42 Because the caller use this value after getting re
kojii 2014/12/05 13:11:21 The |isAfterExpansion| is in-out parameter, not ou
346 return 0;
347 }
348
344 unsigned count = 0; 349 unsigned count = 0;
345 if (textJustify == TextJustifyDistribute) { 350 if (textJustify == TextJustifyDistribute) {
346 count = length - 1; 351 count = length - 1;
347 } else { 352 } else {
348 if (direction == LTR) { 353 if (direction == LTR) {
349 for (size_t i = 0; i < length; ++i) { 354 for (size_t i = 0; i < length; ++i) {
350 if (treatAsSpace(characters[i])) 355 if (treatAsSpace(characters[i]))
351 count++; 356 count++;
352 } 357 }
353 } else { 358 } else {
354 for (size_t i = length; i > 0; --i) { 359 for (size_t i = length; i > 0; --i) {
355 if (treatAsSpace(characters[i - 1])) 360 if (treatAsSpace(characters[i - 1]))
356 count++; 361 count++;
357 } 362 }
358 } 363 }
359 } 364 }
360 int lastCharacter = (direction == LTR) ? length - 1 : 0; 365 size_t lastCharacter = (direction == LTR) ? length - 1 : 0;
361 isAfterExpansion = treatAsSpace(characters[lastCharacter]); 366 isAfterExpansion = treatAsSpace(characters[lastCharacter]);
362 367
363 return count; 368 return count;
364 } 369 }
365 370
366 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify) 371 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify)
367 { 372 {
368 unsigned count = 0; 373 unsigned count = 0;
369 if (direction == LTR) { 374 if (direction == LTR) {
370 for (size_t i = 0; i < length; ++i) { 375 for (size_t i = 0; i < length; ++i) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 { 433 {
429 return normalizeSpacesInternal(characters, length); 434 return normalizeSpacesInternal(characters, length);
430 } 435 }
431 436
432 String Character::normalizeSpaces(const UChar* characters, unsigned length) 437 String Character::normalizeSpaces(const UChar* characters, unsigned length)
433 { 438 {
434 return normalizeSpacesInternal(characters, length); 439 return normalizeSpacesInternal(characters, length);
435 } 440 }
436 441
437 } // namespace blink 442 } // 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