Remove all subclasses of EventDispatchMediator except MouseEventDispatchMediator
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Oct 2013 23:49:21 +0000 (23:49 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Oct 2013 23:49:21 +0000 (23:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122579

Reviewed by Antti Koivisto.

Removed UIRequestEventDispatchMediator, GestureEventDispatchMediator, KeyboardEventDispatchMediator,
and WheelEventDispatchMediator. Moved the code in the respective mediateAndDispatchEvent functions
to their respective dispatch*Event functions in Node.cpp and Element.cpp.

* Modules/indieui/UIRequestEvent.cpp:
(WebCore::UIRequestEvent::eventInterface):
* Modules/indieui/UIRequestEvent.h:
* dom/Element.cpp:
(WebCore::deltaMode):
(WebCore::Element::dispatchWheelEvent):
(WebCore::Element::dispatchKeyEvent):
* dom/GestureEvent.cpp:
* dom/GestureEvent.h:
* dom/KeyboardEvent.cpp:
* dom/KeyboardEvent.h:
* dom/Node.cpp:
(WebCore::Node::dispatchGestureEvent):
(WebCore::Node::dispatchUIRequestEvent):
* dom/WheelEvent.cpp:
* dom/WheelEvent.h:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indieui/UIRequestEvent.cpp
Source/WebCore/Modules/indieui/UIRequestEvent.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/GestureEvent.cpp
Source/WebCore/dom/GestureEvent.h
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h

index 60c1bc4..a18ecad 100644 (file)
@@ -1,3 +1,31 @@
+2013-10-09  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Remove all subclasses of EventDispatchMediator except MouseEventDispatchMediator
+        https://bugs.webkit.org/show_bug.cgi?id=122579
+
+        Reviewed by Antti Koivisto.
+
+        Removed UIRequestEventDispatchMediator, GestureEventDispatchMediator, KeyboardEventDispatchMediator,
+        and WheelEventDispatchMediator. Moved the code in the respective mediateAndDispatchEvent functions
+        to their respective dispatch*Event functions in Node.cpp and Element.cpp.
+
+        * Modules/indieui/UIRequestEvent.cpp:
+        (WebCore::UIRequestEvent::eventInterface):
+        * Modules/indieui/UIRequestEvent.h:
+        * dom/Element.cpp:
+        (WebCore::deltaMode):
+        (WebCore::Element::dispatchWheelEvent):
+        (WebCore::Element::dispatchKeyEvent):
+        * dom/GestureEvent.cpp:
+        * dom/GestureEvent.h:
+        * dom/KeyboardEvent.cpp:
+        * dom/KeyboardEvent.h:
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchGestureEvent):
+        (WebCore::Node::dispatchUIRequestEvent):
+        * dom/WheelEvent.cpp:
+        * dom/WheelEvent.h:
+
 2013-10-09  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         [CSS Shapes] Lines that don't intersect shape-outside should ignore both left and right margins
index a9bb4c1..5809ac3 100644 (file)
@@ -73,27 +73,11 @@ UIRequestEvent::UIRequestEvent()
 UIRequestEvent::~UIRequestEvent()
 {
 }
-    
+
 EventInterface UIRequestEvent::eventInterface() const
 {
     return UIRequestEventInterfaceType;
 }
-
-UIRequestEventDispatchMediator::UIRequestEventDispatchMediator(PassRefPtr<UIRequestEvent> event)
-    : EventDispatchMediator(event)
-{
-}
-
-UIRequestEvent* UIRequestEventDispatchMediator::event() const
-{
-    return static_cast<UIRequestEvent*>(EventDispatchMediator::event());
-}
-
-bool UIRequestEventDispatchMediator::mediateAndDispatchEvent(EventDispatcher* dispatcher) const
-{
-    dispatcher->dispatch();
-    return event()->defaultHandled() || event()->defaultPrevented();
-}
     
 } // namespace WebCore
 
index ef827a0..93b0a2f 100644 (file)
@@ -63,21 +63,6 @@ private:
     RefPtr<EventTarget> m_receiver;
 };
 
