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 24 matching lines...) Expand all Loading... |
35 #include "core/events/WindowEventContext.h" | 35 #include "core/events/WindowEventContext.h" |
36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
37 #include "core/frame/LocalDOMWindow.h" | 37 #include "core/frame/LocalDOMWindow.h" |
38 #include "core/inspector/InspectorTraceEvents.h" | 38 #include "core/inspector/InspectorTraceEvents.h" |
39 #include "platform/EventDispatchForbiddenScope.h" | 39 #include "platform/EventDispatchForbiddenScope.h" |
40 #include "platform/TraceEvent.h" | 40 #include "platform/TraceEvent.h" |
41 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 bool EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeRawPtr<EventDisp
atchMediator> mediator) | 45 WebInputEventResult EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeR
awPtr<EventDispatchMediator> mediator) |
46 { | 46 { |
47 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patchEvent"); | 47 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patchEvent"); |
48 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 48 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
49 EventDispatcher dispatcher(node, &mediator->event()); | 49 EventDispatcher dispatcher(node, &mediator->event()); |
50 return mediator->dispatchEvent(dispatcher); | 50 return mediator->dispatchEvent(dispatcher); |
51 } | 51 } |
52 | 52 |
53 EventDispatcher::EventDispatcher(Node& node, PassRefPtrWillBeRawPtr<Event> event
) | 53 EventDispatcher::EventDispatcher(Node& node, PassRefPtrWillBeRawPtr<Event> event
) |
54 : m_node(node) | 54 : m_node(node) |
55 , m_event(event) | 55 , m_event(event) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Some elements (e.g. the color picker) may set active state to true before | 95 // Some elements (e.g. the color picker) may set active state to true before |
96 // calling this method and expect the state to be reset during the call. | 96 // calling this method and expect the state to be reset during the call. |
97 node.setActive(false); | 97 node.setActive(false); |
98 | 98 |
99 // always send click | 99 // always send click |
100 EventDispatcher(node, MouseEvent::create(EventTypeNames::click, node.documen
t().domWindow(), underlyingEvent, creationScope)).dispatch(); | 100 EventDispatcher(node, MouseEvent::create(EventTypeNames::click, node.documen
t().domWindow(), underlyingEvent, creationScope)).dispatch(); |
101 | 101 |
102 nodesDispatchingSimulatedClicks->remove(&node); | 102 nodesDispatchingSimulatedClicks->remove(&node); |
103 } | 103 } |
104 | 104 |
105 bool EventDispatcher::dispatch() | 105 WebInputEventResult EventDispatcher::dispatch() |
106 { | 106 { |
107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patch"); | 107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patch"); |
108 | 108 |
109 #if ENABLE(ASSERT) | 109 #if ENABLE(ASSERT) |
110 ASSERT(!m_eventDispatched); | 110 ASSERT(!m_eventDispatched); |
111 m_eventDispatched = true; | 111 m_eventDispatched = true; |
112 #endif | 112 #endif |
113 if (event().eventPath().isEmpty()) { | 113 if (event().eventPath().isEmpty()) { |
114 // eventPath() can be empty if event path is shrinked by relataedTarget
retargeting. | 114 // eventPath() can be empty if event path is shrinked by relataedTarget
retargeting. |
115 return true; | 115 return WebInputEventResult::NotHandled; |
116 } | 116 } |
117 m_event->eventPath().ensureWindowEventContext(); | 117 m_event->eventPath().ensureWindowEventContext(); |
118 | 118 |
119 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); | 119 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); |
120 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 120 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
121 ASSERT(m_event->target()); | 121 ASSERT(m_event->target()); |
122 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis
patchEvent::data(*m_event)); | 122 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis
patchEvent::data(*m_event)); |
123 void* preDispatchEventHandlerResult; | 123 void* preDispatchEventHandlerResult; |
124 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) { | 124 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat
ching) { |
125 if (dispatchEventAtCapturing() == ContinueDispatching) { | 125 if (dispatchEventAtCapturing() == ContinueDispatching) { |
126 if (dispatchEventAtTarget() == ContinueDispatching) | 126 if (dispatchEventAtTarget() == ContinueDispatching) |
127 dispatchEventAtBubbling(); | 127 dispatchEventAtBubbling(); |
128 } | 128 } |
129 } | 129 } |
130 dispatchEventPostProcess(preDispatchEventHandlerResult); | 130 dispatchEventPostProcess(preDispatchEventHandlerResult); |
131 | 131 |
132 // Ensure that after event dispatch, the event's target object is the | 132 // Ensure that after event dispatch, the event's target object is the |
133 // outermost shadow DOM boundary. | 133 // outermost shadow DOM boundary. |
134 m_event->setTarget(m_event->eventPath().windowEventContext().target()); | 134 m_event->setTarget(m_event->eventPath().windowEventContext().target()); |
135 m_event->setCurrentTarget(nullptr); | 135 m_event->setCurrentTarget(nullptr); |
136 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); | 136 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); |
137 | 137 |
138 return !m_event->defaultPrevented(); | 138 return m_event->eventResult(); |
139 } | 139 } |
140 | 140 |
141 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*&
preDispatchEventHandlerResult) | 141 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*&
preDispatchEventHandlerResult) |
142 { | 142 { |
143 // Give the target node a chance to do some work before DOM event handlers g
et a crack. | 143 // Give the target node a chance to do some work before DOM event handlers g
et a crack. |
144 preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get(
)); | 144 preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get(
)); |
145 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D
oneDispatching : ContinueDispatching; | 145 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D
oneDispatching : ContinueDispatching; |
146 } | 146 } |
147 | 147 |
148 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing() | 148 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing() |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); | 226 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); |
227 ASSERT(!m_event->defaultPrevented()); | 227 ASSERT(!m_event->defaultPrevented()); |
228 if (m_event->defaultHandled()) | 228 if (m_event->defaultHandled()) |
229 return; | 229 return; |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 } | 235 } |
OLD | NEW |