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

Side by Side 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 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 unified diff | Download patch
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 0x1F110, 0x1F129, 256 0x1F110, 0x1F129,
257 0x1F130, 0x1F149, 257 0x1F130, 0x1F149,
258 0x1F150, 0x1F169, 258 0x1F150, 0x1F169,
259 0x1F170, 0x1F189, 259 0x1F170, 0x1F189,
260 0x1F200, 0x1F6FF 260 0x1F200, 0x1F6FF
261 }; 261 };
262 262
263 return valueInIntervalList(cjkSymbolRanges, c); 263 return valueInIntervalList(cjkSymbolRanges, c);
264 } 264 }
265 265
266 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion) 266 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJu stify)
267 { 267 {
268 unsigned count = 0; 268 unsigned count = 0;
269 if (direction == LTR) { 269 if (textJustify == JustifyDistribute) {
270 for (size_t i = 0; i < length; ++i) { 270 count = length - 1;
271 if (treatAsSpace(characters[i])) { 271 } else {
272 count++; 272 if (direction == LTR) {
273 isAfterExpansion = true; 273 for (size_t i = 0; i < length; ++i) {
274 } else { 274 if (treatAsSpace(characters[i]))
275 isAfterExpansion = false; 275 count++;
276 } 276 }
277 } 277 } else {
278 } else { 278 for (size_t i = length; i > 0; --i) {
279 for (size_t i = length; i > 0; --i) { 279 if (treatAsSpace(characters[i - 1]))
280 if (treatAsSpace(characters[i - 1])) { 280 count++;
281 count++;
282 isAfterExpansion = true;
283 } else {
284 isAfterExpansion = false;
285 } 281 }
286 } 282 }
287 } 283 }
284 if (direction == LTR) {
285 if (treatAsSpace(characters[length - 1]))
286 isAfterExpansion = true;
287 else
288 isAfterExpansion = false;
289 } else {
290 if (treatAsSpace(characters[0]))
291 isAfterExpansion = true;
292 else
293 isAfterExpansion = false;
294 }
295
288 return count; 296 return count;
289 } 297 }
290 298
291 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion) 299 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJu stify)
292 { 300 {
293 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId eographsInComplexText(); 301 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId eographsInComplexText();
294 unsigned count = 0; 302 unsigned count = 0;
295 if (direction == LTR) { 303 if (direction == LTR) {
296 for (size_t i = 0; i < length; ++i) { 304 for (size_t i = 0; i < length; ++i) {
297 UChar32 character = characters[i]; 305 UChar32 character = characters[i];
298 if (treatAsSpace(character)) { 306 if (treatAsSpace(character)) {
299 count++; 307 count++;
300 isAfterExpansion = true; 308 isAfterExpansion = true;
301 continue; 309 continue;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 { 376 {
369 return normalizeSpacesInternal(characters, length); 377 return normalizeSpacesInternal(characters, length);
370 } 378 }
371 379
372 String Character::normalizeSpaces(const UChar* characters, unsigned length) 380 String Character::normalizeSpaces(const UChar* characters, unsigned length)
373 { 381 {
374 return normalizeSpacesInternal(characters, length); 382 return normalizeSpacesInternal(characters, length);
375 } 383 }
376 384
377 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698