mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
Bug 653780 - Use real MouseEvents, not simple Events for TapDow, TapMove and TapUp [r=wjohnston]
This commit is contained in:
parent
d8f37cc945
commit
21e7ef18b7
@ -126,6 +126,13 @@ function MouseModule() {
|
|||||||
|
|
||||||
|
|
||||||
MouseModule.prototype = {
|
MouseModule.prototype = {
|
||||||
|
_initMouseEventFromEvent: function _initMouseEventFromEvent(aDestEvent, aSrcEvent, aType, aCanBubble, aCancellable) {
|
||||||
|
aDestEvent.initMouseEvent(aType, aCanBubble, aCancellable, window, aSrcEvent.detail,
|
||||||
|
aSrcEvent.screenX, aSrcEvent.screenY, aSrcEvent.clientX, aSrcEvent.clientY,
|
||||||
|
aSrcEvent.ctrlKey, aSrcEvent.altKey, aSrcEvent.shiftKey, aSrcEvent.metaKey,
|
||||||
|
aSrcEvent.button, aSrcEvent.relatedTarget);
|
||||||
|
},
|
||||||
|
|
||||||
handleEvent: function handleEvent(aEvent) {
|
handleEvent: function handleEvent(aEvent) {
|
||||||
switch (aEvent.type) {
|
switch (aEvent.type) {
|
||||||
case "contextmenu":
|
case "contextmenu":
|
||||||
@ -213,10 +220,8 @@ MouseModule.prototype = {
|
|||||||
|
|
||||||
// Do tap
|
// Do tap
|
||||||
if (!this._kinetic.isActive()) {
|
if (!this._kinetic.isActive()) {
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("MouseEvent");
|
||||||
event.initEvent("TapDown", true, true);
|
this._initMouseEventFromEvent(event, aEvent, "TapDown", true, true);
|
||||||
event.clientX = aEvent.clientX;
|
|
||||||
event.clientY = aEvent.clientY;
|
|
||||||
let success = aEvent.target.dispatchEvent(event);
|
let success = aEvent.target.dispatchEvent(event);
|
||||||
if (success) {
|
if (success) {
|
||||||
this._recordEvent(aEvent);
|
this._recordEvent(aEvent);
|
||||||
@ -268,10 +273,8 @@ MouseModule.prototype = {
|
|||||||
if (this._target) {
|
if (this._target) {
|
||||||
let isClick = dragData.isClick();
|
let isClick = dragData.isClick();
|
||||||
|
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("MouseEvents");
|
||||||
event.initEvent("TapUp", true, true);
|
this._initMouseEventFromEvent(event, aEvent, "TapUp", true, true);
|
||||||
event.clientX = aEvent.clientX
|
|
||||||
event.clientY = aEvent.clientY;
|
|
||||||
event.isClick = isClick;
|
event.isClick = isClick;
|
||||||
|
|
||||||
let success = aEvent.target.dispatchEvent(event);
|
let success = aEvent.target.dispatchEvent(event);
|
||||||
@ -335,11 +338,13 @@ MouseModule.prototype = {
|
|||||||
this.dY += dragData.prevPanY - sY;
|
this.dY += dragData.prevPanY - sY;
|
||||||
|
|
||||||
if (dragData.isPan()) {
|
if (dragData.isPan()) {
|
||||||
this.sendMove(aEvent.clientX, aEvent.clientY, aEvent.target);
|
this.sendMove(aEvent);
|
||||||
|
|
||||||
// Only pan when mouse event isn't part of a click. Prevent jittering on tap.
|
// Only pan when mouse event isn't part of a click. Prevent jittering on tap.
|
||||||
this._kinetic.addData(sX - dragData.prevPanX, sY - dragData.prevPanY);
|
this._kinetic.addData(sX - dragData.prevPanX, sY - dragData.prevPanY);
|
||||||
|
|
||||||
|
// dragBy will reset dX and dY values to 0
|
||||||
this._dragBy(this.dX, this.dY);
|
this._dragBy(this.dX, this.dY);
|
||||||
// dragBy will reset dX and dY values to 0.
|
|
||||||
|
|
||||||
// Let everyone know when mousemove begins a pan
|
// Let everyone know when mousemove begins a pan
|
||||||
if (!oldIsPan && dragData.isPan()) {
|
if (!oldIsPan && dragData.isPan()) {
|
||||||
@ -361,12 +366,10 @@ MouseModule.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMove: function(aX, aY, aTarget) {
|
sendMove: function(aEvent) {
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("MouseEvents");
|
||||||
event.initEvent("TapMove", true, true);
|
this._initMouseEventFromEvent(event, aEvent, "TapMove", true, true);
|
||||||
event.clientX = aX;
|
aEvent.target.dispatchEvent(event);
|
||||||
event.clientY = aY;
|
|
||||||
aTarget.dispatchEvent(event);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user