Bug 1376964 - Part 1: Record the docshell's "bypass cache" flag on FontFaceSet. r=jfkthame

MozReview-Commit-ID: FW19nms4ZEB

--HG--
extra : rebase_source : c6407c336cd3187ed66781f717bff079616c97ba
This commit is contained in:
Cameron McCormack 2017-07-12 16:35:44 +08:00
Родитель 6d648badcb
Коммит 1f2b492e8c
2 изменённых файлов: 24 добавлений и 17 удалений

Просмотреть файл

@ -106,6 +106,7 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowInner* aWindow, nsIDocument* aDocument)
, mHasLoadingFontFaces(false)
, mHasLoadingFontFacesIsDirty(false)
, mDelayedLoadCheck(false)
, mBypassCache(false)
{
MOZ_ASSERT(mDocument, "We should get a valid document from the caller!");
@ -118,6 +119,24 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowInner* aWindow, nsIDocument* aDocument)
mResolveLazilyCreatedReadyPromise = true;
}
// Record the state of the "bypass cache" flags from the docshell now,
// since we want to look at them from style worker threads, and we can
// only get to the docshell through a weak pointer (which is only
// possible on the main thread).
//
// In theory the load type of a docshell could change after the document
// is loaded, but handling that doesn't seem too important.
if (nsCOMPtr<nsIDocShell> docShell = mDocument->GetDocShell()) {
uint32_t loadType;
uint32_t flags;
if ((NS_SUCCEEDED(docShell->GetLoadType(&loadType)) &&
((loadType >> 16) & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)) ||
(NS_SUCCEEDED(docShell->GetDefaultLoadFlags(&flags)) &&
(flags & nsIRequest::LOAD_BYPASS_CACHE))) {
mBypassCache = true;
}
}
if (!mDocument->DidFireDOMContentLoaded()) {
mDocument->AddSystemEventListener(NS_LITERAL_STRING("DOMContentLoaded"),
this, false, false);
@ -1327,23 +1346,7 @@ FontFaceSet::CheckFontLoad(const gfxFontFaceSrc* aFontFaceSrc,
*aPrincipal = aFontFaceSrc->mOriginPrincipal;
}
*aBypassCache = false;
nsCOMPtr<nsIDocShell> docShell = mDocument->GetDocShell();
if (docShell) {
uint32_t loadType;
if (NS_SUCCEEDED(docShell->GetLoadType(&loadType))) {
if ((loadType >> 16) & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
*aBypassCache = true;
}
}
uint32_t flags;
if (NS_SUCCEEDED(docShell->GetDefaultLoadFlags(&flags))) {
if (flags & nsIRequest::LOAD_BYPASS_CACHE) {
*aBypassCache = true;
}
}
}
*aBypassCache = mBypassCache;
return NS_OK;
}

Просмотреть файл

@ -355,6 +355,10 @@ private:
// Whether CheckLoadingFinished calls should be ignored. See comment in
// OnFontFaceStatusChanged.
bool mDelayedLoadCheck;
// Whether the docshell for our document indicated that loads should
// bypass the cache.
bool mBypassCache;
};
} // namespace dom