-class UIRequestEventDispatchMediator : public EventDispatchMediator {
-public:
-    static PassRefPtr<UIRequestEventDispatchMediator> create(PassRefPtr<UIRequestEvent> event)
-    {
-        return adoptRef(new UIRequestEventDispatchMediator(event));
-    }
-    
-private:
-    explicit UIRequestEventDispatchMediator(PassRefPtr<UIRequestEvent>);
-    
-    UIRequestEvent* event() const;
-    
-    virtual bool mediateAndDispatchEvent(EventDispatcher*) const OVERRIDE;
-};
-    
 } // namespace WebCore
 
 #endif // ENABLE(INDIE_UI)
index b575765..b0f0a5e 100644 (file)
@@ -72,6 +72,7 @@
 #include "NodeList.h"
 #include "NodeRenderStyle.h"
 #include "Page.h"
+#include "PlatformWheelEvent.h"
 #include "PointerLockController.h"
 #include "PseudoElement.h"
 #include "RenderRegion.h"
@@ -245,14 +246,34 @@ bool Element::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicSt
     return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::create(MouseEvent::create(eventType, document().defaultView(), event, detail, relatedTarget)));
 }
 
+inline static unsigned deltaMode(const PlatformWheelEvent& event)
+{
+    return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::DOM_DELTA_PAGE : WheelEvent::DOM_DELTA_PIXEL;
+}
+
 bool Element::dispatchWheelEvent(const PlatformWheelEvent& event)
 {
-    return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document().defaultView()));
+    if (!(event.deltaX() || event.deltaY()))
+        return true;
+
+    RefPtr<WheelEvent> wheelEvent = WheelEvent::create(
+        FloatPoint(event.wheelTicksX(), event.wheelTicksY()),
+        FloatPoint(event.deltaX(), event.deltaY()),
+        deltaMode(event),
+        document().defaultView(),
+        event.globalPosition(),
+        event.position(),
+        event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(),
+        event.directionInvertedFromDevice(),
+        event.timestamp());
+
+    return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(wheelEvent)) && !wheelEvent->defaultHandled();
 }
 
-bool Element::dispatchKeyEvent(const PlatformKeyboardEvent& event)
+bool Element::dispatchKeyEvent(const PlatformKeyboardEvent& platformEvent)
 {
-    return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::create(KeyboardEvent::create(event, document().defaultView())));
+    RefPtr<KeyboardEvent> event = KeyboardEvent::create(platformEvent, document().defaultView());
+    return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(event)) && !event->defaultHandled();
 }
 
 void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
index 47502f0..d688e65 100644 (file)
@@ -105,26 +105,6 @@ GestureEvent::GestureEvent(const AtomicString& type, double timestamp, PassRefPt
 {
 }
 
-GestureEventDispatchMediator::GestureEventDispatchMediator(PassRefPtr<GestureEvent> gestureEvent)
-    : EventDispatchMediator(gestureEvent)
-{
-}
-
-GestureEvent* GestureEventDispatchMediator::event() const
-{
-    return static_cast<GestureEvent*>(EventDispatchMediator::event());
-}
-
-bool GestureEventDispatchMediator::mediateAndDispatchEvent(EventDispatcher* dispatcher) const
-{
-    if (isDisabledFormControl(dispatcher->node()))
-        return true;
-
-    dispatcher->dispatch();
-    ASSERT(!event()->defaultPrevented());
-    return event()->defaultHandled() || event()->defaultPrevented();
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(GESTURE_EVENTS)
index fb0d2bd..e34e74e 100644 (file)
@@ -61,21 +61,6 @@ private:
     float m_deltaY;
 };
 
-class GestureEventDispatchMediator : public EventDispatchMediator {
-public:
-    static PassRefPtr<GestureEventDispatchMediator> create(PassRefPtr<GestureEvent> gestureEvent)
-    {
-        return adoptRef(new GestureEventDispatchMediator(gestureEvent));
-    }
-
-private:
-    explicit GestureEventDispatchMediator(PassRefPtr<GestureEvent>);
-
-    GestureEvent* event() const;
-
-    virtual bool mediateAndDispatchEvent(EventDispatcher*) const OVERRIDE;
-};
-
 } // namespace WebCore
 
 #endif // ENABLE(GESTURE_EVENTS)
