| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 { | 143 { |
| 144 if (!isLoaded()) | 144 if (!isLoaded()) |
| 145 return createLoadingFallbackFontData(fontDescription); | 145 return createLoadingFallbackFontData(fontDescription); |
| 146 | 146 |
| 147 if (!m_font->ensureCustomFontData() || m_period == FailurePeriod) | 147 if (!m_font->ensureCustomFontData() || m_period == FailurePeriod) |
| 148 return nullptr; | 148 return nullptr; |
| 149 | 149 |
| 150 m_histograms.recordFallbackTime(m_font.get()); | 150 m_histograms.recordFallbackTime(m_font.get()); |
| 151 | 151 |
| 152 return SimpleFontData::create( | 152 return SimpleFontData::create( |
| 153 m_font->platformDataFromCustomData(fontDescription.effectiveFontSize(), | 153 m_font->platformDataFromCustomData( |
| 154 fontDescription.isSyntheticBold(), fontDescription.isSyntheticItalic
(), | 154 fontDescription.isSyntheticBold(), |
| 155 fontDescription.orientation()), CustomFontData::create()); | 155 fontDescription.isSyntheticItalic(), |
| 156 fontDescription.orientation()), |
| 157 fontDescription.effectiveFontSize(), |
| 158 CustomFontData::create()); |
| 156 } | 159 } |
| 157 | 160 |
| 158 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(c
onst FontDescription& fontDescription) | 161 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(c
onst FontDescription& fontDescription) |
| 159 { | 162 { |
| 160 // This temporary font is not retained and should not be returned. | 163 // This temporary font is not retained and should not be returned. |
| 161 FontCachePurgePreventer fontCachePurgePreventer; | 164 FontCachePurgePreventer fontCachePurgePreventer; |
| 162 SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastRe
sortFallbackFont(fontDescription); | 165 SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastRe
sortFallbackFont(fontDescription); |
| 163 if (!temporaryFont) { | 166 if (!temporaryFont) { |
| 164 ASSERT_NOT_REACHED(); | 167 ASSERT_NOT_REACHED(); |
| 165 return nullptr; | 168 return nullptr; |
| 166 } | 169 } |
| 167 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_pe
riod == BlockPeriod ? CSSCustomFontData::InvisibleFallback : CSSCustomFontData::
VisibleFallback); | 170 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_pe
riod == BlockPeriod ? CSSCustomFontData::InvisibleFallback : CSSCustomFontData::
VisibleFallback); |
| 168 return SimpleFontData::create(temporaryFont->platformData(), cssFontData); | 171 return SimpleFontData::create(temporaryFont->platformData(), fontDescription
.effectiveFontSize(), cssFontData); |
| 169 } | 172 } |
| 170 | 173 |
| 171 void RemoteFontFaceSource::beginLoadIfNeeded() | 174 void RemoteFontFaceSource::beginLoadIfNeeded() |
| 172 { | 175 { |
| 173 if (m_fontSelector->document() && m_font->stillNeedsLoad()) { | 176 if (m_fontSelector->document() && m_font->stillNeedsLoad()) { |
| 174 m_font->load(m_fontSelector->document()->fetcher()); | 177 m_font->load(m_fontSelector->document()->fetcher()); |
| 175 m_histograms.loadStarted(); | 178 m_histograms.loadStarted(); |
| 176 } | 179 } |
| 177 m_font->startLoadLimitTimersIfNeeded(); | 180 m_font->startLoadLimitTimersIfNeeded(); |
| 178 | 181 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 interventionResult |= 1 << 0; | 286 interventionResult |= 1 << 0; |
| 284 if (triggered) | 287 if (triggered) |
| 285 interventionResult |= 1 << 1; | 288 interventionResult |= 1 << 1; |
| 286 const int boundary = 1 << 2; | 289 const int boundary = 1 << 2; |
| 287 | 290 |
| 288 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I
nterventionResult", boundary)); | 291 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I
nterventionResult", boundary)); |
| 289 interventionHistogram.count(interventionResult); | 292 interventionHistogram.count(interventionResult); |
| 290 } | 293 } |
| 291 | 294 |
| 292 } // namespace blink | 295 } // namespace blink |
| OLD | NEW |