OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/css/CSSFontFaceSource.h" | 27 #include "core/css/CSSFontFaceSource.h" |
28 | 28 |
29 #include "RuntimeEnabledFeatures.h" | 29 #include "RuntimeEnabledFeatures.h" |
30 #include "core/css/CSSCustomFontData.h" | 30 #include "core/css/CSSCustomFontData.h" |
31 #include "core/css/CSSFontFace.h" | 31 #include "core/css/CSSFontFace.h" |
32 #include "core/platform/graphics/FontCache.h" | 32 #include "platform/fonts/FontCache.h" |
33 #include "core/platform/graphics/SimpleFontData.h" | |
34 #include "platform/fonts/FontDescription.h" | 33 #include "platform/fonts/FontDescription.h" |
| 34 #include "platform/fonts/SimpleFontData.h" |
35 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
36 #include "wtf/CurrentTime.h" | 36 #include "wtf/CurrentTime.h" |
37 | 37 |
38 #if ENABLE(SVG_FONTS) | 38 #if ENABLE(SVG_FONTS) |
39 #include "SVGNames.h" | 39 #include "SVGNames.h" |
40 #include "core/svg/SVGFontData.h" | 40 #include "core/svg/SVGFontData.h" |
41 #include "core/svg/SVGFontElement.h" | 41 #include "core/svg/SVGFontElement.h" |
42 #include "core/svg/SVGFontFaceElement.h" | 42 #include "core/svg/SVGFontFaceElement.h" |
43 #endif | 43 #endif |
44 | 44 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
fontDescription) | 129 PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
fontDescription) |
130 { | 130 { |
131 // If the font hasn't loaded or an error occurred, then we've got nothing. | 131 // If the font hasn't loaded or an error occurred, then we've got nothing. |
132 if (!isValid()) | 132 if (!isValid()) |
133 return 0; | 133 return 0; |
134 | 134 |
135 if (isLocal()) { | 135 if (isLocal()) { |
136 // We're local. Just return a SimpleFontData from the normal cache. | 136 // We're local. Just return a SimpleFontData from the normal cache. |
137 // We don't want to check alternate font family names here, so pass true
as the checkingAlternateName parameter. | 137 // We don't want to check alternate font family names here, so pass true
as the checkingAlternateName parameter. |
138 RefPtr<SimpleFontData> fontData = fontCache()->getFontData(fontDescripti
on, m_string, true); | 138 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fo
ntDescription, m_string, true); |
139 m_histograms.recordLocalFont(fontData); | 139 m_histograms.recordLocalFont(fontData); |
140 return fontData; | 140 return fontData; |
141 } | 141 } |
142 | 142 |
143 // See if we have a mapping in our FontData cache. | 143 // See if we have a mapping in our FontData cache. |
144 AtomicString emptyFontFamily = ""; | 144 AtomicString emptyFontFamily = ""; |
145 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily); | 145 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily); |
146 | 146 |
147 RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).iterat
or->value; | 147 RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).iterat
or->value; |
148 if (fontData) | 148 if (fontData) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 SVGFontData::create(m_svgFontFaceElement.get()), | 211 SVGFontData::create(m_svgFontFaceElement.get()), |
212 fontDescription.effectiveFontSize(), | 212 fontDescription.effectiveFontSize(), |
213 fontDescription.isSyntheticBold(), | 213 fontDescription.isSyntheticBold(), |
214 fontDescription.isSyntheticItalic()); | 214 fontDescription.isSyntheticItalic()); |
215 } | 215 } |
216 #endif | 216 #endif |
217 } | 217 } |
218 } else { | 218 } else { |
219 // This temporary font is not retained and should not be returned. | 219 // This temporary font is not retained and should not be returned. |
220 FontCachePurgePreventer fontCachePurgePreventer; | 220 FontCachePurgePreventer fontCachePurgePreventer; |
221 SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFal
lbackFont(fontDescription); | 221 SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLa
stResortFallbackFont(fontDescription); |
222 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true); | 222 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true); |
223 cssFontData->setCSSFontFaceSource(this); | 223 cssFontData->setCSSFontFaceSource(this); |
224 fontData = SimpleFontData::create(temporaryFont->platformData(), cssFont
Data); | 224 fontData = SimpleFontData::create(temporaryFont->platformData(), cssFont
Data); |
225 } | 225 } |
226 | 226 |
227 return fontData; // No release, because fontData is a reference to a RefPtr
that is held in the m_fontDataTable. | 227 return fontData; // No release, because fontData is a reference to a RefPtr
that is held in the m_fontDataTable. |
228 } | 228 } |
229 | 229 |
230 #if ENABLE(SVG_FONTS) | 230 #if ENABLE(SVG_FONTS) |
231 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const | 231 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const |
(...skipping 20 matching lines...) Expand all Loading... |
252 if (m_hasExternalSVGFont) | 252 if (m_hasExternalSVGFont) |
253 return m_font->ensureSVGFontData(); | 253 return m_font->ensureSVGFontData(); |
254 #endif | 254 #endif |
255 return m_font->ensureCustomFontData(); | 255 return m_font->ensureCustomFontData(); |
256 } | 256 } |
257 | 257 |
258 bool CSSFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescript
ion) | 258 bool CSSFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescript
ion) |
259 { | 259 { |
260 if (!isLocal()) | 260 if (!isLocal()) |
261 return false; | 261 return false; |
262 return fontCache()->isPlatformFontAvailable(fontDescription, m_string); | 262 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, m_st
ring); |
263 } | 263 } |
264 | 264 |
265 void CSSFontFaceSource::beginLoadIfNeeded() | 265 void CSSFontFaceSource::beginLoadIfNeeded() |
266 { | 266 { |
267 if (m_face && m_font) | 267 if (m_face && m_font) |
268 m_face->beginLoadIfNeeded(this); | 268 m_face->beginLoadIfNeeded(this); |
269 } | 269 } |
270 | 270 |
271 void CSSFontFaceSource::FontLoadHistograms::loadStarted() | 271 void CSSFontFaceSource::FontLoadHistograms::loadStarted() |
272 { | 272 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (size < 50 * 1024) | 308 if (size < 50 * 1024) |
309 return "WebFont.DownloadTime.1.10KBTo50KB"; | 309 return "WebFont.DownloadTime.1.10KBTo50KB"; |
310 if (size < 100 * 1024) | 310 if (size < 100 * 1024) |
311 return "WebFont.DownloadTime.2.50KBTo100KB"; | 311 return "WebFont.DownloadTime.2.50KBTo100KB"; |
312 if (size < 1024 * 1024) | 312 if (size < 1024 * 1024) |
313 return "WebFont.DownloadTime.3.100KBTo1MB"; | 313 return "WebFont.DownloadTime.3.100KBTo1MB"; |
314 return "WebFont.DownloadTime.4.Over1MB"; | 314 return "WebFont.DownloadTime.4.Over1MB"; |
315 } | 315 } |
316 | 316 |
317 } | 317 } |
OLD | NEW |