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

Side by Side Diff: Source/core/events/MouseEvent.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/MouseEvent.h ('k') | Source/core/html/HTMLElement.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) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return target() ? target()->toNode() : 0; 210 return target() ? target()->toNode() : 0;
211 } 211 }
212 212
213 DEFINE_TRACE(MouseEvent) 213 DEFINE_TRACE(MouseEvent)
214 { 214 {
215 visitor->trace(m_relatedTarget); 215 visitor->trace(m_relatedTarget);
216 visitor->trace(m_dataTransfer); 216 visitor->trace(m_dataTransfer);
217 MouseRelatedEvent::trace(visitor); 217 MouseRelatedEvent::trace(visitor);
218 } 218 }
219 219
220 PassRefPtrWillBeRawPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const At omicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWill BeRawPtr<Event> underlyingEvent) 220 PassRefPtrWillBeRawPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const At omicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWill BeRawPtr<Event> underlyingEvent, SimulatedClickCreationScope creationScope)
221 { 221 {
222 return adoptRefWillBeNoop(new SimulatedMouseEvent(eventType, view, underlyin gEvent)); 222 return adoptRefWillBeNoop(new SimulatedMouseEvent(eventType, view, underlyin gEvent, creationScope));
223 } 223 }
224 224
225 SimulatedMouseEvent::~SimulatedMouseEvent() 225 SimulatedMouseEvent::~SimulatedMouseEvent()
226 { 226 {
227 } 227 }
228 228
229 SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP trWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent ) 229 SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP trWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent , SimulatedClickCreationScope creationScope)
230 : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 0, 0, 230 : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 0, 0,
231 nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable) 231 nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable)
232 { 232 {
233 setTrusted(true); 233 setTrusted(creationScope == SimulatedClickCreationScope::FromUserAgent);
234 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) { 234 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) {
235 m_ctrlKey = keyStateEvent->ctrlKey(); 235 m_ctrlKey = keyStateEvent->ctrlKey();
236 m_altKey = keyStateEvent->altKey(); 236 m_altKey = keyStateEvent->altKey();
237 m_shiftKey = keyStateEvent->shiftKey(); 237 m_shiftKey = keyStateEvent->shiftKey();
238 m_metaKey = keyStateEvent->metaKey(); 238 m_metaKey = keyStateEvent->metaKey();
239 } 239 }
240 setUnderlyingEvent(underlyingEvent); 240 setUnderlyingEvent(underlyingEvent);
241 241
242 if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) { 242 if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
243 MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent()); 243 MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 doubleClickEvent->setTrusted(event().isTrusted()); 308 doubleClickEvent->setTrusted(event().isTrusted());
309 if (event().defaultHandled()) 309 if (event().defaultHandled())
310 doubleClickEvent->setDefaultHandled(); 310 doubleClickEvent->setDefaultHandled();
311 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); 311 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent));
312 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) 312 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ())
313 return false; 313 return false;
314 return !swallowEvent; 314 return !swallowEvent;
315 } 315 }
316 316
317 } // namespace blink 317 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/events/MouseEvent.h ('k') | Source/core/html/HTMLElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698