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

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

Issue 2620293002: Remove CSSFontSelector argument and member from CSSSegmentedFontFace (Closed)
Patch Set: Update test for CL comments Created 3 years, 10 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: 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) {
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSFontFace.h ('k') | third_party/WebKit/Source/core/css/CSSFontSelector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698