Chromium Code Reviews| Index: Source/platform/fonts/Character.cpp |
| diff --git a/Source/platform/fonts/Character.cpp b/Source/platform/fonts/Character.cpp |
| index 9ae36fc83ca78d1ffee41b510d576eb556914cdd..9c9dc6db716ad030a39c9ea8c3eab26cb5164e00 100644 |
| --- a/Source/platform/fonts/Character.cpp |
| +++ b/Source/platform/fonts/Character.cpp |
| @@ -343,22 +343,32 @@ unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le |
| { |
| unsigned count = 0; |
| if (textJustify == TextJustifyDistribute) { |
| - count = length - 1; |
| - } else { |
| - if (direction == LTR) { |
| - for (size_t i = 0; i < length; ++i) { |
| - if (treatAsSpace(characters[i])) |
| - count++; |
| + if (length == 0) |
| + return 0; |
| + int lastCharacter = (direction == LTR) ? length - 1 : 0; |
| + isAfterExpansion = treatAsSpace(characters[lastCharacter]); |
| + return length - 1; |
|
kojii
2014/12/11 08:47:36
I jumped in from the mid of review discussions wit
|
| + } |
| + |
| + if (direction == LTR) { |
| + for (size_t i = 0; i < length; ++i) { |
| + if (treatAsSpace(characters[i])) { |
| + count++; |
| + isAfterExpansion = true; |
| + } else { |
| + isAfterExpansion = false; |
| } |
| - } else { |
| - for (size_t i = length; i > 0; --i) { |
| - if (treatAsSpace(characters[i - 1])) |
| - count++; |
| + } |
| + } else { |
| + for (size_t i = length; i > 0; --i) { |
| + if (treatAsSpace(characters[i - 1])) { |
| + count++; |
| + isAfterExpansion = true; |
| + } else { |
| + isAfterExpansion = false; |
| } |
| } |
| } |
| - int lastCharacter = (direction == LTR) ? length - 1 : 0; |
| - isAfterExpansion = treatAsSpace(characters[lastCharacter]); |
| return count; |
| } |