summaryrefslogtreecommitdiffstats
path: root/dom/base/StyleSheetList.h
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
commit9e5e58c0f6e1c65674cc688816f387532661d6f1 (patch)
treee211b95d505d1ecdf8f7b3513464dd329cbbcc54 /dom/base/StyleSheetList.h
parent16dba9a30b849c9381fab5fe53b722c7901e5283 (diff)
downloadUXP-9e5e58c0f6e1c65674cc688816f387532661d6f1.tar
UXP-9e5e58c0f6e1c65674cc688816f387532661d6f1.tar.gz
UXP-9e5e58c0f6e1c65674cc688816f387532661d6f1.tar.lz
UXP-9e5e58c0f6e1c65674cc688816f387532661d6f1.tar.xz
UXP-9e5e58c0f6e1c65674cc688816f387532661d6f1.zip
Bug 1425769 - Base class for ShadowRoot and Document to manage style state
Tag #1375
Diffstat (limited to 'dom/base/StyleSheetList.h')
-rw-r--r--dom/base/StyleSheetList.h44
1 files changed, 36 insertions, 8 deletions
diff --git a/dom/base/StyleSheetList.h b/dom/base/StyleSheetList.h
index dfedc2214..ea5c33a98 100644
--- a/dom/base/StyleSheetList.h
+++ b/dom/base/StyleSheetList.h
@@ -7,8 +7,10 @@
#ifndef mozilla_dom_StyleSheetList_h
#define mozilla_dom_StyleSheetList_h
+#include "mozilla/dom/StyleScope.h"
#include "nsIDOMStyleSheetList.h"
#include "nsWrapperCache.h"
+#include "nsStubDocumentObserver.h"
class nsINode;
@@ -17,28 +19,54 @@ class StyleSheet;
namespace dom {
-class StyleSheetList : public nsIDOMStyleSheetList
- , public nsWrapperCache
+class StyleSheetList final : public nsIDOMStyleSheetList
+ , public nsWrapperCache
+ , public nsStubDocumentObserver
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(StyleSheetList, nsIDOMStyleSheetList)
+
NS_DECL_NSIDOMSTYLESHEETLIST
+ NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
+
+ explicit StyleSheetList(StyleScope& aScope);
+
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
- virtual nsINode* GetParentObject() const = 0;
+ nsINode* GetParentObject() const
+ {
+ return mStyleScope ? &mStyleScope->AsNode() : nullptr;
+ }
- virtual uint32_t Length() = 0;
- virtual StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
- StyleSheet* Item(uint32_t aIndex)
+ uint32_t Length() const
+ {
+ return mStyleScope ? mStyleScope->SheetCount() : 0;
+ }
+
+ StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) const
+ {
+ if (!mStyleScope) {
+ aFound = false;
+ return nullptr;
+ }
+
+ StyleSheet* sheet = mStyleScope->SheetAt(aIndex);
+ aFound = !!sheet;
+ return sheet;
+ }
+
+ StyleSheet* Item(uint32_t aIndex) const
{
bool dummy = false;
return IndexedGetter(aIndex, dummy);
}
protected:
- virtual ~StyleSheetList() {}
+ virtual ~StyleSheetList();
+
+ StyleScope* mStyleScope; // Weak, cleared on "NodeWillBeDestroyed".
};
} // namespace dom