Bug 1535874 - Don't clear out nsStyleSheetService::gInstance when random other nsStyleSheetService objects are destroyed. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D23815

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2019-03-27 22:40:14 +00:00
Родитель 7c21782019
Коммит e90bcb5786
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -2299,6 +2299,10 @@ UniquePtr<ServoStyleSet> nsDocumentViewer::CreateStyleSet(Document* aDocument) {
auto cache = nsLayoutStylesheetCache::Singleton();
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
MOZ_ASSERT(sheetService,
"should never be creating a StyleSet after the style sheet "
"service has gone");
auto styleSet = MakeUnique<ServoStyleSet>();
// User sheets

Просмотреть файл

@ -36,14 +36,18 @@ nsStyleSheetService::nsStyleSheetService() {
"Convention for Style Sheet");
NS_ASSERTION(!gInstance,
"Someone is using CreateInstance instead of GetService");
gInstance = this;
if (!gInstance) {
gInstance = this;
}
nsLayoutStatics::AddRef();
}
nsStyleSheetService::~nsStyleSheetService() {
UnregisterWeakMemoryReporter(this);
gInstance = nullptr;
if (gInstance == this) {
gInstance = nullptr;
}
nsLayoutStatics::Release();
}