Make EventDispatchMediator RefCounted.
authorhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Aug 2011 03:25:57 +0000 (03:25 +0000)
committerhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Aug 2011 03:25:57 +0000 (03:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65529

Reviewed by Dimitri Glazkov.

Make EventDispatchMediator RefCounted so that it can be enqueued into a
ScopedEventQueue and called later.
A necessary change for ScopedEventQueue should be addressed in another patch.

No changes to functionality so no new tests.

* dom/Event.cpp:
(WebCore::EventDispatchMediator::create):
* dom/Event.h:
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):
* dom/EventDispatcher.h:
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEventDispatchMediator::create):
* dom/KeyboardEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::create):
* dom/MouseEvent.h:
* dom/Node.cpp:
(WebCore::Node::dispatchEvent):
(WebCore::Node::dispatchKeyEvent):
(WebCore::Node::dispatchMouseEvent):
(WebCore::Node::dispatchWheelEvent):
* dom/WheelEvent.cpp:
(WebCore::WheelEventDispatchMediator::create):
* dom/WheelEvent.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92256 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/EventDispatcher.h
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h

index 568bee2..691ae6e 100644 (file)
@@ -1,3 +1,37 @@
+2011-08-02  Hayato Ito  <hayato@chromium.org>
+
+        Make EventDispatchMediator RefCounted.
+        https://bugs.webkit.org/show_bug.cgi?id=65529
+
+        Reviewed by Dimitri Glazkov.
+
+        Make EventDispatchMediator RefCounted so that it can be enqueued into a
+        ScopedEventQueue and called later.
+        A necessary change for ScopedEventQueue should be addressed in another patch.
+
+        No changes to functionality so no new tests.
+
+        * dom/Event.cpp:
+        (WebCore::EventDispatchMediator::create):
+        * dom/Event.h:
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchEvent):
+        * dom/EventDispatcher.h:
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEventDispatchMediator::create):
+        * dom/KeyboardEvent.h:
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEventDispatchMediator::create):
+        * dom/MouseEvent.h:
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchEvent):
+        (WebCore::Node::dispatchKeyEvent):
+        (WebCore::Node::dispatchMouseEvent):
+        (WebCore::Node::dispatchWheelEvent):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEventDispatchMediator::create):
+        * dom/WheelEvent.h:
+
 2011-08-02  David Reveman  <reveman@chromium.org>
 
         [Chromium] Use edge-distance method for layer anti-aliasing.
index 1758a27..8882241 100644 (file)
@@ -289,6 +289,11 @@ void Event::setUnderlyingEvent(PassRefPtr<Event> ue)
     m_underlyingEvent = ue;
 }
 
+PassRefPtr<EventDispatchMediator> EventDispatchMediator::create(PassRefPtr<Event> event)
+{
+    return adoptRef(new EventDispatchMediator(event));
+}
+
 EventDispatchMediator::EventDispatchMediator(PassRefPtr<Event> event)
     : m_event(event)
 {
index c1d6d6f..008bb42 100644 (file)
@@ -199,14 +199,15 @@ namespace WebCore {
         RefPtr<Event> m_underlyingEvent;
     };
 
-class EventDispatchMediator {
+class EventDispatchMediator : public RefCounted<Event> {
 public:
-    explicit EventDispatchMediator(PassRefPtr<Event>);
+    static PassRefPtr<EventDispatchMediator> create(PassRefPtr<Event>);
     virtual ~EventDispatchMediator();
 
     virtual bool dispatchEvent(EventDispatcher*) const;
 
 protected:
+    explicit EventDispatchMediator(PassRefPtr<Event>);
     EventDispatchMediator();
 
     Event* event() const;
index aa71589..86b1b11 100644 (file)
@@ -46,12 +46,12 @@ namespace WebCore {
 
 static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0;
 
-bool EventDispatcher::dispatchEvent(Node* node, const EventDispatchMediator& mediator)
+bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<EventDispatchMediator> mediator)
 {
     ASSERT(!eventDispatchForbidden());
 
     EventDispatcher dispatcher(node);
-    return mediator.dispatchEvent(&dispatcher);
+    return mediator->dispatchEvent(&dispatcher);
 }
 
 static EventTarget* findElementInstance(Node* referenceNode)
index 1e51f98..e92402b 100644 (file)
@@ -48,8 +48,9 @@ enum EventDispatchBehavior {
 
 class EventDispatcher {
 public:
-    static bool dispatchEvent(Node*, const EventDispatchMediator&);
+    static bool dispatchEvent(Node*, PassRefPtr<EventDispatchMediator>);
     static void dispatchScopedEvent(Node*, PassRefPtr<Event>);
+    static void dispatchScopedEventDispatchMediator(Node*, PassRefPtr<EventDispatchMediator>);
 
     static void dispatchSimulatedClick(Node*, PassRefPtr<Event> underlyingEvent, bool sendMouseEvents, bool showPressedLook);
 
index b6ab1b6..1c8c9ea 100644 (file)
@@ -159,6 +159,11 @@ KeyboardEvent* findKeyboardEvent(Event* event)
     return 0;
 }
 
+PassRefPtr<KeyboardEventDispatchMediator> KeyboardEventDispatchMediator::create(PassRefPtr<KeyboardEvent> event)
+{
+    return adoptRef(new KeyboardEventDispatchMediator(event));
+}
+
 KeyboardEventDispatchMediator::KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent> event)
     : EventDispatchMediator(event)
 {
index 68910b5..1d0ab56 100644 (file)
@@ -117,9 +117,9 @@ namespace WebCore {
 
 class KeyboardEventDispatchMediator : public EventDispatchMediator {
 public:
-    explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>);
-
+    static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardEvent>);
 private:
+    explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>);
     virtual bool dispatchEvent(EventDispatcher*) const;
 };
 
index 2a6ed77..0e71ef5 100644 (file)
@@ -159,6 +159,11 @@ SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
     }
 }
 
+PassRefPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(PassRefPtr<MouseEvent> mouseEvent)
+{
+    return adoptRef(new MouseEventDispatchMediator(mouseEvent));
+}
+
 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtr<MouseEvent> mouseEvent)
     : EventDispatchMediator(mouseEvent)
 {
index bab2b42..8eb62d9 100644 (file)
@@ -100,9 +100,10 @@ private:
 
 class MouseEventDispatchMediator : public EventDispatchMediator {
 public:
-    explicit MouseEventDispatchMediator(PassRefPtr<MouseEvent>);
+    static PassRefPtr<MouseEventDispatchMediator> create(PassRefPtr<MouseEvent>);
 
 private:
+    explicit MouseEventDispatchMediator(PassRefPtr<MouseEvent>);
     MouseEvent* event() const;
 
     virtual bool dispatchEvent(EventDispatcher*) const;
index 2529321..ec813a3 100644 (file)
@@ -2714,7 +2714,7 @@ void Node::dispatchScopedEvent(PassRefPtr<Event> event)
 
 bool Node::dispatchEvent(PassRefPtr<Event> event)
 {
-    return EventDispatcher::dispatchEvent(this, EventDispatchMediator(event));
+    return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(event));
 }
 
 void Node::dispatchSubtreeModifiedEvent()
@@ -2746,13 +2746,13 @@ void Node::dispatchUIEvent(const AtomicString& eventType, int detail, PassRefPtr
 
 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event)
 {
-    return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator(KeyboardEvent::create(event, document()->defaultView())));
+    return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::create(KeyboardEvent::create(event, document()->defaultView())));
 }
 
 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicString& eventType,
     int detail, Node* relatedTarget)
 {
-    return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator(MouseEvent::create(eventType, document()->defaultView(), event, detail, relatedTarget)));
+    return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::create(MouseEvent::create(eventType, document()->defaultView(), event, detail, relatedTarget)));
 }
 
 void Node::dispatchSimulatedClick(PassRefPtr<Event> event, bool sendMouseEvents, bool showPressedLook)
@@ -2762,7 +2762,7 @@ void Node::dispatchSimulatedClick(PassRefPtr<Event> event, bool sendMouseEvents,
 
 bool Node::dispatchWheelEvent(const PlatformWheelEvent& event)
 {
-    return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator(event, document()->defaultView()));
+    return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document()->defaultView()));
 }
 
 void Node::dispatchFocusEvent()
index 573ea63..85b5622 100644 (file)
@@ -91,6 +91,11 @@ inline static WheelEvent::Granularity granularity(const PlatformWheelEvent& even
     return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::Page : WheelEvent::Pixel;
 }
 
+PassRefPtr<WheelEventDispatchMediator> WheelEventDispatchMediator::create(const PlatformWheelEvent& event, PassRefPtr<AbstractView> view)
+{
+    return adoptRef(new WheelEventDispatchMediator(event, view));
+}
+
 WheelEventDispatchMediator::WheelEventDispatchMediator(const PlatformWheelEvent& event, PassRefPtr<AbstractView> view)
 {
     if (!(event.deltaX() || event.deltaY()))
index 0f85912..2a92c2b 100644 (file)
@@ -83,9 +83,9 @@ namespace WebCore {
 
 class WheelEventDispatchMediator : public EventDispatchMediator {
 public:
-    WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
-
+    static PassRefPtr<WheelEventDispatchMediator> create(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
 private:
+    WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
     WheelEvent* event() const;
     virtual bool dispatchEvent(EventDispatcher*) const;
 };