summaryrefslogtreecommitdiffstats
path: root/dom/base/StyleSheetList.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-04-17 16:02:56 +0200
committerGitHub <noreply@github.com>2020-04-17 16:02:56 +0200
commitd5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf (patch)
tree2bfef192cbb748b675ce8308c242a376798e265d /dom/base/StyleSheetList.h
parent5caf99795aa81e1fc145b8e937b1ee8197ed2486 (diff)
parentf35aa3e15fedf3cd4ad163d60ab74a9537ca5c82 (diff)
downloadUXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.gz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.lz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.xz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.zip
Merge pull request #1518 from MoonchildProductions/shadowdom-merge
Incremental shadowdom-merge
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