index d722d57..c16433c 100644 (file)
@@ -213,20 +213,4 @@ 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)
-{
-}
-
-bool KeyboardEventDispatchMediator::mediateAndDispatchEvent(EventDispatcher* dispatcher) const
-{
-    // Make sure not to return true if we already took default action while handling the event.
-    return EventDispatchMediator::mediateAndDispatchEvent(dispatcher) && !event()->defaultHandled();
-}
-
 } // namespace WebCore
index 38442be..3ec2371 100644 (file)
@@ -128,14 +128,6 @@ private:
 
 KeyboardEvent* findKeyboardEvent(Event*);
 
-class KeyboardEventDispatchMediator : public EventDispatchMediator {
-public:
-    static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardEvent>);
-private:
-    explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>);
-    virtual bool mediateAndDispatchEvent(EventDispatcher*) const OVERRIDE;
-};
-
 } // namespace WebCore
 
 #endif // KeyboardEvent_h
index 7c73910..e330ca6 100644 (file)
@@ -2111,7 +2111,14 @@ bool Node::dispatchGestureEvent(const PlatformGestureEvent& event)
     RefPtr<GestureEvent> gestureEvent = GestureEvent::create(document().defaultView(), event);
     if (!gestureEvent.get())
         return false;
-    return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::create(gestureEvent));
+
+    if (isDisabledFormControl(this))
+        return true;
+
+    EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(gestureEvent));
+
+    ASSERT(!gestureEvent->defaultPrevented());
+    return gestureEvent->defaultHandled() || gestureEvent->defaultPrevented();
 }
 #endif
 
@@ -2125,7 +2132,8 @@ bool Node::dispatchTouchEvent(PassRefPtr<TouchEvent> event)
 #if ENABLE(INDIE_UI)
 bool Node::dispatchUIRequestEvent(PassRefPtr<UIRequestEvent> event)
 {
-    return EventDispatcher::dispatchEvent(this, UIRequestEventDispatchMediator::create(event));
+    EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(event));
+    return event->defaultHandled() || event->defaultPrevented();
 }
 #endif
     
index 2fb52f6..a9acbb7 100644 (file)
@@ -125,35 +125,4 @@ bool WheelEvent::isMouseEvent() const
     return false;
 }
 
-inline static unsigned deltaMode(const PlatformWheelEvent& event)
-{
-    return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::DOM_DELTA_PAGE : WheelEvent::DOM_DELTA_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()))
-        return;
-
-    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()),
-        deltaMode(event), view, event.globalPosition(), event.position(),
-        event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.directionInvertedFromDevice(), event.timestamp()));
-}
-
-WheelEvent* WheelEventDispatchMediator::event() const
-{
-    return static_cast<WheelEvent*>(EventDispatchMediator::event());
-}
-
-bool WheelEventDispatchMediator::mediateAndDispatchEvent(EventDispatcher* dispatcher) const
-{
-    ASSERT(event());
-    return EventDispatchMediator::mediateAndDispatchEvent(dispatcher) && !event()->defaultHandled();
-}
-
 } // namespace WebCore
index aa7a1a5..5c1c105 100644 (file)
@@ -111,15 +111,6 @@ private:
     bool m_directionInvertedFromDevice;
 };
 
-class WheelEventDispatchMediator : public EventDispatchMediator {
-public:
-    static PassRefPtr<WheelEventDispatchMediator> create(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
-private:
-    WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
-    WheelEvent* event() const;
-    virtual bool mediateAndDispatchEvent(EventDispatcher*) const OVERRIDE;
-};
-
 } // namespace WebCore
 
 #endif // WheelEvent_h