Chromium Code Reviews| Index: third_party/WebKit/Source/platform/fonts/FontFallbackList.cpp |
| diff --git a/third_party/WebKit/Source/platform/fonts/FontFallbackList.cpp b/third_party/WebKit/Source/platform/fonts/FontFallbackList.cpp |
| index 6067f5b89fb397adf686d90ef33ae309a3a057a8..33c3f549bd77ffe4873ba3cc42ee387db45ee6ff 100644 |
| --- a/third_party/WebKit/Source/platform/fonts/FontFallbackList.cpp |
| +++ b/third_party/WebKit/Source/platform/fonts/FontFallbackList.cpp |
| @@ -48,6 +48,7 @@ FontFallbackList::FontFallbackList() |
| , m_familyIndex(0) |
| , m_generation(FontCache::fontCache()->generation()) |
| , m_hasLoadingFallback(false) |
| + , m_hasNonBlankFontData(false) |
| { |
| } |
| @@ -60,6 +61,7 @@ void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec |
| m_cachedPrimarySimpleFontData = 0; |
| m_familyIndex = 0; |
| m_hasLoadingFallback = false; |
| + m_hasNonBlankFontData = false; |
| if (m_fontSelector != fontSelector) |
| m_fontSelector = fontSelector; |
| m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; |
| @@ -155,33 +157,30 @@ const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon |
| PassRefPtr<FontData> FontFallbackList::getFontData(const FontDescription& fontDescription, int& familyIndex) const |
| { |
| - RefPtr<FontData> result; |
| - |
| - int startIndex = familyIndex; |
| - const FontFamily* startFamily = &fontDescription.family(); |
| - for (int i = 0; startFamily && i < startIndex; i++) |
| - startFamily = startFamily->next(); |
| - const FontFamily* currFamily = startFamily; |
| - while (currFamily && !result) { |
| + const FontFamily* currFamily = &fontDescription.family(); |
| + for (int i = 0; currFamily && i < familyIndex; i++) |
| + currFamily = currFamily->next(); |
| + |
| + for (; currFamily; currFamily = currFamily->next()) { |
| familyIndex++; |
| if (currFamily->family().length()) { |
| + RefPtr<FontData> result; |
| if (m_fontSelector) |
| result = m_fontSelector->getFontData(fontDescription, currFamily->family()); |
| - |
| if (!result) |
| result = FontCache::fontCache()->getFontData(fontDescription, currFamily->family()); |
| + if (result) |
| + return result.release(); |
| } |
| - currFamily = currFamily->next(); |
| } |
| + familyIndex = cAllFamiliesScanned; |
| - if (!currFamily) |
| - familyIndex = cAllFamiliesScanned; |
| - |
| - if (result || startIndex) |
| - return result.release(); |
| + if (m_hasNonBlankFontData) |
| + return nullptr; |
| - // If it's the primary font that we couldn't find, we try the following. In all other cases, we will |
| - // just use per-character system fallback. |
| + // If we couldn't find any non-blank font data in the family list, we try |
| + // the following. In all other cases, we will just use per-character system |
| + // fallback. |
| if (m_fontSelector) { |
| // Try the user's preferred standard font. |
| @@ -238,6 +237,8 @@ const FontData* FontFallbackList::fontDataAt(const FontDescription& fontDescript |
| m_fontList.append(result); |
| if (result->isLoadingFallback()) |
| m_hasLoadingFallback = true; |
| + else |
|
drott
2015/12/01 09:36:22
Is there a way we could avoid the additional flag?
|
| + m_hasNonBlankFontData = true; |
| } |
| return result.get(); |
| } |