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