From 8e6ce5fae721e5a4caf38b0b72e1c4a0324ae55e Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 18:15:57 -0500 Subject: Bug 1121994 - Implement adopted callback for custom elements. Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'dom/base/CustomElementRegistry.h') diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 30e2c00ab..e9b2bee56 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -38,6 +38,12 @@ struct LifecycleCallbackArgs nsString namespaceURI; }; +struct LifecycleAdoptedCallbackArgs +{ + nsCOMPtr mOldDocument; + nsCOMPtr mNewDocument; +}; + class CustomElementCallback { public: @@ -54,6 +60,13 @@ public: mArgs = aArgs; } + void SetAdoptedCallbackArgs(LifecycleAdoptedCallbackArgs& aAdoptedCallbackArgs) + { + MOZ_ASSERT(mType == nsIDocument::eAdopted, + "Arguments are only used by adopted callback."); + mAdoptedCallbackArgs = aAdoptedCallbackArgs; + } + private: // The this value to use for invocation of the callback. RefPtr mThisObject; @@ -63,6 +76,7 @@ private: // Arguments to be passed to the callback, // used by the attribute changed callback. LifecycleCallbackArgs mArgs; + LifecycleAdoptedCallbackArgs mAdoptedCallbackArgs; // CustomElementData that contains this callback in the // callback queue. CustomElementData* mOwnerData; @@ -365,6 +379,7 @@ public: static void EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType, Element* aCustomElement, LifecycleCallbackArgs* aArgs, + LifecycleAdoptedCallbackArgs* aAdoptedCallbackArgs, CustomElementDefinition* aDefinition); void GetCustomPrototype(nsIAtom* aAtom, @@ -381,7 +396,9 @@ private: static UniquePtr CreateCustomElementCallback( nsIDocument::ElementCallbackType aType, Element* aCustomElement, - LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition); + LifecycleCallbackArgs* aArgs, + LifecycleAdoptedCallbackArgs* aAdoptedCallbackArgs, + CustomElementDefinition* aDefinition); /** * Registers an unresolved custom element that is a candidate for -- cgit v1.2.3