diff options
Diffstat (limited to 'Source/WebCore/dom/DocumentEventQueue.cpp')
-rw-r--r-- | Source/WebCore/dom/DocumentEventQueue.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/Source/WebCore/dom/DocumentEventQueue.cpp b/Source/WebCore/dom/DocumentEventQueue.cpp index 631653ab7..9e077f72f 100644 --- a/Source/WebCore/dom/DocumentEventQueue.cpp +++ b/Source/WebCore/dom/DocumentEventQueue.cpp @@ -11,10 +11,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -31,6 +31,7 @@ #include "DOMWindow.h" #include "Document.h" #include "Event.h" +#include "EventNames.h" #include "SuspendableTimer.h" #include <wtf/Ref.h> @@ -38,30 +39,27 @@ namespace WebCore { class DocumentEventQueue::Timer final : public SuspendableTimer { public: - static PassOwnPtr<Timer> create(DocumentEventQueue& eventQueue) - { - return adoptPtr(new Timer(eventQueue)); - } - -private: Timer(DocumentEventQueue& eventQueue) - : SuspendableTimer(&eventQueue.m_document) + : SuspendableTimer(eventQueue.m_document) , m_eventQueue(eventQueue) { } - virtual void fired() override +private: + void fired() override { ASSERT(!isSuspended()); m_eventQueue.pendingEventTimerFired(); } + const char* activeDOMObjectName() const override { return "DocumentEventQueueTimer"; } + DocumentEventQueue& m_eventQueue; }; DocumentEventQueue::DocumentEventQueue(Document& document) : m_document(document) - , m_pendingEventTimer(Timer::create(*this)) + , m_pendingEventTimer(std::make_unique<Timer>(*this)) , m_isClosed(false) { m_pendingEventTimer->suspendIfNeeded(); @@ -71,15 +69,15 @@ DocumentEventQueue::~DocumentEventQueue() { } -bool DocumentEventQueue::enqueueEvent(PassRefPtr<Event> event) +bool DocumentEventQueue::enqueueEvent(Ref<Event>&& event) { ASSERT(event->target()); - ASSERT(!m_queuedEvents.contains(event.get())); + ASSERT(!m_queuedEvents.contains(event.ptr())); if (m_isClosed) return false; - m_queuedEvents.add(event); + m_queuedEvents.add(event.ptr()); if (!m_pendingEventTimer->isActive()) m_pendingEventTimer->startOneShot(0); return true; @@ -102,9 +100,9 @@ void DocumentEventQueue::enqueueOrDispatchScrollEvent(Node& target) bool bubbles = target.isDocumentNode(); bool cancelable = false; - RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, bubbles, cancelable); + Ref<Event> scrollEvent = Event::create(eventNames().scrollEvent, bubbles, cancelable); scrollEvent->setTarget(&target); - enqueueEvent(scrollEvent.release()); + enqueueEvent(WTFMove(scrollEvent)); } bool DocumentEventQueue::cancelEvent(Event& event) @@ -149,9 +147,9 @@ void DocumentEventQueue::dispatchEvent(Event& event) // Why do we have this special case here instead of a virtual function on EventTarget? EventTarget& eventTarget = *event.target(); if (DOMWindow* window = eventTarget.toDOMWindow()) - window->dispatchEvent(&event, 0); + window->dispatchEvent(event, nullptr); else - eventTarget.dispatchEvent(&event); + eventTarget.dispatchEvent(event); } } |