Chromium Code Reviews| 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..f425e26042a35a570da4d8d5875ff968d9facb2a 100644 | 
| --- a/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp | 
| +++ b/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp | 
| @@ -13,17 +13,38 @@ | 
| 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_fallbackStage( | 
| +// Due to crbug.com/322658 we cannot reliably select Emoji fonts on Android at | 
| +// the moment. Disabling this functionality on Android to avoid reports of | 
| +// unreliable behavior until this issue is solved. | 
| +#if !OS(ANDROID) | 
| + // Currently we have to push the Emoji font to the top of the list | 
| 
 
drott
2016/02/05 13:29:18
Looks like the windows failures indicate there is
 
 | 
| + // due to https://github.com/behdad/harfbuzz/issues/217 | 
| + isNonTextFallbackPriority(fontFallbackPriority) | 
| + ? FallbackPriorityFonts | 
| 
 
eae
2016/02/17 18:55:17
Indent line 40 and 41 one more level.
isNonTextFa
 
 | 
| + : FontGroupFonts | 
| +#else | 
| + FontGroupFonts | 
| +#endif | 
| + ) | 
| + , m_fontFallbackPriority(fontFallbackPriority) | 
| + , m_symbolsFontCursor(0) | 
| { | 
| } | 
| @@ -71,12 +92,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 (m_fallbackStage == FallbackPriorityFonts) { | 
| + FontDataRange fallbackPriorityFont = nextFallbackPriorityFont(); | 
| + if (!fallbackPriorityFont.isNull()) | 
| + return fallbackPriorityFont; | 
| + // No more prioritized fallback fonts, proceed to processing the CSS | 
| + // defined fonts. | 
| + m_fallbackStage = FontGroupFonts; | 
| + return next(hintList); | 
| + } | 
| - // If there is no fontData coming from the fallback list, it means | 
| - // we have reached the system fallback stage. | 
| - if (!fontData) { | 
| - m_fallbackStage = SystemFonts; | 
| + if (m_fallbackStage == SystemFonts) { | 
| // We've reached pref + system fallback. | 
| ASSERT(hintList.size()); | 
| RefPtr<SimpleFontData> systemFont = uniqueSystemFontForHint(hintList[0]); | 
| @@ -95,6 +121,19 @@ 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 = 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 +176,25 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList) | 
| return next(hintList); | 
| } | 
| +FontDataRange FontFallbackIterator::nextFallbackPriorityFont() | 
| +{ | 
| + ASSERT(m_fontFallbackPriority != FontFallbackPriority::Invalid); | 
| + FontCache* fontCache = FontCache::fontCache(); | 
| + | 
| + const Vector<AtomicString>* priorityFontList = | 
| + fontCache->fontListForFallbackPriority( | 
| + m_fontDescription, m_fontFallbackPriority); | 
| + | 
| + if (m_symbolsFontCursor == priorityFontList->size()) | 
| + return FontDataRange(); | 
| + | 
| + RefPtr<SimpleFontData> priorityFont = fontCache->getFontData( | 
| + m_fontDescription, | 
| + priorityFontList->at(m_symbolsFontCursor)); | 
| + m_symbolsFontCursor++; | 
| + return FontDataRange(priorityFont); | 
| +} | 
| + | 
| const PassRefPtr<SimpleFontData> FontFallbackIterator::uniqueSystemFontForHint(UChar32 hint) | 
| { | 
| FontCache* fontCache = FontCache::fontCache(); |