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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: RemoteFontFaceSource cache-aware behavior, fix Created 4 years, 2 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/RemoteFontFaceSource.cpp
diff --git a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
index 57e48b357383b9e79a6dbd8d8a53cf995dde2af5..e058a71841c01b64337d670f2f3bb9f15cfb04c3 100644
--- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
+++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
@@ -154,23 +154,30 @@ void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) {
m_histograms.longLimitExceeded(m_isInterventionTriggered);
}
-void RemoteFontFaceSource::switchToSwapPeriod() {
- ASSERT(m_period == BlockPeriod);
- m_period = SwapPeriod;
+void RemoteFontFaceSource::willReloadAfterDiskCacheMiss(const FontResource*) {
+ if (m_period == SwapPeriod || m_period == FailurePeriod)
+ didBecomeVisibleFallback();
Kunihiko Sakamoto 2016/10/11 08:07:38 We should move to next period here, instead of kee
Shao-Chuan Lee 2016/10/11 10:58:48 Done.
+}
+void RemoteFontFaceSource::didBecomeVisibleFallback() {
pruneTable();
if (m_face) {
m_fontSelector->fontFaceInvalidated();
m_face->didBecomeVisibleFallback(this);
}
+}
+void RemoteFontFaceSource::switchToSwapPeriod() {
+ DCHECK(m_period == BlockPeriod);
+ m_period = SwapPeriod;
+ didBecomeVisibleFallback();
m_histograms.recordFallbackTime(m_font.get());
}
void RemoteFontFaceSource::switchToFailurePeriod() {
if (m_period == BlockPeriod)
switchToSwapPeriod();
- ASSERT(m_period == SwapPeriod);
+ DCHECK(m_period == SwapPeriod);
m_period = FailurePeriod;
}
@@ -193,6 +200,25 @@ bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() {
return networkIsSlow && m_display == FontDisplayAuto;
}
+bool RemoteFontFaceSource::shouldUseInvisibleFallback() const {
+ if (m_period == BlockPeriod)
+ return true;
+ if (m_font->resourceRequest().isCacheAwareLoadingActivated()) {
+ switch (m_display) {
+ case FontDisplaySwap:
+ case FontDisplayFallback:
+ case FontDisplayOptional:
+ return true;
+ case FontDisplayAuto:
+ case FontDisplayBlock:
+ break;
+ case FontDisplayEnumMax:
+ NOTREACHED();
+ }
+ }
+ return false;
+}
+
PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(
const FontDescription& fontDescription) {
if (!isLoaded())
@@ -223,8 +249,8 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(
return nullptr;
}
RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(
- this, m_period == BlockPeriod ? CSSCustomFontData::InvisibleFallback
- : CSSCustomFontData::VisibleFallback);
+ this, shouldUseInvisibleFallback() ? CSSCustomFontData::InvisibleFallback
+ : CSSCustomFontData::VisibleFallback);
return SimpleFontData::create(temporaryFont->platformData(), cssFontData);
}
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.h ('k') | third_party/WebKit/Source/core/fetch/FetchRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698