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

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

Issue 457273002: Webfonts should not block load event for more than one frame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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/FontLoader.cpp
diff --git a/Source/core/css/FontLoader.cpp b/Source/core/css/FontLoader.cpp
index 8646bfac6081351779dfab144ff835b6477edbc5..247ab09ff9021bdd0c1e21df5386785b23abb7de 100644
--- a/Source/core/css/FontLoader.cpp
+++ b/Source/core/css/FontLoader.cpp
@@ -26,20 +26,20 @@ FontLoader::~FontLoader()
return;
}
m_beginLoadingTimer.stop();
-
- // When the m_fontsToBeginLoading vector is destroyed it will decrement the
- // request counts on the ResourceFetcher for all the fonts that were pending
- // at the time the FontLoader dies.
+ // This will decrement the request counts on the ResourceFetcher for all the
+ // fonts that were pending at the time the FontLoader dies.
+ clearPendingFonts();
#endif
}
void FontLoader::addFontToBeginLoading(FontResource* fontResource)
{
- if (!m_resourceFetcher || !fontResource->stillNeedsLoad())
+ if (!m_resourceFetcher || !fontResource->stillNeedsLoad() || fontResource->loadScheduled())
return;
m_fontsToBeginLoading.append(
std::make_pair(fontResource, ResourceLoader::RequestCountTracker(m_resourceFetcher, fontResource)));
+ fontResource->setLoadScheduled(true);
if (!m_beginLoadingTimer.isActive())
m_beginLoadingTimer.startOneShot(0, FROM_HERE);
}
@@ -80,12 +80,19 @@ void FontLoader::clearResourceFetcherAndFontSelector()
}
m_beginLoadingTimer.stop();
- m_fontsToBeginLoading.clear();
+ clearPendingFonts();
m_resourceFetcher = nullptr;
m_fontSelector = nullptr;
}
#endif
+void FontLoader::clearPendingFonts()
+{
+ for (FontsToLoadVector::iterator it = m_fontsToBeginLoading.begin(); it != m_fontsToBeginLoading.end(); ++it)
+ it->first->setLoadScheduled(false);
+ m_fontsToBeginLoading.clear();
+}
+
void FontLoader::trace(Visitor* visitor)
{
visitor->trace(m_resourceFetcher);

Powered by Google App Engine
This is Rietveld 408576698