mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 597286, part 8: Create new longtap event and use it to bring up context menus [r=mbrubeck]
This commit is contained in:
parent
cab4c0015e
commit
2817ccff66
@ -46,7 +46,7 @@
|
|||||||
const kDoubleClickInterval = 400;
|
const kDoubleClickInterval = 400;
|
||||||
|
|
||||||
// Amount of time to wait before tap becomes long tap
|
// Amount of time to wait before tap becomes long tap
|
||||||
const kLongTapWait = 700;
|
const kLongTapWait = 500;
|
||||||
|
|
||||||
// If a tap lasts longer than this duration in ms, treat it as a single-tap
|
// If a tap lasts longer than this duration in ms, treat it as a single-tap
|
||||||
// immediately instead of waiting for a possible double tap.
|
// immediately instead of waiting for a possible double tap.
|
||||||
@ -581,7 +581,7 @@ MouseModule.prototype = {
|
|||||||
let ev = this._downUpEvents[0];
|
let ev = this._downUpEvents[0];
|
||||||
|
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("Events");
|
||||||
event.initEvent("LongTap", true, false);
|
event.initEvent("TapLong", true, false);
|
||||||
event.clientX = ev.clientX;
|
event.clientX = ev.clientX;
|
||||||
event.clientY = ev.clientY;
|
event.clientY = ev.clientY;
|
||||||
ev.target.dispatchEvent(event);
|
ev.target.dispatchEvent(event);
|
||||||
|
@ -417,7 +417,6 @@ var BrowserUI = {
|
|||||||
|
|
||||||
messageManager.addMessageListener("Browser:Highlight", this);
|
messageManager.addMessageListener("Browser:Highlight", this);
|
||||||
messageManager.addMessageListener("Browser:OpenURI", this);
|
messageManager.addMessageListener("Browser:OpenURI", this);
|
||||||
messageManager.addMessageListener("Browser:ContextMenu", ContextHelper);
|
|
||||||
messageManager.addMessageListener("Browser:SaveAs:Return", this);
|
messageManager.addMessageListener("Browser:SaveAs:Return", this);
|
||||||
|
|
||||||
// listening mousedown for automatically dismiss some popups (e.g. larry)
|
// listening mousedown for automatically dismiss some popups (e.g. larry)
|
||||||
@ -2369,11 +2368,7 @@ var ContextHelper = {
|
|||||||
return this._popup = document.getElementById("context-popup");
|
return this._popup = document.getElementById("context-popup");
|
||||||
},
|
},
|
||||||
|
|
||||||
showPopup: function ch_showPopup(aData) {
|
showPopup: function ch_showPopup(aMessage) {
|
||||||
this.receiveMessage(aData);
|
|
||||||
},
|
|
||||||
|
|
||||||
receiveMessage: function ch_receiveMessage(aMessage) {
|
|
||||||
this.popupState = aMessage.json;
|
this.popupState = aMessage.json;
|
||||||
this.popupState.target = aMessage.target;
|
this.popupState.target = aMessage.target;
|
||||||
|
|
||||||
@ -2398,7 +2393,7 @@ var ContextHelper = {
|
|||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
this.popupState = null;
|
this.popupState = null;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow the first and last *non-hidden* elements to be selected in CSS.
|
// Allow the first and last *non-hidden* elements to be selected in CSS.
|
||||||
@ -2413,6 +2408,7 @@ var ContextHelper = {
|
|||||||
|
|
||||||
this.sizeToContent();
|
this.sizeToContent();
|
||||||
BrowserUI.pushPopup(this, [this._popup]);
|
BrowserUI.pushPopup(this, [this._popup]);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function ch_hide() {
|
hide: function ch_hide() {
|
||||||
|
@ -1269,7 +1269,22 @@ const ContentTouchHandler = {
|
|||||||
document.addEventListener("TapUp", this, false);
|
document.addEventListener("TapUp", this, false);
|
||||||
document.addEventListener("TapSingle", this, false);
|
document.addEventListener("TapSingle", this, false);
|
||||||
document.addEventListener("TapDouble", this, false);
|
document.addEventListener("TapDouble", this, false);
|
||||||
|
document.addEventListener("TapLong", this, false);
|
||||||
document.addEventListener("PanBegin", this, false);
|
document.addEventListener("PanBegin", this, false);
|
||||||
|
|
||||||
|
document.addEventListener("PopupChanged", this._popupChanged.bind(this), false);
|
||||||
|
|
||||||
|
// Context menus have the following flow:
|
||||||
|
// [parent] mousedown -> TapDown -> Browser:MouseDown
|
||||||
|
// [child] Browser:MouseDown -> contextmenu -> Browser:ContextMenu
|
||||||
|
// [parent] Browser:ContextMenu -> ...* -> TapLong
|
||||||
|
//
|
||||||
|
// * = Here some time will elapse. Although we get the context menu we need
|
||||||
|
// ASAP, we do not act on the context menu until we receive a LongTap.
|
||||||
|
// This is so we can show the context menu as soon as we know it is
|
||||||
|
// a long tap, without waiting for child process.
|
||||||
|
//
|
||||||
|
messageManager.addMessageListener("Browser:ContextMenu", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEvent: function handleEvent(ev) {
|
handleEvent: function handleEvent(ev) {
|
||||||
@ -1292,12 +1307,24 @@ const ContentTouchHandler = {
|
|||||||
case "TapDouble":
|
case "TapDouble":
|
||||||
this.tapDouble(ev.clientX1, ev.clientY1, ev.clientX2, ev.clientY2);
|
this.tapDouble(ev.clientX1, ev.clientY1, ev.clientX2, ev.clientY2);
|
||||||
break;
|
break;
|
||||||
|
case "TapLong":
|
||||||
|
this.tapLong();
|
||||||
|
break;
|
||||||
case "PanBegin":
|
case "PanBegin":
|
||||||
this.panBegin();
|
this.panBegin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
receiveMessage: function receiveMessage(aMessage) {
|
||||||
|
this._contextMenu = { name: aMessage.name, json: aMessage.json, target: aMessage.target };
|
||||||
|
},
|
||||||
|
|
||||||
|
_popupChanged: function _popupChanged() {
|
||||||
|
TapHighlightHelper.hide(200);
|
||||||
|
this._contextMenu = null;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the event concern the browser content
|
* Check if the event concern the browser content
|
||||||
*/
|
*/
|
||||||
@ -1329,15 +1356,19 @@ const ContentTouchHandler = {
|
|||||||
|
|
||||||
tapUp: function tapUp(aX, aY) {
|
tapUp: function tapUp(aX, aY) {
|
||||||
TapHighlightHelper.hide(200);
|
TapHighlightHelper.hide(200);
|
||||||
|
this._contextMenu = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
panBegin: function panBegin() {
|
panBegin: function panBegin() {
|
||||||
TapHighlightHelper.hide(0);
|
TapHighlightHelper.hide(0);
|
||||||
|
this._contextMenu = null;
|
||||||
|
|
||||||
this._dispatchMouseEvent("Browser:MouseCancel");
|
this._dispatchMouseEvent("Browser:MouseCancel");
|
||||||
},
|
},
|
||||||
|
|
||||||
tapSingle: function tapSingle(aX, aY, aModifiers) {
|
tapSingle: function tapSingle(aX, aY, aModifiers) {
|
||||||
TapHighlightHelper.hide(200);
|
TapHighlightHelper.hide(200);
|
||||||
|
this._contextMenu = null;
|
||||||
|
|
||||||
// Cancel the mouse click if we are showing a context menu
|
// Cancel the mouse click if we are showing a context menu
|
||||||
if (!ContextHelper.popupState)
|
if (!ContextHelper.popupState)
|
||||||
@ -1347,6 +1378,8 @@ const ContentTouchHandler = {
|
|||||||
|
|
||||||
tapDouble: function tapDouble(aX1, aY1, aX2, aY2) {
|
tapDouble: function tapDouble(aX1, aY1, aX2, aY2) {
|
||||||
TapHighlightHelper.hide();
|
TapHighlightHelper.hide();
|
||||||
|
this._contextMenu = null;
|
||||||
|
|
||||||
|
|
||||||
this._dispatchMouseEvent("Browser:MouseCancel");
|
this._dispatchMouseEvent("Browser:MouseCancel");
|
||||||
|
|
||||||
@ -1360,6 +1393,16 @@ const ContentTouchHandler = {
|
|||||||
this._dispatchMouseEvent("Browser:ZoomToPoint", aX1, aY1);
|
this._dispatchMouseEvent("Browser:ZoomToPoint", aX1, aY1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tapLong: function tapLong() {
|
||||||
|
if (this._contextMenu) {
|
||||||
|
TapHighlightHelper.hide();
|
||||||
|
if (ContextHelper.showPopup(this._contextMenu))
|
||||||
|
// Stop all input sequences
|
||||||
|
ih.cancelPending();
|
||||||
|
this._contextMenu = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
toString: function toString() {
|
toString: function toString() {
|
||||||
return "[ContentTouchHandler] { }";
|
return "[ContentTouchHandler] { }";
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,6 @@ function Content() {
|
|||||||
this._progressController.start();
|
this._progressController.start();
|
||||||
|
|
||||||
this._formAssistant = new FormAssistant();
|
this._formAssistant = new FormAssistant();
|
||||||
this._contextTimeout = new Util.Timeout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Content.prototype = {
|
Content.prototype = {
|
||||||
@ -375,9 +374,7 @@ Content.prototype = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Browser:MouseDown":
|
case "Browser:MouseDown": {
|
||||||
this._contextTimeout.clear();
|
|
||||||
|
|
||||||
let element = elementFromPoint(x, y);
|
let element = elementFromPoint(x, y);
|
||||||
if (!element)
|
if (!element)
|
||||||
return;
|
return;
|
||||||
@ -387,12 +384,11 @@ Content.prototype = {
|
|||||||
sendAsyncMessage("Browser:Highlight", { rects: rects });
|
sendAsyncMessage("Browser:Highlight", { rects: rects });
|
||||||
}
|
}
|
||||||
|
|
||||||
this._contextTimeout.once(500, function() {
|
let event = content.document.createEvent("PopupEvents");
|
||||||
let event = content.document.createEvent("PopupEvents");
|
event.initEvent("contextmenu", true, true);
|
||||||
event.initEvent("contextmenu", true, true);
|
element.dispatchEvent(event);
|
||||||
element.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "Browser:MouseUp": {
|
case "Browser:MouseUp": {
|
||||||
let element = elementFromPoint(x, y);
|
let element = elementFromPoint(x, y);
|
||||||
@ -410,7 +406,6 @@ Content.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "Browser:MouseCancel":
|
case "Browser:MouseCancel":
|
||||||
this._contextTimeout.clear();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Browser:SaveAs":
|
case "Browser:SaveAs":
|
||||||
@ -497,7 +492,6 @@ Content.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
startLoading: function startLoading() {
|
startLoading: function startLoading() {
|
||||||
this._contextTimeout.clear();
|
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user