| 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 d39461ea17599168f456dc3b8ec20e11cce00222..7f87e408c03c78c518b1ffbd3657d9fee53c9f7f 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)
|
| @@ -77,26 +79,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()
|
| @@ -128,7 +127,7 @@ void RemoteFontFaceSource::switchToSwapPeriod()
|
|
|
| pruneTable();
|
| if (m_face) {
|
| - m_fontLoader->fontFaceInvalidated();
|
| + m_fontSelector->fontFaceInvalidated();
|
| m_face->didBecomeVisibleFallback(this);
|
| }
|
|
|
| @@ -174,8 +173,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();
|
|
|
| if (m_face)
|
| m_face->didBeginLoad();
|
| @@ -184,7 +186,7 @@ void RemoteFontFaceSource::beginLoadIfNeeded()
|
| DEFINE_TRACE(RemoteFontFaceSource)
|
| {
|
| visitor->trace(m_font);
|
| - visitor->trace(m_fontLoader);
|
| + visitor->trace(m_fontSelector);
|
| CSSFontFaceSource::trace(visitor);
|
| }
|
|
|
|
|