summaryrefslogtreecommitdiffstats
path: root/dom/base/ShadowRoot.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/ShadowRoot.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/ShadowRoot.h')
-rw-r--r--dom/base/ShadowRoot.h44
1 files changed, 13 insertions, 31 deletions
diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h
index c525ba8e8..a24c8138e 100644
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -8,8 +8,7 @@
#define mozilla_dom_shadowroot_h__
#include "mozilla/dom/DocumentFragment.h"
-#include "mozilla/dom/StyleSheetList.h"
-#include "mozilla/StyleSheet.h"
+#include "mozilla/dom/StyleScope.h"
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIContentInlines.h"
@@ -27,12 +26,11 @@ class EventChainPreVisitor;
namespace dom {
class Element;
-class ShadowRootStyleSheetList;
class ShadowRoot final : public DocumentFragment,
+ public StyleScope,
public nsStubMutationObserver
{
- friend class ShadowRootStyleSheetList;
public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRoot,
DocumentFragment)
@@ -49,15 +47,20 @@ public:
// Shadow DOM v1
Element* Host();
- ShadowRootMode Mode()
+ ShadowRootMode Mode() const
{
return mMode;
}
- bool IsClosed()
+ bool IsClosed() const
{
return mMode == ShadowRootMode::Closed;
}
+ // StyleScope.
+ nsINode& AsNode() final
+ {
+ return *this;
+ }
// [deprecated] Shadow DOM v0
void AddToIdTable(Element* aElement, nsIAtom* aId);
@@ -66,7 +69,10 @@ public:
void RemoveSheet(StyleSheet* aSheet);
bool ApplyAuthorStyles();
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
- StyleSheetList* StyleSheets();
+ StyleSheetList* StyleSheets()
+ {
+ return &StyleScope::EnsureDOMStyleSheets();
+ }
/**
* Distributes all the explicit children of the pool host to the content
@@ -155,8 +161,6 @@ protected:
// owns |mProtoBinding|.
RefPtr<nsXBLBinding> mAssociatedBinding;
- RefPtr<ShadowRootStyleSheetList> mStyleSheetList;
-
// A boolean that indicates that an insertion point was added or removed
// from this ShadowRoot and that the nodes need to be redistributed into
// the insertion points. After this flag is set, nodes will be distributed
@@ -172,28 +176,6 @@ protected:
nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
};
-class ShadowRootStyleSheetList : public StyleSheetList
-{
-public:
- explicit ShadowRootStyleSheetList(ShadowRoot* aShadowRoot);
-
- NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
-
- virtual nsINode* GetParentObject() const override
- {
- return mShadowRoot;
- }
-
- uint32_t Length() override;
- StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
-
-protected:
- virtual ~ShadowRootStyleSheetList();
-
- RefPtr<ShadowRoot> mShadowRoot;
-};
-
} // namespace dom
} // namespace mozilla