Bug 1384162 part 3 - Move document container setting into nsContentDLF::CreateBlankDocument before adding any nodes. r=bz
authorXidorn Quan <me@upsuper.org>
Wed, 26 Jul 2017 20:02:58 +1000
changeset 422304 558d00335f144dce9bacf6ebc9762cdde63e4a42
parent 422303 e0a391cfa6d6d97f0e6c5b59ca3fa550ace414a5
child 422305 0b3e4b5b8e4d6b195d9db08d034e99575e0a7c90
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1384162
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1384162 part 3 - Move document container setting into nsContentDLF::CreateBlankDocument before adding any nodes. r=bz MozReview-Commit-ID: KdXQH5eRD7a
docshell/base/nsDocShell.cpp
layout/build/nsContentDLF.cpp
layout/build/nsContentDLF.h
testing/web-platform/meta/cssom-view/matchMedia.xht.ini
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8182,24 +8182,22 @@ nsDocShell::CreateAboutBlankContentViewe
         principal = NullPrincipal::CreateWithInheritedAttributes(aPrincipal);
       } else {
         principal = NullPrincipal::CreateWithInheritedAttributes(this);
       }
     } else {
       principal = aPrincipal;
     }
     // generate (about:blank) document to load
-    blankDoc = nsContentDLF::CreateBlankDocument(mLoadGroup, principal);
+    blankDoc = nsContentDLF::CreateBlankDocument(mLoadGroup, principal, this);
     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
       // after being set here.
       blankDoc->SetSandboxFlags(mSandboxFlags);
 
       // create a content viewer for us and the new document
       docFactory->CreateInstanceForDocument(
         NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view",
         getter_AddRefs(viewer));
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -260,32 +260,34 @@ nsContentDLF::CreateInstanceForDocument(
   // Bind the document to the Content Viewer
   contentViewer->LoadStart(aDocument);
   contentViewer.forget(aContentViewer);
   return NS_OK;
 }
 
 /* static */ already_AddRefed<nsIDocument>
 nsContentDLF::CreateBlankDocument(nsILoadGroup* aLoadGroup,
-                                  nsIPrincipal* aPrincipal)
+                                  nsIPrincipal* aPrincipal,
+                                  nsDocShell* aContainer)
 {
   // create a new blank HTML document
   nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID));
 
   if (!blankDoc) {
     return nullptr;
   }
 
   // initialize
   nsCOMPtr<nsIURI> uri;
   NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank"));
   if (!uri) {
     return nullptr;
   }
   blankDoc->ResetToURI(uri, aLoadGroup, aPrincipal);
+  blankDoc->SetContainer(aContainer);
 
   // add some simple content structure
   nsNodeInfoManager *nim = blankDoc->NodeInfoManager();
 
   RefPtr<mozilla::dom::NodeInfo> htmlNodeInfo;
 
   // generate an html html element
   htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML,
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsContentDLF_h__
 #define nsContentDLF_h__
 
 #include "nsIDocumentLoaderFactory.h"
 #include "nsMimeTypes.h"
 
+class nsDocShell;
 class nsIChannel;
 class nsIContentViewer;
 class nsILoadGroup;
 class nsIStreamListener;
 
 #define CONTENT_DLF_CONTRACTID "@mozilla.org/content/document-loader-factory;1"
 #define PLUGIN_DLF_CONTRACTID "@mozilla.org/content/plugin/document-loader-factory;1"
 
@@ -47,17 +48,19 @@ public:
                              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 already_AddRefed<nsIDocument>
-  CreateBlankDocument(nsILoadGroup* aLoadGroup, nsIPrincipal* aPrincipal);
+  CreateBlankDocument(nsILoadGroup* aLoadGroup,
+                      nsIPrincipal* aPrincipal,
+                      nsDocShell* aContainer);
 
 private:
   static nsresult EnsureUAStyleSheet();
   static bool IsImageContentType(const char* aContentType);
 };
 
 nsresult
 NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
--- a/testing/web-platform/meta/cssom-view/matchMedia.xht.ini
+++ b/testing/web-platform/meta/cssom-view/matchMedia.xht.ini
@@ -1,16 +1,18 @@
 [matchMedia.xht]
   type: testharness
   expected: TIMEOUT
   [window.matchMedia exists]
     expected: FAIL
 
   [MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"]
-    expected: FAIL
+    expected:
+      if stylo: PASS
+      FAIL
 
   [Resize iframe from 200x100 to 200x50, then to 100x50]
     expected: NOTRUN
 
   [Listeners are called in the order which they have been added]
     expected: NOTRUN
 
   [Listener added twice is only called once.]