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

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

Issue 1615923004: Add FontCache API for retrieving prioritized fallback fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documenting public method Created 4 years, 10 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: third_party/WebKit/Source/platform/fonts/FontCache.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontCache.cpp b/third_party/WebKit/Source/platform/fonts/FontCache.cpp
index 462f0d04ff0cd9443d31061f85b23e7733a538f1..a9cf27c8c50d1e2b94553347070e567db26bea86 100644
--- a/third_party/WebKit/Source/platform/fonts/FontCache.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontCache.cpp
@@ -194,6 +194,41 @@ SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(const FontDescri
return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef();
}
+template <FontFallbackPriority fallbackPriority>
+const Vector<AtomicString>* FontCache::initAndGetFontListForFallbackPriority(const FontDescription& fontDescription)
+{
+ DEFINE_STATIC_LOCAL(Vector<AtomicString>, fontsList, ());
+ DEFINE_STATIC_LOCAL(bool, fontsListInitialized, (false));
+ if (fontsListInitialized)
+ return &fontsList;
+
+ for (auto fontCandidate :
+ platformFontListForFallbackPriority(fallbackPriority)) {
+ if (isPlatformFontAvailable(fontDescription, fontCandidate))
+ fontsList.append(fontCandidate);
+ }
+ fontsListInitialized = true;
+ return &fontsList;
+}
+
+const Vector<AtomicString>* FontCache::fontListForFallbackPriority(const FontDescription& fontDescription, FontFallbackPriority fallbackPriority)
+{
+ // Explicit template instantiations for valid values.
+ switch (fallbackPriority) {
+ case FontFallbackPriority::Symbols:
+ return initAndGetFontListForFallbackPriority<FontFallbackPriority::Symbols>(fontDescription);
+ case FontFallbackPriority::Math:
+ return initAndGetFontListForFallbackPriority<FontFallbackPriority::Math>(fontDescription);
+ case FontFallbackPriority::EmojiText:
+ return initAndGetFontListForFallbackPriority<FontFallbackPriority::EmojiText>(fontDescription);
+ case FontFallbackPriority::EmojiEmoji:
+ return initAndGetFontListForFallbackPriority<FontFallbackPriority::EmojiEmoji>(fontDescription);
+ default:
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+}
+
void FontCache::releaseFontData(const SimpleFontData* fontData)
{
ASSERT(gFontDataCache);
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.h ('k') | third_party/WebKit/Source/platform/fonts/FontCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698