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

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

Issue 1174683004: Populates sourceDevice attribute into MouseEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Create a new init function Created 5 years, 6 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
Index: Source/core/events/MouseEvent.cpp
diff --git a/Source/core/events/MouseEvent.cpp b/Source/core/events/MouseEvent.cpp
index cba1190a3047dba42be57d947a694f65d5184043..cffec1515a15c701157d5410f9b0d7813f8f7178 100644
--- a/Source/core/events/MouseEvent.cpp
+++ b/Source/core/events/MouseEvent.cpp
@@ -97,13 +97,17 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
, m_syntheticEventType(syntheticEventType)
{
setUICreateTime(uiCreateTime);
+ if (syntheticEventType == PlatformMouseEvent::FromTouch)
+ setSourceDevice(InputDevice::firesTouchEventsInputDevice());
+ else
+ setSourceDevice(InputDevice::doesntFireTouchEventsInputDevice());
}
MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& initializer)
: MouseRelatedEvent(eventType, initializer.bubbles(), initializer.cancelable(), initializer.view(), initializer.detail(), IntPoint(initializer.screenX(), initializer.screenY()),
IntPoint(0 /* pageX */, 0 /* pageY */),
IntPoint(initializer.movementX(), initializer.movementY()),
- initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), initializer.metaKey(), false /* isSimulated */)
+ initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), initializer.metaKey(), false /* isSimulated */, initializer.sourceDevice())
, m_button(initializer.button())
, m_buttons(initializer.buttons())
, m_relatedTarget(initializer.relatedTarget())
@@ -134,7 +138,7 @@ unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers)
void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
int detail, int screenX, int screenY, int clientX, int clientY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
- short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons)
+ short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDevice* sourceDevice, unsigned short buttons)
{
if (dispatched())
return;
@@ -142,7 +146,7 @@ void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty
if (scriptState && scriptState->world().isIsolatedWorld())
UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shiftKey, metaKey);
- initUIEvent(type, canBubble, cancelable, view, detail);
+ initUIEvent(type, canBubble, cancelable, view, detail, sourceDevice);
m_screenLocation = IntPoint(screenX, screenY);
m_ctrlKey = ctrlKey;
@@ -159,6 +163,12 @@ void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty
// FIXME: m_dataTransfer is not set to nullptr here.
}
+void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, int detail, int screenX, int screenY,
+ int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons)
+{
+ initMouseEvent(scriptState, type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, nullptr, buttons);
+}
+
const AtomicString& MouseEvent::interfaceName() const
{
return EventNames::MouseEvent;
@@ -288,7 +298,7 @@ bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons
doubleClickEvent->initMouseEvent(nullptr, EventTypeNames::dblclick, event().bubbles(), event().cancelable(), event().view(),
event().detail(), event().screenX(), event().screenY(), event().clientX(), event().clientY(),
event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey(),
- event().button(), relatedTarget, event().buttons());
+ event().button(), relatedTarget, event().sourceDevice(), event().buttons());
if (event().defaultHandled())
doubleClickEvent->setDefaultHandled();
EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));

Powered by Google App Engine
This is Rietveld 408576698