зеркало из https://github.com/mozilla/pjs.git
Bug 653009 (part 1/2) - Make preventDefault on touch events compatible with WebKit [r=wesj] DONTBUILD (mobile only)
--HG-- extra : rebase_source : bb77614e151f8491d2ebe0daaed2b1f809780b92
This commit is contained in:
Родитель
09e94e1fe3
Коммит
fbc28ab631
|
@ -1639,7 +1639,6 @@ const ContentTouchHandler = {
|
||||||
document.addEventListener("TapLong", this, false);
|
document.addEventListener("TapLong", this, false);
|
||||||
document.addEventListener("TapMove", this, false);
|
document.addEventListener("TapMove", this, false);
|
||||||
|
|
||||||
document.addEventListener("PanBegin", this, false);
|
|
||||||
document.addEventListener("PopupChanged", this, false);
|
document.addEventListener("PopupChanged", this, false);
|
||||||
document.addEventListener("CancelTouchSequence", this, false);
|
document.addEventListener("CancelTouchSequence", this, false);
|
||||||
|
|
||||||
|
@ -1665,7 +1664,6 @@ const ContentTouchHandler = {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (aEvent.type) {
|
switch (aEvent.type) {
|
||||||
case "PanBegin":
|
|
||||||
case "PopupChanged":
|
case "PopupChanged":
|
||||||
case "CancelTouchSequence":
|
case "CancelTouchSequence":
|
||||||
this._clearPendingMessages();
|
this._clearPendingMessages();
|
||||||
|
|
|
@ -1205,6 +1205,8 @@ ConsoleAPIObserver.init();
|
||||||
|
|
||||||
var TouchEventHandler = {
|
var TouchEventHandler = {
|
||||||
element: null,
|
element: null,
|
||||||
|
isCancellable: true,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
addMessageListener("Browser:MouseUp", this);
|
addMessageListener("Browser:MouseUp", this);
|
||||||
addMessageListener("Browser:MouseDown", this);
|
addMessageListener("Browser:MouseDown", this);
|
||||||
|
@ -1222,12 +1224,13 @@ var TouchEventHandler = {
|
||||||
|
|
||||||
switch (aMessage.name) {
|
switch (aMessage.name) {
|
||||||
case "Browser:MouseDown":
|
case "Browser:MouseDown":
|
||||||
let cwu = Util.getWindowUtils(content);
|
this.isCancellable = true;
|
||||||
this.element = elementFromPoint(json.x, json.y);
|
this.element = elementFromPoint(json.x, json.y);
|
||||||
cancelled = !this.sendEvent("touchstart", json, this.element);
|
cancelled = !this.sendEvent("touchstart", json, this.element);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Browser:MouseUp":
|
case "Browser:MouseUp":
|
||||||
|
this.isCancellable = false;
|
||||||
if (this.element)
|
if (this.element)
|
||||||
this.sendEvent("touchend", json, this.element);
|
this.sendEvent("touchend", json, this.element);
|
||||||
this.element = null;
|
this.element = null;
|
||||||
|
@ -1239,9 +1242,15 @@ var TouchEventHandler = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aMessage.name != "Browser:MouseUp")
|
if (this.isCancellable) {
|
||||||
sendAsyncMessage("Browser:CaptureEvents", { messageId: json.messageId,
|
sendAsyncMessage("Browser:CaptureEvents", { messageId: json.messageId,
|
||||||
panning: cancelled });
|
panning: cancelled });
|
||||||
|
// Panning can be cancelled only during the "touchstart" event and the
|
||||||
|
// first "touchmove" event. After it's cancelled, it stays cancelled
|
||||||
|
// until the next touchstart event.
|
||||||
|
if (cancelled || aMessage.name == "Browser:MouseMove")
|
||||||
|
this.isCancellable = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
sendEvent: function(aName, aData, aElement) {
|
sendEvent: function(aName, aData, aElement) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче