| 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 6f68e61ac9619288fe64f8cc9d1f668d0f5db6ad..6e355db1f64efbfa7c00974883ce10c4c03feb6d 100644
|
| --- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
|
| +++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
|
| @@ -16,9 +16,11 @@
|
|
|
| namespace blink {
|
|
|
| -RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, PassRefPtrWillBeRawPtr<FontLoader> fontLoader)
|
| +RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, PassRefPtrWillBeRawPtr<FontLoader> fontLoader, FontDisplay display)
|
| : m_font(font)
|
| , m_fontLoader(fontLoader)
|
| + , m_display(display)
|
| + , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod)
|
| {
|
| m_font->addClient(this);
|
| }
|
| @@ -44,17 +46,17 @@ void RemoteFontFaceSource::pruneTable()
|
|
|
| bool RemoteFontFaceSource::isLoading() const
|
| {
|
| - return !m_font->stillNeedsLoad() && !m_font->isLoaded();
|
| + return m_period != FailurePeriod && !m_font->stillNeedsLoad() && !m_font->isLoaded();
|
| }
|
|
|
| bool RemoteFontFaceSource::isLoaded() const
|
| {
|
| - return m_font->isLoaded();
|
| + return m_period == FailurePeriod || m_font->isLoaded();
|
| }
|
|
|
| bool RemoteFontFaceSource::isValid() const
|
| {
|
| - return !m_font->errorOccurred();
|
| + return m_period != FailurePeriod && !m_font->errorOccurred();
|
| }
|
|
|
| void RemoteFontFaceSource::didStartFontLoad(FontResource*)
|
| @@ -80,17 +82,50 @@ void RemoteFontFaceSource::fontLoaded(FontResource*)
|
| }
|
| }
|
|
|
| -void RemoteFontFaceSource::fontLoadWaitLimitExceeded(FontResource*)
|
| +void RemoteFontFaceSource::fontLoadShortLimitExceeded(FontResource*)
|
| {
|
| + if (m_display == FontDisplayFallback)
|
| + switchToSwapPeriod();
|
| + else if (m_display == FontDisplayOptional)
|
| + switchToFailurePeriod();
|
| +}
|
| +
|
| +void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*)
|
| +{
|
| + if (m_display == FontDisplayAuto || m_display == FontDisplayBlock)
|
| + switchToSwapPeriod();
|
| + else if (m_display == FontDisplayFallback)
|
| + switchToFailurePeriod();
|
| +}
|
| +
|
| +void RemoteFontFaceSource::switchToSwapPeriod()
|
| +{
|
| + ASSERT(m_period == BlockPeriod);
|
| + m_period = SwapPeriod;
|
| +
|
| pruneTable();
|
| if (m_face) {
|
| m_fontLoader->fontFaceInvalidated();
|
| - m_face->fontLoadWaitLimitExceeded(this);
|
| + m_face->fontDataInvalidated(this);
|
| }
|
|
|
| m_histograms.recordFallbackTime(m_font.get());
|
| }
|
|
|
| +void RemoteFontFaceSource::switchToFailurePeriod()
|
| +{
|
| + if (m_period == BlockPeriod)
|
| + switchToSwapPeriod();
|
| + ASSERT(m_period == SwapPeriod);
|
| + m_period = FailurePeriod;
|
| +
|
| + pruneTable();
|
| + if (m_face) {
|
| + m_fontLoader->fontFaceInvalidated();
|
| + m_face->fontLoaded(this);
|
| + }
|
| +}
|
| +
|
| PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescription& fontDescription)
|
| {
|
| if (!isLoaded())
|
| @@ -117,7 +152,7 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(c
|
| ASSERT_NOT_REACHED();
|
| return nullptr;
|
| }
|
| - RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_font->exceedsFontLoadWaitLimit() ? CSSCustomFontData::VisibleFallback : CSSCustomFontData::InvisibleFallback);
|
| + RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_period == BlockPeriod ? CSSCustomFontData::InvisibleFallback : CSSCustomFontData::VisibleFallback);
|
| return SimpleFontData::create(temporaryFont->platformData(), cssFontData);
|
| }
|
|
|
|
|