| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 EventDispatcher::EventDispatcher(Node* node, PassRefPtr<Event> event) | 53 EventDispatcher::EventDispatcher(Node* node, PassRefPtr<Event> event) |
| 54 : m_node(node) | 54 : m_node(node) |
| 55 , m_event(event) | 55 , m_event(event) |
| 56 #ifndef NDEBUG | 56 #ifndef NDEBUG |
| 57 , m_eventDispatched(false) | 57 , m_eventDispatched(false) |
| 58 #endif | 58 #endif |
| 59 { | 59 { |
| 60 ASSERT(node); | 60 ASSERT(node); |
| 61 ASSERT(m_event.get()); | 61 ASSERT(m_event.get()); |
| 62 ASSERT(!m_event->type().isNull()); // JavaScript code can create an event wi
th an empty name, but not null. | 62 ASSERT(!m_event->type().isNull()); // JavaScript code can create an event wi
th an empty name, but not null. |
| 63 m_view = node->document()->view(); | 63 m_view = node->document().view(); |
| 64 EventRetargeter::ensureEventPath(m_node.get(), m_event.get()); | 64 EventRetargeter::ensureEventPath(m_node.get(), m_event.get()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<EventDispatchMe
diator> mediator) | 67 void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<EventDispatchMe
diator> mediator) |
| 68 { | 68 { |
| 69 // We need to set the target here because it can go away by the time we actu
ally fire the event. | 69 // We need to set the target here because it can go away by the time we actu
ally fire the event. |
| 70 mediator->event()->setTarget(EventRetargeter::eventTargetRespectingTargetRul
es(node)); | 70 mediator->event()->setTarget(EventRetargeter::eventTargetRespectingTargetRul
es(node)); |
| 71 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); | 71 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent,
SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions
visualOptions) | 74 void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent,
SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions
visualOptions) |
| 75 { | 75 { |
| 76 if (isDisabledFormControl(node)) | 76 if (isDisabledFormControl(node)) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 if (!gNodesDispatchingSimulatedClicks) | 79 if (!gNodesDispatchingSimulatedClicks) |
| 80 gNodesDispatchingSimulatedClicks = new HashSet<Node*>; | 80 gNodesDispatchingSimulatedClicks = new HashSet<Node*>; |
| 81 else if (gNodesDispatchingSimulatedClicks->contains(node)) | 81 else if (gNodesDispatchingSimulatedClicks->contains(node)) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 gNodesDispatchingSimulatedClicks->add(node); | 84 gNodesDispatchingSimulatedClicks->add(node); |
| 85 | 85 |
| 86 if (mouseEventOptions == SendMouseOverUpDownEvents) | 86 if (mouseEventOptions == SendMouseOverUpDownEvents) |
| 87 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseover
Event, node->document()->defaultView(), underlyingEvent)).dispatch(); | 87 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseover
Event, node->document().defaultView(), underlyingEvent)).dispatch(); |
| 88 | 88 |
| 89 if (mouseEventOptions != SendNoEvents) | 89 if (mouseEventOptions != SendNoEvents) |
| 90 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mousedown
Event, node->document()->defaultView(), underlyingEvent)).dispatch(); | 90 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mousedown
Event, node->document().defaultView(), underlyingEvent)).dispatch(); |
| 91 node->setActive(true, visualOptions == ShowPressedLook); | 91 node->setActive(true, visualOptions == ShowPressedLook); |
| 92 if (mouseEventOptions != SendNoEvents) | 92 if (mouseEventOptions != SendNoEvents) |
| 93 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseupEv
ent, node->document()->defaultView(), underlyingEvent)).dispatch(); | 93 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseupEv
ent, node->document().defaultView(), underlyingEvent)).dispatch(); |
| 94 node->setActive(false); | 94 node->setActive(false); |
| 95 | 95 |
| 96 // always send click | 96 // always send click |
| 97 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().clickEvent, n
ode->document()->defaultView(), underlyingEvent)).dispatch(); | 97 EventDispatcher(node, SimulatedMouseEvent::create(eventNames().clickEvent, n
ode->document().defaultView(), underlyingEvent)).dispatch(); |
| 98 | 98 |
| 99 gNodesDispatchingSimulatedClicks->remove(node); | 99 gNodesDispatchingSimulatedClicks->remove(node); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool EventDispatcher::dispatch() | 102 bool EventDispatcher::dispatch() |
| 103 { | 103 { |
| 104 #ifndef NDEBUG | 104 #ifndef NDEBUG |
| 105 ASSERT(!m_eventDispatched); | 105 ASSERT(!m_eventDispatched); |
| 106 m_eventDispatched = true; | 106 m_eventDispatched = true; |
| 107 #endif | 107 #endif |
| 108 ChildNodesLazySnapshot::takeChildNodesLazySnapshot(); | 108 ChildNodesLazySnapshot::takeChildNodesLazySnapshot(); |
| 109 | 109 |
| 110 m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.
get())); | 110 m_event->setTarget(EventRetargeter::eventTargetRespectingTargetRules(m_node.
get())); |
| 111 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 111 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
| 112 ASSERT(m_event->target()); | 112 ASSERT(m_event->target()); |
| 113 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topEventC
ontext()); | 113 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topEventC
ontext()); |
| 114 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat
chEvent(m_node->document(), *m_event, windowEventContext.window(), m_node.get(),
m_event->eventPath()); | 114 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat
chEvent(&m_node->document(), *m_event, windowEventContext.window(), m_node.get()
, m_event->eventPath()); |
| 115 | 115 |
| 116 void* preDispatchEventHandlerResult; | 116 void* preDispatchEventHandlerResult; |
| 117 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) | 117 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) |
| 118 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) | 118 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) |
| 119 if (dispatchEventAtTarget() == ContinueDispatching) | 119 if (dispatchEventAtTarget() == ContinueDispatching) |
| 120 dispatchEventAtBubbling(windowEventContext); | 120 dispatchEventAtBubbling(windowEventContext); |
| 121 dispatchEventPostProcess(preDispatchEventHandlerResult); | 121 dispatchEventPostProcess(preDispatchEventHandlerResult); |
| 122 | 122 |
| 123 // Ensure that after event dispatch, the event's target object is the | 123 // Ensure that after event dispatch, the event's target object is the |
| 124 // outermost shadow DOM boundary. | 124 // outermost shadow DOM boundary. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 const EventContext* EventDispatcher::topEventContext() | 222 const EventContext* EventDispatcher::topEventContext() |
| 223 { | 223 { |
| 224 return m_event->eventPath().isEmpty() ? 0 : m_event->eventPath().last().get(
); | 224 return m_event->eventPath().isEmpty() ? 0 : m_event->eventPath().last().get(
); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } | 227 } |
| OLD | NEW |