| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ASSERT(!m_eventDispatched); | 110 ASSERT(!m_eventDispatched); |
| 111 m_eventDispatched = true; | 111 m_eventDispatched = true; |
| 112 #endif | 112 #endif |
| 113 | 113 |
| 114 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); | 114 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); |
| 115 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 115 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 116 ASSERT(m_event->target()); | 116 ASSERT(m_event->target()); |
| 117 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEv
entContext()); | 117 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEv
entContext()); |
| 118 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EventDispatch"
, "data", InspectorEventDispatchEvent::data(*m_event)); | 118 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EventDispatch"
, "data", InspectorEventDispatchEvent::data(*m_event)); |
| 119 | 119 |
| 120 void* preDispatchEventHandlerResult; | 120 if (dispatchEventPreProcess() == ContinueDispatching) |
| 121 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) | |
| 122 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) | 121 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) |
| 123 if (dispatchEventAtTarget() == ContinueDispatching) | 122 if (dispatchEventAtTarget() == ContinueDispatching) |
| 124 dispatchEventAtBubbling(windowEventContext); | 123 dispatchEventAtBubbling(windowEventContext); |
| 125 dispatchEventPostProcess(preDispatchEventHandlerResult); | 124 dispatchEventPostProcess(); |
| 126 | 125 |
| 127 // Ensure that after event dispatch, the event's target object is the | 126 // Ensure that after event dispatch, the event's target object is the |
| 128 // outermost shadow DOM boundary. | 127 // outermost shadow DOM boundary. |
| 129 m_event->setTarget(windowEventContext.target()); | 128 m_event->setTarget(windowEventContext.target()); |
| 130 m_event->setCurrentTarget(0); | 129 m_event->setCurrentTarget(0); |
| 131 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorUpdateCountersEvent::data
()); | 130 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorUpdateCountersEvent::data
()); |
| 132 | 131 |
| 133 return !m_event->defaultPrevented(); | 132 return !m_event->defaultPrevented(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*&
preDispatchEventHandlerResult) | 135 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess() |
| 137 { | 136 { |
| 138 // Give the target node a chance to do some work before DOM event handlers g
et a crack. | |
| 139 preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get(
)); | |
| 140 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D
oneDispatching : ContinueDispatching; | 137 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D
oneDispatching : ContinueDispatching; |
| 141 } | 138 } |
| 142 | 139 |
| 143 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(Windo
wEventContext& windowEventContext) | 140 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(Windo
wEventContext& windowEventContext) |
| 144 { | 141 { |
| 145 // Trigger capturing event handlers, starting at the top and working our way
down. | 142 // Trigger capturing event handlers, starting at the top and working our way
down. |
| 146 m_event->setEventPhase(Event::CAPTURING_PHASE); | 143 m_event->setEventPhase(Event::CAPTURING_PHASE); |
| 147 | 144 |
| 148 if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagat
ionStopped()) | 145 if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagat
ionStopped()) |
| 149 return DoneDispatching; | 146 return DoneDispatching; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 eventContext.handleLocalEvents(m_event.get()); | 179 eventContext.handleLocalEvents(m_event.get()); |
| 183 if (m_event->propagationStopped()) | 180 if (m_event->propagationStopped()) |
| 184 return; | 181 return; |
| 185 } | 182 } |
| 186 if (m_event->bubbles() && !m_event->cancelBubble()) { | 183 if (m_event->bubbles() && !m_event->cancelBubble()) { |
| 187 m_event->setEventPhase(Event::BUBBLING_PHASE); | 184 m_event->setEventPhase(Event::BUBBLING_PHASE); |
| 188 windowContext.handleLocalEvents(m_event.get()); | 185 windowContext.handleLocalEvents(m_event.get()); |
| 189 } | 186 } |
| 190 } | 187 } |
| 191 | 188 |
| 192 inline void EventDispatcher::dispatchEventPostProcess(void* preDispatchEventHand
lerResult) | 189 inline void EventDispatcher::dispatchEventPostProcess() |
| 193 { | 190 { |
| 194 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); | 191 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); |
| 195 m_event->setCurrentTarget(0); | 192 m_event->setCurrentTarget(0); |
| 196 m_event->setEventPhase(0); | 193 m_event->setEventPhase(0); |
| 197 | 194 |
| 198 // Pass the data from the preDispatchEventHandler to the postDispatchEventHa
ndler. | |
| 199 m_node->postDispatchEventHandler(m_event.get(), preDispatchEventHandlerResul
t); | |
| 200 | |
| 201 // Call default event handlers. While the DOM does have a concept of prevent
ing | 195 // Call default event handlers. While the DOM does have a concept of prevent
ing |
| 202 // default handling, the detail of which handlers are called is an internal | 196 // default handling, the detail of which handlers are called is an internal |
| 203 // implementation detail and not part of the DOM. | 197 // implementation detail and not part of the DOM. |
| 204 if (!m_event->defaultPrevented() && !m_event->defaultHandled()) { | 198 if (!m_event->defaultPrevented() && !m_event->defaultHandled()) { |
| 205 // Non-bubbling events call only one default event handler, the one for
the target. | 199 // Non-bubbling events call only one default event handler, the one for
the target. |
| 206 m_node->willCallDefaultEventHandler(*m_event); | 200 m_node->willCallDefaultEventHandler(*m_event); |
| 207 m_node->defaultEventHandler(m_event.get()); | 201 m_node->defaultEventHandler(m_event.get()); |
| 208 ASSERT(!m_event->defaultPrevented()); | 202 ASSERT(!m_event->defaultPrevented()); |
| 209 if (m_event->defaultHandled()) | 203 if (m_event->defaultHandled()) |
| 210 return; | 204 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 222 } | 216 } |
| 223 } | 217 } |
| 224 } | 218 } |
| 225 | 219 |
| 226 const NodeEventContext* EventDispatcher::topNodeEventContext() | 220 const NodeEventContext* EventDispatcher::topNodeEventContext() |
| 227 { | 221 { |
| 228 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); | 222 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); |
| 229 } | 223 } |
| 230 | 224 |
| 231 } | 225 } |
| OLD | NEW |