Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/RemoteFontFaceSource.h" | 5 #include "core/css/RemoteFontFaceSource.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomFontData.h" | 7 #include "core/css/CSSCustomFontData.h" |
| 8 #include "core/css/CSSFontFace.h" | 8 #include "core/css/CSSFontFace.h" |
| 9 #include "core/css/CSSFontSelector.h" | 9 #include "core/css/CSSFontSelector.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, | 53 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, |
| 54 CSSFontSelector* fontSelector, | 54 CSSFontSelector* fontSelector, |
| 55 FontDisplay display) | 55 FontDisplay display) |
| 56 : m_font(font), | 56 : m_font(font), |
| 57 m_fontSelector(fontSelector), | 57 m_fontSelector(fontSelector), |
| 58 m_display(display), | 58 m_display(display), |
| 59 m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod), | 59 m_period(BlockPeriod), |
|
Kunihiko Sakamoto
2016/10/12 06:10:14
Would this change current behavior when WebFontsCa
Shao-Chuan Lee
2016/10/12 06:50:58
If the flag is off then isCacheAwareLoadingActivat
Kunihiko Sakamoto
2016/10/12 08:56:30
Ah OK, I missed that part.
| |
| 60 m_histograms(font->url().protocolIsData() | 60 m_histograms(font->url().protocolIsData() |
| 61 ? FontLoadHistograms::FromDataURL | 61 ? FontLoadHistograms::FromDataURL |
| 62 : font->isLoaded() ? FontLoadHistograms::FromMemoryCache | 62 : font->isLoaded() ? FontLoadHistograms::FromMemoryCache |
| 63 : FontLoadHistograms::FromUnknown), | 63 : FontLoadHistograms::FromUnknown), |
| 64 m_isInterventionTriggered(false) { | 64 m_isInterventionTriggered(false) { |
| 65 ThreadState::current()->registerPreFinalizer(this); | 65 ThreadState::current()->registerPreFinalizer(this); |
| 66 m_font->addClient(this); | 66 m_font->addClient(this); |
| 67 | 67 |
| 68 if (shouldTriggerWebFontsIntervention()) { | 68 if (shouldTriggerWebFontsIntervention()) { |
| 69 m_isInterventionTriggered = true; | 69 m_isInterventionTriggered = true; |
| 70 m_period = SwapPeriod; | 70 m_period = SwapPeriod; |
| 71 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create( | 71 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create( |
| 72 OtherMessageSource, InfoMessageLevel, | 72 OtherMessageSource, InfoMessageLevel, |
| 73 "Slow network is detected. Fallback font will be used while loading: " + | 73 "Slow network is detected. Fallback font will be used while loading: " + |
| 74 m_font->url().elidedString())); | 74 m_font->url().elidedString())); |
| 75 } | 75 } |
| 76 | |
| 77 if (m_display == FontDisplaySwap && | |
| 78 !m_font->resourceRequest().isCacheAwareLoadingActivated()) | |
| 79 m_period = SwapPeriod; | |
| 76 } | 80 } |
| 77 | 81 |
| 78 RemoteFontFaceSource::~RemoteFontFaceSource() {} | 82 RemoteFontFaceSource::~RemoteFontFaceSource() {} |
| 79 | 83 |
| 80 void RemoteFontFaceSource::dispose() { | 84 void RemoteFontFaceSource::dispose() { |
| 81 m_font->removeClient(this); | 85 m_font->removeClient(this); |
| 82 m_font = nullptr; | 86 m_font = nullptr; |
| 83 pruneTable(); | 87 pruneTable(); |
| 84 } | 88 } |
| 85 | 89 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) { | 151 void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) { |
| 148 if (m_display == FontDisplayBlock || | 152 if (m_display == FontDisplayBlock || |
| 149 (!m_isInterventionTriggered && m_display == FontDisplayAuto)) | 153 (!m_isInterventionTriggered && m_display == FontDisplayAuto)) |
| 150 switchToSwapPeriod(); | 154 switchToSwapPeriod(); |
| 151 else if (m_display == FontDisplayFallback) | 155 else if (m_display == FontDisplayFallback) |
| 152 switchToFailurePeriod(); | 156 switchToFailurePeriod(); |
| 153 | 157 |
| 154 m_histograms.longLimitExceeded(m_isInterventionTriggered); | 158 m_histograms.longLimitExceeded(m_isInterventionTriggered); |
| 155 } | 159 } |
| 156 | 160 |
| 161 void RemoteFontFaceSource::willReloadAfterDiskCacheMiss(const FontResource*) { | |
| 162 if (m_display == FontDisplaySwap) | |
| 163 switchToSwapPeriod(); | |
| 164 } | |
| 165 | |
| 157 void RemoteFontFaceSource::switchToSwapPeriod() { | 166 void RemoteFontFaceSource::switchToSwapPeriod() { |
| 158 ASSERT(m_period == BlockPeriod); | 167 ASSERT(m_period == BlockPeriod); |
| 159 m_period = SwapPeriod; | 168 m_period = SwapPeriod; |
| 160 | 169 |
| 161 pruneTable(); | 170 pruneTable(); |
| 162 if (m_face) { | 171 if (m_face) { |
| 163 m_fontSelector->fontFaceInvalidated(); | 172 m_fontSelector->fontFaceInvalidated(); |
| 164 m_face->didBecomeVisibleFallback(this); | 173 m_face->didBecomeVisibleFallback(this); |
| 165 } | 174 } |
| 166 | 175 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 return Miss; | 428 return Miss; |
| 420 case FromUnknown: | 429 case FromUnknown: |
| 421 // Fall through. | 430 // Fall through. |
| 422 default: | 431 default: |
| 423 NOTREACHED(); | 432 NOTREACHED(); |
| 424 } | 433 } |
| 425 return Miss; | 434 return Miss; |
| 426 } | 435 } |
| 427 | 436 |
| 428 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |