| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "core/dom/ContainerNode.h" | 28 #include "core/dom/ContainerNode.h" |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/dom/Element.h" | 30 #include "core/dom/Element.h" |
| 31 #include "core/events/EventDispatchMediator.h" | 31 #include "core/events/EventDispatchMediator.h" |
| 32 #include "core/events/MouseEvent.h" | 32 #include "core/events/MouseEvent.h" |
| 33 #include "core/events/ScopedEventQueue.h" | 33 #include "core/events/ScopedEventQueue.h" |
| 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/frame/UseCounter.h" |
| 37 #include "core/inspector/InspectorTraceEvents.h" | 38 #include "core/inspector/InspectorTraceEvents.h" |
| 38 #include "platform/EventDispatchForbiddenScope.h" | 39 #include "platform/EventDispatchForbiddenScope.h" |
| 39 #include "platform/TraceEvent.h" | 40 #include "platform/TraceEvent.h" |
| 40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 DispatchEventResult EventDispatcher::dispatchEvent(Node& node, EventDispatchMedi
ator* mediator) | 45 DispatchEventResult EventDispatcher::dispatchEvent(Node& node, EventDispatchMedi
ator* mediator) |
| 45 { | 46 { |
| 46 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patchEvent"); | 47 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patchEvent"); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 m_event->eventPath()[0].handleLocalEvents(*m_event); | 171 m_event->eventPath()[0].handleLocalEvents(*m_event); |
| 171 return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching
; | 172 return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching
; |
| 172 } | 173 } |
| 173 | 174 |
| 174 inline void EventDispatcher::dispatchEventAtBubbling() | 175 inline void EventDispatcher::dispatchEventAtBubbling() |
| 175 { | 176 { |
| 176 // Trigger bubbling event handlers, starting at the bottom and working our w
ay up. | 177 // Trigger bubbling event handlers, starting at the bottom and working our w
ay up. |
| 177 size_t size = m_event->eventPath().size(); | 178 size_t size = m_event->eventPath().size(); |
| 178 for (size_t i = 1; i < size; ++i) { | 179 for (size_t i = 1; i < size; ++i) { |
| 179 const NodeEventContext& eventContext = m_event->eventPath()[i]; | 180 const NodeEventContext& eventContext = m_event->eventPath()[i]; |
| 180 if (eventContext.currentTargetSameAsTarget()) | 181 if (eventContext.currentTargetSameAsTarget()) { |
| 181 m_event->setEventPhase(Event::AT_TARGET); | 182 m_event->setEventPhase(Event::AT_TARGET); |
| 182 else if (m_event->bubbles() && !m_event->cancelBubble()) | 183 } else if (m_event->bubbles() && !m_event->cancelBubble()) { |
| 183 m_event->setEventPhase(Event::BUBBLING_PHASE); | 184 m_event->setEventPhase(Event::BUBBLING_PHASE); |
| 184 else | 185 } else { |
| 186 if (m_event->bubbles() && m_event->cancelBubble() && eventContext.no
de()->hasEventListeners(m_event->type())) |
| 187 UseCounter::count(eventContext.node()->document(), UseCounter::E
ventCancelBubbleAffected); |
| 185 continue; | 188 continue; |
| 189 } |
| 186 eventContext.handleLocalEvents(*m_event); | 190 eventContext.handleLocalEvents(*m_event); |
| 187 if (m_event->propagationStopped()) | 191 if (m_event->propagationStopped()) |
| 188 return; | 192 return; |
| 189 } | 193 } |
| 190 if (m_event->bubbles() && !m_event->cancelBubble()) { | 194 if (m_event->bubbles() && !m_event->cancelBubble()) { |
| 191 m_event->setEventPhase(Event::BUBBLING_PHASE); | 195 m_event->setEventPhase(Event::BUBBLING_PHASE); |
| 192 m_event->eventPath().windowEventContext().handleLocalEvents(*m_event); | 196 m_event->eventPath().windowEventContext().handleLocalEvents(*m_event); |
| 197 } else if (m_event->bubbles() && m_event->eventPath().windowEventContext().w
indow()->hasEventListeners(m_event->type())) { |
| 198 UseCounter::count(m_event->eventPath().windowEventContext().window()->ge
tExecutionContext(), UseCounter::EventCancelBubbleAffected); |
| 193 } | 199 } |
| 194 } | 200 } |
| 195 | 201 |
| 196 inline void EventDispatcher::dispatchEventPostProcess(EventDispatchHandlingState
* preDispatchEventHandlerResult) | 202 inline void EventDispatcher::dispatchEventPostProcess(EventDispatchHandlingState
* preDispatchEventHandlerResult) |
| 197 { | 203 { |
| 198 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); | 204 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); |
| 199 m_event->setCurrentTarget(nullptr); | 205 m_event->setCurrentTarget(nullptr); |
| 200 m_event->setEventPhase(0); | 206 m_event->setEventPhase(0); |
| 201 | 207 |
| 202 // Pass the data from the preDispatchEventHandler to the postDispatchEventHa
ndler. | 208 // Pass the data from the preDispatchEventHandler to the postDispatchEventHa
ndler. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 232 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); | 238 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); |
| 233 ASSERT(!m_event->defaultPrevented()); | 239 ASSERT(!m_event->defaultPrevented()); |
| 234 if (m_event->defaultHandled()) | 240 if (m_event->defaultHandled()) |
| 235 return; | 241 return; |
| 236 } | 242 } |
| 237 } | 243 } |
| 238 } | 244 } |
| 239 } | 245 } |
| 240 | 246 |
| 241 } // namespace blink | 247 } // namespace blink |
| OLD | NEW |