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

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

Issue 1764933002: Reland: Use FontFallbackPriority Fonts in FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/FontFallbackIterator.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp b/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
index f13d587b3a6cf07ad0162214af6a87caf8922936..0b73e27a1ecf6b965bceb88178c68c4a6ca35fea 100644
--- a/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
@@ -13,17 +13,24 @@
namespace blink {
-PassRefPtr<FontFallbackIterator> FontFallbackIterator::create(const FontDescription& description, PassRefPtr<FontFallbackList> fallbackList)
+PassRefPtr<FontFallbackIterator> FontFallbackIterator::create(
+ const FontDescription& description,
+ PassRefPtr<FontFallbackList> fallbackList,
+ FontFallbackPriority fontFallbackPriority)
{
- return adoptRef(new FontFallbackIterator(description, fallbackList));
+ return adoptRef(new FontFallbackIterator(
+ description, fallbackList, fontFallbackPriority));
}
-FontFallbackIterator::FontFallbackIterator(const FontDescription& description, PassRefPtr<FontFallbackList> fallbackList)
+FontFallbackIterator::FontFallbackIterator(const FontDescription& description,
+ PassRefPtr<FontFallbackList> fallbackList,
+ FontFallbackPriority fontFallbackPriority)
: m_fontDescription(description)
, m_fontFallbackList(fallbackList)
, m_currentFontDataIndex(0)
, m_segmentedIndex(0)
, m_fallbackStage(FontGroupFonts)
+ , m_fontFallbackPriority(fontFallbackPriority)
{
}
@@ -71,12 +78,17 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
if (m_fallbackStage == OutOfLuck)
return FontDataRange();
- const FontData* fontData = m_fontFallbackList->fontDataAt(m_fontDescription, m_currentFontDataIndex);
-
- // If there is no fontData coming from the fallback list, it means
- // we have reached the system fallback stage.
- if (!fontData) {
+ if (m_fallbackStage == FallbackPriorityFonts) {
+ // Only try one fallback priority font,
+ // then proceed to regular system fallback.
m_fallbackStage = SystemFonts;
+ FontDataRange fallbackPriorityFontRange(fallbackPriorityFont(hintList[0]));
+ if (fallbackPriorityFontRange.hasFontData())
+ return fallbackPriorityFontRange;
+ return next(hintList);
+ }
+
+ if (m_fallbackStage == SystemFonts) {
// We've reached pref + system fallback.
ASSERT(hintList.size());
RefPtr<SimpleFontData> systemFont = uniqueSystemFontForHint(hintList[0]);
@@ -95,6 +107,21 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
return FontDataRange(lastResort);
}
+ ASSERT(m_fallbackStage == FontGroupFonts
+ || m_fallbackStage == SegmentedFace);
+ const FontData* fontData = m_fontFallbackList->fontDataAt(
+ m_fontDescription, m_currentFontDataIndex);
+
+ if (!fontData) {
+ // If there is no fontData coming from the fallback list, it means
+ // we are now looking at system fonts, either for prioritized symbol
+ // or emoji fonts or by calling system fallback API.
+ m_fallbackStage = isNonTextFallbackPriority(m_fontFallbackPriority)
+ ? FallbackPriorityFonts
+ : SystemFonts;
+ return next(hintList);
+ }
+
// Otherwise we've received a fontData from the font-family: set of fonts,
// and a non-segmented one in this case.
if (!fontData->isSegmented()) {
@@ -137,6 +164,16 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
return next(hintList);
}
+const PassRefPtr<SimpleFontData> FontFallbackIterator::fallbackPriorityFont(
+ UChar32 hint)
+{
+ return FontCache::fontCache()->fallbackFontForCharacter(
+ m_fontDescription,
+ hint,
+ m_fontFallbackList->primarySimpleFontData(m_fontDescription),
+ m_fontFallbackPriority);
+}
+
const PassRefPtr<SimpleFontData> FontFallbackIterator::uniqueSystemFontForHint(UChar32 hint)
{
FontCache* fontCache = FontCache::fontCache();

Powered by Google App Engine
This is Rietveld 408576698