Make EventDispatcher take an Event object in its constructor.
authorhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 07:57:37 +0000 (07:57 +0000)
committerhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 07:57:37 +0000 (07:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109898

Reviewed by Dimitri Glazkov.

Source/WebCore:

Re-landing r143145, which caused a crash when deltaX and deltaY of a PlatformWheelEvent are both zero.

Fixed a crash by early exiting in EventDispatcher::dispatchEvent(Node*, PassRefPtr<EventDispatcher*>)
if mediator's event() returns null.

Also Added a layout test to catch this kind of crash in the future.

Test: fast/events/platform-wheelevent-with-delta-zero-crash.html

* dom/EventDispatchMediator.cpp:
(WebCore::EventDispatchMediator::dispatchEvent):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):
(WebCore::EventDispatcher::EventDispatcher):
(WebCore::EventDispatcher::ensureEventPath):
(WebCore::EventDispatcher::dispatchSimulatedClick):
(WebCore::EventDispatcher::dispatch):
(WebCore::EventDispatcher::dispatchEventPreProcess):
(WebCore::EventDispatcher::dispatchEventAtCapturing):
(WebCore::EventDispatcher::dispatchEventAtTarget):
(WebCore::EventDispatcher::dispatchEventAtBubbling):
(WebCore::EventDispatcher::dispatchEventPostProcess):
* dom/EventDispatcher.h:
(EventDispatcher):
(WebCore::EventDispatcher::node):
(WebCore::EventDispatcher::event):
* dom/FocusEvent.cpp:
(WebCore::FocusEventDispatchMediator::dispatchEvent):
(WebCore::BlurEventDispatchMediator::dispatchEvent):
(WebCore::FocusInEventDispatchMediator::dispatchEvent):
(WebCore::FocusOutEventDispatchMediator::dispatchEvent):
* dom/GestureEvent.cpp:
(WebCore::GestureEventDispatchMediator::dispatchEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* dom/WheelEvent.cpp:
(WebCore::WheelEventDispatchMediator::dispatchEvent):
Assert event() rather than an early exit since this code path should be hit only when event() is non-null.

LayoutTests:

* fast/events/platform-wheelevent-with-delta-zero-crash-expected.txt: Added.
* fast/events/platform-wheelevent-with-delta-zero-crash.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/EventDispatchMediator.cpp
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/EventDispatcher.h
Source/WebCore/dom/FocusEvent.cpp
Source/WebCore/dom/GestureEvent.cpp
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/WheelEvent.cpp

index fcd9076..9a8fa87 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-18  Hayato Ito  <hayato@chromium.org>
+
+        Make EventDispatcher take an Event object in its constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=109898
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/events/platform-wheelevent-with-delta-zero-crash-expected.txt: Added.
+        * fast/events/platform-wheelevent-with-delta-zero-crash.html: Added.
+
 2013-02-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a flaky failing test expectation to inspector/editor/brace-matcher.html on Mac per bug 110186.
diff --git a/LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash-expected.txt b/LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash-expected.txt
new file mode 100644 (file)
index 0000000..76e8f97
--- /dev/null
@@ -0,0 +1,5 @@
+Ensures that a mouse scrolling with (deltaX=0, deltaY=0) doesn't crash the browser.
+
+Passes if doesn't crash.
+
+
diff --git a/LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash.html b/LayoutTests/fast/events/platform-wheelevent-with-delta-zero-crash.html
new file mode 100644 (file)
index 0000000..d86f242
--- /dev/null
@@ -0,0 +1,25 @@
+<html>
+<head>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function runTest()
+{
+    if (!window.eventSender)
+        return;
+    var area = document.getElementById('area');
+    var x = area.offsetLeft + area.offsetWidth / 2;
+    var y = area.offsetTop + area.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseScrollBy(0, 0);
+}
+</script>
+</head>
+<body onload="runTest()">
+    <p id="description">Ensures that a mouse scrolling with (deltaX=0, deltaY=0) doesn't crash the browser.
+    <p>Passes if doesn't crash.
+    <div id="area" style="width:100px;height:100px">
+    </div>
+</body>
+</html>
index 510a0b9..45ef4f1 100644 (file)
@@ -1,3 +1,49 @@
+2013-02-18  Hayato Ito  <hayato@chromium.org>
+
+        Make EventDispatcher take an Event object in its constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=109898
+
+        Reviewed by Dimitri Glazkov.
+
+        Re-landing r143145, which caused a crash when deltaX and deltaY of a PlatformWheelEvent are both zero.
+
+        Fixed a crash by early exiting in EventDispatcher::dispatchEvent(Node*, PassRefPtr<EventDispatcher*>)
+        if mediator's event() returns null.
+
+        Also Added a layout test to catch this kind of crash in the future.
+
+        Test: fast/events/platform-wheelevent-with-delta-zero-crash.html
+
+        * dom/EventDispatchMediator.cpp:
+        (WebCore::EventDispatchMediator::dispatchEvent):
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchEvent):
+        (WebCore::EventDispatcher::EventDispatcher):
+        (WebCore::EventDispatcher::ensureEventPath):
+        (WebCore::EventDispatcher::dispatchSimulatedClick):
+        (WebCore::EventDispatcher::dispatch):
+        (WebCore::EventDispatcher::dispatchEventPreProcess):
+        (WebCore::EventDispatcher::dispatchEventAtCapturing):
+        (WebCore::EventDispatcher::dispatchEventAtTarget):
+        (WebCore::EventDispatcher::dispatchEventAtBubbling):
+        (WebCore::EventDispatcher::dispatchEventPostProcess):
+        * dom/EventDispatcher.h:
+        (EventDispatcher):
+        (WebCore::EventDispatcher::node):
+        (WebCore::EventDispatcher::event):
+        * dom/FocusEvent.cpp:
+        (WebCore::FocusEventDispatchMediator::dispatchEvent):
+        (WebCore::BlurEventDispatchMediator::dispatchEvent):
+        (WebCore::FocusInEventDispatchMediator::dispatchEvent):
+        (WebCore::FocusOutEventDispatchMediator::dispatchEvent):
+        * dom/GestureEvent.cpp:
+        (WebCore::GestureEventDispatchMediator::dispatchEvent):
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEventDispatchMediator::dispatchEvent):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEventDispatchMediator::dispatchEvent):
+        Assert event() rather than an early exit since this code path should be hit only when event() is non-null.
+
 2013-02-18  Takashi Sakamoto  <tasak@google.com>
 
         :before/:after pseudo elements do not always apply to the proper element
