Bug 1477079 - Skip XBL style building if document's pres shell went away. r?emilio
MozReview-Commit-ID: DDURHgDyMCx
--- 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;
}