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

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

Issue 1285793004: isTrusted is incorrect for events generated by Element.click() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Change bool on SimulatedMouseEvent to the enum class introduced everywhere else Created 5 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
« no previous file with comments | « Source/core/events/EventDispatcher.h ('k') | Source/core/events/MouseEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (mouseEventOptions == SendMouseOverUpDownEvents) 87 if (mouseEventOptions == SendMouseOverUpDownEvents)
88 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseo ver, node.document().domWindow(), underlyingEvent)).dispatch(); 88 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseo ver, node.document().domWindow(), underlyingEvent, creationScope)).dispatch();
89 89
90 if (mouseEventOptions != SendNoEvents) { 90 if (mouseEventOptions != SendNoEvents) {
91 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::moused own, node.document().domWindow(), underlyingEvent)).dispatch(); 91 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::moused own, node.document().domWindow(), underlyingEvent, creationScope)).dispatch();
92 node.setActive(true); 92 node.setActive(true);
93 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseu p, node.document().domWindow(), underlyingEvent)).dispatch(); 93 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::mouseu p, node.document().domWindow(), underlyingEvent, creationScope)).dispatch();
94 } 94 }
95 // Some elements (e.g. the color picker) may set active state to true before 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. 96 // calling this method and expect the state to be reset during the call.
97 node.setActive(false); 97 node.setActive(false);
98 98
99 // always send click 99 // always send click
100 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, nod e.document().domWindow(), underlyingEvent)).dispatch(); 100 EventDispatcher(node, SimulatedMouseEvent::create(EventTypeNames::click, nod e.document().domWindow(), underlyingEvent, creationScope)).dispatch();
101 101
102 nodesDispatchingSimulatedClicks->remove(&node); 102 nodesDispatchingSimulatedClicks->remove(&node);
103 } 103 }
104 104
105 bool EventDispatcher::dispatch() 105 bool EventDispatcher::dispatch()
106 { 106 {
107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch"); 107 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dis patch");
108 108
109 #if ENABLE(ASSERT) 109 #if ENABLE(ASSERT)
110 ASSERT(!m_eventDispatched); 110 ASSERT(!m_eventDispatched);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( )); 226 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( ));
227 ASSERT(!m_event->defaultPrevented()); 227 ASSERT(!m_event->defaultPrevented());
228 if (m_event->defaultHandled()) 228 if (m_event->defaultHandled())
229 return; 229 return;
230 } 230 }
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 } 235 }
OLDNEW
« no previous file with comments | « Source/core/events/EventDispatcher.h ('k') | Source/core/events/MouseEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698