index a309c69..a3ca4c8 100644 (file)
@@ -50,7 +50,8 @@ EventDispatchMediator::EventDispatchMediator(PassRefPtr<Event> event)
 
 bool EventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    return dispatcher->dispatchEvent(m_event.get());
+    ASSERT(m_event.get() == dispatcher->event());
+    return dispatcher->dispatch();
 }
 
 } // namespace WebCore
index 4c6c835..feb017e 100644 (file)
@@ -50,28 +50,32 @@ static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0;
 bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<EventDispatchMediator> mediator)
 {
     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
-
-    EventDispatcher dispatcher(node);
+    if (!mediator->event())
+        return true;
+    EventDispatcher dispatcher(node, mediator->event());
     return mediator->dispatchEvent(&dispatcher);
 }
 
-EventDispatcher::EventDispatcher(Node* node)
+EventDispatcher::EventDispatcher(Node* node, PassRefPtr<Event> event)
     : m_node(node)
+    , m_event(event)
     , m_eventPathInitialized(false)
 #ifndef NDEBUG
     , m_eventDispatched(false)
 #endif
 {
     ASSERT(node);
+    ASSERT(m_event.get());
+    ASSERT(!m_event->type().isNull()); // JavaScript code can create an event with an empty name, but not null.
     m_view = node->document()->view();
 }
 
-EventPath& EventDispatcher::ensureEventPath(Event* event)
+EventPath& EventDispatcher::ensureEventPath()
 {
     if (m_eventPathInitialized)
         return m_eventPath;
     m_eventPathInitialized = true;
-    EventRetargeter::calculateEventPath(m_node.get(), event, m_eventPath);
+    EventRetargeter::calculateEventPath(m_node.get(), m_event.get(), m_eventPath);
     return m_eventPath;
 }
 
@@ -95,140 +99,138 @@ void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent,
     gNodesDispatchingSimulatedClicks->add(node);
 
     if (mouseEventOptions == SendMouseOverUpDownEvents)
-        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mouseoverEvent, node->document()->defaultView(), underlyingEvent));
+        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseoverEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
 
     if (mouseEventOptions != SendNoEvents)
