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

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

Issue 1429713004: Implement CSS font-display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: failure does not mean loaded Created 5 years, 1 month 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/fetch/FontResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/FontResource.cpp b/third_party/WebKit/Source/core/fetch/FontResource.cpp
index 53d9d05c20c865717a827298590ac6423983865e..68f88e06d3e15ad5d54be2c4edbfbe05db011138 100644
--- a/third_party/WebKit/Source/core/fetch/FontResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/FontResource.cpp
@@ -38,7 +38,10 @@
namespace blink {
-static const double fontLoadWaitLimitSec = 3.0;
+// Durations of font-display periods.
+// https://tabatkins.github.io/specs/css-font-display/#font-display-desc
+static const double fontLoadWaitShortLimitSec = 0.1;
+static const double fontLoadWaitLongLimitSec = 3.0;
enum FontPackageFormat {
PackageFormatUnknown,
@@ -77,9 +80,9 @@ ResourcePtr<FontResource> FontResource::fetch(FetchRequest& request, ResourceFet
FontResource::FontResource(const ResourceRequest& resourceRequest)
: Resource(resourceRequest, Font)
, m_state(Unloaded)
- , m_exceedsFontLoadWaitLimit(false)
, m_corsFailed(false)
- , m_fontLoadWaitLimitTimer(this, &FontResource::fontLoadWaitLimitCallback)
+ , m_fontLoadShortLimitTimer(this, &FontResource::fontLoadShortLimitCallback)
+ , m_fontLoadLongLimitTimer(this, &FontResource::fontLoadLongLimitCallback)
{
}
@@ -121,7 +124,8 @@ void FontResource::beginLoadIfNeeded(ResourceFetcher* dl)
if (m_state != LoadInitiated) {
m_state = LoadInitiated;
Resource::load(dl, m_options);
- m_fontLoadWaitLimitTimer.startOneShot(fontLoadWaitLimitSec, BLINK_FROM_HERE);
+ m_fontLoadShortLimitTimer.startOneShot(fontLoadWaitShortLimitSec, BLINK_FROM_HERE);
+ m_fontLoadLongLimitTimer.startOneShot(fontLoadWaitLongLimitSec, BLINK_FROM_HERE);
ResourceClientWalker<FontResourceClient> walker(m_clients);
while (FontResourceClient* client = walker.next())
@@ -156,14 +160,22 @@ bool FontResource::isSafeToUnlock() const
return m_data->hasOneRef();
}
-void FontResource::fontLoadWaitLimitCallback(Timer<FontResource>*)
+void FontResource::fontLoadShortLimitCallback(Timer<FontResource>*)
{
if (!isLoading())
return;
- m_exceedsFontLoadWaitLimit = true;
ResourceClientWalker<FontResourceClient> walker(m_clients);
while (FontResourceClient* client = walker.next())
- client->fontLoadWaitLimitExceeded(this);
+ client->fontLoadShortLimitExceeded(this);
+}
+
+void FontResource::fontLoadLongLimitCallback(Timer<FontResource>*)
+{
+ if (!isLoading())
+ return;
+ ResourceClientWalker<FontResourceClient> walker(m_clients);
+ while (FontResourceClient* client = walker.next())
+ client->fontLoadLongLimitExceeded(this);
}
void FontResource::allClientsRemoved()
@@ -174,7 +186,8 @@ void FontResource::allClientsRemoved()
void FontResource::checkNotify()
{
- m_fontLoadWaitLimitTimer.stop();
+ m_fontLoadShortLimitTimer.stop();
+ m_fontLoadLongLimitTimer.stop();
ResourceClientWalker<FontResourceClient> w(m_clients);
while (FontResourceClient* c = w.next())
c->fontLoaded(this);
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FontResource.h ('k') | third_party/WebKit/Source/core/frame/UseCounter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698