2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-10-01 07:04:10 +04:00
|
|
|
|
|
|
|
/* code for loading in @font-face defined font data */
|
|
|
|
|
2016-12-16 06:16:31 +03:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
|
|
|
#include "mozilla/Logging.h"
|
|
|
|
|
2008-10-01 07:04:10 +04:00
|
|
|
#include "nsFontFaceLoader.h"
|
|
|
|
|
2008-11-06 03:32:12 +03:00
|
|
|
#include "nsError.h"
|
2019-01-25 23:52:00 +03:00
|
|
|
#include "mozilla/AutoRestore.h"
|
2011-06-12 06:30:16 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_layout.h"
|
2015-11-25 08:48:16 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2017-09-29 05:10:13 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2014-10-02 06:32:05 +04:00
|
|
|
#include "FontFaceSet.h"
|
2008-10-01 07:04:10 +04:00
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
2014-10-02 06:32:05 +04:00
|
|
|
#include "nsIHttpChannel.h"
|
2008-11-06 03:32:12 +03:00
|
|
|
#include "nsIContentPolicy.h"
|
2017-09-29 05:10:13 +03:00
|
|
|
#include "nsIThreadRetargetableRequest.h"
|
2008-11-06 03:32:12 +03:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2017-09-29 05:10:13 +03:00
|
|
|
#include "nsNetCID.h"
|
2008-10-01 07:04:10 +04:00
|
|
|
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2011-04-12 14:53:20 +04:00
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
using namespace mozilla;
|
2015-10-16 09:10:14 +03:00
|
|
|
using namespace mozilla::dom;
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOG(args) \
|
|
|
|
MOZ_LOG(gfxUserFontSet::GetUserFontsLog(), mozilla::LogLevel::Debug, args)
|
2015-06-04 01:22:28 +03:00
|
|
|
#define LOG_ENABLED() \
|
|
|
|
MOZ_LOG_TEST(gfxUserFontSet::GetUserFontsLog(), LogLevel::Debug)
|
2008-10-01 07:04:10 +04:00
|
|
|
|
2016-01-07 08:03:05 +03:00
|
|
|
static uint32_t GetFallbackDelay() {
|
|
|
|
return Preferences::GetInt("gfx.downloadable_fonts.fallback_delay", 3000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t GetShortFallbackDelay() {
|
|
|
|
return Preferences::GetInt("gfx.downloadable_fonts.fallback_delay_short",
|
|
|
|
100);
|
|
|
|
}
|
|
|
|
|
2014-09-08 11:23:20 +04:00
|
|
|
nsFontFaceLoader::nsFontFaceLoader(gfxUserFontEntry* aUserFontEntry,
|
2015-10-16 09:10:14 +03:00
|
|
|
nsIURI* aFontURI, FontFaceSet* aFontFaceSet,
|
2013-09-25 17:48:20 +04:00
|
|
|
nsIChannel* aChannel)
|
2018-06-14 12:54:03 +03:00
|
|
|
: mUserFontEntry(aUserFontEntry),
|
|
|
|
mFontURI(aFontURI),
|
|
|
|
mFontFaceSet(aFontFaceSet),
|
|
|
|
mChannel(aChannel),
|
|
|
|
mStreamLoader(nullptr) {
|
2017-03-14 16:57:34 +03:00
|
|
|
MOZ_ASSERT(mFontFaceSet,
|
|
|
|
"We should get a valid FontFaceSet from the caller!");
|
2015-11-25 08:48:16 +03:00
|
|
|
mStartTime = TimeStamp::Now();
|
2019-06-06 22:08:52 +03:00
|
|
|
|
|
|
|
// We add an explicit load block rather than just rely on the network
|
|
|
|
// request's block, since we need to do some OMT work after the load
|
|
|
|
// is finished before we unblock load.
|
|
|
|
mFontFaceSet->Document()->BlockOnload();
|
2008-10-01 07:04:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFontFaceLoader::~nsFontFaceLoader() {
|
2019-01-25 23:52:00 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
2014-09-08 11:23:20 +04:00
|
|
|
if (mUserFontEntry) {
|
|
|
|
mUserFontEntry->mLoader = nullptr;
|
2012-04-26 21:50:41 +04:00
|
|
|
}
|
2011-01-06 00:48:48 +03:00
|
|
|
if (mLoadTimer) {
|
|
|
|
mLoadTimer->Cancel();
|
2012-07-30 18:20:58 +04:00
|
|
|
mLoadTimer = nullptr;
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
2014-10-02 06:32:05 +04:00
|
|
|
if (mFontFaceSet) {
|
|
|
|
mFontFaceSet->RemoveLoader(this);
|
2019-06-06 22:08:52 +03:00
|
|
|
mFontFaceSet->Document()->UnblockOnload(false);
|
2009-01-19 12:21:29 +03:00
|
|
|
}
|
2008-10-01 07:04:10 +04:00
|
|
|
}
|
|
|
|
|
2013-09-25 17:48:20 +04:00
|
|
|
void nsFontFaceLoader::StartedLoading(nsIStreamLoader* aStreamLoader) {
|
2016-01-07 08:03:05 +03:00
|
|
|
int32_t loadTimeout;
|
2018-10-04 00:50:21 +03:00
|
|
|
StyleFontDisplay fontDisplay = GetFontDisplay();
|
|
|
|
if (fontDisplay == StyleFontDisplay::Auto ||
|
|
|
|
fontDisplay == StyleFontDisplay::Block) {
|
2016-01-07 08:03:05 +03:00
|
|
|
loadTimeout = GetFallbackDelay();
|
|
|
|
} else {
|
|
|
|
loadTimeout = GetShortFallbackDelay();
|
|
|
|
}
|
|
|
|
|
2011-01-06 00:48:48 +03:00
|
|
|
if (loadTimeout > 0) {
|
2017-10-16 09:13:31 +03:00
|
|
|
NS_NewTimerWithFuncCallback(
|
|
|
|
getter_AddRefs(mLoadTimer), LoadTimerCallback, static_cast<void*>(this),
|
|
|
|
loadTimeout, nsITimer::TYPE_ONE_SHOT, "LoadTimerCallback",
|
|
|
|
mFontFaceSet->Document()->EventTargetFor(TaskCategory::Other));
|
2011-01-06 00:48:48 +03:00
|
|
|
} else {
|
2014-09-25 07:16:53 +04:00
|
|
|
mUserFontEntry->mFontDataLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
|
|
|
mStreamLoader = aStreamLoader;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* static */
|
|
|
|
void nsFontFaceLoader::LoadTimerCallback(nsITimer* aTimer, void* aClosure) {
|
2013-09-25 17:48:20 +04:00
|
|
|
nsFontFaceLoader* loader = static_cast<nsFontFaceLoader*>(aClosure);
|
2011-01-06 00:48:48 +03:00
|
|
|
|
2019-01-25 23:52:00 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!loader->mInLoadTimerCallback);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!loader->mInStreamComplete);
|
|
|
|
AutoRestore<bool> scope{loader->mInLoadTimerCallback};
|
|
|
|
loader->mInLoadTimerCallback = true;
|
|
|
|
|
2014-10-02 06:32:05 +04:00
|
|
|
if (!loader->mFontFaceSet) {
|
2013-03-14 09:24:40 +04:00
|
|
|
// We've been canceled
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-08 11:23:20 +04:00
|
|
|
gfxUserFontEntry* ufe = loader->mUserFontEntry.get();
|
2018-10-04 00:50:21 +03:00
|
|
|
StyleFontDisplay fontDisplay = loader->GetFontDisplay();
|
2016-01-07 08:03:05 +03:00
|
|
|
|
|
|
|
// Depending upon the value of the font-display descriptor for the font,
|
|
|
|
// their may be one or two timeouts associated with each font. The
|
|
|
|
// LOADING_SLOWLY state indicates that the fallback font is shown. The
|
|
|
|
// LOADING_TIMED_OUT state indicates that the fallback font is shown *and* the
|
|
|
|
// downloaded font resource will not replace the fallback font when the load
|
|
|
|
// completes.
|
2011-01-06 00:48:48 +03:00
|
|
|
|
2016-01-07 08:03:05 +03:00
|
|
|
bool updateUserFontSet = true;
|
|
|
|
switch (fontDisplay) {
|
2018-10-04 00:50:21 +03:00
|
|
|
case StyleFontDisplay::Auto:
|
|
|
|
case StyleFontDisplay::Block:
|
2016-01-07 08:03:05 +03:00
|
|
|
// If the entry is loading, check whether it's >75% done; if so,
|
|
|
|
// we allow another timeout period before showing a fallback font.
|
|
|
|
if (ufe->mFontDataLoadingState == gfxUserFontEntry::LOADING_STARTED) {
|
|
|
|
int64_t contentLength;
|
|
|
|
uint32_t numBytesRead;
|
|
|
|
if (NS_SUCCEEDED(loader->mChannel->GetContentLength(&contentLength)) &&
|
|
|
|
contentLength > 0 && contentLength < UINT32_MAX &&
|
|
|
|
NS_SUCCEEDED(
|
|
|
|
loader->mStreamLoader->GetNumBytesRead(&numBytesRead)) &&
|
|
|
|
numBytesRead > 3 * (uint32_t(contentLength) >> 2)) {
|
|
|
|
// More than 3/4 the data has been downloaded, so allow 50% extra
|
|
|
|
// time and hope the remainder will arrive before the additional
|
|
|
|
// time expires.
|
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_ALMOST_DONE;
|
|
|
|
uint32_t delay;
|
|
|
|
loader->mLoadTimer->GetDelay(&delay);
|
2017-06-12 22:34:10 +03:00
|
|
|
loader->mLoadTimer->InitWithNamedFuncCallback(
|
|
|
|
LoadTimerCallback, static_cast<void*>(loader), delay >> 1,
|
|
|
|
nsITimer::TYPE_ONE_SHOT, "nsFontFaceLoader::LoadTimerCallback");
|
2016-01-07 08:03:05 +03:00
|
|
|
updateUserFontSet = false;
|
|
|
|
LOG(("userfonts (%p) 75%% done, resetting timer\n", loader));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (updateUserFontSet) {
|
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
|
|
|
|
}
|
|
|
|
break;
|
2018-10-04 00:50:21 +03:00
|
|
|
case StyleFontDisplay::Swap:
|
2016-01-07 08:03:05 +03:00
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
|
|
|
|
break;
|
2018-10-04 00:50:21 +03:00
|
|
|
case StyleFontDisplay::Fallback: {
|
2016-01-07 08:03:05 +03:00
|
|
|
if (ufe->mFontDataLoadingState == gfxUserFontEntry::LOADING_STARTED) {
|
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
|
|
|
|
} else {
|
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_TIMED_OUT;
|
|
|
|
updateUserFontSet = false;
|
|
|
|
}
|
|
|
|
break;
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
2018-10-04 00:50:21 +03:00
|
|
|
case StyleFontDisplay::Optional:
|
2016-01-07 08:03:05 +03:00
|
|
|
ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_TIMED_OUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("strange font-display value");
|
2016-01-07 08:03:05 +03:00
|
|
|
break;
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the font is not 75% loaded, or if we've already timed out once
|
|
|
|
// before, we mark this entry as "loading slowly", so the fallback
|
|
|
|
// font will be used in the meantime, and tell the context to refresh.
|
|
|
|
if (updateUserFontSet) {
|
2015-10-16 09:10:14 +03:00
|
|
|
nsTArray<gfxUserFontSet*> fontSets;
|
|
|
|
ufe->GetUserFontSets(fontSets);
|
|
|
|
for (gfxUserFontSet* fontSet : fontSets) {
|
|
|
|
nsPresContext* ctx = FontFaceSet::GetPresContextFor(fontSet);
|
|
|
|
if (ctx) {
|
|
|
|
fontSet->IncrementGeneration();
|
|
|
|
ctx->UserFontSetUpdated(ufe);
|
2016-01-07 08:03:05 +03:00
|
|
|
LOG(("userfonts (%p) timeout reflow for pres context %p display %d\n",
|
2018-10-04 00:50:21 +03:00
|
|
|
loader, ctx, static_cast<int>(fontDisplay)));
|
2015-10-16 09:10:14 +03:00
|
|
|
}
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-29 05:10:13 +03:00
|
|
|
NS_IMPL_ISUPPORTS(nsFontFaceLoader, nsIStreamLoaderObserver, nsIRequestObserver)
|
2008-10-01 07:04:10 +04:00
|
|
|
|
2017-09-29 05:10:13 +03:00
|
|
|
// nsIStreamLoaderObserver
|
2008-10-01 07:04:10 +04:00
|
|
|
NS_IMETHODIMP
|
2008-10-29 21:09:50 +03:00
|
|
|
nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
|
|
|
nsISupports* aContext, nsresult aStatus,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aStringLen,
|
|
|
|
const uint8_t* aString) {
|
2017-09-29 05:10:13 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-01-25 23:52:00 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
|
|
|
|
|
|
|
AutoRestore<bool> scope{mInStreamComplete};
|
|
|
|
mInStreamComplete = true;
|
2017-09-29 05:10:13 +03:00
|
|
|
|
2019-01-21 13:39:07 +03:00
|
|
|
DropChannel();
|
|
|
|
|
2019-06-06 22:08:52 +03:00
|
|
|
if (mLoadTimer) {
|
|
|
|
mLoadTimer->Cancel();
|
|
|
|
mLoadTimer = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-02 06:32:05 +04:00
|
|
|
if (!mFontFaceSet) {
|
2009-01-19 12:21:29 +03:00
|
|
|
// We've been canceled
|
|
|
|
return aStatus;
|
|
|
|
}
|
|
|
|
|
2015-11-25 08:48:16 +03:00
|
|
|
TimeStamp doneTime = TimeStamp::Now();
|
|
|
|
TimeDuration downloadTime = doneTime - mStartTime;
|
|
|
|
uint32_t downloadTimeMS = uint32_t(downloadTime.ToMilliseconds());
|
|
|
|
Telemetry::Accumulate(Telemetry::WEBFONT_DOWNLOAD_TIME, downloadTimeMS);
|
|
|
|
|
2018-10-04 00:50:21 +03:00
|
|
|
if (GetFontDisplay() == StyleFontDisplay::Fallback) {
|
2016-01-07 08:03:05 +03:00
|
|
|
uint32_t loadTimeout = GetFallbackDelay();
|
|
|
|
if (downloadTimeMS > loadTimeout &&
|
|
|
|
(mUserFontEntry->mFontDataLoadingState ==
|
|
|
|
gfxUserFontEntry::LOADING_SLOWLY)) {
|
|
|
|
mUserFontEntry->mFontDataLoadingState =
|
|
|
|
gfxUserFontEntry::LOADING_TIMED_OUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:04:10 +04:00
|
|
|
if (LOG_ENABLED()) {
|
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
2015-11-25 08:48:16 +03:00
|
|
|
LOG(("userfonts (%p) download completed - font uri: (%s) time: %d ms\n",
|
2016-08-26 09:02:31 +03:00
|
|
|
this, mFontURI->GetSpecOrDefault().get(), downloadTimeMS));
|
2008-10-01 07:04:10 +04:00
|
|
|
} else {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("userfonts (%p) download failed - font uri: (%s) error: %8.8" PRIx32
|
|
|
|
"\n",
|
|
|
|
this, mFontURI->GetSpecOrDefault().get(),
|
|
|
|
static_cast<uint32_t>(aStatus)));
|
2008-10-01 07:04:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-13 17:54:54 +04:00
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
|
|
|
// for HTTP requests, check whether the request _actually_ succeeded;
|
|
|
|
// the "request status" in aStatus does not necessarily indicate this,
|
|
|
|
// because HTTP responses such as 404 (Not Found) will still result in
|
|
|
|
// a success code and potentially an HTML error page from the server
|
|
|
|
// as the resulting data. We don't want to use that as a font.
|
2011-11-11 03:38:23 +04:00
|
|
|
nsCOMPtr<nsIRequest> request;
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel;
|
|
|
|
aLoader->GetRequest(getter_AddRefs(request));
|
|
|
|
httpChannel = do_QueryInterface(request);
|
2011-07-13 17:54:54 +04:00
|
|
|
if (httpChannel) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool succeeded;
|
2011-07-13 17:54:54 +04:00
|
|
|
nsresult rv = httpChannel->GetRequestSucceeded(&succeeded);
|
|
|
|
if (NS_SUCCEEDED(rv) && !succeeded) {
|
|
|
|
aStatus = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 22:08:52 +03:00
|
|
|
mFontFaceSet->GetUserFontSet()->RecordFontLoadDone(aStringLen, doneTime);
|
|
|
|
|
2014-09-08 11:23:20 +04:00
|
|
|
// The userFontEntry is responsible for freeing the downloaded data
|
2009-08-30 17:55:24 +04:00
|
|
|
// (aString) when finished with it; the pointer is no longer valid
|
2014-09-25 07:16:53 +04:00
|
|
|
// after FontDataDownloadComplete returns.
|
2011-07-13 17:54:54 +04:00
|
|
|
// This is called even in the case of a failed download (HTTP 404, etc),
|
|
|
|
// as there may still be data to be freed (e.g. an error page),
|
2014-09-25 07:16:53 +04:00
|
|
|
// and we need to load the next source.
|
2008-10-01 07:04:10 +04:00
|
|
|
|
2019-06-06 22:08:52 +03:00
|
|
|
// FontDataDownloadComplete will load the platform font on a worker thread,
|
|
|
|
// and will call FontLoadComplete when it has finished its work.
|
|
|
|
mUserFontEntry->FontDataDownloadComplete(aString, aStringLen, aStatus, this);
|
|
|
|
return NS_SUCCESS_ADOPTED_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsFontFaceLoader::FontLoadComplete() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-11-25 08:48:16 +03:00
|
|
|
|
2019-06-14 22:25:50 +03:00
|
|
|
if (!mFontFaceSet) {
|
|
|
|
// We've been canceled
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:04:10 +04:00
|
|
|
// when new font loaded, need to reflow
|
2019-06-06 22:08:52 +03:00
|
|
|
nsTArray<gfxUserFontSet*> fontSets;
|
|
|
|
mUserFontEntry->GetUserFontSets(fontSets);
|
|
|
|
for (gfxUserFontSet* fontSet : fontSets) {
|
|
|
|
nsPresContext* ctx = FontFaceSet::GetPresContextFor(fontSet);
|
|
|
|
if (ctx) {
|
|
|
|
// Update layout for the presence of the new font. Since this is
|
|
|
|
// asynchronous, reflows will coalesce.
|
|
|
|
ctx->UserFontSetUpdated(mUserFontEntry);
|
|
|
|
LOG(("userfonts (%p) reflow for pres context %p\n", this, ctx));
|
2015-10-16 09:10:14 +03:00
|
|
|
}
|
2008-10-01 07:04:10 +04:00
|
|
|
}
|
|
|
|
|
2019-01-25 23:52:00 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mFontFaceSet);
|
|
|
|
mFontFaceSet->RemoveLoader(this);
|
2019-06-06 22:08:52 +03:00
|
|
|
mFontFaceSet->Document()->UnblockOnload(false);
|
2014-10-02 06:32:05 +04:00
|
|
|
mFontFaceSet = nullptr;
|
2013-03-14 09:24:40 +04:00
|
|
|
|
2019-06-06 22:08:52 +03:00
|
|
|
return NS_OK;
|
2008-10-01 07:04:10 +04:00
|
|
|
}
|
|
|
|
|
2017-09-29 05:10:13 +03:00
|
|
|
// nsIRequestObserver
|
|
|
|
NS_IMETHODIMP
|
2019-02-28 02:41:04 +03:00
|
|
|
nsFontFaceLoader::OnStartRequest(nsIRequest* aRequest) {
|
2017-09-29 05:10:13 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIThreadRetargetableRequest> req = do_QueryInterface(aRequest);
|
|
|
|
if (req) {
|
|
|
|
nsCOMPtr<nsIEventTarget> sts =
|
|
|
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(req->RetargetDeliveryTo(sts)));
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-03-12 03:14:00 +03:00
|
|
|
nsFontFaceLoader::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) {
|
2017-09-29 05:10:13 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-01-21 13:39:07 +03:00
|
|
|
DropChannel();
|
2017-09-29 05:10:13 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-19 12:21:29 +03:00
|
|
|
void nsFontFaceLoader::Cancel() {
|
2019-01-25 23:52:00 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mFontFaceSet);
|
|
|
|
|
2018-08-10 17:08:12 +03:00
|
|
|
mUserFontEntry->LoadCanceled();
|
2019-02-05 17:41:57 +03:00
|
|
|
mUserFontEntry = nullptr;
|
2019-06-06 22:08:52 +03:00
|
|
|
mFontFaceSet->Document()->UnblockOnload(false);
|
2014-10-02 06:32:05 +04:00
|
|
|
mFontFaceSet = nullptr;
|
2011-01-06 00:48:48 +03:00
|
|
|
if (mLoadTimer) {
|
|
|
|
mLoadTimer->Cancel();
|
2012-07-30 18:20:58 +04:00
|
|
|
mLoadTimer = nullptr;
|
2011-01-06 00:48:48 +03:00
|
|
|
}
|
2019-02-11 05:10:52 +03:00
|
|
|
if (nsCOMPtr<nsIChannel> channel = mChannel.forget()) {
|
|
|
|
channel->Cancel(NS_BINDING_ABORTED);
|
|
|
|
}
|
2009-01-19 12:21:29 +03:00
|
|
|
}
|
|
|
|
|
2016-01-07 08:03:05 +03:00
|
|
|
StyleFontDisplay nsFontFaceLoader::GetFontDisplay() {
|
2018-10-04 00:50:21 +03:00
|
|
|
if (!StaticPrefs::layout_css_font_display_enabled()) {
|
|
|
|
return StyleFontDisplay::Auto;
|
2016-01-07 08:03:05 +03:00
|
|
|
}
|
2018-10-04 00:50:21 +03:00
|
|
|
return mUserFontEntry->GetFontDisplay();
|
2016-01-07 08:03:05 +03:00
|
|
|
}
|