Bug 1477079 - Skip XBL style building if document's pres shell went away. r?emilio draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 23 Jul 2018 11:20:43 +1000
changeset 821339 194ac72b655fab21336e9aa750b698543733c60b
parent 821326 54c01f0092e1f1edcede61fd08042e99d76d5c30
push id117067
push userbmo:cam@mcc.id.au
push dateMon, 23 Jul 2018 01:22:28 +0000
reviewersemilio
bugs1477079
milestone63.0a1
Bug 1477079 - Skip XBL style building if document's pres shell went away. r?emilio MozReview-Commit-ID: DDURHgDyMCx
dom/xbl/nsXBLResourceLoader.cpp
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -175,18 +175,22 @@ nsXBLResourceLoader::StyleSheetLoaded(St
 
   mResources->AppendStyleSheet(aSheet);
 
   if (!mInLoadResourcesFunc)
     mPendingSheets--;
 
   if (mPendingSheets == 0) {
     // All stylesheets are loaded.
-    mResources->ComputeServoStyles(
-      *mBoundDocument->GetShell()->StyleSet());
+
+    // Our document might have been undisplayed after this sheet load
+    // was started, so check before building the XBL cascade data.
+    if (nsIPresShell* shell = mBoundDocument->GetShell()) {
+      mResources->ComputeServoStyles(*shell->StyleSet());
+    }
 
     // XXX Check for mPendingScripts when scripts also come online.
     if (!mInLoadResourcesFunc)
       NotifyBoundElements();
   }
   return NS_OK;
 }