Index: third_party/WebKit/Source/core/css/CSSFontFace.cpp |
diff --git a/third_party/WebKit/Source/core/css/CSSFontFace.cpp b/third_party/WebKit/Source/core/css/CSSFontFace.cpp |
index e46ce5bbf3c7f5f4218a613e52a500cb83e4e4f2..a4abbc589b1670ed650c40ce19f5dc347b2a2b14 100644 |
--- a/third_party/WebKit/Source/core/css/CSSFontFace.cpp |
+++ b/third_party/WebKit/Source/core/css/CSSFontFace.cpp |
@@ -53,7 +53,7 @@ void CSSFontFace::didBeginLoad() { |
setLoadStatus(FontFace::Loading); |
} |
-void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { |
+void CSSFontFace::fontLoaded(RemoteFontFaceSource* source, Document* document) { |
if (!isValid() || source != m_sources.first()) |
return; |
@@ -66,7 +66,7 @@ void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { |
setLoadStatus(FontFace::Error); |
} else { |
m_sources.removeFirst(); |
- load(); |
+ load(document); |
} |
} |
@@ -113,7 +113,8 @@ PassRefPtr<SimpleFontData> CSSFontFace::getFontData( |
return nullptr; |
} |
-bool CSSFontFace::maybeLoadFont(const FontDescription& fontDescription, |
+bool CSSFontFace::maybeLoadFont(Document* document, |
+ const FontDescription& fontDescription, |
const String& text) { |
// This is a fast path of loading web font in style phase. For speed, this |
// only checks if the first character of the text is included in the font's |
@@ -122,35 +123,42 @@ bool CSSFontFace::maybeLoadFont(const FontDescription& fontDescription, |
UChar32 character = text.characterStartingAt(0); |
if (m_ranges->contains(character)) { |
if (loadStatus() == FontFace::Unloaded) |
- load(fontDescription); |
+ load(document, fontDescription); |
return true; |
} |
return false; |
} |
-bool CSSFontFace::maybeLoadFont(const FontDescription& fontDescription, |
+bool CSSFontFace::maybeLoadFont(Document* document, |
+ const FontDescription& fontDescription, |
const FontDataForRangeSet& rangeSet) { |
if (m_ranges == rangeSet.ranges()) { |
if (loadStatus() == FontFace::Unloaded) { |
- load(fontDescription); |
+ load(document, fontDescription); |
} |
return true; |
} |
return false; |
} |
-void CSSFontFace::load() { |
+void CSSFontFace::load(Document* document) { |
FontDescription fontDescription; |
FontFamily fontFamily; |
fontFamily.setFamily(m_fontFace->family()); |
fontDescription.setFamily(fontFamily); |
fontDescription.setTraits(m_fontFace->traits()); |
- load(fontDescription); |
+ load(document, fontDescription); |
} |
-void CSSFontFace::load(const FontDescription& fontDescription) { |
- if (loadStatus() == FontFace::Unloaded) |
+void CSSFontFace::load(Document* document, |
+ const FontDescription& fontDescription) { |
+ if (loadStatus() == FontFace::Unloaded) { |
setLoadStatus(FontFace::Loading); |
+ // Only begin loading if we have been added to a CSSSegmentedFontFace |
+ // (which happens when we are ready to start loading). |
+ if (m_segmentedFontFace) |
+ FontFaceSet::from(*document)->beginFontLoading(m_fontFace); |
+ } |
ASSERT(loadStatus() == FontFace::Loading); |
while (!m_sources.isEmpty()) { |
@@ -180,12 +188,6 @@ void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) { |
m_fontFace->setError(); |
else |
m_fontFace->setLoadStatus(newStatus); |
- |
- if (!m_segmentedFontFace) |
- return; |
- Document* document = m_segmentedFontFace->fontSelector()->document(); |
- if (document && newStatus == FontFace::Loading) |
- FontFaceSet::from(*document)->beginFontLoading(m_fontFace); |
} |
DEFINE_TRACE(CSSFontFace) { |