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

Side by Side Diff: sky/engine/core/events/EventDispatcher.cpp

Issue 870073003: Remove mouse events from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 11 matching lines...) Expand all
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA. 23 * Boston, MA 02110-1301, USA.
24 */ 24 */
25 25
26 #include "sky/engine/config.h" 26 #include "sky/engine/config.h"
27 #include "sky/engine/core/events/EventDispatcher.h" 27 #include "sky/engine/core/events/EventDispatcher.h"
28 28
29 #include "sky/engine/core/dom/ContainerNode.h" 29 #include "sky/engine/core/dom/ContainerNode.h"
30 #include "sky/engine/core/dom/Document.h" 30 #include "sky/engine/core/dom/Document.h"
31 #include "sky/engine/core/dom/Element.h" 31 #include "sky/engine/core/dom/Element.h"
32 #include "sky/engine/core/events/Event.h"
32 #include "sky/engine/core/events/EventDispatchMediator.h" 33 #include "sky/engine/core/events/EventDispatchMediator.h"
33 #include "sky/engine/core/events/MouseEvent.h"
34 #include "sky/engine/core/events/ScopedEventQueue.h" 34 #include "sky/engine/core/events/ScopedEventQueue.h"
35 #include "sky/engine/core/events/WindowEventContext.h" 35 #include "sky/engine/core/events/WindowEventContext.h"
36 #include "sky/engine/core/frame/FrameView.h" 36 #include "sky/engine/core/frame/FrameView.h"
37 #include "sky/engine/core/frame/LocalDOMWindow.h"
37 #include "sky/engine/core/inspector/InspectorTraceEvents.h" 38 #include "sky/engine/core/inspector/InspectorTraceEvents.h"
38 #include "sky/engine/platform/EventDispatchForbiddenScope.h" 39 #include "sky/engine/platform/EventDispatchForbiddenScope.h"
39 #include "sky/engine/platform/TraceEvent.h" 40 #include "sky/engine/platform/TraceEvent.h"
40 #include "sky/engine/wtf/RefPtr.h" 41 #include "sky/engine/wtf/RefPtr.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<EventDispatchMediator > mediator) 45 bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<EventDispatchMediator > mediator)
45 { 46 {
46 TRACE_EVENT0("blink", "EventDispatcher::dispatchEvent"); 47 TRACE_EVENT0("blink", "EventDispatcher::dispatchEvent");
(...skipping 18 matching lines...) Expand all
65 m_event->ensureEventPath().resetWith(m_node.get()); 66 m_event->ensureEventPath().resetWith(m_node.get());
66 } 67 }
67 68
68 void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<EventDispatchMe diator> mediator) 69 void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr<EventDispatchMe diator> mediator)
69 { 70 {
70 // We need to set the target here because it can go away by the time we actu ally fire the event. 71 // We need to set the target here because it can go away by the time we actu ally fire the event.
71 mediator->event()->setTarget(EventPath::eventTargetRespectingTargetRules(nod e)); 72 mediator->event()->setTarget(EventPath::eventTargetRespectingTargetRules(nod e));
72 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); 73 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator);
73 } 74 }
74 75
75 void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions)
76 {
77 // This persistent vector doesn't cause leaks, because added Nodes are remov ed
78 // before dispatchSimulatedClick() returns. This vector is here just to prev ent
79 // the code from running into an infinite recursion of dispatchSimulatedClic k().
80 DEFINE_STATIC_LOCAL(OwnPtr<HashSet<RawPtr<Node> > >, nodesDispatchingSimulat edClicks, (adoptPtr(new HashSet<RawPtr<Node> >())));
81
82 if (nodesDispatchingSimulatedClicks->contains(node))
83 return;
84
85 nodesDispatchingSimulatedClicks->add(node);
86
87 if (mouseEventOptions == SendMouseOverUpDownEvents)
88 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseo ver, node->document().domWindow(), underlyingEvent)).dispatch();
89
90 if (mouseEventOptions != SendNoEvents) {
91 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::moused own, node->document().domWindow(), underlyingEvent)).dispatch();
92 node->setActive(true);
93 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseu p, node->document().domWindow(), underlyingEvent)).dispatch();
94 }
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.
97 node->setActive(false);
98
99 // always send click
100 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, nod e->document().domWindow(), underlyingEvent)).dispatch();
101
102 nodesDispatchingSimulatedClicks->remove(node);
103 }
104
105 bool EventDispatcher::dispatch() 76 bool EventDispatcher::dispatch()
106 { 77 {
107 TRACE_EVENT0("blink", "EventDispatcher::dispatch"); 78 TRACE_EVENT0("blink", "EventDispatcher::dispatch");
108 79
109 #if ENABLE(ASSERT) 80 #if ENABLE(ASSERT)
110 ASSERT(!m_eventDispatched); 81 ASSERT(!m_eventDispatched);
111 m_eventDispatched = true; 82 m_eventDispatched = true;
112 #endif 83 #endif
113 84
114 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get()) ); 85 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get()) );
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 185 }
215 } 186 }
216 } 187 }
217 188
218 const NodeEventContext* EventDispatcher::topNodeEventContext() 189 const NodeEventContext* EventDispatcher::topNodeEventContext()
219 { 190 {
220 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); 191 return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last();
221 } 192 }
222 193
223 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698