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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (m_display == FontDisplayBlock || | 164 if (m_display == FontDisplayBlock || |
165 (!m_isInterventionTriggered && m_display == FontDisplayAuto)) | 165 (!m_isInterventionTriggered && m_display == FontDisplayAuto)) |
166 switchToSwapPeriod(); | 166 switchToSwapPeriod(); |
167 else if (m_display == FontDisplayFallback) | 167 else if (m_display == FontDisplayFallback) |
168 switchToFailurePeriod(); | 168 switchToFailurePeriod(); |
169 | 169 |
170 m_histograms.longLimitExceeded(m_isInterventionTriggered); | 170 m_histograms.longLimitExceeded(m_isInterventionTriggered); |
171 } | 171 } |
172 | 172 |
173 void RemoteFontFaceSource::switchToSwapPeriod() { | 173 void RemoteFontFaceSource::switchToSwapPeriod() { |
174 ASSERT(m_period == BlockPeriod); | 174 DCHECK_EQ(m_period, BlockPeriod); |
175 m_period = SwapPeriod; | 175 m_period = SwapPeriod; |
176 | 176 |
177 pruneTable(); | 177 pruneTable(); |
178 if (m_face) { | 178 if (m_face) { |
179 m_fontSelector->fontFaceInvalidated(); | 179 m_fontSelector->fontFaceInvalidated(); |
180 m_face->didBecomeVisibleFallback(this); | 180 m_face->didBecomeVisibleFallback(this); |
181 } | 181 } |
182 | 182 |
183 m_histograms.recordFallbackTime(); | 183 m_histograms.recordFallbackTime(); |
184 } | 184 } |
185 | 185 |
186 void RemoteFontFaceSource::switchToFailurePeriod() { | 186 void RemoteFontFaceSource::switchToFailurePeriod() { |
187 if (m_period == BlockPeriod) | 187 if (m_period == BlockPeriod) |
188 switchToSwapPeriod(); | 188 switchToSwapPeriod(); |
189 ASSERT(m_period == SwapPeriod); | 189 DCHECK_EQ(m_period, SwapPeriod); |
190 m_period = FailurePeriod; | 190 m_period = FailurePeriod; |
191 } | 191 } |
192 | 192 |
193 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() { | 193 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() { |
194 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) | 194 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) |
195 return true; | 195 return true; |
196 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || | 196 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || |
197 m_histograms.dataSource() == FontLoadHistograms::FromDataURL) | 197 m_histograms.dataSource() == FontLoadHistograms::FromDataURL) |
198 return false; | 198 return false; |
199 | 199 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 | 234 |
235 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData( | 235 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData( |
236 const FontDescription& fontDescription) { | 236 const FontDescription& fontDescription) { |
237 // This temporary font is not retained and should not be returned. | 237 // This temporary font is not retained and should not be returned. |
238 FontCachePurgePreventer fontCachePurgePreventer; | 238 FontCachePurgePreventer fontCachePurgePreventer; |
239 SimpleFontData* temporaryFont = | 239 SimpleFontData* temporaryFont = |
240 FontCache::fontCache()->getNonRetainedLastResortFallbackFont( | 240 FontCache::fontCache()->getNonRetainedLastResortFallbackFont( |
241 fontDescription); | 241 fontDescription); |
242 if (!temporaryFont) { | 242 if (!temporaryFont) { |
243 ASSERT_NOT_REACHED(); | 243 NOTREACHED(); |
244 return nullptr; | 244 return nullptr; |
245 } | 245 } |
246 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create( | 246 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create( |
247 this, m_period == BlockPeriod ? CSSCustomFontData::InvisibleFallback | 247 this, m_period == BlockPeriod ? CSSCustomFontData::InvisibleFallback |
248 : CSSCustomFontData::VisibleFallback); | 248 : CSSCustomFontData::VisibleFallback); |
249 return SimpleFontData::create(temporaryFont->platformData(), cssFontData); | 249 return SimpleFontData::create(temporaryFont->platformData(), cssFontData); |
250 } | 250 } |
251 | 251 |
252 void RemoteFontFaceSource::beginLoadIfNeeded() { | 252 void RemoteFontFaceSource::beginLoadIfNeeded() { |
253 if (isLoaded()) | 253 if (isLoaded()) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 return Miss; | 478 return Miss; |
479 case FromUnknown: | 479 case FromUnknown: |
480 // Fall through. | 480 // Fall through. |
481 default: | 481 default: |
482 NOTREACHED(); | 482 NOTREACHED(); |
483 } | 483 } |
484 return Miss; | 484 return Miss; |
485 } | 485 } |
486 | 486 |
487 } // namespace blink | 487 } // namespace blink |
OLD | NEW |