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

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

Issue 2270293002: Replace ASSERT*() with DCHECK*() in core/events/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: isUnreachableNode -> checkReachableNode Created 4 years, 4 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 28 matching lines...) Expand all
39 #include "core/inspector/InspectorTraceEvents.h" 39 #include "core/inspector/InspectorTraceEvents.h"
40 #include "platform/EventDispatchForbiddenScope.h" 40 #include "platform/EventDispatchForbiddenScope.h"
41 #include "platform/TraceEvent.h" 41 #include "platform/TraceEvent.h"
42 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 DispatchEventResult EventDispatcher::dispatchEvent(Node& node, EventDispatchMedi ator* mediator) 46 DispatchEventResult EventDispatcher::dispatchEvent(Node& node, EventDispatchMedi ator* mediator)
47 { 47 {
48 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patchEvent"); 48 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patchEvent");
49 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 49 #if DCHECK_IS_ON()
50 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden());
51 #endif
50 EventDispatcher dispatcher(node, &mediator->event()); 52 EventDispatcher dispatcher(node, &mediator->event());
51 return mediator->dispatchEvent(dispatcher); 53 return mediator->dispatchEvent(dispatcher);
52 } 54 }
53 55
54 EventDispatcher::EventDispatcher(Node& node, Event* event) 56 EventDispatcher::EventDispatcher(Node& node, Event* event)
55 : m_node(node) 57 : m_node(node)
56 , m_event(event) 58 , m_event(event)
57 #if ENABLE(ASSERT)
58 , m_eventDispatched(false)
59 #endif
60 { 59 {
61 ASSERT(m_event.get()); 60 DCHECK(m_event.get());
62 m_view = node.document().view(); 61 m_view = node.document().view();
63 m_event->initEventPath(*m_node); 62 m_event->initEventPath(*m_node);
64 } 63 }
65 64
66 void EventDispatcher::dispatchScopedEvent(Node& node, EventDispatchMediator* med iator) 65 void EventDispatcher::dispatchScopedEvent(Node& node, EventDispatchMediator* med iator)
67 { 66 {
68 // We need to set the target here because it can go away by the time we actu ally fire the event. 67 // We need to set the target here because it can go away by the time we actu ally fire the event.
69 mediator->event().setTarget(EventPath::eventTargetRespectingTargetRules(node )); 68 mediator->event().setTarget(EventPath::eventTargetRespectingTargetRules(node ));
70 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); 69 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator);
71 } 70 }
(...skipping 28 matching lines...) Expand all
100 // always send click 99 // always send click
101 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();
102 101
103 nodesDispatchingSimulatedClicks.remove(&node); 102 nodesDispatchingSimulatedClicks.remove(&node);
104 } 103 }
105 104
106 DispatchEventResult EventDispatcher::dispatch() 105 DispatchEventResult EventDispatcher::dispatch()
107 { 106 {
108 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch"); 107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch");
109 108
110 #if ENABLE(ASSERT) 109 #if DCHECK_IS_ON()
111 ASSERT(!m_eventDispatched); 110 DCHECK(!m_eventDispatched);
112 m_eventDispatched = true; 111 m_eventDispatched = true;
113 #endif 112 #endif
114 if (event().eventPath().isEmpty()) { 113 if (event().eventPath().isEmpty()) {
115 // 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.
116 return DispatchEventResult::NotCanceled; 115 return DispatchEventResult::NotCanceled;
117 } 116 }
118 m_event->eventPath().ensureWindowEventContext(); 117 m_event->eventPath().ensureWindowEventContext();
119 118
120 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); 119 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node));
121 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 120 #if DCHECK_IS_ON()
122 ASSERT(m_event->target()); 121 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden());
122 #endif
123 DCHECK(m_event->target());
123 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event)); 124 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event));
124 EventDispatchHandlingState* preDispatchEventHandlerResult = nullptr; 125 EventDispatchHandlingState* preDispatchEventHandlerResult = nullptr;
125 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat ching) { 126 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat ching) {
126 if (dispatchEventAtCapturing() == ContinueDispatching) { 127 if (dispatchEventAtCapturing() == ContinueDispatching) {
127 if (dispatchEventAtTarget() == ContinueDispatching) 128 if (dispatchEventAtTarget() == ContinueDispatching)
128 dispatchEventAtBubbling(); 129 dispatchEventAtBubbling();
129 } 130 }
130 } 131 }
131 dispatchEventPostProcess(preDispatchEventHandlerResult); 132 dispatchEventPostProcess(preDispatchEventHandlerResult);
132 133
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // should not have their default handlers invoked. 221 // should not have their default handlers invoked.
221 bool isTrustedOrClick = !RuntimeEnabledFeatures::trustedEventsDefaultActionE nabled() || m_event->isTrusted() || isClick; 222 bool isTrustedOrClick = !RuntimeEnabledFeatures::trustedEventsDefaultActionE nabled() || m_event->isTrusted() || isClick;
222 223
223 // Call default event handlers. While the DOM does have a concept of prevent ing 224 // Call default event handlers. While the DOM does have a concept of prevent ing
224 // default handling, the detail of which handlers are called is an internal 225 // default handling, the detail of which handlers are called is an internal
225 // implementation detail and not part of the DOM. 226 // implementation detail and not part of the DOM.
226 if (!m_event->defaultPrevented() && !m_event->defaultHandled() && isTrustedO rClick) { 227 if (!m_event->defaultPrevented() && !m_event->defaultHandled() && isTrustedO rClick) {
227 // Non-bubbling events call only one default event handler, the one for the target. 228 // Non-bubbling events call only one default event handler, the one for the target.
228 m_node->willCallDefaultEventHandler(*m_event); 229 m_node->willCallDefaultEventHandler(*m_event);
229 m_node->defaultEventHandler(m_event.get()); 230 m_node->defaultEventHandler(m_event.get());
230 ASSERT(!m_event->defaultPrevented()); 231 DCHECK(!m_event->defaultPrevented());
231 // For bubbling events, call default event handlers on the same targets in the 232 // For bubbling events, call default event handlers on the same targets in the
232 // same order as the bubbling phase. 233 // same order as the bubbling phase.
233 if (!m_event->defaultHandled() && m_event->bubbles()) { 234 if (!m_event->defaultHandled() && m_event->bubbles()) {
234 size_t size = m_event->eventPath().size(); 235 size_t size = m_event->eventPath().size();
235 for (size_t i = 1; i < size; ++i) { 236 for (size_t i = 1; i < size; ++i) {
236 m_event->eventPath()[i].node()->willCallDefaultEventHandler(*m_e vent); 237 m_event->eventPath()[i].node()->willCallDefaultEventHandler(*m_e vent);
237 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( )); 238 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( ));
238 ASSERT(!m_event->defaultPrevented()); 239 DCHECK(!m_event->defaultPrevented());
239 if (m_event->defaultHandled()) 240 if (m_event->defaultHandled())
240 break; 241 break;
241 } 242 }
242 } 243 }
243 if (m_event->defaultHandled() && !m_event->isTrusted() && !isClick) 244 if (m_event->defaultHandled() && !m_event->isTrusted() && !isClick)
244 Deprecation::countDeprecation(m_node->document(), UseCounter::Untrus tedEventDefaultHandled); 245 Deprecation::countDeprecation(m_node->document(), UseCounter::Untrus tedEventDefaultHandled);
245 } 246 }
246 } 247 }
247 248
248 } // namespace blink 249 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventDispatcher.h ('k') | third_party/WebKit/Source/core/events/EventListenerMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698