Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: third_party/WebKit/Source/core/events/EventDispatcher.cpp

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: Fix typo Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
34 #include "core/events/WindowEventContext.h" 34 #include "core/events/WindowEventContext.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalDOMWindow.h" 36 #include "core/frame/LocalDOMWindow.h"
37 #include "core/inspector/InspectorTraceEvents.h" 37 #include "core/inspector/InspectorTraceEvents.h"
38 #include "platform/EventDispatchForbiddenScope.h" 38 #include "platform/EventDispatchForbiddenScope.h"
39 #include "platform/TraceEvent.h" 39 #include "platform/TraceEvent.h"
40 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 bool EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeRawPtr<EventDisp atchMediator> mediator) 44 DispatchEventResult EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeR awPtr<EventDispatchMediator> mediator)
45 { 45 {
46 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patchEvent"); 46 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patchEvent");
47 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 47 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
48 EventDispatcher dispatcher(node, &mediator->event()); 48 EventDispatcher dispatcher(node, &mediator->event());
49 return mediator->dispatchEvent(dispatcher); 49 return mediator->dispatchEvent(dispatcher);
50 } 50 }
51 51
52 EventDispatcher::EventDispatcher(Node& node, PassRefPtrWillBeRawPtr<Event> event ) 52 EventDispatcher::EventDispatcher(Node& node, PassRefPtrWillBeRawPtr<Event> event )
53 : m_node(node) 53 : m_node(node)
54 , m_event(event) 54 , m_event(event)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Some elements (e.g. the color picker) may set active state to true before 94 // Some elements (e.g. the color picker) may set active state to true before
95 // calling this method and expect the state to be reset during the call. 95 // calling this method and expect the state to be reset during the call.
96 node.setActive(false); 96 node.setActive(false);
97 97
98 // always send click 98 // always send click
99 EventDispatcher(node, MouseEvent::create(EventTypeNames::click, node.documen t().domWindow(), underlyingEvent, creationScope)).dispatch(); 99 EventDispatcher(node, MouseEvent::create(EventTypeNames::click, node.documen t().domWindow(), underlyingEvent, creationScope)).dispatch();
100 100
101 nodesDispatchingSimulatedClicks->remove(&node); 101 nodesDispatchingSimulatedClicks->remove(&node);
102 } 102 }
103 103
104 bool EventDispatcher::dispatch() 104 DispatchEventResult EventDispatcher::dispatch()
105 { 105 {
106 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch"); 106 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch");
107 107
108 #if ENABLE(ASSERT) 108 #if ENABLE(ASSERT)
109 ASSERT(!m_eventDispatched); 109 ASSERT(!m_eventDispatched);
110 m_eventDispatched = true; 110 m_eventDispatched = true;
111 #endif 111 #endif
112 if (event().eventPath().isEmpty()) { 112 if (event().eventPath().isEmpty()) {
113 // eventPath() can be empty if event path is shrinked by relataedTarget retargeting. 113 // eventPath() can be empty if event path is shrinked by relataedTarget retargeting.
114 return true; 114 return DispatchEventResult::NotCanceled;
115 } 115 }
116 m_event->eventPath().ensureWindowEventContext(); 116 m_event->eventPath().ensureWindowEventContext();
117 117
118 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); 118 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node));
119 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 119 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
120 ASSERT(m_event->target()); 120 ASSERT(m_event->target());
121 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event)); 121 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event));
122 void* preDispatchEventHandlerResult; 122 void* preDispatchEventHandlerResult;
123 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat ching) { 123 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat ching) {
124 if (dispatchEventAtCapturing() == ContinueDispatching) { 124 if (dispatchEventAtCapturing() == ContinueDispatching) {
125 if (dispatchEventAtTarget() == ContinueDispatching) 125 if (dispatchEventAtTarget() == ContinueDispatching)
126 dispatchEventAtBubbling(); 126 dispatchEventAtBubbling();
127 } 127 }
128 } 128 }
129 dispatchEventPostProcess(preDispatchEventHandlerResult); 129 dispatchEventPostProcess(preDispatchEventHandlerResult);
130 130
131 // Ensure that after event dispatch, the event's target object is the 131 // Ensure that after event dispatch, the event's target object is the
132 // outermost shadow DOM boundary. 132 // outermost shadow DOM boundary.
133 m_event->setTarget(m_event->eventPath().windowEventContext().target()); 133 m_event->setTarget(m_event->eventPath().windowEventContext().target());
134 m_event->setCurrentTarget(nullptr); 134 m_event->setCurrentTarget(nullptr);
135 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 135 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
136 136
137 return !m_event->defaultPrevented(); 137 return EventTarget::dispatchEventResult(*m_event);
138 } 138 }
139 139
140 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*& preDispatchEventHandlerResult) 140 inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess(void*& preDispatchEventHandlerResult)
141 { 141 {
142 // Give the target node a chance to do some work before DOM event handlers g et a crack. 142 // Give the target node a chance to do some work before DOM event handlers g et a crack.
143 preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get( )); 143 preDispatchEventHandlerResult = m_node->preDispatchEventHandler(m_event.get( ));
144 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D oneDispatching : ContinueDispatching; 144 return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? D oneDispatching : ContinueDispatching;
145 } 145 }
146 146
147 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing() 147 inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( )); 232 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( ));
233 ASSERT(!m_event->defaultPrevented()); 233 ASSERT(!m_event->defaultPrevented());
234 if (m_event->defaultHandled()) 234 if (m_event->defaultHandled())
235 return; 235 return;
236 } 236 }
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventDispatcher.h ('k') | third_party/WebKit/Source/core/events/EventTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698