Bug 1446568: Move a couple more stuff from nsDocument to nsIDocument. r=smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Mar 2018 19:30:15 +0100
changeset 768879 56273dc25c99b8a0a2224d5f1765a4b187eb502f
parent 768878 dfe32f2fe3cb5823529fcf3a29ea1e6a76dd3b53
child 768880 f389c2a63993315c7957cc9a77beecc10c231c3c
push id102997
push userbmo:emilio@crisal.io
push dateSat, 17 Mar 2018 00:00:09 +0000
reviewerssmaug
bugs1446568
milestone61.0a1
Bug 1446568: Move a couple more stuff from nsDocument to nsIDocument. r=smaug MozReview-Commit-ID: JC2nqzJEq7U
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsIDocument.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2239,17 +2239,17 @@ nsIDocument::IsVisibleConsideringAncesto
       return false;
     }
   } while ((parent = parent->GetParentDocument()));
 
   return true;
       }
 
 void
-nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
+nsIDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
 {
   nsCOMPtr<nsIURI> uri;
   nsCOMPtr<nsIPrincipal> principal;
   if (aChannel) {
     // Note: this code is duplicated in XULDocument::StartDocumentLoad and
     // nsScriptSecurityManager::GetChannelResultPrincipal.
     // Note: this should match nsDocShell::OnLoadingSite
     NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
@@ -2443,17 +2443,17 @@ nsIDocument::ResetToURI(nsIURI* aURI,
 
   // Refresh the principal on the compartment.
   if (nsPIDOMWindowInner* win = GetInnerWindow()) {
     nsGlobalWindowInner::Cast(win)->RefreshCompartmentPrincipal();
   }
 }
 
 already_AddRefed<nsIPrincipal>
-nsDocument::MaybeDowngradePrincipal(nsIPrincipal* aPrincipal)
+nsIDocument::MaybeDowngradePrincipal(nsIPrincipal* aPrincipal)
 {
   if (!aPrincipal) {
     return nullptr;
   }
 
   // We can't load a document with an expanded principal. If we're given one,
   // automatically downgrade it to the last principal it subsumes (which is the
   // extension principal, in the case of extension content scripts).
@@ -2860,17 +2860,17 @@ nsDocument::StartDocumentLoad(const char
   // in an early stage to reduce the blocking time.
   mFlashClassification = FlashClassification::Unclassified;
   mPrincipalFlashClassifier->AsyncClassify(GetPrincipal());
 
   return NS_OK;
 }
 
 void
-nsDocument::SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages)
+nsIDocument::SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages)
 {
   for (uint32_t i = 0; i < aMessages.Length(); ++i) {
     nsAutoString messageTag;
     aMessages[i]->GetTag(messageTag);
 
     nsAutoString category;
     aMessages[i]->GetCategory(category);
 
@@ -5104,17 +5104,17 @@ nsIDocument::RemoveObserver(nsIDocumentO
     RemoveMutationObserver(aObserver);
     return mObservers.RemoveElement(aObserver);
   }
 
   return mObservers.Contains(aObserver);
 }
 
 void
-nsDocument::MaybeEndOutermostXBLUpdate()
+nsIDocument::MaybeEndOutermostXBLUpdate()
 {
   // Only call BindingManager()->EndOutermostUpdate() when
   // we're not in an update and it is safe to run scripts.
   if (mUpdateNestLevel == 0 && mInXBLUpdate) {
     if (nsContentUtils::IsSafeToRunScript()) {
       mInXBLUpdate = false;
       BindingManager()->EndOutermostUpdate();
     } else if (!mInDestructor) {
@@ -8353,17 +8353,17 @@ nsIDocument::GetLayoutHistoryState() con
       docShell->GetLayoutHistoryState(getter_AddRefs(state));
     }
   }
 
   return state.forget();
 }
 
 void
-nsDocument::EnsureOnloadBlocker()
+nsIDocument::EnsureOnloadBlocker()
 {
   // If mScriptGlobalObject is null, we shouldn't be messing with the loadgroup
   // -- it's not ours.
   if (mOnloadBlockCount != 0 && mScriptGlobalObject) {
     nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
     if (loadGroup) {
       // Check first to see if mOnloadBlocker is in the loadgroup.
       nsCOMPtr<nsISimpleEnumerator> requests;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -144,18 +144,16 @@ class nsDocument : public nsIDocument,
 public:
   typedef mozilla::dom::Element Element;
   typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
 
-  already_AddRefed<nsIPrincipal> MaybeDowngradePrincipal(nsIPrincipal* aPrincipal);
-
   // StartDocumentLoad is pure virtual so that subclasses must override it.
   // The nsDocument StartDocumentLoad does some setup, but does NOT set
   // *aDocListener; this is the job of subclasses.
   virtual nsresult StartDocumentLoad(const char* aCommand,
                                      nsIChannel* aChannel,
                                      nsILoadGroup* aLoadGroup,
                                      nsISupports* aContainer,
                                      nsIStreamListener **aDocListener,
@@ -237,18 +235,16 @@ public:
   void ReportUseCounters(UseCounterReportKind aKind = UseCounterReportKind::eDefault);
 
   bool IsSynthesized();
 
   // Check whether shadow DOM is enabled for the global of aObject.
   static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject);
   // Check whether shadow DOM is enabled for the document this node belongs to.
   static bool IsShadowDOMEnabled(const nsINode* aNode);
-private:
-  void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
 
 public:
   // nsIDOMDocument
   NS_DECL_NSIDOMDOCUMENT
 
   using mozilla::dom::DocumentOrShadowRoot::GetElementById;
   using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagName;
   using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagNameNS;
@@ -282,18 +278,16 @@ public:
   void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
   void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData)
   {
     mLoadedAsInteractiveData = aLoadedAsInteractiveData;
   }
 
   nsresult CloneDocHelper(nsDocument* clone, bool aPreallocateChildren) const;
 
-  void MaybeEndOutermostXBLUpdate();
-
   // Only BlockOnload should call this!
   void AsyncBlockOnload();
 
   virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
   // DocAddSizeOfIncludingThis is inherited from nsIDocument.
 
   virtual nsIDOMNode* AsDOMNode() override { return this; }
 
@@ -322,18 +316,16 @@ protected:
 
 #ifdef DEBUG
   void VerifyRootContentState();
 #endif
 
   explicit nsDocument(const char* aContentType);
   virtual ~nsDocument();
 
-  void EnsureOnloadBlocker();
-
 public:
   // FIXME(emilio): This needs to be here instead of in nsIDocument because Rust
   // can't represent alignas(8) values on 32-bit architectures, which would
   // cause nsIDocument's layout to be wrong in the Rust side.
   //
   // This can be fixed after updating to rust 1.25 and updating bindgen to
   // include https://github.com/rust-lang-nursery/rust-bindgen/pull/1271.
   js::ExpandoAndGeneration mExpandoAndGeneration;
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -100,16 +100,17 @@ class nsIDOMNodeList;
 class nsIHTMLCollection;
 class nsILayoutHistoryState;
 class nsILoadContext;
 class nsIObjectLoadingContent;
 class nsIObserver;
 class nsIPrincipal;
 class nsIRequest;
 class nsIRunnable;
+class nsISecurityConsoleMessage;
 class nsIStreamListener;
 class nsIStructuredCloneContainer;
 class nsIURI;
 class nsIVariant;
 class nsViewManager;
 class nsPresContext;
 class nsRange;
 class nsSMILAnimationController;
@@ -1430,16 +1431,18 @@ 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:
+  void MaybeEndOutermostXBLUpdate();
+
   void DispatchContentLoadedEvents();
 
   void DispatchPageTransition(mozilla::dom::EventTarget* aDispatchTarget,
                               const nsAString& aType,
                               bool aPersisted);
 
   // Call this before the document does something that will unbind all content.
   // That will stop us from doing a lot of work as each element is removed.
@@ -3657,16 +3660,22 @@ public:
    * anonymous. Otherwise, when aFrame is in a subdocument, we use the frame
    * element containing the subdocument containing aFrame, and/or find the
    * nearest non-anonymous ancestor in this document.
    * Returns null if there is no such element.
    */
   nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const;
 
 protected:
+  already_AddRefed<nsIPrincipal> MaybeDowngradePrincipal(nsIPrincipal* aPrincipal);
+
+  void EnsureOnloadBlocker();
+
+  void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
+
   // Returns true if the scheme for the url for this document is "about".
   bool IsAboutPage() const;
 
   bool ContainsEMEContent();
   bool ContainsMSEContent();
 
   void MaybeInitializeFinalizeFrameLoaders();