- Revision
- 92450
- Author
- [email protected]
- Date
- 2011-08-04 23:14:11 -0700 (Thu, 04 Aug 2011)
Log Message
Make ScopedEventQueue enqueue an EventDispatchMediator, instead of an Event.
https://bugs.webkit.org/show_bug.cgi?id=65613
Reviewed by Dimitri Glazkov.
No changes to functionality so no new tests.
* dom/Event.h:
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchScopedEvent):
* dom/EventDispatcher.h:
* dom/Node.cpp:
(WebCore::Node::dispatchScopedEvent):
(WebCore::Node::dispatchScopedEventDispatchMediator):
* dom/Node.h:
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::~ScopedEventQueue):
(WebCore::ScopedEventQueue::enqueueEventDispatchMediator):
(WebCore::ScopedEventQueue::dispatchAllEvents):
(WebCore::ScopedEventQueue::dispatchEvent):
* dom/ScopedEventQueue.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (92449 => 92450)
--- trunk/Source/WebCore/ChangeLog 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/ChangeLog 2011-08-05 06:14:11 UTC (rev 92450)
@@ -1,3 +1,27 @@
+2011-08-04 Hayato Ito <[email protected]>
+
+ Make ScopedEventQueue enqueue an EventDispatchMediator, instead of an Event.
+ https://bugs.webkit.org/show_bug.cgi?id=65613
+
+ Reviewed by Dimitri Glazkov.
+
+ No changes to functionality so no new tests.
+
+ * dom/Event.h:
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchScopedEvent):
+ * dom/EventDispatcher.h:
+ * dom/Node.cpp:
+ (WebCore::Node::dispatchScopedEvent):
+ (WebCore::Node::dispatchScopedEventDispatchMediator):
+ * dom/Node.h:
+ * dom/ScopedEventQueue.cpp:
+ (WebCore::ScopedEventQueue::~ScopedEventQueue):
+ (WebCore::ScopedEventQueue::enqueueEventDispatchMediator):
+ (WebCore::ScopedEventQueue::dispatchAllEvents):
+ (WebCore::ScopedEventQueue::dispatchEvent):
+ * dom/ScopedEventQueue.h:
+
2011-08-04 James Robinson <[email protected]>
Unreviewed build fix. gcc 4.5 can't figure out that the 'data' variables are always initialized in these functions.
Modified: trunk/Source/WebCore/dom/Event.h (92449 => 92450)
--- trunk/Source/WebCore/dom/Event.h 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/Event.h 2011-08-05 06:14:11 UTC (rev 92450)
@@ -205,12 +205,11 @@
virtual ~EventDispatchMediator();
virtual bool dispatchEvent(EventDispatcher*) const;
+ Event* event() const;
protected:
explicit EventDispatchMediator(PassRefPtr<Event>);
EventDispatchMediator();
-
- Event* event() const;
void setEvent(PassRefPtr<Event>);
private:
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (92449 => 92450)
--- trunk/Source/WebCore/dom/EventDispatcher.cpp 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp 2011-08-05 06:14:11 UTC (rev 92450)
@@ -84,12 +84,11 @@
return referenceNode->isSVGElement() ? findElementInstance(referenceNode) : referenceNode;
}
-void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<Event> event)
+void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<EventDispatchMediator> mediator)
{
// We need to set the target here because it can go away by the time we actually fire the event.
- event->setTarget(eventTargetRespectingSVGTargetRules(node));
-
- ScopedEventQueue::instance()->enqueueEvent(event);
+ mediator->event()->setTarget(eventTargetRespectingSVGTargetRules(node));
+ ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator);
}
void EventDispatcher::dispatchSimulatedClick(Node* node, PassRefPtr<Event> underlyingEvent, bool sendMouseEvents, bool showPressedLook)
Modified: trunk/Source/WebCore/dom/EventDispatcher.h (92449 => 92450)
--- trunk/Source/WebCore/dom/EventDispatcher.h 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/EventDispatcher.h 2011-08-05 06:14:11 UTC (rev 92450)
@@ -49,7 +49,7 @@
class EventDispatcher {
public:
static bool dispatchEvent(Node*, PassRefPtr<EventDispatchMediator>);
- static void dispatchScopedEvent(Node*, PassRefPtr<Event>);
+ static void dispatchScopedEvent(Node*, PassRefPtr<EventDispatchMediator>);
static void dispatchSimulatedClick(Node*, PassRefPtr<Event> underlyingEvent, bool sendMouseEvents, bool showPressedLook);
Modified: trunk/Source/WebCore/dom/Node.cpp (92449 => 92450)
--- trunk/Source/WebCore/dom/Node.cpp 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/Node.cpp 2011-08-05 06:14:11 UTC (rev 92450)
@@ -2709,9 +2709,14 @@
void Node::dispatchScopedEvent(PassRefPtr<Event> event)
{
- EventDispatcher::dispatchScopedEvent(this, event);
+ dispatchScopedEventDispatchMediator(EventDispatchMediator::create(event));
}
+void Node::dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator> eventDispatchMediator)
+{
+ EventDispatcher::dispatchScopedEvent(this, eventDispatchMediator);
+}
+
bool Node::dispatchEvent(PassRefPtr<Event> event)
{
return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(event));
Modified: trunk/Source/WebCore/dom/Node.h (92449 => 92450)
--- trunk/Source/WebCore/dom/Node.h 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/Node.h 2011-08-05 06:14:11 UTC (rev 92450)
@@ -50,6 +50,7 @@
class Element;
class Event;
class EventContext;
+class EventDispatchMediator;
class EventListener;
class FloatPoint;
class Frame;
@@ -546,6 +547,7 @@
using EventTarget::dispatchEvent;
bool dispatchEvent(PassRefPtr<Event>);
void dispatchScopedEvent(PassRefPtr<Event>);
+ void dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator>);
virtual void handleLocalEvents(Event*);
Modified: trunk/Source/WebCore/dom/ScopedEventQueue.cpp (92449 => 92450)
--- trunk/Source/WebCore/dom/ScopedEventQueue.cpp 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/ScopedEventQueue.cpp 2011-08-05 06:14:11 UTC (rev 92450)
@@ -32,7 +32,10 @@
#include "ScopedEventQueue.h"
#include "Event.h"
+#include "EventDispatcher.h"
#include "EventTarget.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
@@ -46,7 +49,7 @@
ScopedEventQueue::~ScopedEventQueue()
{
ASSERT(!m_scopingLevel);
- ASSERT(!m_queuedEvents.size());
+ ASSERT(!m_queuedEventDispatchMediators.size());
}
void ScopedEventQueue::initialize()
@@ -56,27 +59,28 @@
s_instance = instance.leakPtr();
}
-void ScopedEventQueue::enqueueEvent(PassRefPtr<Event> event)
+void ScopedEventQueue::enqueueEventDispatchMediator(PassRefPtr<EventDispatchMediator> mediator)
{
if (m_scopingLevel)
- m_queuedEvents.append(event);
+ m_queuedEventDispatchMediators.append(mediator);
else
- dispatchEvent(event);
+ dispatchEvent(mediator);
}
void ScopedEventQueue::dispatchAllEvents()
{
- Vector<RefPtr<Event> > queuedEvents;
- queuedEvents.swap(m_queuedEvents);
+ Vector<RefPtr<EventDispatchMediator> > queuedEventDispatchMediators;
+ queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators);
- for (size_t i = 0; i < queuedEvents.size(); i++)
- dispatchEvent(queuedEvents[i].release());
+ for (size_t i = 0; i < queuedEventDispatchMediators.size(); i++)
+ dispatchEvent(queuedEventDispatchMediators[i].release());
}
-void ScopedEventQueue::dispatchEvent(PassRefPtr<Event> event) const
+void ScopedEventQueue::dispatchEvent(PassRefPtr<EventDispatchMediator> mediator) const
{
- RefPtr<EventTarget> eventTarget = event->target();
- eventTarget->dispatchEvent(event);
+ ASSERT(mediator->event()->target());
+ Node* node = mediator->event()->target()->toNode();
+ EventDispatcher::dispatchEvent(node, mediator);
}
ScopedEventQueue* ScopedEventQueue::instance()
Modified: trunk/Source/WebCore/dom/ScopedEventQueue.h (92449 => 92450)
--- trunk/Source/WebCore/dom/ScopedEventQueue.h 2011-08-05 06:05:51 UTC (rev 92449)
+++ trunk/Source/WebCore/dom/ScopedEventQueue.h 2011-08-05 06:14:11 UTC (rev 92450)
@@ -32,13 +32,13 @@
#define ScopedEventQueue_h
#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
-class Event;
+class EventDispatchMediator;
class ScopedEventQueue {
WTF_MAKE_NONCOPYABLE(ScopedEventQueue);
@@ -46,7 +46,7 @@
public:
~ScopedEventQueue();
- void enqueueEvent(PassRefPtr<Event>);
+ void enqueueEventDispatchMediator(PassRefPtr<EventDispatchMediator>);
void dispatchAllEvents();
static ScopedEventQueue* instance();
@@ -56,9 +56,9 @@
private:
ScopedEventQueue();
static void initialize();
- void dispatchEvent(PassRefPtr<Event>) const;
+ void dispatchEvent(PassRefPtr<EventDispatchMediator>) const;
- Vector<RefPtr<Event> > m_queuedEvents;
+ Vector<RefPtr<EventDispatchMediator> > m_queuedEventDispatchMediators;
unsigned m_scopingLevel;
static ScopedEventQueue* s_instance;