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

Unified Diff: Source/core/fetch/FontResource.cpp

Issue 171823002: Make text visible when font loading takes longer than 3 seconds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 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
« no previous file with comments | « Source/core/fetch/FontResource.h ('k') | Source/platform/fonts/CustomFontData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/FontResource.cpp
diff --git a/Source/core/fetch/FontResource.cpp b/Source/core/fetch/FontResource.cpp
index cd1882941f1ee1da8e7332f1d1387de34b9f4b62..18ed44eb308ba80dda674e111c677f775141af2b 100644
--- a/Source/core/fetch/FontResource.cpp
+++ b/Source/core/fetch/FontResource.cpp
@@ -44,9 +44,13 @@
namespace WebCore {
+static const double fontLoadWaitLimitSec = 3.0;
+
FontResource::FontResource(const ResourceRequest& resourceRequest)
: Resource(resourceRequest, Font)
, m_loadInitiated(false)
+ , m_exceedsFontLoadWaitLimit(false)
+ , m_fontLoadWaitLimitTimer(this, &FontResource::fontLoadWaitLimitCallback)
{
}
@@ -74,6 +78,7 @@ void FontResource::beginLoadIfNeeded(ResourceFetcher* dl)
if (!m_loadInitiated) {
m_loadInitiated = true;
Resource::load(dl, m_options);
+ m_fontLoadWaitLimitTimer.startOneShot(fontLoadWaitLimitSec);
ResourceClientWalker<FontResourceClient> walker(m_clients);
while (FontResourceClient* client = walker.next())
@@ -155,6 +160,16 @@ SVGFontElement* FontResource::getSVGFontById(const String& fontName) const
}
#endif
+void FontResource::fontLoadWaitLimitCallback(Timer<FontResource>*)
+{
+ if (!isLoading())
+ return;
+ m_exceedsFontLoadWaitLimit = true;
+ ResourceClientWalker<FontResourceClient> walker(m_clients);
+ while (FontResourceClient* client = walker.next())
+ client->fontLoadWaitLimitExceeded(this);
+}
+
void FontResource::allClientsRemoved()
{
m_fontData.clear();
@@ -163,6 +178,7 @@ void FontResource::allClientsRemoved()
void FontResource::checkNotify()
{
+ m_fontLoadWaitLimitTimer.stop();
ResourceClientWalker<FontResourceClient> w(m_clients);
while (FontResourceClient* c = w.next())
c->fontLoaded(this);
« no previous file with comments | « Source/core/fetch/FontResource.h ('k') | Source/platform/fonts/CustomFontData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698