#include "config.h"
#include "core/events/DOMWindowEventQueue.h"
-#include "core/dom/Document.h"
#include "core/events/Event.h"
-#include "core/frame/DOMWindow.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/SuspendableTimer.h"
+#include "core/inspector/InspectorInstrumentation.h"
-namespace WebCore {
+namespace blink {
-class DOMWindowEventQueueTimer : public SuspendableTimer {
+class DOMWindowEventQueueTimer : public NoBaseWillBeGarbageCollectedFinalized<DOMWindowEventQueueTimer>, public SuspendableTimer {
WTF_MAKE_NONCOPYABLE(DOMWindowEventQueueTimer);
public:
DOMWindowEventQueueTimer(DOMWindowEventQueue* eventQueue, ExecutionContext* context)
: SuspendableTimer(context)
, m_eventQueue(eventQueue) { }
+ void trace(Visitor* visitor) { visitor->trace(m_eventQueue); }
private:
virtual void fired() { m_eventQueue->pendingEventTimerFired(); }
- DOMWindowEventQueue* m_eventQueue;
+
+ RawPtrWillBeMember<DOMWindowEventQueue> m_eventQueue;
};
-PassRefPtr<DOMWindowEventQueue> DOMWindowEventQueue::create(ExecutionContext* context)
+PassRefPtrWillBeRawPtr<DOMWindowEventQueue> DOMWindowEventQueue::create(ExecutionContext* context)
{
- return adoptRef(new DOMWindowEventQueue(context));
+ return adoptRefWillBeNoop(new DOMWindowEventQueue(context));
}
DOMWindowEventQueue::DOMWindowEventQueue(ExecutionContext* context)
- : m_pendingEventTimer(adoptPtr(new DOMWindowEventQueueTimer(this, context)))
+ : m_pendingEventTimer(adoptPtrWillBeNoop(new DOMWindowEventQueueTimer(this, context)))
, m_isClosed(false)
{
m_pendingEventTimer->suspendIfNeeded();
{
}
+void DOMWindowEventQueue::trace(Visitor* visitor)
+{
+#if ENABLE(OILPAN)
+ visitor->trace(m_pendingEventTimer);
+ visitor->trace(m_queuedEvents);
+#endif
+ EventQueue::trace(visitor);
+}
+
bool DOMWindowEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event)
{
if (m_isClosed)
return false;
ASSERT(event->target());
+ InspectorInstrumentation::didEnqueueEvent(event->target(), event.get());
+
bool wasAdded = m_queuedEvents.add(event).isNewEntry;
ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
bool DOMWindowEventQueue::cancelEvent(Event* event)
{
- ListHashSet<RefPtrWillBePersistent<Event>, 16>::iterator it = m_queuedEvents.find(event);
+ WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_queuedEvents.find(event);
bool found = it != m_queuedEvents.end();
- if (found)
+ if (found) {
+ InspectorInstrumentation::didRemoveEvent(event->target(), event);
m_queuedEvents.remove(it);
+ }
if (m_queuedEvents.isEmpty())
m_pendingEventTimer->stop();
return found;
{
m_isClosed = true;
m_pendingEventTimer->stop();
+ if (InspectorInstrumentation::hasFrontends()) {
+ for (const auto& queuedEvent : m_queuedEvents) {
+ RefPtrWillBeRawPtr<Event> event = queuedEvent;
+ if (event)
+ InspectorInstrumentation::didRemoveEvent(event->target(), event.get());
+ }
+ }
m_queuedEvents.clear();
}
bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry;
ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
- RefPtr<DOMWindowEventQueue> protector(this);
+ RefPtrWillBeRawPtr<DOMWindowEventQueue> protector(this);
while (!m_queuedEvents.isEmpty()) {
- ListHashSet<RefPtrWillBePersistent<Event>, 16>::iterator iter = m_queuedEvents.begin();
+ WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator iter = m_queuedEvents.begin();
RefPtrWillBeRawPtr<Event> event = *iter;
m_queuedEvents.remove(iter);
if (!event)
break;
dispatchEvent(event.get());
+ InspectorInstrumentation::didRemoveEvent(event->target(), event.get());
}
}