Changeset 143244 in webkit


Ignore:
Timestamp:
Feb 18, 2013 11:07:50 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r143145.
http://trac.webkit.org/changeset/143145
https://bugs.webkit.org/show_bug.cgi?id=110143

Causes frequent crashes. (Requested by eric_carlson on
#webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-02-18

  • dom/EventDispatchMediator.cpp:

(WebCore::EventDispatchMediator::dispatchEvent):

  • dom/EventDispatcher.cpp:

(WebCore::EventDispatcher::dispatchEvent):
(WebCore::EventDispatcher::EventDispatcher):
(WebCore::EventDispatcher::ensureEventPath):
(WebCore::EventDispatcher::dispatchSimulatedClick):
(WebCore::EventDispatcher::dispatchEventPreProcess):
(WebCore::EventDispatcher::dispatchEventAtCapturing):
(WebCore::EventDispatcher::dispatchEventAtTarget):
(WebCore::EventDispatcher::dispatchEventAtBubbling):
(WebCore::EventDispatcher::dispatchEventPostProcess):

  • dom/EventDispatcher.h:

(EventDispatcher):
(WebCore::EventDispatcher::node):
(WebCore):

  • 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):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143243 r143244  
     12013-02-18  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r143145.
     4        http://trac.webkit.org/changeset/143145
     5        https://bugs.webkit.org/show_bug.cgi?id=110143
     6
     7        Causes frequent crashes. (Requested by eric_carlson on
     8        #webkit).
     9
     10        * dom/EventDispatchMediator.cpp:
     11        (WebCore::EventDispatchMediator::dispatchEvent):
     12        * dom/EventDispatcher.cpp:
     13        (WebCore::EventDispatcher::dispatchEvent):
     14        (WebCore::EventDispatcher::EventDispatcher):
     15        (WebCore::EventDispatcher::ensureEventPath):
     16        (WebCore::EventDispatcher::dispatchSimulatedClick):
     17        (WebCore::EventDispatcher::dispatchEventPreProcess):
     18        (WebCore::EventDispatcher::dispatchEventAtCapturing):
     19        (WebCore::EventDispatcher::dispatchEventAtTarget):
     20        (WebCore::EventDispatcher::dispatchEventAtBubbling):
     21        (WebCore::EventDispatcher::dispatchEventPostProcess):
     22        * dom/EventDispatcher.h:
     23        (EventDispatcher):
     24        (WebCore::EventDispatcher::node):
     25        (WebCore):
     26        * dom/FocusEvent.cpp:
     27        (WebCore::FocusEventDispatchMediator::dispatchEvent):
     28        (WebCore::BlurEventDispatchMediator::dispatchEvent):
     29        (WebCore::FocusInEventDispatchMediator::dispatchEvent):
     30        (WebCore::FocusOutEventDispatchMediator::dispatchEvent):
     31        * dom/GestureEvent.cpp:
     32        (WebCore::GestureEventDispatchMediator::dispatchEvent):
     33        * dom/MouseEvent.cpp:
     34        (WebCore::MouseEventDispatchMediator::dispatchEvent):
     35
    1362013-02-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    237
  • trunk/Source/WebCore/dom/EventDispatchMediator.cpp

    r143145 r143244  
    5151bool EventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
    5252{
    53     ASSERT(m_event.get() == dispatcher->event());
    54     return dispatcher->dispatch();
     53    return dispatcher->dispatchEvent(m_event.get());
    5554}
    5655
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r143145 r143244  
    5252    ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
    5353
    54     EventDispatcher dispatcher(node, mediator->event());
     54    EventDispatcher dispatcher(node);
    5555    return mediator->dispatchEvent(&dispatcher);
    5656}
    5757
    58 EventDispatcher::EventDispatcher(Node* node, PassRefPtr<Event> event)
     58EventDispatcher::EventDispatcher(Node* node)
    5959    : m_node(node)
    60     , m_event(event)
    6160    , m_eventPathInitialized(false)
    6261#ifndef NDEBUG
     
    6564{
    6665    ASSERT(node);
    67     ASSERT(m_event.get());
    68     ASSERT(!m_event->type().isNull()); // JavaScript code can create an event with an empty name, but not null.
    6966    m_view = node->document()->view();
    7067}
    7168
    72 EventPath& EventDispatcher::ensureEventPath()
     69EventPath& EventDispatcher::ensureEventPath(Event* event)
    7370{
    7471    if (m_eventPathInitialized)
    7572        return m_eventPath;
    7673    m_eventPathInitialized = true;
    77     EventRetargeter::calculateEventPath(m_node.get(), m_event.get(), m_eventPath);
     74    EventRetargeter::calculateEventPath(m_node.get(), event, m_eventPath);
    7875    return m_eventPath;
    7976}
     
    9996
    10097    if (mouseEventOptions == SendMouseOverUpDownEvents)
    101         EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseoverEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     98        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mouseoverEvent, node->document()->defaultView(), underlyingEvent));
    10299
    103100    if (mouseEventOptions != SendNoEvents)
    104         EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mousedownEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     101        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mousedownEvent, node->document()->defaultView(), underlyingEvent));
    105102    node->setActive(true, visualOptions == ShowPressedLook);
    106103    if (mouseEventOptions != SendNoEvents)
    107         EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseupEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     104        EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().mouseupEvent, node->document()->defaultView(), underlyingEvent));
    108105    node->setActive(false);
    109106
    110107    // always send click
    111     EventDispatcher(node, SimulatedMouseEvent::create(eventNames().clickEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
     108    EventDispatcher(node).dispatchEvent(SimulatedMouseEvent::create(eventNames().clickEvent, node->document()->defaultView(), underlyingEvent));
    112109
    113110    gNodesDispatchingSimulatedClicks->remove(node);
    114111}
    115112
    116 bool EventDispatcher::dispatch()
     113bool EventDispatcher::dispatchEvent(PassRefPtr<Event> prpEvent)
    117114{
    118115#ifndef NDEBUG
     
    120117    m_eventDispatched = true;
    121118#endif
     119    RefPtr<Event> event = prpEvent;
    122120    ChildNodesLazySnapshot::takeChildNodesLazySnapshot();
    123121
    124     m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
     122    event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
    125123    ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
    126     ASSERT(m_event->target());
    127     ensureEventPath();
    128     WindowEventContext windowEventContext(m_event.get(), m_node.get(), topEventContext());
    129     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(m_node->document(), *m_event, windowEventContext.window(), m_node.get(), m_eventPath);
     124    ASSERT(event->target());
     125    ASSERT(!event->type().isNull()); // JavaScript code can create an event with an empty name, but not null.
     126    ensureEventPath(event.get());
     127    WindowEventContext windowEventContext(event.get(), m_node.get(), topEventContext());
     128    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(m_node->document(), *event, windowEventContext.window(), m_node.get(), m_eventPath);
    130129
    131130    void* preDispatchEventHandlerResult;
    132     if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispatching)
    133         if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching)
    134             if (dispatchEventAtTarget() == ContinueDispatching)
    135                 dispatchEventAtBubbling(windowEventContext);
    136     dispatchEventPostProcess(preDispatchEventHandlerResult);
     131    if (dispatchEventPreProcess(event, preDispatchEventHandlerResult) == ContinueDispatching)
     132        if (dispatchEventAtCapturing(event, windowEventContext) == ContinueDispatching)
     133            if (dispatchEventAtTarget(event) == ContinueDispatching)
     134                dispatchEventAtBubbling(event, windowEventContext);
     135    dispatchEventPostProcess(event, preDispatchEventHandlerResult);
    137136
    138137    // Ensure that after event dispatch, the event's target object is the
    139138    // outermost shadow DOM boundary.
    140     m_event->setTarget(windowEventContext.target());
    141     m_event->setCurrentTarget(0);
     139    event->setTarget(windowEventContext.target());
     140    event->setCurrentTarget(0);
    142141    InspectorInstrumentation::didDispatchEvent(cookie);
    143142
    144     return !m_event->defaultPrevented();
    145 }
    146 
    147 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*& preDispatchEventHandlerResult)
     143    return !event->defaultPrevented();
     144}
     145
     146inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(PassRefPtr<Event> event, void*& preDispatchEventHandlerResult)
    148147{
    149148    // Give the target node a chance to do some work before DOM event handlers get a crack.
    150     preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get());
    151     return (m_eventPath.isEmpty() || m_event->propagationStopped()) ? DoneDispatching : ContinueDispatching;
    152 }
    153 
    154 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(WindowEventContext& windowEventContext)
     149    preDispatchEventHandlerResult = m_node->preDispatchEventHandler(event.get());
     150    return (m_eventPath.isEmpty() || event->propagationStopped()) ? DoneDispatching : ContinueDispatching;
     151}
     152
     153inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(PassRefPtr<Event> event, WindowEventContext& windowEventContext)
    155154{
    156155    // Trigger capturing event handlers, starting at the top and working our way down.
    157     m_event->setEventPhase(Event::CAPTURING_PHASE);
    158 
    159     if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagationStopped())
     156    event->setEventPhase(Event::CAPTURING_PHASE);
     157
     158    if (windowEventContext.handleLocalEvents(event.get()) && event->propagationStopped())
    160159        return DoneDispatching;
    161160
     
    163162        const EventContext& eventContext = *m_eventPath[i];
    164163        if (eventContext.currentTargetSameAsTarget()) {
    165             if (m_event->bubbles())
     164            if (event->bubbles())
    166165                continue;
    167             m_event->setEventPhase(Event::AT_TARGET);
     166            event->setEventPhase(Event::AT_TARGET);
    168167        } else
    169             m_event->setEventPhase(Event::CAPTURING_PHASE);
    170         eventContext.handleLocalEvents(m_event.get());
    171         if (m_event->propagationStopped())
     168            event->setEventPhase(Event::CAPTURING_PHASE);
     169        eventContext.handleLocalEvents(event.get());
     170        if (event->propagationStopped())
    172171            return DoneDispatching;
    173172    }
     
    176175}
    177176
    178 inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget()
    179 {
    180     m_event->setEventPhase(Event::AT_TARGET);
    181     m_eventPath[0]->handleLocalEvents(m_event.get());
    182     return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching;
    183 }
    184 
    185 inline EventDispatchContinuation EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowContext)
    186 {
    187     if (m_event->bubbles() && !m_event->cancelBubble()) {
     177inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget(PassRefPtr<Event> event)
     178{
     179    event->setEventPhase(Event::AT_TARGET);
     180    m_eventPath[0]->handleLocalEvents(event.get());
     181    return event->propagationStopped() ? DoneDispatching : ContinueDispatching;
     182}
     183
     184inline EventDispatchContinuation EventDispatcher::dispatchEventAtBubbling(PassRefPtr<Event> event, WindowEventContext& windowContext)
     185{
     186    if (event->bubbles() && !event->cancelBubble()) {
    188187        // Trigger bubbling event handlers, starting at the bottom and working our way up.
    189         m_event->setEventPhase(Event::BUBBLING_PHASE);
     188        event->setEventPhase(Event::BUBBLING_PHASE);
    190189
    191190        size_t size = m_eventPath.size();
     
    193192            const EventContext& eventContext = *m_eventPath[i];
    194193            if (eventContext.currentTargetSameAsTarget())
    195                 m_event->setEventPhase(Event::AT_TARGET);
     194                event->setEventPhase(Event::AT_TARGET);
    196195            else
    197                 m_event->setEventPhase(Event::BUBBLING_PHASE);
    198             eventContext.handleLocalEvents(m_event.get());
    199             if (m_event->propagationStopped() || m_event->cancelBubble())
     196                event->setEventPhase(Event::BUBBLING_PHASE);
     197            eventContext.handleLocalEvents(event.get());
     198            if (event->propagationStopped() || event->cancelBubble())
    200199                return DoneDispatching;
    201200        }
    202         windowContext.handleLocalEvents(m_event.get());
     201        windowContext.handleLocalEvents(event.get());
    203202    }
    204203    return ContinueDispatching;
    205204}
    206205
    207 inline void EventDispatcher::dispatchEventPostProcess(void* preDispatchEventHandlerResult)
    208 {
    209     m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
    210     m_event->setCurrentTarget(0);
    211     m_event->setEventPhase(0);
     206inline void EventDispatcher::dispatchEventPostProcess(PassRefPtr<Event> event, void* preDispatchEventHandlerResult)
     207{
     208    event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.get()));
     209    event->setCurrentTarget(0);
     210    event->setEventPhase(0);
    212211
    213212    // Pass the data from the preDispatchEventHandler to the postDispatchEventHandler.
    214     m_node->postDispatchEventHandler(m_event.get(), preDispatchEventHandlerResult);
     213    m_node->postDispatchEventHandler(event.get(), preDispatchEventHandlerResult);
    215214
    216215    // Call default event handlers. While the DOM does have a concept of preventing
    217216    // default handling, the detail of which handlers are called is an internal
    218217    // implementation detail and not part of the DOM.
    219     if (!m_event->defaultPrevented() && !m_event->defaultHandled()) {
     218    if (!event->defaultPrevented() && !event->defaultHandled()) {
    220219        // Non-bubbling events call only one default event handler, the one for the target.
    221         m_node->defaultEventHandler(m_event.get());
    222         ASSERT(!m_event->defaultPrevented());
    223         if (m_event->defaultHandled())
     220        m_node->defaultEventHandler(event.get());
     221        ASSERT(!event->defaultPrevented());
     222        if (event->defaultHandled())
    224223            return;
    225224        // For bubbling events, call default event handlers on the same targets in the
    226225        // same order as the bubbling phase.
    227         if (m_event->bubbles()) {
     226        if (event->bubbles()) {
    228227            size_t size = m_eventPath.size();
    229228            for (size_t i = 1; i < size; ++i) {
    230                 m_eventPath[i]->node()->defaultEventHandler(m_event.get());
    231                 ASSERT(!m_event->defaultPrevented());
    232                 if (m_event->defaultHandled())
     229                m_eventPath[i]->node()->defaultEventHandler(event.get());
     230                ASSERT(!event->defaultPrevented());
     231                if (event->defaultHandled())
    233232                    return;
    234233            }
  • trunk/Source/WebCore/dom/EventDispatcher.h

    r143145 r143244  
    3131#include <wtf/Forward.h>
    3232#include <wtf/HashMap.h>
    33 #include <wtf/PassRefPtr.h>
    3433#include <wtf/Vector.h>
    3534
     
    5958    static void dispatchSimulatedClick(Node*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
    6059
    61     bool dispatch();
    62     Node* node() const { return m_node.get(); }
    63     Event* event() const { return m_event.get(); }
    64     EventPath& ensureEventPath();
     60    bool dispatchEvent(PassRefPtr<Event>);
     61    Node* node() const;
     62    EventPath& ensureEventPath(Event*);
    6563
    6664private:
    67     EventDispatcher(Node*, PassRefPtr<Event>);
     65    EventDispatcher(Node*);
    6866    const EventContext* topEventContext();
    6967
    70     EventDispatchContinuation dispatchEventPreProcess(void*& preDispatchEventHandlerResult);
    71     EventDispatchContinuation dispatchEventAtCapturing(WindowEventContext&);
    72     EventDispatchContinuation dispatchEventAtTarget();
    73     EventDispatchContinuation dispatchEventAtBubbling(WindowEventContext&);
    74     void dispatchEventPostProcess(void* preDispatchEventHandlerResult);
     68    EventDispatchContinuation dispatchEventPreProcess(PassRefPtr<Event>, void*& preDispatchEventHandlerResult);
     69    EventDispatchContinuation dispatchEventAtCapturing(PassRefPtr<Event>, WindowEventContext&);
     70    EventDispatchContinuation dispatchEventAtTarget(PassRefPtr<Event>);
     71    EventDispatchContinuation dispatchEventAtBubbling(PassRefPtr<Event>, WindowEventContext&);
     72    void dispatchEventPostProcess(PassRefPtr<Event>, void* preDispatchEventHandlerResult);
    7573
    7674    EventPath m_eventPath;
    7775    RefPtr<Node> m_node;
    78     RefPtr<Event> m_event;
    7976    RefPtr<FrameView> m_view;
    8077    bool m_eventPathInitialized;
     
    8481};
    8582
     83inline Node* EventDispatcher::node() const
     84{
     85    return m_node.get();
     86}
     87
    8688}
    8789
  • trunk/Source/WebCore/dom/FocusEvent.cpp

    r143145 r143244  
    7878bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
    7979{
    80     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     80    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
    8181    return EventDispatchMediator::dispatchEvent(dispatcher);
    8282}
     
    9494bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
    9595{
    96     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     96    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
    9797    return EventDispatchMediator::dispatchEvent(dispatcher);
    9898}
     
    110110bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
    111111{
    112     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     112    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
    113113    return EventDispatchMediator::dispatchEvent(dispatcher);
    114114}
     
    126126bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
    127127{
    128     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath());
     128    EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event(), dispatcher->ensureEventPath(event()));
    129129    return EventDispatchMediator::dispatchEvent(dispatcher);
    130130}
  • trunk/Source/WebCore/dom/GestureEvent.cpp

    r143145 r143244  
    123123        return true;
    124124
    125     dispatcher->dispatch();
     125    dispatcher->dispatchEvent(event());
    126126    ASSERT(!event()->defaultPrevented());
    127127    return event()->defaultHandled() || event()->defaultPrevented();
  • trunk/Source/WebCore/dom/MouseEvent.cpp

    r143145 r143244  
    263263{
    264264    if (isSyntheticMouseEvent()) {
    265         EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath());
    266         return dispatcher->dispatch();
     265        EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath(event()));
     266        return dispatcher->dispatchEvent(event());
    267267    }
    268268
     
    276276
    277277    EventTarget* relatedTarget = event()->relatedTarget();
    278     EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath());
    279 
    280     dispatcher->dispatch();
     278    EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event(),  dispatcher->ensureEventPath(event()));
     279
     280    dispatcher->dispatchEvent(event());
    281281    bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented();
    282282
Note: See TracChangeset for help on using the changeset viewer.