Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: Source/core/css/CSSFontFaceSource.cpp

Issue 171823002: Make text visible when font loading takes longer than 3 seconds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSFontFaceSource.h ('k') | Source/core/css/CSSSegmentedFontFace.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void CSSFontFaceSource::fontLoaded(FontResource*) 119 void CSSFontFaceSource::fontLoaded(FontResource*)
120 { 120 {
121 if (!m_fontDataTable.isEmpty()) 121 if (!m_fontDataTable.isEmpty())
122 m_histograms.recordRemoteFont(m_font.get()); 122 m_histograms.recordRemoteFont(m_font.get());
123 123
124 pruneTable(); 124 pruneTable();
125 if (m_face) 125 if (m_face)
126 m_face->fontLoaded(this); 126 m_face->fontLoaded(this);
127 } 127 }
128 128
129 void CSSFontFaceSource::fontLoadWaitLimitExceeded(FontResource*)
130 {
131 pruneTable();
132 if (m_face)
133 m_face->fontLoadWaitLimitExceeded(this);
134 }
135
129 PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription) 136 PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription)
130 { 137 {
131 // If the font hasn't loaded or an error occurred, then we've got nothing. 138 // If the font hasn't loaded or an error occurred, then we've got nothing.
132 if (!isValid()) 139 if (!isValid())
133 return nullptr; 140 return nullptr;
134 141
135 if (isLocal()) { 142 if (isLocal()) {
136 // We're local. Just return a SimpleFontData from the normal cache. 143 // 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. 144 // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
138 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fo ntDescription, m_string, true); 145 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fo ntDescription, m_string, true);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 #endif 223 #endif
217 } 224 }
218 } else { 225 } else {
219 // This temporary font is not retained and should not be returned. 226 // This temporary font is not retained and should not be returned.
220 FontCachePurgePreventer fontCachePurgePreventer; 227 FontCachePurgePreventer fontCachePurgePreventer;
221 SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLa stResortFallbackFont(fontDescription); 228 SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLa stResortFallbackFont(fontDescription);
222 if (!temporaryFont) { 229 if (!temporaryFont) {
223 ASSERT_NOT_REACHED(); 230 ASSERT_NOT_REACHED();
224 return nullptr; 231 return nullptr;
225 } 232 }
226 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true); 233 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true, m_font->exceedsFontLoadWaitLimit() ? CustomFontData::VisibleFallback : CustomFon tData::InvisibleFallback);
227 cssFontData->setCSSFontFaceSource(this); 234 cssFontData->setCSSFontFaceSource(this);
228 fontData = SimpleFontData::create(temporaryFont->platformData(), cssFont Data); 235 fontData = SimpleFontData::create(temporaryFont->platformData(), cssFont Data);
229 } 236 }
230 237
231 return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. 238 return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
232 } 239 }
233 240
234 #if ENABLE(SVG_FONTS) 241 #if ENABLE(SVG_FONTS)
235 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const 242 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const
236 { 243 {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (size < 50 * 1024) 319 if (size < 50 * 1024)
313 return "WebFont.DownloadTime.1.10KBTo50KB"; 320 return "WebFont.DownloadTime.1.10KBTo50KB";
314 if (size < 100 * 1024) 321 if (size < 100 * 1024)
315 return "WebFont.DownloadTime.2.50KBTo100KB"; 322 return "WebFont.DownloadTime.2.50KBTo100KB";
316 if (size < 1024 * 1024) 323 if (size < 1024 * 1024)
317 return "WebFont.DownloadTime.3.100KBTo1MB"; 324 return "WebFont.DownloadTime.3.100KBTo1MB";
318 return "WebFont.DownloadTime.4.Over1MB"; 325 return "WebFont.DownloadTime.4.Over1MB";
319 } 326 }
320 327
321 } 328 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontFaceSource.h ('k') | Source/core/css/CSSSegmentedFontFace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698