Bug 1475351: Properly clear associated ShadowRoot from StyleSheet objects. r=smaug

Just like we do from the document's destructor.

MozReview-Commit-ID: DygmZ0EI9es
This commit is contained in:
Emilio Cobos Álvarez 2018-07-14 16:06:03 +02:00
Родитель dea0d7ad83
Коммит de1504e650
3 изменённых файлов: 9 добавлений и 5 удалений

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

@ -25,6 +25,13 @@ DocumentOrShadowRoot::DocumentOrShadowRoot(nsIDocument& aDoc)
, mKind(Kind::Document)
{}
DocumentOrShadowRoot::~DocumentOrShadowRoot()
{
for (StyleSheet* sheet : mStyleSheets) {
sheet->ClearAssociatedDocumentOrShadowRoot();
}
}
StyleSheetList&
DocumentOrShadowRoot::EnsureDOMStyleSheets()
{

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

@ -100,7 +100,7 @@ public:
already_AddRefed<nsContentList>
GetElementsByClassName(const nsAString& aClasses);
~DocumentOrShadowRoot() = default;
~DocumentOrShadowRoot();
Element* GetPointerLockElement();
Element* GetFullscreenElement();

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

@ -1684,15 +1684,12 @@ nsDocument::~nsDocument()
mFirstChild = nullptr;
mCachedRootElement = nullptr;
// Let the stylesheets know we're going away
for (StyleSheet* sheet : mStyleSheets) {
sheet->ClearAssociatedDocumentOrShadowRoot();
}
for (auto& sheets : mAdditionalSheets) {
for (StyleSheet* sheet : sheets) {
sheet->ClearAssociatedDocumentOrShadowRoot();
}
}
if (mAttrStyleSheet) {
mAttrStyleSheet->SetOwningDocument(nullptr);
}