CustomElementRegistry.h [plain text]
#pragma once
#include "ContextDestructionObserver.h"
#include "QualifiedName.h"
#include <wtf/HashMap.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/AtomicStringHash.h>
namespace JSC {
class JSObject;
class JSValue;
}
namespace WebCore {
class CustomElementRegistry;
class DOMWindow;
class DeferredPromise;
class Element;
class JSCustomElementInterface;
class Node;
class QualifiedName;
class CustomElementRegistry : public RefCounted<CustomElementRegistry>, public ContextDestructionObserver {
public:
static Ref<CustomElementRegistry> create(DOMWindow&, ScriptExecutionContext*);
~CustomElementRegistry();
void addElementDefinition(Ref<JSCustomElementInterface>&&);
bool& elementDefinitionIsRunning() { return m_elementDefinitionIsRunning; }
JSCustomElementInterface* findInterface(const Element&) const;
JSCustomElementInterface* findInterface(const QualifiedName&) const;
JSCustomElementInterface* findInterface(const AtomicString&) const;
JSCustomElementInterface* findInterface(const JSC::JSObject*) const;
bool containsConstructor(const JSC::JSObject*) const;
JSC::JSValue get(const AtomicString&);
void upgrade(Node& root);
HashMap<AtomicString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; }
private:
CustomElementRegistry(DOMWindow&, ScriptExecutionContext*);
DOMWindow& m_window;
HashMap<AtomicString, Ref<JSCustomElementInterface>> m_nameMap;
HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap;
HashMap<AtomicString, Ref<DeferredPromise>> m_promiseMap;
bool m_elementDefinitionIsRunning { false };
friend class ElementDefinitionIsRunningSetForScope;
};
}