summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ScopedEventQueue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ScopedEventQueue.cpp')
-rw-r--r--Source/WebCore/dom/ScopedEventQueue.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/Source/WebCore/dom/ScopedEventQueue.cpp b/Source/WebCore/dom/ScopedEventQueue.cpp
index 503843bc8..8fb659f8e 100644
--- a/Source/WebCore/dom/ScopedEventQueue.cpp
+++ b/Source/WebCore/dom/ScopedEventQueue.cpp
@@ -37,55 +37,43 @@
namespace WebCore {
-ScopedEventQueue::ScopedEventQueue()
- : m_scopingLevel(0)
-{
-}
-
-ScopedEventQueue::~ScopedEventQueue()
-{
- ASSERT(!m_scopingLevel);
- ASSERT(!m_queuedEvents.size());
-}
-
-ScopedEventQueue& ScopedEventQueue::instance()
+ScopedEventQueue& ScopedEventQueue::singleton()
{
static NeverDestroyed<ScopedEventQueue> scopedEventQueue;
return scopedEventQueue;
}
-void ScopedEventQueue::enqueueEvent(PassRefPtr<Event> event)
+void ScopedEventQueue::enqueueEvent(Ref<Event>&& event)
{
if (m_scopingLevel)
- m_queuedEvents.append(event);
+ m_queuedEvents.append(WTFMove(event));
else
dispatchEvent(event);
}
-void ScopedEventQueue::dispatchEvent(PassRefPtr<Event> event) const
+void ScopedEventQueue::dispatchEvent(Event& event) const
{
- ASSERT(event->target());
- // Store the target in a local variable to avoid possibly dereferencing a nullified PassRefPtr after it's passed on.
- Node* node = event->target()->toNode();
- EventDispatcher::dispatchEvent(node, event);
+ ASSERT(event.target());
+ ASSERT(event.target()->toNode());
+ EventDispatcher::dispatchEvent(*event.target()->toNode(), event);
}
void ScopedEventQueue::dispatchAllEvents()
{
- Vector<RefPtr<Event>> queuedEvents = std::move(m_queuedEvents);
- for (size_t i = 0; i < queuedEvents.size(); i++)
- dispatchEvent(queuedEvents[i].release());
+ Vector<Ref<Event>> queuedEvents = WTFMove(m_queuedEvents);
+ for (auto& queuedEvent : queuedEvents)
+ dispatchEvent(queuedEvent);
}
void ScopedEventQueue::incrementScopingLevel()
{
- m_scopingLevel++;
+ ++m_scopingLevel;
}
void ScopedEventQueue::decrementScopingLevel()
{
ASSERT(m_scopingLevel);
- m_scopingLevel--;
+ --m_scopingLevel;
if (!m_scopingLevel)
dispatchAllEvents();
}