Bug 1376964 - Part 2: Record the docshell's "private browsing" flag on FontFaceSet. r=jfkthame
MozReview-Commit-ID: 3j0RISufybF
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -102,16 +102,17 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowIn
, mDocument(aDocument)
, mResolveLazilyCreatedReadyPromise(false)
, mStatus(FontFaceSetLoadStatus::Loaded)
, mNonRuleFacesDirty(false)
, mHasLoadingFontFaces(false)
, mHasLoadingFontFacesIsDirty(false)
, mDelayedLoadCheck(false)
, mBypassCache(false)
+ , mPrivateBrowsing(false)
{
MOZ_ASSERT(mDocument, "We should get a valid document from the caller!");
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aWindow);
// If the pref is not set, don't create the Promise (which the page wouldn't
// be able to get to anyway) as it causes the window.FontFaceSet constructor
// to be created.
@@ -132,16 +133,21 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowIn
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;
}
}
+ // Same for the "private browsing" flag.
+ if (nsCOMPtr<nsILoadContext> loadContext = mDocument->GetLoadContext()) {
+ mPrivateBrowsing = loadContext->UsePrivateBrowsing();
+ }
+
if (!mDocument->DidFireDOMContentLoaded()) {
mDocument->AddSystemEventListener(NS_LITERAL_STRING("DOMContentLoaded"),
this, false, false);
}
mDocument->CSSLoader()->AddObserver(this);
mUserFontSet = new UserFontSet(this);
@@ -1444,23 +1450,16 @@ FontFaceSet::SyncLoadFontData(gfxUserFon
aBuffer = nullptr;
aBufferLength = 0;
return rv;
}
return NS_OK;
}
-bool
-FontFaceSet::GetPrivateBrowsing()
-{
- nsCOMPtr<nsILoadContext> loadContext = mDocument->GetLoadContext();
- return loadContext && loadContext->UsePrivateBrowsing();
-}
-
void
FontFaceSet::OnFontFaceStatusChanged(FontFace* aFontFace)
{
AssertIsMainThreadOrServoFontMetricsLocked();
MOZ_ASSERT(HasAvailableFontFace(aFontFace));
mHasLoadingFontFacesIsDirty = true;
@@ -1859,17 +1858,17 @@ FontFaceSet::UserFontSet::SyncLoadFontDa
}
return mFontFaceSet->SyncLoadFontData(aFontToLoad, aFontFaceSrc,
aBuffer, aBufferLength);
}
/* virtual */ bool
FontFaceSet::UserFontSet::GetPrivateBrowsing()
{
- return mFontFaceSet && mFontFaceSet->GetPrivateBrowsing();
+ return mFontFaceSet && mFontFaceSet->mPrivateBrowsing;
}
/* virtual */ void
FontFaceSet::UserFontSet::DoRebuildUserFontSet()
{
if (!mFontFaceSet) {
return;
}
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -260,17 +260,16 @@ private:
nsCSSFontFaceRule* FindRuleForUserFontEntry(gfxUserFontEntry* aUserFontEntry);
nsresult StartLoad(gfxUserFontEntry* aUserFontEntry,
const gfxFontFaceSrc* aFontFaceSrc);
nsresult CheckFontLoad(const gfxFontFaceSrc* aFontFaceSrc,
nsIPrincipal** aPrincipal,
bool* aBypassCache);
bool IsFontLoadAllowed(nsIURI* aFontLocation, nsIPrincipal* aPrincipal);
- bool GetPrivateBrowsing();
nsresult SyncLoadFontData(gfxUserFontEntry* aFontToLoad,
const gfxFontFaceSrc* aFontFaceSrc,
uint8_t*& aBuffer,
uint32_t& aBufferLength);
nsresult LogMessage(gfxUserFontEntry* aUserFontEntry,
const char* aMessage,
uint32_t aFlags,
nsresult aStatus);
@@ -354,14 +353,18 @@ 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;
+
+ // Whether the docshell for our document indicates that we are in private
+ // browsing mode.
+ bool mPrivateBrowsing;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_FontFaceSet_h)