Bug 752986 - Change VC nav to left/right instead of up/down. Correct home/end constant names. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Tue, 08 May 2012 17:27:11 -0700
changeset 95830 075804813c586cdea9d44d2da8e8cb220a546f82
parent 95829 d2206ed33ce7ef892f0525a8e053a9c45698d981
child 95831 a254a5886fc63d6c3069acfe33f3e0060267896d
push idunknown
push userunknown
push dateunknown
reviewersdavidb
bugs752986
milestone15.0a1
Bug 752986 - Change VC nav to left/right instead of up/down. Correct home/end constant names. r=davidb
accessible/src/jsat/VirtualCursorController.jsm
--- a/accessible/src/jsat/VirtualCursorController.jsm
+++ b/accessible/src/jsat/VirtualCursorController.jsm
@@ -38,31 +38,38 @@ var VirtualCursorController = {
 
   onkeypress: function onkeypress(aEvent) {
     let document = VirtualCursorController.getBrowserApp().
       selectedBrowser.contentDocument;
 
     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_LEFT:
+        VirtualCursorController.moveBackward(document, aEvent.shiftKey);
+        break;
       case aEvent.DOM_VK_UP:
-        VirtualCursorController.moveBackward(document, aEvent.shiftKey);
+        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:
         VirtualCursorController.activateCurrent(document);
         break;
       default:
         return;
     }
@@ -77,30 +84,20 @@ var VirtualCursorController = {
       virtualCursor.moveLast(this.SimpleTraversalRule);
     } else {
       virtualCursor.moveNext(this.SimpleTraversalRule);
     }
   },
 
   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);
     }
   },
 
   activateCurrent: function activateCurrent(document) {
     let virtualCursor = this.getVirtualCursor(document);
     let acc = virtualCursor.position;
 
     if (acc.numActions > 0)