2016-07-25 00:38:00 +03:00
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
2016-10-12 10:26:02 +03:00
|
|
|
|
#ifndef mozilla_dom_CustomElementRegistry_h
|
|
|
|
|
#define mozilla_dom_CustomElementRegistry_h
|
2016-07-25 00:38:00 +03:00
|
|
|
|
|
2016-09-07 12:55:21 +03:00
|
|
|
|
#include "js/GCHashTable.h"
|
2016-07-25 00:38:00 +03:00
|
|
|
|
#include "js/TypeDecls.h"
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2017-03-28 12:05:12 +03:00
|
|
|
|
#include "mozilla/dom/Element.h"
|
2016-09-07 12:55:21 +03:00
|
|
|
|
#include "mozilla/dom/FunctionBinding.h"
|
2016-07-25 00:38:00 +03:00
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
class nsDocument;
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
namespace mozilla {
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
struct CustomElementData;
|
2016-07-25 00:38:00 +03:00
|
|
|
|
struct ElementDefinitionOptions;
|
|
|
|
|
struct LifecycleCallbacks;
|
2016-08-30 06:48:53 +03:00
|
|
|
|
class CallbackFunction;
|
2016-07-25 00:38:00 +03:00
|
|
|
|
class Function;
|
|
|
|
|
class Promise;
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
struct LifecycleCallbackArgs
|
|
|
|
|
{
|
|
|
|
|
nsString name;
|
|
|
|
|
nsString oldValue;
|
|
|
|
|
nsString newValue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CustomElementCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CustomElementCallback(Element* aThisObject,
|
|
|
|
|
nsIDocument::ElementCallbackType aCallbackType,
|
|
|
|
|
CallbackFunction* aCallback,
|
|
|
|
|
CustomElementData* aOwnerData);
|
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
|
|
|
|
|
void Call();
|
|
|
|
|
void SetArgs(LifecycleCallbackArgs& aArgs)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(mType == nsIDocument::eAttributeChanged,
|
|
|
|
|
"Arguments are only used by attribute changed callback.");
|
|
|
|
|
mArgs = aArgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// The this value to use for invocation of the callback.
|
|
|
|
|
RefPtr<Element> mThisObject;
|
|
|
|
|
RefPtr<CallbackFunction> mCallback;
|
|
|
|
|
// The type of callback (eCreated, eAttached, etc.)
|
|
|
|
|
nsIDocument::ElementCallbackType mType;
|
|
|
|
|
// Arguments to be passed to the callback,
|
|
|
|
|
// used by the attribute changed callback.
|
|
|
|
|
LifecycleCallbackArgs mArgs;
|
|
|
|
|
// CustomElementData that contains this callback in the
|
|
|
|
|
// callback queue.
|
|
|
|
|
CustomElementData* mOwnerData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Each custom element has an associated callback queue and an element is
|
|
|
|
|
// being created flag.
|
|
|
|
|
struct CustomElementData
|
|
|
|
|
{
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(CustomElementData)
|
|
|
|
|
|
|
|
|
|
explicit CustomElementData(nsIAtom* aType);
|
|
|
|
|
// Objects in this array are transient and empty after each microtask
|
|
|
|
|
// checkpoint.
|
|
|
|
|
nsTArray<nsAutoPtr<CustomElementCallback>> mCallbackQueue;
|
|
|
|
|
// Custom element type, for <button is="x-button"> or <x-button>
|
|
|
|
|
// this would be x-button.
|
|
|
|
|
nsCOMPtr<nsIAtom> mType;
|
|
|
|
|
// The callback that is next to be processed upon calling RunCallbackQueue.
|
|
|
|
|
int32_t mCurrentCallback;
|
|
|
|
|
// Element is being created flag as described in the custom elements spec.
|
|
|
|
|
bool mElementIsBeingCreated;
|
|
|
|
|
// Flag to determine if the created callback has been invoked, thus it
|
|
|
|
|
// determines if other callbacks can be enqueued.
|
|
|
|
|
bool mCreatedCallbackInvoked;
|
|
|
|
|
// The microtask level associated with the callbacks in the callback queue,
|
|
|
|
|
// it is used to determine if a new queue needs to be pushed onto the
|
|
|
|
|
// processing stack.
|
|
|
|
|
int32_t mAssociatedMicroTask;
|
|
|
|
|
|
|
|
|
|
// Empties the callback queue.
|
|
|
|
|
void RunCallbackQueue();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual ~CustomElementData() {}
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-22 00:42:00 +03:00
|
|
|
|
// The required information for a custom element as defined in:
|
2016-09-01 10:11:32 +03:00
|
|
|
|
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-definition
|
2016-07-22 00:42:00 +03:00
|
|
|
|
struct CustomElementDefinition
|
|
|
|
|
{
|
2016-09-01 10:11:32 +03:00
|
|
|
|
CustomElementDefinition(nsIAtom* aType,
|
2016-07-22 00:42:00 +03:00
|
|
|
|
nsIAtom* aLocalName,
|
2016-09-01 10:11:32 +03:00
|
|
|
|
JSObject* aConstructor,
|
|
|
|
|
JSObject* aPrototype,
|
2016-07-22 00:42:00 +03:00
|
|
|
|
mozilla::dom::LifecycleCallbacks* aCallbacks,
|
|
|
|
|
uint32_t aDocOrder);
|
|
|
|
|
|
|
|
|
|
// The type (name) for this custom element.
|
|
|
|
|
nsCOMPtr<nsIAtom> mType;
|
|
|
|
|
|
|
|
|
|
// The localname to (e.g. <button is=type> -- this would be button).
|
|
|
|
|
nsCOMPtr<nsIAtom> mLocalName;
|
|
|
|
|
|
2016-09-01 10:11:32 +03:00
|
|
|
|
// The custom element constructor.
|
|
|
|
|
JS::Heap<JSObject *> mConstructor;
|
|
|
|
|
|
|
|
|
|
// The prototype to use for new custom elements of this type.
|
|
|
|
|
JS::Heap<JSObject *> mPrototype;
|
|
|
|
|
|
2016-07-22 00:42:00 +03:00
|
|
|
|
// The lifecycle callbacks to call for this custom element.
|
|
|
|
|
nsAutoPtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
|
|
|
|
|
|
2016-09-01 10:11:32 +03:00
|
|
|
|
// A construction stack.
|
|
|
|
|
// TODO: Bug 1287348 - Implement construction stack for upgrading an element
|
2016-07-22 00:42:00 +03:00
|
|
|
|
|
|
|
|
|
// The document custom element order.
|
|
|
|
|
uint32_t mDocOrder;
|
2016-11-17 18:31:50 +03:00
|
|
|
|
|
|
|
|
|
bool IsCustomBuiltIn() {
|
|
|
|
|
return mType != mLocalName;
|
|
|
|
|
}
|
2016-07-22 00:42:00 +03:00
|
|
|
|
};
|
|
|
|
|
|
2017-01-06 02:38:00 +03:00
|
|
|
|
class CustomElementReaction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit CustomElementReaction(CustomElementRegistry* aRegistry,
|
|
|
|
|
CustomElementDefinition* aDefinition)
|
|
|
|
|
: mRegistry(aRegistry)
|
|
|
|
|
, mDefinition(aDefinition)
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtual ~CustomElementReaction() = default;
|
|
|
|
|
virtual void Invoke(Element* aElement) = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
CustomElementRegistry* mRegistry;
|
|
|
|
|
CustomElementDefinition* mDefinition;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CustomElementUpgradeReaction final : public CustomElementReaction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit CustomElementUpgradeReaction(CustomElementRegistry* aRegistry,
|
|
|
|
|
CustomElementDefinition* aDefinition)
|
|
|
|
|
: CustomElementReaction(aRegistry, aDefinition)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual void Invoke(Element* aElement) override;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-21 07:42:00 +03:00
|
|
|
|
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reactions-stack
|
|
|
|
|
class CustomElementReactionsStack
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(CustomElementReactionsStack)
|
|
|
|
|
|
|
|
|
|
CustomElementReactionsStack()
|
|
|
|
|
: mIsBackupQueueProcessing(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// nsWeakPtr is a weak pointer of Element
|
|
|
|
|
// The element reaction queues are stored in ElementReactionQueueMap.
|
|
|
|
|
// We need to lookup ElementReactionQueueMap again to get relevant reaction queue.
|
2017-03-30 12:35:59 +03:00
|
|
|
|
// The choice of 1 for the auto size here is based on gut feeling.
|
|
|
|
|
typedef AutoTArray<nsWeakPtr, 1> ElementQueue;
|
2017-03-21 07:42:00 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enqueue a custom element upgrade reaction
|
|
|
|
|
* https://html.spec.whatwg.org/multipage/scripting.html#enqueue-a-custom-element-upgrade-reaction
|
|
|
|
|
*/
|
|
|
|
|
void EnqueueUpgradeReaction(CustomElementRegistry* aRegistry,
|
|
|
|
|
Element* aElement,
|
|
|
|
|
CustomElementDefinition* aDefinition);
|
|
|
|
|
|
|
|
|
|
// [CEReactions] Before executing the algorithm's steps
|
|
|
|
|
// Push a new element queue onto the custom element reactions stack.
|
|
|
|
|
void CreateAndPushElementQueue();
|
|
|
|
|
|
|
|
|
|
// [CEReactions] After executing the algorithm's steps
|
|
|
|
|
// Pop the element queue from the custom element reactions stack,
|
|
|
|
|
// and invoke custom element reactions in that queue.
|
|
|
|
|
void PopAndInvokeElementQueue();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
~CustomElementReactionsStack() {};
|
|
|
|
|
|
2017-03-30 12:35:59 +03:00
|
|
|
|
// There is 1 reaction in reaction queue, when 1) it becomes disconnected,
|
|
|
|
|
// 2) it’s adopted into a new document, 3) its attributes are changed,
|
|
|
|
|
// appended, removed, or replaced.
|
|
|
|
|
// There are 3 reactions in reaction queue when doing upgrade operation,
|
|
|
|
|
// e.g., create an element, insert a node.
|
|
|
|
|
typedef AutoTArray<nsAutoPtr<CustomElementReaction>, 3> ReactionQueue;
|
2017-03-21 07:42:00 +03:00
|
|
|
|
typedef nsClassHashtable<nsISupportsHashKey, ReactionQueue>
|
|
|
|
|
ElementReactionQueueMap;
|
|
|
|
|
|
|
|
|
|
ElementReactionQueueMap mElementReactionQueueMap;
|
|
|
|
|
|
2017-03-30 12:35:59 +03:00
|
|
|
|
// The choice of 8 for the auto size here is based on gut feeling.
|
|
|
|
|
AutoTArray<ElementQueue, 8> mReactionsStack;
|
2017-03-21 07:42:00 +03:00
|
|
|
|
ElementQueue mBackupQueue;
|
|
|
|
|
// https://html.spec.whatwg.org/#enqueue-an-element-on-the-appropriate-element-queue
|
|
|
|
|
bool mIsBackupQueueProcessing;
|
|
|
|
|
|
|
|
|
|
void InvokeBackupQueue();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Invoke custom element reactions
|
|
|
|
|
* https://html.spec.whatwg.org/multipage/scripting.html#invoke-custom-element-reactions
|
|
|
|
|
*/
|
|
|
|
|
void InvokeReactions(ElementQueue& aElementQueue);
|
|
|
|
|
|
|
|
|
|
void Enqueue(Element* aElement, CustomElementReaction* aReaction);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
class ProcessBackupQueueRunnable : public mozilla::Runnable {
|
|
|
|
|
public:
|
|
|
|
|
explicit ProcessBackupQueueRunnable(CustomElementReactionsStack* aReactionStack)
|
|
|
|
|
: mReactionStack(aReactionStack)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(!mReactionStack->mIsBackupQueueProcessing,
|
|
|
|
|
"mIsBackupQueueProcessing should be initially false");
|
|
|
|
|
mReactionStack->mIsBackupQueueProcessing = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD Run() override
|
|
|
|
|
{
|
|
|
|
|
mReactionStack->InvokeBackupQueue();
|
|
|
|
|
mReactionStack->mIsBackupQueueProcessing = false;
|
|
|
|
|
return NS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
RefPtr<CustomElementReactionsStack> mReactionStack;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-12 10:26:02 +03:00
|
|
|
|
class CustomElementRegistry final : public nsISupports,
|
|
|
|
|
public nsWrapperCache
|
2016-07-25 00:38:00 +03:00
|
|
|
|
{
|
2016-08-30 06:48:53 +03:00
|
|
|
|
// Allow nsDocument to access mCustomDefinitions and mCandidatesMap.
|
|
|
|
|
friend class ::nsDocument;
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
public:
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2016-10-12 10:26:02 +03:00
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CustomElementRegistry)
|
2016-07-25 00:38:00 +03:00
|
|
|
|
|
|
|
|
|
public:
|
2016-12-08 22:22:46 +03:00
|
|
|
|
static bool IsCustomElementEnabled(JSContext* aCx = nullptr,
|
|
|
|
|
JSObject* aObject = nullptr);
|
2017-02-23 13:24:05 +03:00
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
static void ProcessTopElementQueue();
|
|
|
|
|
|
|
|
|
|
static void XPCOMShutdown();
|
|
|
|
|
|
2017-02-23 13:24:05 +03:00
|
|
|
|
explicit CustomElementRegistry(nsPIDOMWindowInner* aWindow);
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Looking up a custom element definition.
|
|
|
|
|
* https://html.spec.whatwg.org/#look-up-a-custom-element-definition
|
|
|
|
|
*/
|
|
|
|
|
CustomElementDefinition* LookupCustomElementDefinition(
|
|
|
|
|
const nsAString& aLocalName, const nsAString* aIs = nullptr) const;
|
|
|
|
|
|
2016-11-17 18:31:50 +03:00
|
|
|
|
CustomElementDefinition* LookupCustomElementDefinition(
|
|
|
|
|
JSContext* aCx, JSObject *aConstructor) const;
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Enqueue created callback or register upgrade candidate for
|
|
|
|
|
* newly created custom elements, possibly extending an existing type.
|
|
|
|
|
* ex. <x-button>, <button is="x-button> (type extension)
|
|
|
|
|
*/
|
|
|
|
|
void SetupCustomElement(Element* aElement, const nsAString* aTypeExtension);
|
|
|
|
|
|
|
|
|
|
void EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
|
|
|
|
|
Element* aCustomElement,
|
|
|
|
|
LifecycleCallbackArgs* aArgs,
|
|
|
|
|
CustomElementDefinition* aDefinition);
|
|
|
|
|
|
|
|
|
|
void GetCustomPrototype(nsIAtom* aAtom,
|
|
|
|
|
JS::MutableHandle<JSObject*> aPrototype);
|
2016-07-25 00:38:00 +03:00
|
|
|
|
|
2017-01-06 02:38:00 +03:00
|
|
|
|
void Upgrade(Element* aElement, CustomElementDefinition* aDefinition);
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
private:
|
2016-10-12 10:26:02 +03:00
|
|
|
|
~CustomElementRegistry();
|
2016-08-30 06:48:53 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers an unresolved custom element that is a candidate for
|
|
|
|
|
* upgrade when the definition is registered via registerElement.
|
|
|
|
|
* |aTypeName| is the name of the custom element type, if it is not
|
|
|
|
|
* provided, then element name is used. |aTypeName| should be provided
|
|
|
|
|
* when registering a custom element that extends an existing
|
|
|
|
|
* element. e.g. <button is="x-button">.
|
|
|
|
|
*/
|
|
|
|
|
void RegisterUnresolvedElement(Element* aElement,
|
|
|
|
|
nsIAtom* aTypeName = nullptr);
|
|
|
|
|
|
2016-09-01 10:11:32 +03:00
|
|
|
|
void UpgradeCandidates(JSContext* aCx,
|
|
|
|
|
nsIAtom* aKey,
|
2017-03-21 07:42:00 +03:00
|
|
|
|
CustomElementDefinition* aDefinition,
|
|
|
|
|
ErrorResult& aRv);
|
2017-01-06 02:38:00 +03:00
|
|
|
|
|
2016-09-01 10:11:32 +03:00
|
|
|
|
typedef nsClassHashtable<nsISupportsHashKey, CustomElementDefinition>
|
2016-08-30 06:48:53 +03:00
|
|
|
|
DefinitionMap;
|
2016-09-01 10:11:32 +03:00
|
|
|
|
typedef nsClassHashtable<nsISupportsHashKey, nsTArray<nsWeakPtr>>
|
2016-08-30 06:48:53 +03:00
|
|
|
|
CandidateMap;
|
2016-09-07 12:55:21 +03:00
|
|
|
|
typedef JS::GCHashMap<JS::Heap<JSObject*>,
|
|
|
|
|
nsCOMPtr<nsIAtom>,
|
|
|
|
|
js::MovableCellHasher<JS::Heap<JSObject*>>,
|
|
|
|
|
js::SystemAllocPolicy> ConstructorMap;
|
2016-08-30 06:48:53 +03:00
|
|
|
|
|
|
|
|
|
// Hashtable for custom element definitions in web components.
|
|
|
|
|
// Custom prototypes are stored in the compartment where
|
|
|
|
|
// registerElement was called.
|
|
|
|
|
DefinitionMap mCustomDefinitions;
|
|
|
|
|
|
2016-09-07 12:55:21 +03:00
|
|
|
|
// Hashtable for looking up definitions by using constructor as key.
|
|
|
|
|
// Custom elements' name are stored here and we need to lookup
|
|
|
|
|
// mCustomDefinitions again to get definitions.
|
|
|
|
|
ConstructorMap mConstructors;
|
|
|
|
|
|
2016-10-07 09:16:00 +03:00
|
|
|
|
typedef nsRefPtrHashtable<nsISupportsHashKey, Promise>
|
|
|
|
|
WhenDefinedPromiseMap;
|
|
|
|
|
WhenDefinedPromiseMap mWhenDefinedPromiseMap;
|
2016-09-07 12:55:21 +03:00
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
// The "upgrade candidates map" from the web components spec. Maps from a
|
|
|
|
|
// namespace id and local name to a list of elements to upgrade if that
|
|
|
|
|
// element is registered as a custom element.
|
|
|
|
|
CandidateMap mCandidatesMap;
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
|
|
|
|
|
2016-08-30 06:48:53 +03:00
|
|
|
|
// Array representing the processing stack in the custom elements
|
|
|
|
|
// specification. The processing stack is conceptually a stack of
|
|
|
|
|
// element queues. Each queue is represented by a sequence of
|
|
|
|
|
// CustomElementData in this array, separated by nullptr that
|
|
|
|
|
// represent the boundaries of the items in the stack. The first
|
|
|
|
|
// queue in the stack is the base element queue.
|
|
|
|
|
static mozilla::Maybe<nsTArray<RefPtr<CustomElementData>>> sProcessingStack;
|
|
|
|
|
|
2016-09-01 10:11:32 +03:00
|
|
|
|
// It is used to prevent reentrant invocations of element definition.
|
|
|
|
|
bool mIsCustomDefinitionRunning;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
class MOZ_RAII AutoSetRunningFlag final {
|
|
|
|
|
public:
|
2016-10-12 10:26:02 +03:00
|
|
|
|
explicit AutoSetRunningFlag(CustomElementRegistry* aRegistry)
|
2016-09-01 10:11:32 +03:00
|
|
|
|
: mRegistry(aRegistry)
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(!mRegistry->mIsCustomDefinitionRunning,
|
|
|
|
|
"IsCustomDefinitionRunning flag should be initially false");
|
|
|
|
|
mRegistry->mIsCustomDefinitionRunning = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~AutoSetRunningFlag() {
|
|
|
|
|
mRegistry->mIsCustomDefinitionRunning = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2016-10-12 10:26:02 +03:00
|
|
|
|
CustomElementRegistry* mRegistry;
|
2016-09-01 10:11:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
public:
|
|
|
|
|
nsISupports* GetParentObject() const;
|
|
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
|
|
void Define(const nsAString& aName, Function& aFunctionConstructor,
|
|
|
|
|
const ElementDefinitionOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
|
|
|
|
|
void Get(JSContext* cx, const nsAString& name,
|
2016-09-22 02:40:00 +03:00
|
|
|
|
JS::MutableHandle<JS::Value> aRetVal);
|
2016-07-25 00:38:00 +03:00
|
|
|
|
|
2016-10-07 09:16:00 +03:00
|
|
|
|
already_AddRefed<Promise> WhenDefined(const nsAString& aName, ErrorResult& aRv);
|
2016-07-25 00:38:00 +03:00
|
|
|
|
};
|
|
|
|
|
|
2017-01-06 02:38:00 +03:00
|
|
|
|
class MOZ_RAII AutoCEReaction final {
|
|
|
|
|
public:
|
2017-03-21 07:42:00 +03:00
|
|
|
|
explicit AutoCEReaction(CustomElementReactionsStack* aReactionsStack)
|
|
|
|
|
: mReactionsStack(aReactionsStack) {
|
|
|
|
|
mReactionsStack->CreateAndPushElementQueue();
|
2017-01-06 02:38:00 +03:00
|
|
|
|
}
|
|
|
|
|
~AutoCEReaction() {
|
2017-03-21 07:42:00 +03:00
|
|
|
|
mReactionsStack->PopAndInvokeElementQueue();
|
2017-01-06 02:38:00 +03:00
|
|
|
|
}
|
|
|
|
|
private:
|
2017-03-21 07:42:00 +03:00
|
|
|
|
RefPtr<CustomElementReactionsStack> mReactionsStack;
|
2017-01-06 02:38:00 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-07-25 00:38:00 +03:00
|
|
|
|
} // namespace dom
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
|
|
2016-10-12 10:26:02 +03:00
|
|
|
|
#endif // mozilla_dom_CustomElementRegistry_h
|