Bug 752986 - Change VC nav to left/right instead of up/down. Correct home/end constant names. r=davidb

This commit is contained in:
Eitan Isaacson 2012-05-08 17:27:11 -07:00
parent 07b4ed4ca6
commit 6753dea3d5

View File

@ -43,21 +43,28 @@ var VirtualCursorController = {
dump('keypress ' + aEvent.keyCode + '\n');
switch (aEvent.keyCode) {
case aEvent.DOM_END:
case aEvent.DOM_VK_END:
VirtualCursorController.moveForward(document, true);
break;
case aEvent.DOM_HOME:
case aEvent.DOM_VK_HOME:
VirtualCursorController.moveBackward(document, true);
break;
case aEvent.DOM_VK_DOWN:
case aEvent.DOM_VK_RIGHT:
VirtualCursorController.moveForward(document, aEvent.shiftKey);
break;
case aEvent.DOM_VK_UP:
case aEvent.DOM_VK_LEFT:
VirtualCursorController.moveBackward(document, aEvent.shiftKey);
break;
case aEvent.DOM_VK_UP:
if (Services.appinfo.OS == 'Android')
// Return focus to browser chrome, which in Android is a native widget.
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ gecko: { type: 'ToggleChrome:Focus' } }));
break;
case aEvent.DOM_VK_RETURN:
//It is true that desktop does not map the kp enter key to ENTER.
//So for desktop we require a ctrl+return instead.
// XXX: It is true that desktop does not map the keypad enter key to
// DOM_VK_ENTER. So for desktop we require a ctrl+return instead.
if (Services.appinfo.OS == 'Android' || !aEvent.ctrlKey)
return;
case aEvent.DOM_VK_ENTER:
@ -82,20 +89,10 @@ var VirtualCursorController = {
moveBackward: function moveBackward(document, first) {
let virtualCursor = this.getVirtualCursor(document);
if (first) {
virtualCursor.moveFirst(this.SimpleTraversalRule);
return
}
if (!virtualCursor.movePrevious(this.SimpleTraversalRule) &&
Services.appinfo.OS == 'Android') {
// Return focus to browser chrome, which in Android is a native widget.
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ gecko: { type: 'ToggleChrome:Focus' } }));
virtualCursor.position = null;
} else {
virtualCursor.movePrevious(this.SimpleTraversalRule);
}
},