Bug 856325 - We do not support double-tap and hold in web content to bring up an item's context menu, r=eeejay

This commit is contained in:
Max Li 2013-06-03 14:29:14 -04:00
Родитель 7398f26b1b
Коммит 1db7a0162c
3 изменённых файлов: 41 добавлений и 0 удалений

Просмотреть файл

@ -194,6 +194,9 @@ this.AccessFu = {
case 'AccessFu:Input':
this.Input.setEditState(aMessage.json);
break;
case 'AccessFu:ActivateContextMenu':
this.Input.activateContextMenu(aMessage.json);
break;
}
},
@ -232,12 +235,14 @@ this.AccessFu = {
aMessageManager.addMessageListener('AccessFu:Present', this);
aMessageManager.addMessageListener('AccessFu:Input', this);
aMessageManager.addMessageListener('AccessFu:Ready', this);
aMessageManager.addMessageListener('AccessFu:ActivateContextMenu', this);
},
_removeMessageListeners: function _removeMessageListeners(aMessageManager) {
aMessageManager.removeMessageListener('AccessFu:Present', this);
aMessageManager.removeMessageListener('AccessFu:Input', this);
aMessageManager.removeMessageListener('AccessFu:Ready', this);
aMessageManager.removeMessageListener('AccessFu:ActivateContextMenu', this);
},
_handleMessageManager: function _handleMessageManager(aMessageManager) {
@ -532,6 +537,9 @@ var Input = {
case 'doubletap1':
this.activateCurrent();
break;
case 'doubletaphold1':
this.sendContextMenuMessage();
break;
case 'swiperight1':
this.moveCursor('moveNext', 'Simple', 'gestures');
break;
@ -658,6 +666,17 @@ var Input = {
mm.sendAsyncMessage('AccessFu:Activate', {});
},
sendContextMenuMessage: function sendContextMenuMessage() {
let mm = Utils.getMessageManager(Utils.CurrentBrowser);
mm.sendAsyncMessage('AccessFu:ContextMenu', {});
},
activateContextMenu: function activateContextMenu(aMessage) {
if (Utils.MozBuildApp === 'mobile/android')
Services.obs.notifyObservers(null, 'Gesture:LongPress',
JSON.stringify({x: aMessage.x, y: aMessage.y}));
},
setEditState: function setEditState(aEditState) {
this.editState = aEditState;
},

Просмотреть файл

@ -227,6 +227,9 @@ this.TouchAdapter = {
case 'doubletap-tap':
details.type = 'tripletap';
break;
case 'doubletap-dwell':
details.type = 'doubletaphold';
break;
case 'tap-dwell':
details.type = 'taphold';
break;
@ -260,6 +263,9 @@ this.TouchAdapter = {
if (aDetails.type == 'tap') {
emitDelay = 50;
aDetails.type = 'doubletap';
} else if (aDetails.type == 'dwell') {
emitDelay = 50;
aDetails.type = 'doubletaphold';
} else {
aDetails.touches.push(this.MOUSE_ID);
}

Просмотреть файл

@ -156,6 +156,20 @@ function activateCurrent(aMessage) {
activateAccessible(vc.position);
}
function activateContextMenu(aMessage) {
function sendContextMenuCoordinates(aAccessible) {
let objX = {}, objY = {}, objW = {}, objH = {};
aAccessible.getBounds(objX, objY, objW, objH);
let x = objX.value + objW.value / 2;
let y = objY.value + objH.value / 2;
sendAsyncMessage('AccessFu:ActivateContextMenu', {x: x, y: y});
}
let vc = Utils.getVirtualCursor(content.document);
if (!forwardMessage(vc, aMessage))
sendContextMenuCoordinates(vc.position);
}
function scroll(aMessage) {
let vc = Utils.getVirtualCursor(content.document);
@ -248,6 +262,7 @@ addMessageListener(
addMessageListener('AccessFu:VirtualCursor', virtualCursorControl);
addMessageListener('AccessFu:Activate', activateCurrent);
addMessageListener('AccessFu:ContextMenu', activateContextMenu);
addMessageListener('AccessFu:Scroll', scroll);
if (!eventManager) {
@ -263,6 +278,7 @@ addMessageListener(
removeMessageListener('AccessFu:VirtualCursor', virtualCursorControl);
removeMessageListener('AccessFu:Activate', activateCurrent);
removeMessageListener('AccessFu:ContextMenu', activateContextMenu);
removeMessageListener('AccessFu:Scroll', scroll);
eventManager.stop();