LifecycleCallbackQueue.h [plain text]
#ifndef LifecycleCallbackQueue_h
#define LifecycleCallbackQueue_h
#if ENABLE(CUSTOM_ELEMENTS)
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
namespace WebCore {
class JSCustomElementInterface;
class Document;
class Element;
class LifecycleQueueItem;
class QualifiedName;
class LifecycleCallbackQueue {
WTF_MAKE_NONCOPYABLE(LifecycleCallbackQueue);
public:
LifecycleCallbackQueue();
~LifecycleCallbackQueue();
static void enqueueElementUpgrade(Element&, JSCustomElementInterface&);
static void enqueueAttributeChangedCallback(Element&, JSCustomElementInterface&,
const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue);
void invokeAll();
private:
Vector<LifecycleQueueItem> m_items;
};
class CustomElementLifecycleProcessingStack {
public:
CustomElementLifecycleProcessingStack()
: m_previousProcessingStack(s_currentProcessingStack)
{
s_currentProcessingStack = this;
}
~CustomElementLifecycleProcessingStack()
{
if (UNLIKELY(m_queue))
processQueue();
s_currentProcessingStack = m_previousProcessingStack;
}
static LifecycleCallbackQueue* ensureCurrentQueue();
static bool hasCurrentProcessingStack() { return s_currentProcessingStack; }
private:
void processQueue();
LifecycleCallbackQueue* m_queue { nullptr };
CustomElementLifecycleProcessingStack* m_previousProcessingStack;
static CustomElementLifecycleProcessingStack* s_currentProcessingStack;
};
}
#endif
#endif // LifecycleCallbackQueue_h