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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« 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