Bug 1446568: Move a couple other methods from nsDocument to nsIDocument. r=smaug
Need to add an static_cast for nsIDOMDocument, but it'll be temporary, I'd
expect.
MozReview-Commit-ID: 1cSwlcQZL5N
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1583,17 +1583,17 @@ nsDocument::nsDocument(const char* aCont
// void state used to differentiate an empty source from an unselected source
mPreloadPictureFoundSource.SetIsVoid(true);
// For determining if this is a flash document which should be
// blocked based on its principal.
mPrincipalFlashClassifier = new PrincipalFlashClassifier();
}
void
-nsDocument::ClearAllBoxObjects()
+nsIDocument::ClearAllBoxObjects()
{
if (mBoxObjectTable) {
for (auto iter = mBoxObjectTable->Iter(); !iter.Done(); iter.Next()) {
nsPIBoxObject* boxObject = iter.UserData();
if (boxObject) {
boxObject->Clear();
}
}
@@ -2936,17 +2936,17 @@ nsIDocument::ApplySettingsFromCSP(bool a
if (!mUpgradeInsecurePreloads) {
rv = preloadCsp->GetUpgradeInsecureRequests(&mUpgradeInsecurePreloads);
NS_ENSURE_SUCCESS_VOID(rv);
}
}
}
nsresult
-nsDocument::InitCSP(nsIChannel* aChannel)
+nsIDocument::InitCSP(nsIChannel* aChannel)
{
MOZ_ASSERT(!mScriptGlobalObject,
"CSP must be initialized before mScriptGlobalObject is set!");
if (!CSPService::sCSPEnabled) {
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSP is disabled, skipping CSP init for document %p", this));
return NS_OK;
}
@@ -3004,17 +3004,17 @@ nsDocument::InitCSP(nsIChannel* aChannel
}
return NS_OK;
}
MOZ_LOG(gCspPRLog, LogLevel::Debug, ("Document is an add-on or CSP header specified %p", this));
nsCOMPtr<nsIContentSecurityPolicy> csp;
- rv = principal->EnsureCSP(this, getter_AddRefs(csp));
+ rv = principal->EnsureCSP(static_cast<nsDocument*>(this), getter_AddRefs(csp));
NS_ENSURE_SUCCESS(rv, rv);
// ----- if the doc is an addon, apply its CSP.
if (addonPolicy) {
nsCOMPtr<nsIAddonPolicyService> aps = do_GetService("@mozilla.org/addons/policy-service;1");
nsAutoString addonCSP;
Unused << ExtensionPolicyService::GetSingleton().GetBaseCSP(addonCSP);
@@ -8463,46 +8463,46 @@ nsDocument::UnblockOnload(bool aFireSync
false);
asyncDispatcher->PostDOMEvent();
}
}
}
class nsUnblockOnloadEvent : public Runnable {
public:
- explicit nsUnblockOnloadEvent(nsDocument* aDoc)
+ explicit nsUnblockOnloadEvent(nsIDocument* aDoc)
: mozilla::Runnable("nsUnblockOnloadEvent")
, mDoc(aDoc)
{
}
NS_IMETHOD Run() override {
mDoc->DoUnblockOnload();
return NS_OK;
}
private:
- RefPtr<nsDocument> mDoc;
+ RefPtr<nsIDocument> mDoc;
};
void
-nsDocument::PostUnblockOnloadEvent()
+nsIDocument::PostUnblockOnloadEvent()
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> evt = new nsUnblockOnloadEvent(this);
nsresult rv =
Dispatch(TaskCategory::Other, evt.forget());
if (NS_SUCCEEDED(rv)) {
// Stabilize block count so we don't post more events while this one is up
++mOnloadBlockCount;
} else {
NS_WARNING("failed to dispatch nsUnblockOnloadEvent");
}
}
void
-nsDocument::DoUnblockOnload()
+nsIDocument::DoUnblockOnload()
{
NS_PRECONDITION(!mDisplayDocument,
"Shouldn't get here for resource document");
NS_PRECONDITION(mOnloadBlockCount != 0,
"Shouldn't have a count of zero here, since we stabilized in "
"PostUnblockOnloadEvent");
--mOnloadBlockCount;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -68,17 +68,16 @@
class nsDOMStyleSheetSetList;
class nsDocument;
class nsIRadioVisitor;
class nsIFormControl;
struct nsRadioGroupStruct;
class nsOnloadBlocker;
-class nsUnblockOnloadEvent;
class nsDOMNavigationTiming;
class nsWindowSizes;
class nsHtml5TreeOpExecutor;
class nsDocumentOnStack;
class nsISecurityConsoleMessage;
namespace mozilla {
class EventChainPreVisitor;
@@ -307,23 +306,16 @@ public:
// The application cache that this document is associated with, if
// any. This can change during the lifetime of the document.
nsCOMPtr<nsIApplicationCache> mApplicationCache;
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
private:
friend class nsUnblockOnloadEvent;
- void PostUnblockOnloadEvent();
- void DoUnblockOnload();
-
- nsresult InitCSP(nsIChannel* aChannel);
-
- void ClearAllBoxObjects();
-
// These are not implemented and not supported.
nsDocument(const nsDocument& aOther);
nsDocument& operator=(const nsDocument& aOther);
};
class nsDocumentOnStack
{
public:
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -111,16 +111,17 @@ class nsIStructuredCloneContainer;
class nsIURI;
class nsIVariant;
class nsViewManager;
class nsPresContext;
class nsRange;
class nsSMILAnimationController;
class nsSVGElement;
class nsTextNode;
+class nsUnblockOnloadEvent;
class nsWindowSizes;
class nsDOMCaretPosition;
class nsViewportInfo;
class nsIGlobalObject;
struct nsCSSSelectorList;
namespace mozilla {
class AbstractThread;
@@ -1432,16 +1433,26 @@ public:
//
// This array contains nodes that have been blocked to prevent
// user tracking. They most likely have had their nsIChannel
// canceled by the URL classifier (Safebrowsing).
//
already_AddRefed<nsSimpleContentList> BlockedTrackingNodes() const;
protected:
+ friend class nsUnblockOnloadEvent;
+
+ nsresult InitCSP(nsIChannel* aChannel);
+
+ void PostUnblockOnloadEvent();
+
+ void DoUnblockOnload();
+
+ void ClearAllBoxObjects();
+
void MaybeEndOutermostXBLUpdate();
void DispatchContentLoadedEvents();
void DispatchPageTransition(mozilla::dom::EventTarget* aDispatchTarget,
const nsAString& aType,
bool aPersisted);