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

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: 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..939585d00c261601e2548c8ba9cdd3feec6ea0c8 100644
--- a/Source/core/events/MouseEvent.cpp
+++ b/Source/core/events/MouseEvent.cpp
@@ -34,7 +34,7 @@ namespace blink {
PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(ScriptState* scriptState, const AtomicString& type, const MouseEventInit& initializer)
{
- if (scriptState->world().isIsolatedWorld())
+ if (scriptState && scriptState->world().isIsolatedWorld())
UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), initializer.metaKey());
return adoptRefWillBeNoop(new MouseEvent(type, initializer));
}
@@ -89,7 +89,8 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
: MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint(screenX, screenY),
IntPoint(windowX, windowY),
IntPoint(movementX, movementY),
- ctrlKey, altKey, shiftKey, metaKey, isSimulated)
+ ctrlKey, altKey, shiftKey, metaKey, isSimulated,
+ syntheticEventType == PlatformMouseEvent::FromTouch ? InputDevice::firesTouchEventsInputDevice() : InputDevice::doesntFireTouchEventsInputDevice())
, m_button(button)
, m_buttons(buttons)
, m_relatedTarget(relatedTarget)
@@ -103,7 +104,7 @@ MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
: 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())
@@ -284,7 +285,9 @@ bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons
// Special case: If it's a double click event, we also send the dblclick event. This is not part
// of the DOM specs, but is used for compatibility with the ondblclick="" attribute. This is treated
// as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
- RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create();
+ MouseEventInit eventInitDict;
+ eventInitDict.setSourceDevice(event().sourceDevice());
+ RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(nullptr, EventTypeNames::dblclick, eventInitDict);
doubleClickEvent->initMouseEvent(nullptr, EventTypeNames::dblclick, event().bubbles(), event().cancelable(), event().view(),
Rick Byers 2015/06/25 03:34:54 nit: You should really be using either an eventIni
lanwei 2015/06/25 19:26:40 Done.
event().detail(), event().screenX(), event().screenY(), event().clientX(), event().clientY(),
event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey(),

Powered by Google App Engine
This is Rietveld 408576698