Bug 1415541 - No need to destroy frames if Destroy was called on the shell. r=bz, a=gchang
authorMats Palmgren <mats@mozilla.com>
Thu, 16 Nov 2017 18:58:29 +0100
changeset 444872 d55f73f1c890b02fb033accdcaf285633f93648e
parent 444871 b5b9ca5f99b999a53215356e1f3d4b42f7f76557
child 444873 2817b3785e54fc1585f9f3db71b0217fa2e52ced
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, gchang
bugs1415541
milestone58.0
Bug 1415541 - No need to destroy frames if Destroy was called on the shell. r=bz, a=gchang MozReview-Commit-ID: CgiFqeKHF3N
dom/xml/nsXMLPrettyPrinter.cpp
--- a/dom/xml/nsXMLPrettyPrinter.cpp
+++ b/dom/xml/nsXMLPrettyPrinter.cpp
@@ -43,17 +43,17 @@ nsXMLPrettyPrinter::~nsXMLPrettyPrinter(
 
 nsresult
 nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
                                 bool* aDidPrettyPrint)
 {
     *aDidPrettyPrint = false;
 
     // Check for iframe with display:none. Such iframes don't have presshells
-    nsIPresShell* shell = aDocument->GetShell();
+    nsCOMPtr<nsIPresShell> shell = aDocument->GetShell();
     if (!shell) {
         return NS_OK;
     }
 
     // check if we're in an invisible iframe
     nsPIDOMWindowOuter *internalWin = aDocument->GetWindow();
     nsCOMPtr<Element> frameElem;
     if (internalWin) {
@@ -148,17 +148,18 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocum
     NS_ENSURE_TRUE(rootCont, NS_ERROR_UNEXPECTED);
 
     // Grab the system principal.
     nsCOMPtr<nsIPrincipal> sysPrincipal;
     nsContentUtils::GetSecurityManager()->
         GetSystemPrincipal(getter_AddRefs(sysPrincipal));
 
     // Destroy any existing frames before we unbind anonymous content.
-    if (rootCont->IsElement()) {
+    // Note that the shell might be Destroy'ed by now (see bug 1415541).
+    if (!shell->IsDestroying() && rootCont->IsElement()) {
         shell->DestroyFramesForAndRestyle(rootCont->AsElement());
     }
 
     // Load the bindings.
     RefPtr<nsXBLBinding> unused;
     bool ignored;
     rv = xblService->LoadBindings(rootCont, bindingUri, sysPrincipal,
                                   getter_AddRefs(unused), &ignored);