CustomElementRegistry.h [plain text]
#pragma once
#include "JSDOMPromise.h"
#include "QualifiedName.h"
#include <wtf/HashMap.h>
#include <wtf/SetForScope.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/AtomicStringHash.h>
namespace JSC {
class JSObject;
class JSValue;
}
namespace WebCore {
class CustomElementRegistry;
class DOMWindow;
class Element;
class JSCustomElementInterface;
class QualifiedName;
class CustomElementRegistry : public RefCounted<CustomElementRegistry> {
public:
static Ref<CustomElementRegistry> create(DOMWindow&);
~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&);
HashMap<AtomicString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; }
private:
CustomElementRegistry(DOMWindow&);
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;
};
}