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

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: patch for landing 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-distribute.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 isAfterExpansion = true;
347 return length;
348 }
349
350 if (direction == LTR) {
351 for (size_t i = 0; i < length; ++i) {
352 if (treatAsSpace(characters[i])) {
353 count++;
354 isAfterExpansion = true;
355 } else {
356 isAfterExpansion = false;
357 }
358 }
347 } else { 359 } else {
348 if (direction == LTR) { 360 for (size_t i = length; i > 0; --i) {
349 for (size_t i = 0; i < length; ++i) { 361 if (treatAsSpace(characters[i - 1])) {
350 if (treatAsSpace(characters[i])) 362 count++;
351 count++; 363 isAfterExpansion = true;
352 } 364 } else {
353 } else { 365 isAfterExpansion = false;
354 for (size_t i = length; i > 0; --i) {
355 if (treatAsSpace(characters[i - 1]))
356 count++;
357 } 366 }
358 } 367 }
359 } 368 }
360 int lastCharacter = (direction == LTR) ? length - 1 : 0;
361 isAfterExpansion = treatAsSpace(characters[lastCharacter]);
362 369
363 return count; 370 return count;
364 } 371 }
365 372
366 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify) 373 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const TextJustify textJus tify)
367 { 374 {
368 unsigned count = 0; 375 unsigned count = 0;
369 if (direction == LTR) { 376 if (direction == LTR) {
370 for (size_t i = 0; i < length; ++i) { 377 for (size_t i = 0; i < length; ++i) {
371 UChar32 character = characters[i]; 378 UChar32 character = characters[i];
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 { 449 {
443 return normalizeSpacesInternal(characters, length); 450 return normalizeSpacesInternal(characters, length);
444 } 451 }
445 452
446 String Character::normalizeSpaces(const UChar* characters, unsigned length) 453 String Character::normalizeSpaces(const UChar* characters, unsigned length)
447 { 454 {
448 return normalizeSpacesInternal(characters, length); 455 return normalizeSpacesInternal(characters, length);
449 } 456 }
450 457
451 } // namespace blink 458 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css3-text/css3-text-justify/text-justify-distribute.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698