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 0d5f323799f2cf30939d9da36dda534df5e8b7d5..21b07dc825f1ed0424d5dbebe16701d490691d1b 100644 |
| --- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| +++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| @@ -56,7 +56,7 @@ RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, |
| : m_font(font), |
| m_fontSelector(fontSelector), |
| m_display(display), |
| - m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod), |
| + m_period(BlockPeriod), |
| m_histograms(font->url().protocolIsData() |
| ? FontLoadHistograms::FromDataURL |
| : font->isLoaded() ? FontLoadHistograms::FromMemoryCache |
| @@ -73,6 +73,10 @@ RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, |
| "Slow network is detected. Fallback font will be used while loading: " + |
| m_font->url().elidedString())); |
| } |
| + |
| + if (m_display == FontDisplaySwap && |
| + !m_font->resourceRequest().isCacheAwareLoadingActivated()) |
| + m_period = SwapPeriod; |
| } |
| RemoteFontFaceSource::~RemoteFontFaceSource() {} |
| @@ -158,6 +162,11 @@ void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) { |
| m_histograms.longLimitExceeded(m_isInterventionTriggered); |
| } |
| +void RemoteFontFaceSource::willReloadAfterDiskCacheMiss(const FontResource*) { |
| + if (m_display == FontDisplaySwap) |
| + switchToSwapPeriod(); |
| +} |
| + |
| void RemoteFontFaceSource::switchToSwapPeriod() { |
| ASSERT(m_period == BlockPeriod); |
| m_period = SwapPeriod; |
| @@ -234,7 +243,15 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData( |
| void RemoteFontFaceSource::beginLoadIfNeeded() { |
| if (m_fontSelector->document() && m_font->stillNeedsLoad()) { |
| + // TODO(shaochuan): Cache-aware loading may be deactivated in startLoad(), |
| + // set |m_period| to correct value if deactivated. crbug.com/632580 |
| + bool wasCacheAwareLoadingActivated = |
| + m_font->resourceRequest().isCacheAwareLoadingActivated(); |
| m_fontSelector->document()->fetcher()->startLoad(m_font); |
| + if (m_display == FontDisplaySwap && wasCacheAwareLoadingActivated && |
| + !m_font->resourceRequest().isCacheAwareLoadingActivated()) |
| + m_period = SwapPeriod; |
|
Kunihiko Sakamoto
2016/10/21 05:41:07
You should call switchToSwapPeriod() instead, so t
Shao-Chuan Lee
2016/10/21 07:18:01
Done.
|
| + |
| if (!m_font->isLoaded()) |
| m_font->startLoadLimitTimers(); |
| m_histograms.loadStarted(); |