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

Unified Diff: Source/core/events/MouseEvent.cpp

Issue 1227363006: Virtualize EventDispatchMediator creation and cleanup calling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master_event_trusted_main
Patch Set: Rebase Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/events/MouseEvent.h ('k') | Source/core/events/PointerEvent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/MouseEvent.cpp
diff --git a/Source/core/events/MouseEvent.cpp b/Source/core/events/MouseEvent.cpp
index 83ba73d4d25e52166548184dfdae99e2055e11f6..a3756508e9e83c137371641acbd208e926a1d951 100644
--- a/Source/core/events/MouseEvent.cpp
+++ b/Source/core/events/MouseEvent.cpp
@@ -76,6 +76,7 @@ MouseEvent::MouseEvent()
, m_relatedTarget(nullptr)
, m_dataTransfer(nullptr)
, m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
+ , m_isTrusted(false)
{
}
@@ -96,6 +97,7 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
, m_relatedTarget(relatedTarget)
, m_dataTransfer(dataTransfer)
, m_syntheticEventType(syntheticEventType)
+ , m_isTrusted(false)
{
setUICreateTime(uiCreateTime);
}
@@ -110,6 +112,7 @@ MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
, m_relatedTarget(initializer.relatedTarget())
, m_dataTransfer(nullptr)
, m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
+ , m_isTrusted(false)
{
initCoordinates(IntPoint(initializer.clientX(), initializer.clientY()));
}
@@ -230,6 +233,7 @@ SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
: MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 0, 0,
nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable)
{
+ setTrusted(true);
if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
m_ctrlKey = keyStateEvent->ctrlKey();
m_altKey = keyStateEvent->altKey();
@@ -245,18 +249,23 @@ SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
}
}
+PassRefPtrWillBeRawPtr<EventDispatchMediator> MouseEvent::createMediator()
+{
+ return MouseEventDispatchMediator::create(this);
+}
+
DEFINE_TRACE(SimulatedMouseEvent)
{
MouseEvent::trace(visitor);
}
-PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent, MouseEventType mouseEventType)
+PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent)
{
- return adoptRefWillBeNoop(new MouseEventDispatchMediator(mouseEvent, mouseEventType));
+ return adoptRefWillBeNoop(new MouseEventDispatchMediator(mouseEvent));
}
-MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent, MouseEventType mouseEventType)
- : EventDispatchMediator(mouseEvent), m_mouseEventType(mouseEventType)
+MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent)
+ : EventDispatchMediator(mouseEvent)
{
}
@@ -267,7 +276,7 @@ MouseEvent& MouseEventDispatchMediator::event() const
bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
- if (isSyntheticMouseEvent()) {
+ if (!event().isTrusted()) {
event().eventPath().adjustForRelatedTarget(dispatcher.node(), event().relatedTarget());
return dispatcher.dispatch();
}
@@ -297,6 +306,9 @@ bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons
event().detail(), event().screenX(), event().screenY(), event().clientX(), event().clientY(),
event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey(),
event().button(), relatedTarget, event().sourceDevice(), event().buttons());
+
+ // Inherit the trusted status from the original event.
+ doubleClickEvent->setTrusted(event().isTrusted());
if (event().defaultHandled())
doubleClickEvent->setDefaultHandled();
EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));
« no previous file with comments | « Source/core/events/MouseEvent.h ('k') | Source/core/events/PointerEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698