diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-05 11:21:03 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:25 -0500 |
commit | 704318ea0a9f55cad18c4ea7f2a6805485a33d39 (patch) | |
tree | b82489a50d50b80be46593871c8011dc98475914 /dom/base/CustomElementRegistry.h | |
parent | bbb717ec12e63be39929806f62a603bdb4f61de9 (diff) | |
download | UXP-704318ea0a9f55cad18c4ea7f2a6805485a33d39.tar UXP-704318ea0a9f55cad18c4ea7f2a6805485a33d39.tar.gz UXP-704318ea0a9f55cad18c4ea7f2a6805485a33d39.tar.lz UXP-704318ea0a9f55cad18c4ea7f2a6805485a33d39.tar.xz UXP-704318ea0a9f55cad18c4ea7f2a6805485a33d39.zip |
Bug 1299363 - Part 5-2: Implement new upgrade steps.
Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.h')
-rw-r--r-- | dom/base/CustomElementRegistry.h | 30 |
1 files changed, 23 insertions, 7 deletions
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<Element> 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<nsIAtom> mLocalName; // The custom element constructor. - JS::Heap<JSObject *> mConstructor; + RefPtr<CustomElementConstructor> mConstructor; // The prototype to use for new custom elements of this type. JS::Heap<JSObject *> 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<CustomElementCallback> 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<JSObject*> 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(); |