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

Unified Diff: Source/core/css/CSSFontFaceSource.cpp

Issue 23446007: Use unicode-range to prevent unnecessary @font-face donwnloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/CSSFontFaceSource.cpp
diff --git a/Source/core/css/CSSFontFaceSource.cpp b/Source/core/css/CSSFontFaceSource.cpp
index 106a66bf714a7834439f587b5c4ab3d7aa401ac0..cec3acd1883a0e7d2d6be0c49b0ed3e162b35461 100644
--- a/Source/core/css/CSSFontFaceSource.cpp
+++ b/Source/core/css/CSSFontFaceSource.cpp
@@ -68,6 +68,10 @@ void CSSFontFaceSource::pruneTable()
if (m_fontDataTable.isEmpty())
return;
+ for (FontDataTable::iterator it = m_fontDataTable.begin(); it != m_fontDataTable.end(); ++it) {
+ if (SimpleFontData* fontData = it->value.get())
+ fontData->clearCSSFontFaceSource();
+ }
m_fontDataTable.clear();
}
@@ -82,6 +86,13 @@ bool CSSFontFaceSource::isLocal() const
return true;
}
+bool CSSFontFaceSource::isLoading() const
+{
+ if (m_font)
+ return !m_font->stillNeedsLoad() && !m_font->isLoaded();
+ return false;
+}
+
bool CSSFontFaceSource::isLoaded() const
{
if (m_font)
@@ -193,14 +204,11 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
#endif
}
} else {
- // Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
- // and the loader may invoke arbitrary delegate or event handler code.
- fontSelector->beginLoadingFontSoon(m_font.get());
-
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer fontCachePurgePreventer;
SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
fontData = SimpleFontData::create(temporaryFont->platformData(), true, true);
+ fontData->setCSSFontFaceSource(this);
}
return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
@@ -254,6 +262,13 @@ void CSSFontFaceSource::willUseFontData()
m_histograms.willUseFontData();
}
+void CSSFontFaceSource::beginLoadingFontSoon()
+{
+ ASSERT(m_face);
+ ASSERT(m_font);
+ m_face->beginLoadingFontSoon(m_font.get());
+}
+
CSSFontFaceSource::FontLoadHistograms::~FontLoadHistograms()
{
if (m_styledTime > 0)

Powered by Google App Engine
This is Rietveld 408576698