Chromium Code Reviews| 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 3d5e63fc319c0aef557a82230917478d23164b27..18a8394be8b5ac41708b9e852f7d310afcb1236a 100644 |
| --- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| +++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| @@ -6,7 +6,9 @@ |
| #include "core/css/CSSCustomFontData.h" |
| #include "core/css/CSSFontFace.h" |
| -#include "core/css/FontLoader.h" |
| +#include "core/css/CSSFontSelector.h" |
| +#include "core/dom/Document.h" |
| +#include "core/inspector/ConsoleMessage.h" |
| #include "core/page/NetworkStateNotifier.h" |
| #include "platform/Histogram.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| @@ -17,9 +19,9 @@ |
| namespace blink { |
| -RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, FontLoader* fontLoader, FontDisplay display) |
| +RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, CSSFontSelector* fontSelector, FontDisplay display) |
| : m_font(font) |
| - , m_fontLoader(fontLoader) |
| + , m_fontSelector(fontSelector) |
| , m_display(display) |
| , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod) |
| , m_isInterventionTriggered(false) |
| @@ -82,26 +84,23 @@ bool RemoteFontFaceSource::isValid() const |
| return !m_font->errorOccurred(); |
| } |
| -void RemoteFontFaceSource::didStartFontLoad(FontResource*) |
| -{ |
| - // We may send duplicated reports when multiple CSSFontFaceSource are |
| - // registered at this FontResource. Associating the same URL to different |
| - // font-family causes the case, but we treat them as indivisual resources. |
| - m_histograms.loadStarted(); |
| -} |
| - |
| void RemoteFontFaceSource::fontLoaded(FontResource*) |
| { |
| m_histograms.recordRemoteFont(m_font.get()); |
| m_histograms.fontLoaded(m_isInterventionTriggered); |
| m_font->ensureCustomFontData(); |
| - if (m_font->getStatus() == Resource::DecodeError) |
| - m_fontLoader->didFailToDecode(m_font.get()); |
| + // FIXME: Provide more useful message such as OTS rejection reason. |
| + // See crbug.com/97467 |
| + if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document()) { |
| + m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, "Failed to decode downloaded font: " + m_font->url().elidedString())); |
| + if (m_font->otsParsingMessage().length() > 1) |
| + m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsParsingMessage())); |
| + } |
| pruneTable(); |
| if (m_face) { |
| - m_fontLoader->fontFaceInvalidated(); |
| + m_fontSelector->fontFaceInvalidated(); |
| m_face->fontLoaded(this); |
| } |
| // Should not do anything after this line since the m_face->fontLoaded() |
| @@ -133,7 +132,7 @@ void RemoteFontFaceSource::switchToSwapPeriod() |
| pruneTable(); |
| if (m_face) { |
| - m_fontLoader->fontFaceInvalidated(); |
| + m_fontSelector->fontFaceInvalidated(); |
| m_face->didBecomeVisibleFallback(this); |
| } |
| @@ -179,8 +178,11 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(c |
| void RemoteFontFaceSource::beginLoadIfNeeded() |
| { |
| - if (m_font->stillNeedsLoad()) |
| - m_fontLoader->addFontToBeginLoading(m_font.get()); |
| + if (m_fontSelector->document() && m_font->stillNeedsLoad()) { |
| + m_font->load(m_fontSelector->document()->fetcher()); |
| + m_histograms.loadStarted(); |
| + } |
| + m_font->startLoadLimitTimersIfNeeded(); |
|
Nate Chapin
2016/04/07 23:46:16
https://tabatkins.github.io/specs/css-font-display
Kunihiko Sakamoto
2016/04/08 02:37:16
Agreed, thanks for doing this!
|
| if (m_face) |
| m_face->didBeginLoad(); |
| @@ -189,7 +191,7 @@ void RemoteFontFaceSource::beginLoadIfNeeded() |
| DEFINE_TRACE(RemoteFontFaceSource) |
| { |
| visitor->trace(m_font); |
| - visitor->trace(m_fontLoader); |
| + visitor->trace(m_fontSelector); |
| CSSFontFaceSource::trace(visitor); |
| } |