Bug 1384162 part 1 - DeCOMtaminate nsContentDLF::CreateBlankDocument. r?bz draft
authorXidorn Quan <me@upsuper.org>
Wed, 26 Jul 2017 19:32:45 +1000
changeset 615797 bfc102b367952aa96249ef81ffa02b37f2609ac6
parent 615791 188f099027d56984fe59c9fcfdcebad302752a49
child 615798 8c6505a74e9a3fde72f16d830c9509ee9af919ac
child 615801 caef389697d2574703670b693297ad4c4c66b2ec
push id70476
push userxquan@mozilla.com
push dateWed, 26 Jul 2017 10:13:28 +0000
reviewersbz
bugs1384162
milestone56.0a1
Bug 1384162 part 1 - DeCOMtaminate nsContentDLF::CreateBlankDocument. r?bz MozReview-Commit-ID: 1KNNSIqrmZh
docshell/base/nsDocShell.cpp
docshell/base/nsIDocumentLoaderFactory.idl
layout/build/nsContentDLF.cpp
layout/build/nsContentDLF.h
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -42,16 +42,17 @@
 
 #include "nsArray.h"
 #include "nsArrayUtils.h"
 #include "nsICaptivePortalService.h"
 #include "nsIDOMStorage.h"
 #include "nsIContentViewer.h"
 #include "nsIDocumentLoaderFactory.h"
 #include "nsCURILoader.h"
+#include "nsContentDLF.h"
 #include "nsDocShellCID.h"
 #include "nsDOMCID.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "nsRect.h"
 #include "prenv.h"
 #include "nsIDOMWindow.h"
@@ -8181,18 +8182,18 @@ nsDocShell::CreateAboutBlankContentViewe
         principal = NullPrincipal::CreateWithInheritedAttributes(aPrincipal);
       } else {
         principal = NullPrincipal::CreateWithInheritedAttributes(this);
       }
     } else {
       principal = aPrincipal;
     }
     // generate (about:blank) document to load
-    docFactory->CreateBlankDocument(mLoadGroup, principal,
-                                    getter_AddRefs(blankDoc));
+    nsContentDLF::CreateBlankDocument(mLoadGroup, principal,
+                                      getter_AddRefs(blankDoc));
     if (blankDoc) {
       // Hack: set the base URI manually, since this document never
       // got Reset() with a channel.
       blankDoc->SetBaseURI(aBaseURI);
 
       blankDoc->SetContainer(this);
 
       // Copy our sandbox flags to the document. These are immutable
--- a/docshell/base/nsIDocumentLoaderFactory.idl
+++ b/docshell/base/nsIDocumentLoaderFactory.idl
@@ -30,17 +30,9 @@ interface nsIDocumentLoaderFactory : nsI
                               in ACString aContentType, 
                               in nsIDocShell aContainer,
                               in nsISupports aExtraInfo,
                               out nsIStreamListener aDocListenerResult);
 
     nsIContentViewer createInstanceForDocument(in nsISupports aContainer,
                                          in nsIDocument aDocument,
                                          in string aCommand);
-
-    /**
-     * Create a blank document using the given loadgroup and given
-     * principal.  aPrincipal is allowed to be null, in which case the
-     * new document will get the about:blank codebase principal.
-     */
-    nsIDocument createBlankDocument(in nsILoadGroup aLoadGroup,
-                                    in nsIPrincipal aPrincipal);
 };
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -258,20 +258,20 @@ nsContentDLF::CreateInstanceForDocument(
   nsCOMPtr<nsIContentViewer> contentViewer = NS_NewContentViewer();
 
   // Bind the document to the Content Viewer
   contentViewer->LoadStart(aDocument);
   contentViewer.forget(aContentViewer);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
+/* static */ nsresult
+nsContentDLF::CreateBlankDocument(nsILoadGroup* aLoadGroup,
                                   nsIPrincipal* aPrincipal,
-                                  nsIDocument **aDocument)
+                                  nsIDocument** aDocument)
 {
   *aDocument = nullptr;
 
   nsresult rv = NS_ERROR_FAILURE;
 
   // create a new blank HTML document
   nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID));
 
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -41,16 +41,25 @@ public:
   nsresult CreateXULDocument(const char* aCommand,
                              nsIChannel* aChannel,
                              nsILoadGroup* aLoadGroup,
                              nsIDocShell* aContainer,
                              nsISupports* aExtraInfo,
                              nsIStreamListener** aDocListener,
                              nsIContentViewer** aContentViewer);
 
+  /**
+   * Create a blank document using the given loadgroup and given
+   * principal.  aPrincipal is allowed to be null, in which case the
+   * new document will get the about:blank codebase principal.
+   */
+  static nsresult CreateBlankDocument(nsILoadGroup* aLoadGroup,
+                                      nsIPrincipal* aPrincipal,
+                                      nsIDocument** aDocument);
+
 private:
   static nsresult EnsureUAStyleSheet();
   static bool IsImageContentType(const char* aContentType);
 };
 
 nsresult
 NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
 
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -1387,17 +1387,8 @@ NS_IMETHODIMP
 nsDirectoryViewerFactory::CreateInstanceForDocument(nsISupports* aContainer,
                                                     nsIDocument* aDocument,
                                                     const char *aCommand,
                                                     nsIContentViewer** aDocViewerResult)
 {
   NS_NOTYETIMPLEMENTED("didn't expect to get here");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
-
-NS_IMETHODIMP
-nsDirectoryViewerFactory::CreateBlankDocument(nsILoadGroup *aLoadGroup,
-                                              nsIPrincipal *aPrincipal,
-                                              nsIDocument **_retval) {
-
-  NS_NOTYETIMPLEMENTED("didn't expect to get here");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}