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

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

Issue 2494243003: Set WebFont priority to very low if the network is detected to be slow (Closed)
Patch Set: addressed comments Created 4 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/css/RemoteFontFaceSource.cpp
diff --git a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
index e6f9a8c7845dd7d7ec5e0fb09577a04afb6d853a..1427b5237256d7dc87ead3b10b6919aa544ed0b7 100644
--- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
+++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
@@ -17,6 +17,7 @@
#include "platform/fonts/FontCache.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/SimpleFontData.h"
+#include "platform/network/ResourceLoadPriority.h"
#include "public/platform/WebEffectiveConnectionType.h"
#include "wtf/CurrentTime.h"
@@ -200,6 +201,10 @@ bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() {
return networkIsSlow && m_display == FontDisplayAuto;
}
+bool RemoteFontFaceSource::isLowPriorityLoadingAllowedForRemoteFont() const {
+ return m_isInterventionTriggered;
+}
+
PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(
const FontDescription& fontDescription) {
if (!isLoaded())
@@ -237,6 +242,13 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(
void RemoteFontFaceSource::beginLoadIfNeeded() {
if (m_fontSelector->document() && m_font->stillNeedsLoad()) {
+ if (!m_font->url().protocolIsData() && !m_font->isLoaded() &&
+ m_display == FontDisplayAuto &&
+ m_font->isLowPriorityLoadingAllowedForRemoteFont()) {
+ // Set the loading priority to VeryLow since this font is not required
+ // for painting the text.
+ m_font->didChangePriority(ResourceLoadPriorityVeryLow, 0);
+ }
m_fontSelector->document()->fetcher()->startLoad(m_font);
if (!m_font->isLoaded())
m_font->startLoadLimitTimers();
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.h ('k') | third_party/WebKit/Source/core/fetch/FontResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698