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

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

Issue 248473005: Make CSSFontFace::willUseFontData() load fonts with unicode-range (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « Source/core/css/CSSFontFace.h ('k') | Source/core/css/CSSFontSelector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSFontFace.cpp
diff --git a/Source/core/css/CSSFontFace.cpp b/Source/core/css/CSSFontFace.cpp
index 9ae257e4d2bc61f2933c3f3b8282a04823f2b6c0..40d6fa384799edcf82a9f45b544d7cfef2f287ff 100644
--- a/Source/core/css/CSSFontFace.cpp
+++ b/Source/core/css/CSSFontFace.cpp
@@ -126,16 +126,13 @@ PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
return nullptr;
}
-void CSSFontFace::willUseFontData(const FontDescription& fontDescription)
+bool CSSFontFace::maybeScheduleFontLoad(const FontDescription& fontDescription, UChar32 character)
{
- // Kicks off font load here only if the @font-face has no unicode-range.
- // @font-faces with unicode-range will be loaded when a GlyphPage for the
- // font is created.
- // FIXME: Pass around the text to render from RenderText, and kick download
- // if m_ranges intersects with the text. Make sure this does not cause
- // performance regression.
- if (m_ranges.isEntireRange())
+ if (m_ranges.contains(character)) {
load(fontDescription);
+ return true;
+ }
+ return false;
}
void CSSFontFace::load(const FontDescription& fontDescription, CSSFontSelector* fontSelector)
@@ -217,6 +214,14 @@ CSSFontFace::UnicodeRangeSet::UnicodeRangeSet(const Vector<UnicodeRange>& ranges
m_ranges.shrink(targetIndex);
}
+bool CSSFontFace::UnicodeRangeSet::contains(UChar32 c) const
+{
+ if (isEntireRange())
+ return true;
+ Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(), m_ranges.end(), c);
+ return it != m_ranges.end() && it->contains(c);
+}
+
bool CSSFontFace::UnicodeRangeSet::intersectsWith(const String& text) const
{
if (text.isEmpty())
@@ -230,8 +235,7 @@ bool CSSFontFace::UnicodeRangeSet::intersectsWith(const String& text) const
while (index < text.length()) {
UChar32 c = text.characterStartingAt(index);
index += U16_LENGTH(c);
- Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(), m_ranges.end(), c);
- if (it != m_ranges.end() && it->contains(c))
+ if (contains(c))
return true;
}
return false;
« no previous file with comments | « Source/core/css/CSSFontFace.h ('k') | Source/core/css/CSSFontSelector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698