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

Unified Diff: Source/platform/fonts/Character.cpp

Issue 255323004: Rendering text-justify:distribute for 8 bit characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Using 2 bits for enum Created 6 years, 4 months 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
Index: Source/platform/fonts/Character.cpp
diff --git a/Source/platform/fonts/Character.cpp b/Source/platform/fonts/Character.cpp
index dec8b4d2728d522557ba00831ed7228dcce4429f..b66c828674ec5a09311f656a474fa4fdce487fdb 100644
--- a/Source/platform/fonts/Character.cpp
+++ b/Source/platform/fonts/Character.cpp
@@ -261,32 +261,40 @@ bool Character::isCJKIdeographOrSymbol(UChar32 c)
return valueInIntervalList(cjkSymbolRanges, c);
}
-unsigned Character::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Character::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJustify)
{
unsigned count = 0;
- if (direction == LTR) {
- for (size_t i = 0; i < length; ++i) {
- if (treatAsSpace(characters[i])) {
- count++;
- isAfterExpansion = true;
- } else {
- isAfterExpansion = false;
- }
- }
+ if (textJustify == JustifyDistribute) {
+ count = length - 1;
} else {
- for (size_t i = length; i > 0; --i) {
- if (treatAsSpace(characters[i - 1])) {
- count++;
- isAfterExpansion = true;
- } else {
- isAfterExpansion = false;
+ if (direction == LTR) {
+ for (size_t i = 0; i < length; ++i) {
+ if (treatAsSpace(characters[i]))
+ count++;
+ }
+ } else {
+ for (size_t i = length; i > 0; --i) {
+ if (treatAsSpace(characters[i - 1]))
+ count++;
}
}
}
+ if (direction == LTR) {
+ if (treatAsSpace(characters[length - 1]))
leviw_travelin_and_unemployed 2014/08/18 17:55:43 int lastCharacter = (direction == ltr) ? length -
dw.im 2014/08/21 00:20:55 Cool!
+ isAfterExpansion = true;
+ else
+ isAfterExpansion = false;
+ } else {
+ if (treatAsSpace(characters[0]))
+ isAfterExpansion = true;
+ else
+ isAfterExpansion = false;
+ }
+
return count;
}
-unsigned Character::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Character::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJustify)
{
static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundIdeographsInComplexText();
unsigned count = 0;

Powered by Google App Engine
This is Rietveld 408576698