nsresult nsXBLPrototypeResources::FlushSkinSheets() { if (mStyleSheetList.Length() == 0) return NS_OK; nsCOMPtr<Document> doc = mLoader->mBinding->XBLDocumentInfo()->GetDocument(); // If doc is null, we're in the process of tearing things down, so just // return without rebuilding anything. if (!doc) { return NS_OK; } // We have scoped stylesheets. Reload any chrome stylesheets we // encounter. (If they aren't skin sheets, it doesn't matter, since // they'll still be in the chrome cache. Skip inline sheets, which // skin sheets can't be, and which in any case don't have a usable // URL to reload.) nsTArray<RefPtr<StyleSheet>> oldSheets; oldSheets.SwapElements(mStyleSheetList); mozilla::css::Loader* cssLoader = doc->CSSLoader(); for (size_t i = 0, count = oldSheets.Length(); i < count; ++i) { StyleSheet* oldSheet = oldSheets[i]; nsIURI* uri = oldSheet->GetSheetURI(); RefPtr<StyleSheet> newSheet; if (!oldSheet->IsInline() && IsChromeURI(uri)) { if (NS_FAILED(cssLoader->LoadSheetSync(uri, &newSheet))) continue; } else { newSheet = oldSheet; } mStyleSheetList.AppendElement(newSheet); } // There may be no shell during unlink. if (auto* shell = doc->GetShell()) { MOZ_ASSERT(shell->GetPresContext()); ComputeServoStyles(*shell->StyleSet()); } return NS_OK; }