-        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mousedownEvent, node->document()->defaultView(), underlyingEvent));
+        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mousedownEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     node->setActive(true, visualOptions == ShowPressedLook);
     if (mouseEventOptions != SendNoEvents)
-        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mouseupEvent, node->document()->defaultView(), underlyingEvent));
+        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseupEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     node->setActive(false);
 
     // always send click
-    EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().clickEvent, node->document()->defaultView(), underlyingEvent));
+    EventDispatcher(node, SimulatedMouseEvent::create(eventNames().clickEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
 
     gNodesDispatchingSimulatedClicks->remove(node);
 }
 
-bool EventDispatcher::dispatchEvent(PassRefPtr<Event> prpEvent)
+bool EventDispatcher::dispatch()
 {
 #ifndef NDEBUG
     ASSERT(!m_eventDispatched);
     m_eventDispatched = true;
 #endif
-    RefPtr<Event> event = prpEvent;
     ChildNodesLazySnapshot::takeChildNodesLazySnapshot();
 
-    event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
+    m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
-    ASSERT(event->target());
-    ASSERT(!event->type().isNull()); // JavaScript code can create an event with an empty name, but not null.
-    ensureEventPath(event.get());
-    WindowEventContext windowEventContext(event.get(), m_node.get(), topEventContext());
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(m_node->document(), *event, windowEventContext.window(), m_node.get(), m_eventPath);
+    ASSERT(m_event->target());
+    ensureEventPath();
+    WindowEventContext windowEventContext(m_event.get(), m_node.get(), topEventContext());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(m_node->document(), *m_event, windowEventContext.window(), m_node.get(), m_eventPath);
 
     void* preDispatchEventHandlerResult;
-    if (dispatchEventPreProcess(event, preDispatchEventHandlerResult) == ContinueDispatching)
-        if (dispatchEventAtCapturing(event, windowEventContext) == ContinueDispatching)
-            if (dispatchEventAtTarget(event) == ContinueDispatching)
-                dispatchEventAtBubbling(event, windowEventContext);
-    dispatchEventPostProcess(event, preDispatchEventHandlerResult);
+    if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispatching)
+        if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching)
+            if (dispatchEventAtTarget() == ContinueDispatching)
+                dispatchEventAtBubbling(windowEventContext);
+    dispatchEventPostProcess(preDispatchEventHandlerResult);
 
     // Ensure that after event dispatch, the event's target object is the
     // outermost shadow DOM boundary.
-    event->setTarget(windowEventContext.target());
-    event->setCurrentTarget(0);
+    m_event->setTarget(windowEventContext.target());
+    m_event->setCurrentTarget(0);
     InspectorInstrumentation::didDispatchEvent(cookie);
 
-    return !event->defaultPrevented();
+    return !m_event->defaultPrevented();
 }
 
-inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(PassRefPtr<Event> event, void*& preDispatchEventHandlerResult)
+inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*& preDispatchEventHandlerResult)
 {
     // Give the target node a chance to do some work before DOM event handlers get a crack.
-    preDispatchEventHandlerResult = m_node->preDispatchEventHandler(event.get());
-    return (m_eventPath.isEmpty() || event->propagationStopped()) ? DoneDispatching : ContinueDispatching;
+    preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get());
+    return (m_eventPath.isEmpty() || m_event->propagationStopped()) ? DoneDispatching : ContinueDispatching;
 }
 
-inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(PassRefPtr<Event> event, WindowEventContext& windowEventContext)
+inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(WindowEventContext& windowEventContext)
 {
     // Trigger capturing event handlers, starting at the top and working our way down.
-    event->setEventPhase(Event::CAPTURING_PHASE);
+    m_event->setEventPhase(Event::CAPTURING_PHASE);
 
-    if (windowEventContext.handleLocalEvents(event.get()) && event->propagationStopped())
+    if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagationStopped())
         return DoneDispatching;
 
     for (size_t i = m_eventPath.size() - 1; i > 0; --i) {
         const EventContext& eventContext = *m_eventPath[i];
         if (eventContext.currentTargetSameAsTarget()) {
-            if (event->bubbles())
+            if (m_event->bubbles())
                 continue;
-            event->setEventPhase(Event::AT_TARGET);
+            m_event->setEventPhase(Event::AT_TARGET);
         } else
-            event->setEventPhase(Event::CAPTURING_PHASE);
-        eventContext.handleLocalEvents(event.get());
-        if (event->propagationStopped())
+            m_event->setEventPhase(Event::CAPTURING_PHASE);
+        eventContext.handleLocalEvents(m_event.get());
+        if (m_event->propagationStopped())
             return DoneDispatching;
     }
 
     return ContinueDispatching;
 }
 
-inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget(PassRefPtr<Event> event)
+inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget()
 {
-    event->setEventPhase(Event::AT_TARGET);
-    m_eventPath[0]->handleLocalEvents(event.get());
-    return event->propagationStopped() ? DoneDispatching : ContinueDispatching;
+    m_event->setEventPhase(Event::AT_TARGET);
+    m_eventPath[0]->handleLocalEvents(m_event.get());
+    return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching;
 }
 
-inline EventDispatchContinuation EventDispatcher::dispatchEventAtBubbling(PassRefPtr<Event> event, WindowEventContext& windowContext)
+inline EventDispatchContinuation EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowContext)
 {
-    if (event->bubbles() && !event->cancelBubble()) {
+    if (m_event->bubbles() && !m_event->cancelBubble()) {
         // Trigger bubbling event handlers, starting at the bottom and working our way up.
-        event->setEventPhase(Event::BUBBLING_PHASE);
+        m_event->setEventPhase(Event::BUBBLING_PHASE);
 
         size_t size = m_eventPath.size();
         for (size_t i = 1; i < size; ++i) {
             const EventContext& eventContext = *m_eventPath[i];
             if (eventContext.currentTargetSameAsTarget())
-                event->setEventPhase(Event::AT_TARGET);
+                m_event->setEventPhase(Event::AT_TARGET);
             else
-                event->setEventPhase(Event::BUBBLING_PHASE);
-            eventContext.handleLocalEvents(event.get());
-            if (event->propagationStopped() || event->cancelBubble())
+                m_event->setEventPhase(Event::BUBBLING_PHASE);
+            eventContext.handleLocalEvents(m_event.get());
+            if (m_event->propagationStopped() || m_event->cancelBubble())
                 return DoneDispatching;
         }
-        windowContext.handleLocalEvents(event.get());
+        windowContext.handleLocalEvents(m_event.get());
     }
     return ContinueDispatching;
 }
 
-inline void EventDispatcher::dispatchEventPostProcess(PassRefPtr<Event> event, void* preDispatchEventHandlerResult)
+inline void EventDispatcher::dispatchEventPostProcess(void* preDispatchEventHandlerResult)
 {
-    event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
-    event->setCurrentTarget(0);
-    event->setEventPhase(0);
+    m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
+    m_event->setCurrentTarget(0);
+    m_event->setEventPhase(0);
 
     // Pass the data from the preDispatchEventHandler to the postDispatchEventHandler.
-    m_node->postDispatchEventHandler(event.get(), preDispatchEventHandlerResult);
+    m_node->postDispatchEventHandler(m_event.get(), preDispatchEventHandlerResult);
 
     // Call default event handlers. While the DOM does have a concept of preventing
     // default handling, the detail of which handlers are called is an internal
     // implementation detail and not part of the DOM.
-    if (!event->defaultPrevented() && !event->defaultHandled()) {
+    if (!m_event->defaultPrevented() && !m_event->defaultHandled()) {
         // Non-bubbling events call only one default event handler, the one for the target.
-        m_node->defaultEventHandler(event.get());
-        ASSERT(!event->defaultPrevented());
-        if (event->defaultHandled())
+        m_node->defaultEventHandler(m_event.get());
+        ASSERT(!m_event->defaultPrevented());
+        if (m_event->defaultHandled())
             return;
         // For bubbling events, call default event handlers on the same targets in the
         // same order as the bubbling phase.
-        if (event->bubbles()) {
+        if (m_event->bubbles()) {
             size_t size = m_eventPath.size();
             for (size_t i = 1; i < size; ++i) {
-                m_eventPath[i]->node()->defaultEventHandler(event.get());
-                ASSERT(!event->defaultPrevented());
-                if (event->defaultHandled())
+                m_eventPath[i]->node()->defaultEventHandler(m_event.get());
+                ASSERT(!m_event->defaultPrevented());
+                if (m_event->defaultHandled())
                     return;
             }
         }
index 992ead8..f002f75 100644 (file)
@@ -30,6 +30,7 @@
 #include "SimulatedClickOptions.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -57,22 +58,24 @@ public:
 
     static void dispatchSimulatedClick(Node*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
 
-    bool dispatchEvent(PassRefPtr<Event>);
-    Node* node() const;
-    EventPath& ensureEventPath(Event*);
+    bool dispatch();
+    Node* node() const { return m_node.get(); }
+    Event* event() const { return m_event.get(); }
+    EventPath& ensureEventPath();
 
 private:
-    EventDispatcher(Node*);
+    EventDispatcher(Node*, PassRefPtr<Event>);
     const EventContext* topEventContext();
 
-    EventDispatchContinuation dispatchEventPreProcess(PassRefPtr<Event>, void*& preDispatchEventHandlerResult);
-    EventDispatchContinuation dispatchEventAtCapturing(PassRefPtr<Event>, WindowEventContext&);
-    EventDispatchContinuation dispatchEventAtTarget(PassRefPtr<Event>);
-    EventDispatchContinuation dispatchEventAtBubbling(PassRefPtr<Event>, WindowEventContext&);
-    void dispatchEventPostProcess(PassRefPtr<Event>, void* preDispatchEventHandlerResult);
+    EventDispatchContinuation dispatchEventPreProcess(void*& preDispatchEventHandlerResult);
+    EventDispatchContinuation dispatchEventAtCapturing(WindowEventContext&);
+    EventDispatchContinuation dispatchEventAtTarget();
+    EventDispatchContinuation dispatchEventAtBubbling(WindowEventContext&);
+    void dispatchEventPostProcess(void* preDispatchEventHandlerResult);
 
     EventPath m_eventPath;
     RefPtr<Node> m_node;
+    RefPtr<Event> m_event;
     RefPtr<FrameView> m_view;
     bool m_eventPathInitialized;
 #ifndef NDEBUG
@@ -80,11 +83,6 @@ private:
 #endif
 };
 
-inline Node* EventDispatcher::node() const
-{
-    return m_node.get();
-}
-
 }
 
 #endif
index 15ba401..473f71e 100644 (file)
@@ -77,7 +77,7 @@ FocusEventDispatchMediator::FocusEventDispatchMediator(PassRefPtr<FocusEvent> fo
 
 bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
+    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     return EventDispatchMediator::dispatchEvent(dispatcher);
 }
 
@@ -93,7 +93,7 @@ BlurEventDispatchMediator::BlurEventDispatchMediator(PassRefPtr<FocusEvent> focu
 
 bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
+    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     return EventDispatchMediator::dispatchEvent(dispatcher);
 }
 
@@ -109,7 +109,7 @@ FocusInEventDispatchMediator::FocusInEventDispatchMediator(PassRefPtr<FocusEvent
 
 bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
+    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     return EventDispatchMediator::dispatchEvent(dispatcher);
 }
 
@@ -125,7 +125,7 @@ FocusOutEventDispatchMediator::FocusOutEventDispatchMediator(PassRefPtr<FocusEve
 
 bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
+    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     return EventDispatchMediator::dispatchEvent(dispatcher);
 }
 
index 3536607..e0671f8 100644 (file)
@@ -122,7 +122,7 @@ bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) co
     if (dispatcher->node()->disabled())
         return true;
 
-    dispatcher->dispatchEvent(event());
+    dispatcher->dispatch();
     ASSERT(!event()->defaultPrevented());
     return event()->defaultHandled() || event()->defaultPrevented();
 }
index d592ca9..e70de35 100644 (file)
@@ -262,8 +262,8 @@ MouseEvent* MouseEventDispatchMediator::event() const
 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
     if (isSyntheticMouseEvent()) {
-        EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath(event()));
-        return dispatcher->dispatchEvent(event());
+        EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath());
+        return dispatcher->dispatch();
     }
 
     if (dispatcher->node()->disabled()) // Don't even send DOM events for disabled controls..
@@ -275,9 +275,9 @@ bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons
     ASSERT(!event()->target() || event()->target() != event()->relatedTarget());
 
     EventTarget* relatedTarget = event()->relatedTarget();
-    EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath(event()));
+    EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath());
 
-    dispatcher->dispatchEvent(event());
+    dispatcher->dispatch();
     bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented();
 
     if (event()->type() != eventNames().clickEvent || event()->detail() != 2)
index dfc45d1..d01168d 100644 (file)
@@ -138,9 +138,7 @@ WheelEvent* WheelEventDispatchMediator::event() const
 
 bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
-    if (!event())
-        return true;
-
+    ASSERT(event());
     return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->defaultHandled();
 }