Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| diff --git a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| index 57e48b357383b9e79a6dbd8d8a53cf995dde2af5..e058a71841c01b64337d670f2f3bb9f15cfb04c3 100644 |
| --- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| +++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| @@ -154,23 +154,30 @@ void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) { |
| m_histograms.longLimitExceeded(m_isInterventionTriggered); |
| } |
| -void RemoteFontFaceSource::switchToSwapPeriod() { |
| - ASSERT(m_period == BlockPeriod); |
| - m_period = SwapPeriod; |
| +void RemoteFontFaceSource::willReloadAfterDiskCacheMiss(const FontResource*) { |
| + if (m_period == SwapPeriod || m_period == FailurePeriod) |
| + didBecomeVisibleFallback(); |
|
Kunihiko Sakamoto
2016/10/11 08:07:38
We should move to next period here, instead of kee
Shao-Chuan Lee
2016/10/11 10:58:48
Done.
|
| +} |
| +void RemoteFontFaceSource::didBecomeVisibleFallback() { |
| pruneTable(); |
| if (m_face) { |
| m_fontSelector->fontFaceInvalidated(); |
| m_face->didBecomeVisibleFallback(this); |
| } |
| +} |
| +void RemoteFontFaceSource::switchToSwapPeriod() { |
| + DCHECK(m_period == BlockPeriod); |
| + m_period = SwapPeriod; |
| + didBecomeVisibleFallback(); |
| m_histograms.recordFallbackTime(m_font.get()); |
| } |
| void RemoteFontFaceSource::switchToFailurePeriod() { |
| if (m_period == BlockPeriod) |
| switchToSwapPeriod(); |
| - ASSERT(m_period == SwapPeriod); |
| + DCHECK(m_period == SwapPeriod); |
| m_period = FailurePeriod; |
| } |
| @@ -193,6 +200,25 @@ bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() { |
| return networkIsSlow && m_display == FontDisplayAuto; |
| } |
| +bool RemoteFontFaceSource::shouldUseInvisibleFallback() const { |
| + if (m_period == BlockPeriod) |
| + return true; |
| + if (m_font->resourceRequest().isCacheAwareLoadingActivated()) { |
| + switch (m_display) { |
| + case FontDisplaySwap: |
| + case FontDisplayFallback: |
| + case FontDisplayOptional: |
| + return true; |
| + case FontDisplayAuto: |
| + case FontDisplayBlock: |
| + break; |
| + case FontDisplayEnumMax: |
| + NOTREACHED(); |
| + } |
| + } |
| + return false; |
| +} |
| + |
| PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData( |
| const FontDescription& fontDescription) { |
| if (!isLoaded()) |
| @@ -223,8 +249,8 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData( |
| return nullptr; |
| } |
| RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create( |
| - this, m_period == BlockPeriod ? CSSCustomFontData::InvisibleFallback |
| - : CSSCustomFontData::VisibleFallback); |
| + this, shouldUseInvisibleFallback() ? CSSCustomFontData::InvisibleFallback |
| + : CSSCustomFontData::VisibleFallback); |
| return SimpleFontData::create(temporaryFont->platformData(), cssFontData); |
| } |