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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 { | 101 { |
102 #ifndef NDEBUG | 102 #ifndef NDEBUG |
103 ASSERT(!m_eventDispatched); | 103 ASSERT(!m_eventDispatched); |
104 m_eventDispatched = true; | 104 m_eventDispatched = true; |
105 #endif | 105 #endif |
106 ChildNodesLazySnapshot::takeChildNodesLazySnapshot(); | 106 ChildNodesLazySnapshot::takeChildNodesLazySnapshot(); |
107 | 107 |
108 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); | 108 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())
); |
109 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 109 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
110 ASSERT(m_event->target()); | 110 ASSERT(m_event->target()); |
111 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topEventC
ontext()); | 111 WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEv
entContext()); |
112 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat
chEvent(&m_node->document(), *m_event, windowEventContext.window(), m_node.get()
, m_event->eventPath()); | 112 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat
chEvent(&m_node->document(), *m_event, windowEventContext.window(), m_node.get()
, m_event->eventPath()); |
113 | 113 |
114 void* preDispatchEventHandlerResult; | 114 void* preDispatchEventHandlerResult; |
115 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) | 115 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) |
116 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) | 116 if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) |
117 if (dispatchEventAtTarget() == ContinueDispatching) | 117 if (dispatchEventAtTarget() == ContinueDispatching) |
118 dispatchEventAtBubbling(windowEventContext); | 118 dispatchEventAtBubbling(windowEventContext); |
119 dispatchEventPostProcess(preDispatchEventHandlerResult); | 119 dispatchEventPostProcess(preDispatchEventHandlerResult); |
120 | 120 |
121 // Ensure that after event dispatch, the event's target object is the | 121 // Ensure that after event dispatch, the event's target object is the |
(...skipping 14 matching lines...) Expand all Loading... |
136 | 136 |
137 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(Windo
wEventContext& windowEventContext) | 137 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(Windo
wEventContext& windowEventContext) |
138 { | 138 { |
139 // Trigger capturing event handlers, starting at the top and working our way
down. | 139 // Trigger capturing event handlers, starting at the top and working our way
down. |
140 m_event->setEventPhase(Event::CAPTURING_PHASE); | 140 m_event->setEventPhase(Event::CAPTURING_PHASE); |
141 | 141 |
142 if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagat
ionStopped()) | 142 if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagat
ionStopped()) |
143 return DoneDispatching; | 143 return DoneDispatching; |
144 | 144 |
145 for (size_t i = m_event->eventPath().size() - 1; i > 0; --i) { | 145 for (size_t i = m_event->eventPath().size() - 1; i > 0; --i) { |
146 const EventContext& eventContext = m_event->eventPath()[i]; | 146 const NodeEventContext& eventContext = m_event->eventPath()[i]; |
147 if (eventContext.currentTargetSameAsTarget()) | 147 if (eventContext.currentTargetSameAsTarget()) |
148 continue; | 148 continue; |
149 eventContext.handleLocalEvents(m_event.get()); | 149 eventContext.handleLocalEvents(m_event.get()); |
150 if (m_event->propagationStopped()) | 150 if (m_event->propagationStopped()) |
151 return DoneDispatching; | 151 return DoneDispatching; |
152 } | 152 } |
153 | 153 |
154 return ContinueDispatching; | 154 return ContinueDispatching; |
155 } | 155 } |
156 | 156 |
157 inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget() | 157 inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget() |
158 { | 158 { |
159 m_event->setEventPhase(Event::AT_TARGET); | 159 m_event->setEventPhase(Event::AT_TARGET); |
160 m_event->eventPath()[0].handleLocalEvents(m_event.get()); | 160 m_event->eventPath()[0].handleLocalEvents(m_event.get()); |
161 return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching
; | 161 return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching
; |
162 } | 162 } |
163 | 163 |
164 inline void EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowC
ontext) | 164 inline void EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowC
ontext) |
165 { | 165 { |
166 // Trigger bubbling event handlers, starting at the bottom and working our w
ay up. | 166 // Trigger bubbling event handlers, starting at the bottom and working our w
ay up. |
167 size_t size = m_event->eventPath().size(); | 167 size_t size = m_event->eventPath().size(); |
168 for (size_t i = 1; i < size; ++i) { | 168 for (size_t i = 1; i < size; ++i) { |
169 const EventContext& eventContext = m_event->eventPath()[i]; | 169 const NodeEventContext& eventContext = m_event->eventPath()[i]; |
170 if (eventContext.currentTargetSameAsTarget()) | 170 if (eventContext.currentTargetSameAsTarget()) |
171 m_event->setEventPhase(Event::AT_TARGET); | 171 m_event->setEventPhase(Event::AT_TARGET); |
172 else if (m_event->bubbles() && !m_event->cancelBubble()) | 172 else if (m_event->bubbles() && !m_event->cancelBubble()) |
173 m_event->setEventPhase(Event::BUBBLING_PHASE); | 173 m_event->setEventPhase(Event::BUBBLING_PHASE); |
174 else | 174 else |
175 continue; | 175 continue; |
176 eventContext.handleLocalEvents(m_event.get()); | 176 eventContext.handleLocalEvents(m_event.get()); |
177 if (m_event->propagationStopped()) | 177 if (m_event->propagationStopped()) |
178 return; | 178 return; |
179 } | 179 } |
(...skipping 30 matching lines...) Expand all Loading... |
210 m_event->eventPath()[i].node()->willCallDefaultEventHandler(*m_e
vent); | 210 m_event->eventPath()[i].node()->willCallDefaultEventHandler(*m_e
vent); |
211 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); | 211 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); |
212 ASSERT(!m_event->defaultPrevented()); | 212 ASSERT(!m_event->defaultPrevented()); |
213 if (m_event->defaultHandled()) | 213 if (m_event->defaultHandled()) |
214 return; | 214 return; |
215 } | 215 } |
216 } | 216 } |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 const EventContext* EventDispatcher::topEventContext() | 220 const NodeEventContext* EventDispatcher::topNodeEventContext() |
221 { | 221 { |
222 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); | 222 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); |
223 } | 223 } |
224 | 224 |
225 } | 225 } |
OLD | NEW |