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

Unified Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 1525963002: (CANCELED) Improve performance of large option list with CJK text (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert to PS2 Created 5 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
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;

Powered by Google App Engine
This is Rietveld 408576698