Bug 1426494 - Share more code between nsIDocument and ShadowRoot

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-06-13 08:21:48 -04:00 committed by Roy Tam
commit db72493615
23 changed files with 369 additions and 335 deletions

View file

@ -48,19 +48,19 @@ StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
void
StyleSheetList::NodeWillBeDestroyed(const nsINode* aNode)
{
mStyleScope = nullptr;
mDocumentOrShadowRoot = nullptr;
}
StyleSheetList::StyleSheetList(StyleScope& aScope)
: mStyleScope(&aScope)
StyleSheetList::StyleSheetList(DocumentOrShadowRoot& aScope)
: mDocumentOrShadowRoot(&aScope)
{
mStyleScope->AsNode().AddMutationObserver(this);
mDocumentOrShadowRoot->AsNode().AddMutationObserver(this);
}
StyleSheetList::~StyleSheetList()
{
if (mStyleScope) {
mStyleScope->AsNode().RemoveMutationObserver(this);
if (mDocumentOrShadowRoot) {
mDocumentOrShadowRoot->AsNode().RemoveMutationObserver(this);
}
}