summaryrefslogtreecommitdiffstats
path: root/dom/base/CustomElementRegistry.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-05 15:31:44 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:27 -0500
commit8573c572fbf5fa68defb3228e7f1450ec234d59b (patch)
tree97c6eefe6718d62d901155eca3badbfec67eebb0 /dom/base/CustomElementRegistry.h
parentf50503df9c2eced785957626273ee07e5312d546 (diff)
downloadUXP-8573c572fbf5fa68defb3228e7f1450ec234d59b.tar
UXP-8573c572fbf5fa68defb3228e7f1450ec234d59b.tar.gz
UXP-8573c572fbf5fa68defb3228e7f1450ec234d59b.tar.lz
UXP-8573c572fbf5fa68defb3228e7f1450ec234d59b.tar.xz
UXP-8573c572fbf5fa68defb3228e7f1450ec234d59b.zip
Bug 1392970 - Part 1: Make CustomElementDefinition ref-counted and put it in CustomElementData.
Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.h')
-rw-r--r--dom/base/CustomElementRegistry.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h
index b731a1858..89e754365 100644
--- a/dom/base/CustomElementRegistry.h
+++ b/dom/base/CustomElementRegistry.h
@@ -13,7 +13,9 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FunctionBinding.h"
+#include "mozilla/dom/WebComponentsBinding.h"
#include "nsCycleCollectionParticipant.h"
+#include "nsGenericHTMLElement.h"
#include "nsWrapperCache.h"
class nsDocument;
@@ -23,7 +25,6 @@ namespace dom {
struct CustomElementData;
struct ElementDefinitionOptions;
-struct LifecycleCallbacks;
class CallbackFunction;
class CustomElementReaction;
class Function;
@@ -115,6 +116,22 @@ struct CustomElementData
// e.g., create an element, insert a node.
AutoTArray<UniquePtr<CustomElementReaction>, 3> mReactionQueue;
+ RefPtr<CustomElementDefinition> mCustomElementDefinition;
+
+ void
+ SetCustomElementDefinition(CustomElementDefinition* aDefinition)
+ {
+ MOZ_ASSERT(!mCustomElementDefinition);
+
+ mCustomElementDefinition = aDefinition;
+ }
+
+ CustomElementDefinition*
+ GetCustomElementDefinition()
+ {
+ return mCustomElementDefinition;
+ }
+
private:
virtual ~CustomElementData() {}
};
@@ -125,6 +142,9 @@ private:
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-definition
struct CustomElementDefinition
{
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CustomElementDefinition)
+ NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CustomElementDefinition)
+
CustomElementDefinition(nsIAtom* aType,
nsIAtom* aLocalName,
Function* aConstructor,
@@ -170,6 +190,9 @@ struct CustomElementDefinition
return mObservedAttributes.Contains(aName);
}
+
+private:
+ ~CustomElementDefinition() {}
};
class CustomElementReaction
@@ -381,7 +404,7 @@ private:
CustomElementDefinition* aDefinition,
ErrorResult& aRv);
- typedef nsClassHashtable<nsISupportsHashKey, CustomElementDefinition>
+ typedef nsRefPtrHashtable<nsISupportsHashKey, CustomElementDefinition>
DefinitionMap;
typedef nsClassHashtable<nsISupportsHashKey, nsTArray<nsWeakPtr>>
CandidateMap;