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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 m_event->initEventPath(*m_node); | 62 m_event->initEventPath(*m_node); |
63 } | 63 } |
64 | 64 |
65 void EventDispatcher::dispatchScopedEvent(Node& node, PassRefPtrWillBeRawPtr<Eve
ntDispatchMediator> mediator) | 65 void EventDispatcher::dispatchScopedEvent(Node& node, PassRefPtrWillBeRawPtr<Eve
ntDispatchMediator> mediator) |
66 { | 66 { |
67 // 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. |
68 mediator->event().setTarget(EventPath::eventTargetRespectingTargetRules(node
)); | 68 mediator->event().setTarget(EventPath::eventTargetRespectingTargetRules(node
)); |
69 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); | 69 ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); |
70 } | 70 } |
71 | 71 |
72 void EventDispatcher::dispatchSimulatedClick(Node& node, Event* underlyingEvent,
SimulatedClickMouseEventOptions mouseEventOptions) | 72 void EventDispatcher::dispatchSimulatedClick(Node& node, Event* underlyingEvent,
SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickCreationScope
creationScope) |
73 { | 73 { |
74 // This persistent vector doesn't cause leaks, because added Nodes are remov
ed | 74 // This persistent vector doesn't cause leaks, because added Nodes are remov
ed |
75 // before dispatchSimulatedClick() returns. This vector is here just to prev
ent | 75 // before dispatchSimulatedClick() returns. This vector is here just to prev
ent |
76 // the code from running into an infinite recursion of dispatchSimulatedClic
k(). | 76 // the code from running into an infinite recursion of dispatchSimulatedClic
k(). |
77 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeMem
ber<Node>>>, nodesDispatchingSimulatedClicks, (adoptPtrWillBeNoop(new WillBeHeap
HashSet<RawPtrWillBeMember<Node>>()))); | 77 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeMem
ber<Node>>>, nodesDispatchingSimulatedClicks, (adoptPtrWillBeNoop(new WillBeHeap
HashSet<RawPtrWillBeMember<Node>>()))); |
78 | 78 |
79 if (isDisabledFormControl(&node)) | 79 if (isDisabledFormControl(&node)) |
80 return; | 80 return; |
81 | 81 |
82 if (nodesDispatchingSimulatedClicks->contains(&node)) | 82 if (nodesDispatchingSimulatedClicks->contains(&node)) |
83 return; | 83 return; |
84 | 84 |
85 nodesDispatchingSimulatedClicks->add(&node); | 85 nodesDispatchingSimulatedClicks->add(&node); |
86 | 86 |
| 87 bool isTrusted = creationScope == SimulatedClickCreationScope::FromUserAgent
; |
| 88 |
87 if (mouseEventOptions == SendMouseOverUpDownEvents) | 89 if (mouseEventOptions == SendMouseOverUpDownEvents) |
88 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseo
ver, node.document().domWindow(), underlyingEvent)).dispatch(); | 90 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseo
ver, node.document().domWindow(), underlyingEvent, isTrusted)).dispatch(); |
89 | 91 |
90 if (mouseEventOptions != SendNoEvents) { | 92 if (mouseEventOptions != SendNoEvents) { |
91 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::moused
own, node.document().domWindow(), underlyingEvent)).dispatch(); | 93 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::moused
own, node.document().domWindow(), underlyingEvent, isTrusted)).dispatch(); |
92 node.setActive(true); | 94 node.setActive(true); |
93 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseu
p, node.document().domWindow(), underlyingEvent)).dispatch(); | 95 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseu
p, node.document().domWindow(), underlyingEvent, isTrusted)).dispatch(); |
94 } | 96 } |
95 // Some elements (e.g. the color picker) may set active state to true before | 97 // 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. | 98 // calling this method and expect the state to be reset during the call. |
97 node.setActive(false); | 99 node.setActive(false); |
98 | 100 |
99 // always send click | 101 // always send click |
100 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, nod
e.document().domWindow(), underlyingEvent)).dispatch(); | 102 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, nod
e.document().domWindow(), underlyingEvent, isTrusted)).dispatch(); |
101 | 103 |
102 nodesDispatchingSimulatedClicks->remove(&node); | 104 nodesDispatchingSimulatedClicks->remove(&node); |
103 } | 105 } |
104 | 106 |
105 bool EventDispatcher::dispatch() | 107 bool EventDispatcher::dispatch() |
106 { | 108 { |
107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patch"); | 109 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis
patch"); |
108 | 110 |
109 #if ENABLE(ASSERT) | 111 #if ENABLE(ASSERT) |
110 ASSERT(!m_eventDispatched); | 112 ASSERT(!m_eventDispatched); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); | 228 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get(
)); |
227 ASSERT(!m_event->defaultPrevented()); | 229 ASSERT(!m_event->defaultPrevented()); |
228 if (m_event->defaultHandled()) | 230 if (m_event->defaultHandled()) |
229 return; | 231 return; |
230 } | 232 } |
231 } | 233 } |
232 } | 234 } |
233 } | 235 } |
234 | 236 |
235 } | 237 } |
OLD | NEW |