From 704318ea0a9f55cad18c4ea7f2a6805485a33d39 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 11:21:03 -0500 Subject: Bug 1299363 - Part 5-2: Implement new upgrade steps. Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'dom/base/CustomElementRegistry.h') diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 620492cbb..c45f3f70c 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -66,6 +66,18 @@ private: CustomElementData* mOwnerData; }; +class CustomElementConstructor final : public CallbackFunction +{ +public: + explicit CustomElementConstructor(CallbackFunction* aOther) + : CallbackFunction(aOther) + { + MOZ_ASSERT(JS::IsConstructor(mCallback)); + } + + already_AddRefed Construct(const char* aExecutionReason, ErrorResult& aRv); +}; + // Each custom element has an associated callback queue and an element is // being created flag. struct CustomElementData @@ -114,7 +126,7 @@ struct CustomElementDefinition { CustomElementDefinition(nsIAtom* aType, nsIAtom* aLocalName, - JSObject* aConstructor, + Function* aConstructor, JSObject* aPrototype, mozilla::dom::LifecycleCallbacks* aCallbacks, uint32_t aDocOrder); @@ -126,7 +138,7 @@ struct CustomElementDefinition nsCOMPtr mLocalName; // The custom element constructor. - JS::Heap mConstructor; + RefPtr mConstructor; // The prototype to use for new custom elements of this type. JS::Heap mPrototype; @@ -156,7 +168,7 @@ public: } virtual ~CustomElementReaction() = default; - virtual void Invoke(Element* aElement) = 0; + virtual void Invoke(Element* aElement, ErrorResult& aRv) = 0; virtual void Traverse(nsCycleCollectionTraversalCallback& aCb) const { } @@ -176,7 +188,7 @@ public: } private: - virtual void Invoke(Element* aElement) override; + virtual void Invoke(Element* aElement, ErrorResult& aRv) override; }; class CustomElementCallbackReaction final : public CustomElementReaction @@ -196,7 +208,7 @@ class CustomElementCallbackReaction final : public CustomElementReaction } private: - virtual void Invoke(Element* aElement) override; + virtual void Invoke(Element* aElement, ErrorResult& aRv) override; UniquePtr mCustomElementCallback; }; @@ -258,7 +270,7 @@ private: * Invoke custom element reactions * https://html.spec.whatwg.org/multipage/scripting.html#invoke-custom-element-reactions */ - void InvokeReactions(ElementQueue* aElementQueue); + void InvokeReactions(ElementQueue* aElementQueue, nsIGlobalObject* aGlobal); void Enqueue(Element* aElement, CustomElementReaction* aReaction); @@ -326,7 +338,11 @@ public: void GetCustomPrototype(nsIAtom* aAtom, JS::MutableHandle aPrototype); - void Upgrade(Element* aElement, CustomElementDefinition* aDefinition); + /** + * Upgrade an element. + * https://html.spec.whatwg.org/multipage/scripting.html#upgrades + */ + void Upgrade(Element* aElement, CustomElementDefinition* aDefinition, ErrorResult& aRv); private: ~CustomElementRegistry(); -- cgit v1.2.3