summaryrefslogtreecommitdiff
path: root/dom/base/StyleSheetList.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:42:07 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:42:07 -0400
commitbea6ef77ad25e5fd1b2f30210f22ecdb1ebd2e0d (patch)
treee211b95d505d1ecdf8f7b3513464dd329cbbcc54 /dom/base/StyleSheetList.cpp
parent6f6e07625c80c5d7129edd98ca4b8ea732f29684 (diff)
downloadaura-central-bea6ef77ad25e5fd1b2f30210f22ecdb1ebd2e0d.tar.gz
Bug 1425769 - Base class for ShadowRoot and Document to manage style state
Tag mcp-graveyard/UXP%1375
Diffstat (limited to 'dom/base/StyleSheetList.cpp')
-rw-r--r--dom/base/StyleSheetList.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/dom/base/StyleSheetList.cpp b/dom/base/StyleSheetList.cpp
index 7274b5ea5..42db3179d 100644
--- a/dom/base/StyleSheetList.cpp
+++ b/dom/base/StyleSheetList.cpp
@@ -8,6 +8,7 @@
#include "mozilla/CSSStyleSheet.h"
#include "mozilla/dom/StyleSheetListBinding.h"
+#include "nsStubDocumentObserver.h"
namespace mozilla {
namespace dom {
@@ -17,7 +18,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheetList)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheetList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheetList)
- NS_INTERFACE_MAP_ENTRY(nsISupports)
+ NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMStyleSheetList)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheetList)
@@ -43,5 +45,24 @@ StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
return NS_OK;
}
+void
+StyleSheetList::NodeWillBeDestroyed(const nsINode* aNode)
+{
+ mStyleScope = nullptr;
+}
+
+StyleSheetList::StyleSheetList(StyleScope& aScope)
+ : mStyleScope(&aScope)
+{
+ mStyleScope->AsNode().AddMutationObserver(this);
+}
+
+StyleSheetList::~StyleSheetList()
+{
+ if (mStyleScope) {
+ mStyleScope->AsNode().RemoveMutationObserver(this);
+ }
+}
+
} // namespace dom
} // namespace mozilla