| Index: third_party/WebKit/Source/platform/fonts/Font.cpp
|
| diff --git a/third_party/WebKit/Source/platform/fonts/Font.cpp b/third_party/WebKit/Source/platform/fonts/Font.cpp
|
| index 4bcd940b7a38c7f25e67a08897932dc52d4124d4..0a80406f863f471ec96c7ce06445f94e9eaede71 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/Font.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/Font.cpp
|
| @@ -239,6 +239,45 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo
|
| return floatWidthForSimpleText(run, fallbackFonts, glyphBounds);
|
| }
|
|
|
| +float Font::widthForUnbrokenRun(const TextRun& run) const
|
| +{
|
| + if (run.length() <= 1 || run.is8Bit())
|
| + return width(run);
|
| +
|
| + float totalWidth = 0;
|
| + const unsigned length = run.length();
|
| + for (unsigned startIndex = 0; startIndex < length; ) {
|
| + UChar32 ch;
|
| + unsigned endIndex = startIndex;
|
| + U16_NEXT(run.characters16(), endIndex, length, ch);
|
| + if (Character::isCJKIdeographOrSymbol(ch)) {
|
| + // For scripts that do not delimit words by spaces, split each
|
| + // character so that input text matches to what the line breaker
|
| + // requests. This improves the cache efficiency in
|
| + // CachingWordShaper.
|
| + for (unsigned i = endIndex; i < length; endIndex = i) {
|
| + U16_NEXT(run.characters16(), i, length, ch);
|
| + if (!(U_GET_GC_MASK(ch) & U_GC_M_MASK))
|
| + break;
|
| + }
|
| + } else {
|
| + // For scripts that delimit words by spaces, let CachingWordShaper
|
| + // handle words.
|
| + for (unsigned i = endIndex; i < length; endIndex = i) {
|
| + U16_NEXT(run.characters16(), i, length, ch);
|
| + if (Character::isCJKIdeographOrSymbol(ch))
|
| + break;
|
| + }
|
| + }
|
| + if (!startIndex && endIndex == length)
|
| + return width(run);
|
| + TextRun subRun = run.subRun(startIndex, endIndex - startIndex);
|
| + totalWidth += width(subRun);
|
| + startIndex = endIndex;
|
| + }
|
| + return totalWidth;
|
| +}
|
| +
|
| PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer) const
|
| {
|
| SkTextBlobBuilder builder;
|
|
|