зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1275833 - Move CustomElementDefinition and CustomElementHashKey from nsDocument to CustomElementRegistry. r=wchen
--HG-- extra : rebase_source : 014bdac82e416878f845ff84c54e1fc697d92b68
This commit is contained in:
Родитель
7f2bb4c2c9
Коммит
0744abcb80
|
@ -94,5 +94,20 @@ CustomElementsRegistry::WhenDefined(const nsAString& name, ErrorResult& aRv)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
CustomElementDefinition::CustomElementDefinition(JSObject* aPrototype,
|
||||
nsIAtom* aType,
|
||||
nsIAtom* aLocalName,
|
||||
LifecycleCallbacks* aCallbacks,
|
||||
uint32_t aNamespaceID,
|
||||
uint32_t aDocOrder)
|
||||
: mPrototype(aPrototype),
|
||||
mType(aType),
|
||||
mLocalName(aLocalName),
|
||||
mCallbacks(aCallbacks),
|
||||
mNamespaceID(aNamespaceID),
|
||||
mDocOrder(aDocOrder)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -23,6 +23,81 @@ struct LifecycleCallbacks;
|
|||
class Function;
|
||||
class Promise;
|
||||
|
||||
class CustomElementHashKey : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef CustomElementHashKey *KeyType;
|
||||
typedef const CustomElementHashKey *KeyTypePointer;
|
||||
|
||||
CustomElementHashKey(int32_t aNamespaceID, nsIAtom *aAtom)
|
||||
: mNamespaceID(aNamespaceID),
|
||||
mAtom(aAtom)
|
||||
{}
|
||||
explicit CustomElementHashKey(const CustomElementHashKey* aKey)
|
||||
: mNamespaceID(aKey->mNamespaceID),
|
||||
mAtom(aKey->mAtom)
|
||||
{}
|
||||
~CustomElementHashKey()
|
||||
{}
|
||||
|
||||
KeyType GetKey() const { return const_cast<KeyType>(this); }
|
||||
bool KeyEquals(const KeyTypePointer aKey) const
|
||||
{
|
||||
MOZ_ASSERT(mNamespaceID != kNameSpaceID_Unknown,
|
||||
"This equals method is not transitive, nor symmetric. "
|
||||
"A key with a namespace of kNamespaceID_Unknown should "
|
||||
"not be stored in a hashtable.");
|
||||
return (kNameSpaceID_Unknown == aKey->mNamespaceID ||
|
||||
mNamespaceID == aKey->mNamespaceID) &&
|
||||
aKey->mAtom == mAtom;
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
|
||||
static PLDHashNumber HashKey(const KeyTypePointer aKey)
|
||||
{
|
||||
return aKey->mAtom->hash();
|
||||
}
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
private:
|
||||
int32_t mNamespaceID;
|
||||
nsCOMPtr<nsIAtom> mAtom;
|
||||
};
|
||||
|
||||
// The required information for a custom element as defined in:
|
||||
// https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html
|
||||
struct CustomElementDefinition
|
||||
{
|
||||
CustomElementDefinition(JSObject* aPrototype,
|
||||
nsIAtom* aType,
|
||||
nsIAtom* aLocalName,
|
||||
mozilla::dom::LifecycleCallbacks* aCallbacks,
|
||||
uint32_t aNamespaceID,
|
||||
uint32_t aDocOrder);
|
||||
|
||||
// The prototype to use for new custom elements of this type.
|
||||
JS::Heap<JSObject *> mPrototype;
|
||||
|
||||
// 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;
|
||||
|
||||
// The lifecycle callbacks to call for this custom element.
|
||||
nsAutoPtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
|
||||
|
||||
// Whether we're currently calling the created callback for a custom element
|
||||
// of this type.
|
||||
bool mElementIsBeingCreated;
|
||||
|
||||
// Element namespace.
|
||||
int32_t mNamespaceID;
|
||||
|
||||
// The document custom element order.
|
||||
uint32_t mDocOrder;
|
||||
};
|
||||
|
||||
class CustomElementsRegistry final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
|
|
|
@ -469,21 +469,6 @@ CustomElementCallback::CustomElementCallback(Element* aThisObject,
|
|||
{
|
||||
}
|
||||
|
||||
CustomElementDefinition::CustomElementDefinition(JSObject* aPrototype,
|
||||
nsIAtom* aType,
|
||||
nsIAtom* aLocalName,
|
||||
LifecycleCallbacks* aCallbacks,
|
||||
uint32_t aNamespaceID,
|
||||
uint32_t aDocOrder)
|
||||
: mPrototype(aPrototype),
|
||||
mType(aType),
|
||||
mLocalName(aLocalName),
|
||||
mCallbacks(aCallbacks),
|
||||
mNamespaceID(aNamespaceID),
|
||||
mDocOrder(aDocOrder)
|
||||
{
|
||||
}
|
||||
|
||||
CustomElementData::CustomElementData(nsIAtom* aType)
|
||||
: mType(aType),
|
||||
mCurrentCallback(-1),
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "jsfriendapi.h"
|
||||
#include "ImportManager.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "CustomElementsRegistry.h"
|
||||
|
||||
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
|
||||
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
|
||||
|
@ -263,48 +264,6 @@ private:
|
|||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CustomElementHashKey : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef CustomElementHashKey *KeyType;
|
||||
typedef const CustomElementHashKey *KeyTypePointer;
|
||||
|
||||
CustomElementHashKey(int32_t aNamespaceID, nsIAtom *aAtom)
|
||||
: mNamespaceID(aNamespaceID),
|
||||
mAtom(aAtom)
|
||||
{}
|
||||
explicit CustomElementHashKey(const CustomElementHashKey* aKey)
|
||||
: mNamespaceID(aKey->mNamespaceID),
|
||||
mAtom(aKey->mAtom)
|
||||
{}
|
||||
~CustomElementHashKey()
|
||||
{}
|
||||
|
||||
KeyType GetKey() const { return const_cast<KeyType>(this); }
|
||||
bool KeyEquals(const KeyTypePointer aKey) const
|
||||
{
|
||||
MOZ_ASSERT(mNamespaceID != kNameSpaceID_Unknown,
|
||||
"This equals method is not transitive, nor symmetric. "
|
||||
"A key with a namespace of kNamespaceID_Unknown should "
|
||||
"not be stored in a hashtable.");
|
||||
return (kNameSpaceID_Unknown == aKey->mNamespaceID ||
|
||||
mNamespaceID == aKey->mNamespaceID) &&
|
||||
aKey->mAtom == mAtom;
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
|
||||
static PLDHashNumber HashKey(const KeyTypePointer aKey)
|
||||
{
|
||||
return aKey->mAtom->hash();
|
||||
}
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
private:
|
||||
int32_t mNamespaceID;
|
||||
nsCOMPtr<nsIAtom> mAtom;
|
||||
};
|
||||
|
||||
struct LifecycleCallbackArgs
|
||||
{
|
||||
nsString name;
|
||||
|
@ -376,40 +335,6 @@ private:
|
|||
virtual ~CustomElementData() {}
|
||||
};
|
||||
|
||||
// The required information for a custom element as defined in:
|
||||
// https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html
|
||||
struct CustomElementDefinition
|
||||
{
|
||||
CustomElementDefinition(JSObject* aPrototype,
|
||||
nsIAtom* aType,
|
||||
nsIAtom* aLocalName,
|
||||
mozilla::dom::LifecycleCallbacks* aCallbacks,
|
||||
uint32_t aNamespaceID,
|
||||
uint32_t aDocOrder);
|
||||
|
||||
// The prototype to use for new custom elements of this type.
|
||||
JS::Heap<JSObject *> mPrototype;
|
||||
|
||||
// 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;
|
||||
|
||||
// The lifecycle callbacks to call for this custom element.
|
||||
nsAutoPtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
|
||||
|
||||
// Whether we're currently calling the created callback for a custom element
|
||||
// of this type.
|
||||
bool mElementIsBeingCreated;
|
||||
|
||||
// Element namespace.
|
||||
int32_t mNamespaceID;
|
||||
|
||||
// The document custom element order.
|
||||
uint32_t mDocOrder;
|
||||
};
|
||||
|
||||
class Registry : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче