Bug 864521 - Replace Fennec's AndroidKeyEvent::KEYCODE enum with Android's AKEYCODE enum. r=jchen
authorChris Peterson <cpeterson@mozilla.com>
Mon, 22 Apr 2013 11:24:43 -0700
changeset 140485 7eba4d94e5a7712bdfd3c4ced0d54797d7b33f42
parent 140484 52fa74fb7b0f96d110fb758405bdf7e7cc8d27b6
child 140486 e9c77bd1e5fee8ec84ae911f806895916e510c87
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs864521
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 864521 - Replace Fennec's AndroidKeyEvent::KEYCODE enum with Android's AKEYCODE enum. r=jchen
widget/android/AndroidJavaWrappers.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AndroidJavaWrappers_h__
 #define AndroidJavaWrappers_h__
 
 #include <jni.h>
+#include <android/input.h>
 #include <android/log.h>
 
 #include "nsGeoPosition.h"
 #include "nsPoint.h"
 #include "nsRect.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/gfx/Rect.h"
@@ -286,265 +287,130 @@ protected:
 public:
     static jclass jViewportClass;
     static jclass jDisplayportClass;
     static jmethodID jViewportCtor;
     static jfieldID jDisplayportPosition;
     static jfieldID jDisplayportResolution;
 };
 
-class AndroidKeyEvent
-{
-public:
-    enum {
-        KEYCODE_UNKNOWN            = 0,
-        KEYCODE_SOFT_LEFT          = 1,
-        KEYCODE_SOFT_RIGHT         = 2,
-        KEYCODE_HOME               = 3,
-        KEYCODE_BACK               = 4,
-        KEYCODE_CALL               = 5,
-        KEYCODE_ENDCALL            = 6,
-        KEYCODE_0                  = 7,
-        KEYCODE_1                  = 8,
-        KEYCODE_2                  = 9,
-        KEYCODE_3                  = 10,
-        KEYCODE_4                  = 11,
-        KEYCODE_5                  = 12,
-        KEYCODE_6                  = 13,
-        KEYCODE_7                  = 14,
-        KEYCODE_8                  = 15,
-        KEYCODE_9                  = 16,
-        KEYCODE_STAR               = 17,
-        KEYCODE_POUND              = 18,
-        KEYCODE_DPAD_UP            = 19,
-        KEYCODE_DPAD_DOWN          = 20,
-        KEYCODE_DPAD_LEFT          = 21,
-        KEYCODE_DPAD_RIGHT         = 22,
-        KEYCODE_DPAD_CENTER        = 23,
-        KEYCODE_VOLUME_UP          = 24,
-        KEYCODE_VOLUME_DOWN        = 25,
-        KEYCODE_POWER              = 26,
-        KEYCODE_CAMERA             = 27,
-        KEYCODE_CLEAR              = 28,
-        KEYCODE_A                  = 29,
-        KEYCODE_B                  = 30,
-        KEYCODE_C                  = 31,
-        KEYCODE_D                  = 32,
-        KEYCODE_E                  = 33,
-        KEYCODE_F                  = 34,
-        KEYCODE_G                  = 35,
-        KEYCODE_H                  = 36,
-        KEYCODE_I                  = 37,
-        KEYCODE_J                  = 38,
-        KEYCODE_K                  = 39,
-        KEYCODE_L                  = 40,
-        KEYCODE_M                  = 41,
-        KEYCODE_N                  = 42,
-        KEYCODE_O                  = 43,
-        KEYCODE_P                  = 44,
-        KEYCODE_Q                  = 45,
-        KEYCODE_R                  = 46,
-        KEYCODE_S                  = 47,
-        KEYCODE_T                  = 48,
-        KEYCODE_U                  = 49,
-        KEYCODE_V                  = 50,
-        KEYCODE_W                  = 51,
-        KEYCODE_X                  = 52,
-        KEYCODE_Y                  = 53,
-        KEYCODE_Z                  = 54,
-        KEYCODE_COMMA              = 55,
-        KEYCODE_PERIOD             = 56,
-        KEYCODE_ALT_LEFT           = 57,
-        KEYCODE_ALT_RIGHT          = 58,
-        KEYCODE_SHIFT_LEFT         = 59,
-        KEYCODE_SHIFT_RIGHT        = 60,
-        KEYCODE_TAB                = 61,
-        KEYCODE_SPACE              = 62,
-        KEYCODE_SYM                = 63,
-        KEYCODE_EXPLORER           = 64,
-        KEYCODE_ENVELOPE           = 65,
-        KEYCODE_ENTER              = 66,
-        KEYCODE_DEL                = 67,
-        KEYCODE_GRAVE              = 68,
-        KEYCODE_MINUS              = 69,
-        KEYCODE_EQUALS             = 70,
-        KEYCODE_LEFT_BRACKET       = 71,
-        KEYCODE_RIGHT_BRACKET      = 72,
-        KEYCODE_BACKSLASH          = 73,
-        KEYCODE_SEMICOLON          = 74,
-        KEYCODE_APOSTROPHE         = 75,
-        KEYCODE_SLASH              = 76,
-        KEYCODE_AT                 = 77,
-        KEYCODE_NUM                = 78,
-        KEYCODE_HEADSETHOOK        = 79,
-        KEYCODE_FOCUS              = 80,
-        KEYCODE_PLUS               = 81,
-        KEYCODE_MENU               = 82,
-        KEYCODE_NOTIFICATION       = 83,
-        KEYCODE_SEARCH             = 84,
-        KEYCODE_MEDIA_PLAY_PAUSE   = 85,
-        KEYCODE_MEDIA_STOP         = 86,
-        KEYCODE_MEDIA_NEXT         = 87,
-        KEYCODE_MEDIA_PREVIOUS     = 88,
-        KEYCODE_MEDIA_REWIND       = 89,
-        KEYCODE_MEDIA_FAST_FORWARD = 90,
-        KEYCODE_MUTE               = 91,
-        KEYCODE_PAGE_UP            = 92,
-        KEYCODE_PAGE_DOWN          = 93,
-        KEYCODE_PICTSYMBOLS        = 94,
-        KEYCODE_SWITCH_CHARSET     = 95,
-        KEYCODE_BUTTON_A           = 96,
-        KEYCODE_BUTTON_B           = 97,
-        KEYCODE_BUTTON_C           = 98,
-        KEYCODE_BUTTON_X           = 99,
-        KEYCODE_BUTTON_Y           = 100,
-        KEYCODE_BUTTON_Z           = 101,
-        KEYCODE_BUTTON_L1          = 102,
-        KEYCODE_BUTTON_R1          = 103,
-        KEYCODE_BUTTON_L2          = 104,
-        KEYCODE_BUTTON_R2          = 105,
-        KEYCODE_BUTTON_THUMBL      = 106,
-        KEYCODE_BUTTON_THUMBR      = 107,
-        KEYCODE_BUTTON_START       = 108,
-        KEYCODE_BUTTON_SELECT      = 109,
-        KEYCODE_BUTTON_MODE        = 110,
-        KEYCODE_ESCAPE             = 111,
-        KEYCODE_FORWARD_DEL        = 112,
-        KEYCODE_CTRL_LEFT          = 113,
-        KEYCODE_CTRL_RIGHT         = 114,
-        KEYCODE_CAPS_LOCK          = 115,
-        KEYCODE_SCROLL_LOCK        = 116,
-        KEYCODE_META_LEFT          = 117,
-        KEYCODE_META_RIGHT         = 118,
-        KEYCODE_FUNCTION           = 119,
-        KEYCODE_SYSRQ              = 120,
-        KEYCODE_BREAK              = 121,
-        KEYCODE_MOVE_HOME          = 122,
-        KEYCODE_MOVE_END           = 123,
-        KEYCODE_INSERT             = 124,
-        KEYCODE_FORWARD            = 125,
-        KEYCODE_MEDIA_PLAY         = 126,
-        KEYCODE_MEDIA_PAUSE        = 127,
-        KEYCODE_MEDIA_CLOSE        = 128,
-        KEYCODE_MEDIA_EJECT        = 129,
-        KEYCODE_MEDIA_RECORD       = 130,
-        KEYCODE_F1                 = 131,
-        KEYCODE_F2                 = 132,
-        KEYCODE_F3                 = 133,
-        KEYCODE_F4                 = 134,
-        KEYCODE_F5                 = 135,
-        KEYCODE_F6                 = 136,
-        KEYCODE_F7                 = 137,
-        KEYCODE_F8                 = 138,
-        KEYCODE_F9                 = 139,
-        KEYCODE_F10                = 140,
-        KEYCODE_F11                = 141,
-        KEYCODE_F12                = 142,
-        KEYCODE_NUM_LOCK           = 143,
-        KEYCODE_NUMPAD_0           = 144,
-        KEYCODE_NUMPAD_1           = 145,
-        KEYCODE_NUMPAD_2           = 146,
-        KEYCODE_NUMPAD_3           = 147,
-        KEYCODE_NUMPAD_4           = 148,
-        KEYCODE_NUMPAD_5           = 149,
-        KEYCODE_NUMPAD_6           = 150,
-        KEYCODE_NUMPAD_7           = 151,
-        KEYCODE_NUMPAD_8           = 152,
-        KEYCODE_NUMPAD_9           = 153,
-        KEYCODE_NUMPAD_DIVIDE      = 154,
-        KEYCODE_NUMPAD_MULTIPLY    = 155,
-        KEYCODE_NUMPAD_SUBTRACT    = 156,
-        KEYCODE_NUMPAD_ADD         = 157,
-        KEYCODE_NUMPAD_DOT         = 158,
-        KEYCODE_NUMPAD_COMMA       = 159,
-        KEYCODE_NUMPAD_ENTER       = 160,
-        KEYCODE_NUMPAD_EQUALS      = 161,
-        KEYCODE_NUMPAD_LEFT_PAREN  = 162,
-        KEYCODE_NUMPAD_RIGHT_PAREN = 163,
-        KEYCODE_VOLUME_MUTE        = 164,
-        KEYCODE_INFO               = 165,
-        KEYCODE_CHANNEL_UP         = 166,
-        KEYCODE_CHANNEL_DOWN       = 167,
-        KEYCODE_ZOOM_IN            = 168,
-        KEYCODE_ZOOM_OUT           = 169,
-        KEYCODE_TV                 = 170,
-        KEYCODE_WINDOW             = 171,
-        KEYCODE_GUIDE              = 172,
-        KEYCODE_DVR                = 173,
-        KEYCODE_BOOKMARK           = 174,
-        KEYCODE_CAPTIONS           = 175,
-        KEYCODE_SETTINGS           = 176,
-        KEYCODE_TV_POWER           = 177,
-        KEYCODE_TV_INPUT           = 178,
-        KEYCODE_STB_POWER          = 179,
-        KEYCODE_STB_INPUT          = 180,
-        KEYCODE_AVR_POWER          = 181,
-        KEYCODE_AVR_INPUT          = 182,
-        KEYCODE_PROG_RED           = 183,
-        KEYCODE_PROG_GREEN         = 184,
-        KEYCODE_PROG_YELLOW        = 185,
-        KEYCODE_PROG_BLUE          = 186,
-        KEYCODE_APP_SWITCH         = 187,
-        KEYCODE_BUTTON_1           = 188,
-        KEYCODE_BUTTON_2           = 189,
-        KEYCODE_BUTTON_3           = 190,
-        KEYCODE_BUTTON_4           = 191,
-        KEYCODE_BUTTON_5           = 192,
-        KEYCODE_BUTTON_6           = 193,
-        KEYCODE_BUTTON_7           = 194,
-        KEYCODE_BUTTON_8           = 195,
-        KEYCODE_BUTTON_9           = 196,
-        KEYCODE_BUTTON_10          = 197,
-        KEYCODE_BUTTON_11          = 198,
-        KEYCODE_BUTTON_12          = 199,
-        KEYCODE_BUTTON_13          = 200,
-        KEYCODE_BUTTON_14          = 201,
-        KEYCODE_BUTTON_15          = 202,
-        KEYCODE_BUTTON_16          = 203,
-        KEYCODE_LANGUAGE_SWITCH    = 204,
-        KEYCODE_MANNER_MODE        = 205,
-        KEYCODE_3D_MODE            = 206,
-        KEYCODE_CONTACTS           = 207,
-        KEYCODE_CALENDAR           = 208,
-        KEYCODE_MUSIC              = 209,
-        KEYCODE_CALCULATOR         = 210,
+enum {
+    // These keycode masks are not defined in android/keycodes.h:
+    AKEYCODE_ESCAPE             = 111,
+    AKEYCODE_FORWARD_DEL        = 112,
+    AKEYCODE_CTRL_LEFT          = 113,
+    AKEYCODE_CTRL_RIGHT         = 114,
+    AKEYCODE_CAPS_LOCK          = 115,
+    AKEYCODE_SCROLL_LOCK        = 116,
+    AKEYCODE_META_LEFT          = 117,
+    AKEYCODE_META_RIGHT         = 118,
+    AKEYCODE_FUNCTION           = 119,
+    AKEYCODE_SYSRQ              = 120,
+    AKEYCODE_BREAK              = 121,
+    AKEYCODE_MOVE_HOME          = 122,
+    AKEYCODE_MOVE_END           = 123,
+    AKEYCODE_INSERT             = 124,
+    AKEYCODE_FORWARD            = 125,
+    AKEYCODE_MEDIA_PLAY         = 126,
+    AKEYCODE_MEDIA_PAUSE        = 127,
+    AKEYCODE_MEDIA_CLOSE        = 128,
+    AKEYCODE_MEDIA_EJECT        = 129,
+    AKEYCODE_MEDIA_RECORD       = 130,
+    AKEYCODE_F1                 = 131,
+    AKEYCODE_F2                 = 132,
+    AKEYCODE_F3                 = 133,
+    AKEYCODE_F4                 = 134,
+    AKEYCODE_F5                 = 135,
+    AKEYCODE_F6                 = 136,
+    AKEYCODE_F7                 = 137,
+    AKEYCODE_F8                 = 138,
+    AKEYCODE_F9                 = 139,
+    AKEYCODE_F10                = 140,
+    AKEYCODE_F11                = 141,
+    AKEYCODE_F12                = 142,
+    AKEYCODE_NUM_LOCK           = 143,
+    AKEYCODE_NUMPAD_0           = 144,
+    AKEYCODE_NUMPAD_1           = 145,
+    AKEYCODE_NUMPAD_2           = 146,
+    AKEYCODE_NUMPAD_3           = 147,
+    AKEYCODE_NUMPAD_4           = 148,
+    AKEYCODE_NUMPAD_5           = 149,
+    AKEYCODE_NUMPAD_6           = 150,
+    AKEYCODE_NUMPAD_7           = 151,
+    AKEYCODE_NUMPAD_8           = 152,
+    AKEYCODE_NUMPAD_9           = 153,
+    AKEYCODE_NUMPAD_DIVIDE      = 154,
+    AKEYCODE_NUMPAD_MULTIPLY    = 155,
+    AKEYCODE_NUMPAD_SUBTRACT    = 156,
+    AKEYCODE_NUMPAD_ADD         = 157,
+    AKEYCODE_NUMPAD_DOT         = 158,
+    AKEYCODE_NUMPAD_COMMA       = 159,
+    AKEYCODE_NUMPAD_ENTER       = 160,
+    AKEYCODE_NUMPAD_EQUALS      = 161,
+    AKEYCODE_NUMPAD_LEFT_PAREN  = 162,
+    AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
+    AKEYCODE_VOLUME_MUTE        = 164,
+    AKEYCODE_INFO               = 165,
+    AKEYCODE_CHANNEL_UP         = 166,
+    AKEYCODE_CHANNEL_DOWN       = 167,
+    AKEYCODE_ZOOM_IN            = 168,
+    AKEYCODE_ZOOM_OUT           = 169,
+    AKEYCODE_TV                 = 170,
+    AKEYCODE_WINDOW             = 171,
+    AKEYCODE_GUIDE              = 172,
+    AKEYCODE_DVR                = 173,
+    AKEYCODE_BOOKMARK           = 174,
+    AKEYCODE_CAPTIONS           = 175,
+    AKEYCODE_SETTINGS           = 176,
+    AKEYCODE_TV_POWER           = 177,
+    AKEYCODE_TV_INPUT           = 178,
+    AKEYCODE_STB_POWER          = 179,
+    AKEYCODE_STB_INPUT          = 180,
+    AKEYCODE_AVR_POWER          = 181,
+    AKEYCODE_AVR_INPUT          = 182,
+    AKEYCODE_PROG_RED           = 183,
+    AKEYCODE_PROG_GREEN         = 184,
+    AKEYCODE_PROG_YELLOW        = 185,
+    AKEYCODE_PROG_BLUE          = 186,
+    AKEYCODE_APP_SWITCH         = 187,
+    AKEYCODE_BUTTON_1           = 188,
+    AKEYCODE_BUTTON_2           = 189,
+    AKEYCODE_BUTTON_3           = 190,
+    AKEYCODE_BUTTON_4           = 191,
+    AKEYCODE_BUTTON_5           = 192,
+    AKEYCODE_BUTTON_6           = 193,
+    AKEYCODE_BUTTON_7           = 194,
+    AKEYCODE_BUTTON_8           = 195,
+    AKEYCODE_BUTTON_9           = 196,
+    AKEYCODE_BUTTON_10          = 197,
+    AKEYCODE_BUTTON_11          = 198,
+    AKEYCODE_BUTTON_12          = 199,
+    AKEYCODE_BUTTON_13          = 200,
+    AKEYCODE_BUTTON_14          = 201,
+    AKEYCODE_BUTTON_15          = 202,
+    AKEYCODE_BUTTON_16          = 203,
+    AKEYCODE_LANGUAGE_SWITCH    = 204,
+    AKEYCODE_MANNER_MODE        = 205,
+    AKEYCODE_3D_MODE            = 206,
+    AKEYCODE_CONTACTS           = 207,
+    AKEYCODE_CALENDAR           = 208,
+    AKEYCODE_MUSIC              = 209,
+    AKEYCODE_CALCULATOR         = 210,
 
-        ACTION_DOWN                = 0,
-        ACTION_UP                  = 1,
-        ACTION_MULTIPLE            = 2,
-        META_ALT_ON                = 0x00000002,
-        META_ALT_LEFT_ON           = 0x00000010,
-        META_ALT_RIGHT_ON          = 0x00000020,
-        META_ALT_MASK              = META_ALT_RIGHT_ON | META_ALT_LEFT_ON | META_ALT_ON,
-        META_SHIFT_ON              = 0x00000001,
-        META_SHIFT_LEFT_ON         = 0x00000040,
-        META_SHIFT_RIGHT_ON        = 0x00000080,
-        META_SHIFT_MASK            = META_SHIFT_RIGHT_ON | META_SHIFT_LEFT_ON | META_SHIFT_ON,
-        META_CTRL_ON               = 0x00001000,
-        META_CTRL_LEFT_ON          = 0x00002000,
-        META_CTRL_RIGHT_ON         = 0x00004000,
-        META_CTRL_MASK             = META_CTRL_RIGHT_ON | META_CTRL_LEFT_ON | META_CTRL_ON,
-        META_META_ON               = 0x00010000,
-        META_META_LEFT_ON          = 0x00020000,
-        META_META_RIGHT_ON         = 0x00040000,
-        META_META_MASK             = META_META_RIGHT_ON | META_META_LEFT_ON | META_META_ON,
-        META_SYM_ON                = 0x00000004,
-        FLAG_WOKE_HERE             = 0x00000001,
-        FLAG_SOFT_KEYBOARD         = 0x00000002,
-        FLAG_KEEP_TOUCH_MODE       = 0x00000004,
-        FLAG_FROM_SYSTEM           = 0x00000008,
-        FLAG_EDITOR_ACTION         = 0x00000010,
-        FLAG_CANCELED              = 0x00000020,
-        FLAG_VIRTUAL_HARD_KEY      = 0x00000040,
-        FLAG_LONG_PRESS            = 0x00000080,
-        FLAG_CANCELED_LONG_PRESS   = 0x00000100,
-        FLAG_TRACKING              = 0x00000200,
-        FLAG_START_TRACKING        = 0x40000000,
-        dummy_java_enum_list_end
-    };
+    AMETA_CTRL_ON               = 0x00001000,
+    AMETA_CTRL_LEFT_ON          = 0x00002000,
+    AMETA_CTRL_RIGHT_ON         = 0x00004000,
+    AMETA_META_ON               = 0x00010000,
+    AMETA_META_LEFT_ON          = 0x00020000,
+    AMETA_META_RIGHT_ON         = 0x00040000,
+
+    AMETA_ALT_MASK              = AMETA_ALT_LEFT_ON   | AMETA_ALT_RIGHT_ON   | AMETA_ALT_ON,
+    AMETA_CTRL_MASK             = AMETA_CTRL_LEFT_ON  | AMETA_CTRL_RIGHT_ON  | AMETA_CTRL_ON,
+    AMETA_META_MASK             = AMETA_META_LEFT_ON  | AMETA_META_RIGHT_ON  | AMETA_META_ON,
+    AMETA_SHIFT_MASK            = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON,
 };
 
 class AndroidMotionEvent
 {
 public:
     enum {
         ACTION_DOWN = 0,
         ACTION_UP = 1,
@@ -645,20 +511,20 @@ public:
     double Y() { return mY; }
     double Z() { return mZ; }
     const nsIntRect& Rect() { return mRect; }
     nsAString& Characters() { return mCharacters; }
     nsAString& CharactersExtra() { return mCharactersExtra; }
     int KeyCode() { return mKeyCode; }
     int MetaState() { return mMetaState; }
     uint32_t DomKeyLocation() { return mDomKeyLocation; }
-    bool IsAltPressed() const { return (mMetaState & AndroidKeyEvent::META_ALT_MASK) != 0; }
-    bool IsShiftPressed() const { return (mMetaState & AndroidKeyEvent::META_SHIFT_MASK) != 0; }
-    bool IsCtrlPressed() const { return (mMetaState & AndroidKeyEvent::META_CTRL_MASK) != 0; }
-    bool IsMetaPressed() const { return (mMetaState & AndroidKeyEvent::META_META_MASK) != 0; }
+    bool IsAltPressed() const { return (mMetaState & AMETA_ALT_MASK) != 0; }
+    bool IsShiftPressed() const { return (mMetaState & AMETA_SHIFT_MASK) != 0; }
+    bool IsCtrlPressed() const { return (mMetaState & AMETA_CTRL_MASK) != 0; }
+    bool IsMetaPressed() const { return (mMetaState & AMETA_META_MASK) != 0; }
     int Flags() { return mFlags; }
     int UnicodeChar() { return mUnicodeChar; }
     int BaseUnicodeChar() { return mBaseUnicodeChar; }
     int RepeatCount() const { return mRepeatCount; }
     int Count() { return mCount; }
     int Start() { return mStart; }
     int End() { return mEnd; }
     int PointerIndex() { return mPointerIndex; }
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1303,107 +1303,107 @@ nsWindow::DispatchMotionEvent(nsInputEve
     event.refPoint = refPoint - offset;
 
     DispatchEvent(&event);
 }
 
 static unsigned int ConvertAndroidKeyCodeToDOMKeyCode(int androidKeyCode)
 {
     // Special-case alphanumeric keycodes because they are most common.
-    if (androidKeyCode >= AndroidKeyEvent::KEYCODE_A &&
-        androidKeyCode <= AndroidKeyEvent::KEYCODE_Z) {
-        return androidKeyCode - AndroidKeyEvent::KEYCODE_A + NS_VK_A;
+    if (androidKeyCode >= AKEYCODE_A &&
+        androidKeyCode <= AKEYCODE_Z) {
+        return androidKeyCode - AKEYCODE_A + NS_VK_A;
     }
 
-    if (androidKeyCode >= AndroidKeyEvent::KEYCODE_0 &&
-        androidKeyCode <= AndroidKeyEvent::KEYCODE_9) {
-        return androidKeyCode - AndroidKeyEvent::KEYCODE_0 + NS_VK_0;
+    if (androidKeyCode >= AKEYCODE_0 &&
+        androidKeyCode <= AKEYCODE_9) {
+        return androidKeyCode - AKEYCODE_0 + NS_VK_0;
     }
 
     switch (androidKeyCode) {
         // KEYCODE_UNKNOWN (0) ... KEYCODE_HOME (3)
-        case AndroidKeyEvent::KEYCODE_BACK:               return NS_VK_ESCAPE;
+        case AKEYCODE_BACK:               return NS_VK_ESCAPE;
         // KEYCODE_CALL (5) ... KEYCODE_POUND (18)
-        case AndroidKeyEvent::KEYCODE_DPAD_UP:            return NS_VK_UP;
-        case AndroidKeyEvent::KEYCODE_DPAD_DOWN:          return NS_VK_DOWN;
-        case AndroidKeyEvent::KEYCODE_DPAD_LEFT:          return NS_VK_LEFT;
-        case AndroidKeyEvent::KEYCODE_DPAD_RIGHT:         return NS_VK_RIGHT;
-        case AndroidKeyEvent::KEYCODE_DPAD_CENTER:        return NS_VK_RETURN;
-        case AndroidKeyEvent::KEYCODE_VOLUME_UP:          return NS_VK_VOLUME_UP;
-        case AndroidKeyEvent::KEYCODE_VOLUME_DOWN:        return NS_VK_VOLUME_DOWN;
+        case AKEYCODE_DPAD_UP:            return NS_VK_UP;
+        case AKEYCODE_DPAD_DOWN:          return NS_VK_DOWN;
+        case AKEYCODE_DPAD_LEFT:          return NS_VK_LEFT;
+        case AKEYCODE_DPAD_RIGHT:         return NS_VK_RIGHT;
+        case AKEYCODE_DPAD_CENTER:        return NS_VK_RETURN;
+        case AKEYCODE_VOLUME_UP:          return NS_VK_VOLUME_UP;
+        case AKEYCODE_VOLUME_DOWN:        return NS_VK_VOLUME_DOWN;
         // KEYCODE_VOLUME_POWER (26) ... KEYCODE_Z (54)
-        case AndroidKeyEvent::KEYCODE_COMMA:              return NS_VK_COMMA;
-        case AndroidKeyEvent::KEYCODE_PERIOD:             return NS_VK_PERIOD;
-        case AndroidKeyEvent::KEYCODE_ALT_LEFT:           return NS_VK_ALT;
-        case AndroidKeyEvent::KEYCODE_ALT_RIGHT:          return NS_VK_ALT;
-        case AndroidKeyEvent::KEYCODE_SHIFT_LEFT:         return NS_VK_SHIFT;
-        case AndroidKeyEvent::KEYCODE_SHIFT_RIGHT:        return NS_VK_SHIFT;
-        case AndroidKeyEvent::KEYCODE_TAB:                return NS_VK_TAB;
-        case AndroidKeyEvent::KEYCODE_SPACE:              return NS_VK_SPACE;
+        case AKEYCODE_COMMA:              return NS_VK_COMMA;
+        case AKEYCODE_PERIOD:             return NS_VK_PERIOD;
+        case AKEYCODE_ALT_LEFT:           return NS_VK_ALT;
+        case AKEYCODE_ALT_RIGHT:          return NS_VK_ALT;
+        case AKEYCODE_SHIFT_LEFT:         return NS_VK_SHIFT;
+        case AKEYCODE_SHIFT_RIGHT:        return NS_VK_SHIFT;
+        case AKEYCODE_TAB:                return NS_VK_TAB;
+        case AKEYCODE_SPACE:              return NS_VK_SPACE;
         // KEYCODE_SYM (63) ... KEYCODE_ENVELOPE (65)
-        case AndroidKeyEvent::KEYCODE_ENTER:              return NS_VK_RETURN;
-        case AndroidKeyEvent::KEYCODE_DEL:                return NS_VK_BACK; // Backspace
-        case AndroidKeyEvent::KEYCODE_GRAVE:              return NS_VK_BACK_QUOTE;
+        case AKEYCODE_ENTER:              return NS_VK_RETURN;
+        case AKEYCODE_DEL:                return NS_VK_BACK; // Backspace
+        case AKEYCODE_GRAVE:              return NS_VK_BACK_QUOTE;
         // KEYCODE_MINUS (69)
-        case AndroidKeyEvent::KEYCODE_EQUALS:             return NS_VK_EQUALS;
-        case AndroidKeyEvent::KEYCODE_LEFT_BRACKET:       return NS_VK_OPEN_BRACKET;
-        case AndroidKeyEvent::KEYCODE_RIGHT_BRACKET:      return NS_VK_CLOSE_BRACKET;
-        case AndroidKeyEvent::KEYCODE_BACKSLASH:          return NS_VK_BACK_SLASH;
-        case AndroidKeyEvent::KEYCODE_SEMICOLON:          return NS_VK_SEMICOLON;
+        case AKEYCODE_EQUALS:             return NS_VK_EQUALS;
+        case AKEYCODE_LEFT_BRACKET:       return NS_VK_OPEN_BRACKET;
+        case AKEYCODE_RIGHT_BRACKET:      return NS_VK_CLOSE_BRACKET;
+        case AKEYCODE_BACKSLASH:          return NS_VK_BACK_SLASH;
+        case AKEYCODE_SEMICOLON:          return NS_VK_SEMICOLON;
         // KEYCODE_APOSTROPHE (75)
-        case AndroidKeyEvent::KEYCODE_SLASH:              return NS_VK_SLASH;
+        case AKEYCODE_SLASH:              return NS_VK_SLASH;
         // KEYCODE_AT (77) ... KEYCODE_MEDIA_FAST_FORWARD (90)
-        case AndroidKeyEvent::KEYCODE_MUTE:               return NS_VK_VOLUME_MUTE;
-        case AndroidKeyEvent::KEYCODE_PAGE_UP:            return NS_VK_PAGE_UP;
-        case AndroidKeyEvent::KEYCODE_PAGE_DOWN:          return NS_VK_PAGE_DOWN;
+        case AKEYCODE_MUTE:               return NS_VK_VOLUME_MUTE;
+        case AKEYCODE_PAGE_UP:            return NS_VK_PAGE_UP;
+        case AKEYCODE_PAGE_DOWN:          return NS_VK_PAGE_DOWN;
         // KEYCODE_PICTSYMBOLS (94) ... KEYCODE_BUTTON_MODE (110)
-        case AndroidKeyEvent::KEYCODE_ESCAPE:             return NS_VK_ESCAPE;
-        case AndroidKeyEvent::KEYCODE_FORWARD_DEL:        return NS_VK_DELETE;
-        case AndroidKeyEvent::KEYCODE_CTRL_LEFT:          return NS_VK_CONTROL;
-        case AndroidKeyEvent::KEYCODE_CTRL_RIGHT:         return NS_VK_CONTROL;
-        case AndroidKeyEvent::KEYCODE_CAPS_LOCK:          return NS_VK_CAPS_LOCK;
-        case AndroidKeyEvent::KEYCODE_SCROLL_LOCK:        return NS_VK_SCROLL_LOCK;
+        case AKEYCODE_ESCAPE:             return NS_VK_ESCAPE;
+        case AKEYCODE_FORWARD_DEL:        return NS_VK_DELETE;
+        case AKEYCODE_CTRL_LEFT:          return NS_VK_CONTROL;
+        case AKEYCODE_CTRL_RIGHT:         return NS_VK_CONTROL;
+        case AKEYCODE_CAPS_LOCK:          return NS_VK_CAPS_LOCK;
+        case AKEYCODE_SCROLL_LOCK:        return NS_VK_SCROLL_LOCK;
         // KEYCODE_META_LEFT (117) ... KEYCODE_FUNCTION (119)
-        case AndroidKeyEvent::KEYCODE_SYSRQ:              return NS_VK_PRINTSCREEN;
-        case AndroidKeyEvent::KEYCODE_BREAK:              return NS_VK_PAUSE;
-        case AndroidKeyEvent::KEYCODE_MOVE_HOME:          return NS_VK_HOME;
-        case AndroidKeyEvent::KEYCODE_MOVE_END:           return NS_VK_END;
-        case AndroidKeyEvent::KEYCODE_INSERT:             return NS_VK_INSERT;
+        case AKEYCODE_SYSRQ:              return NS_VK_PRINTSCREEN;
+        case AKEYCODE_BREAK:              return NS_VK_PAUSE;
+        case AKEYCODE_MOVE_HOME:          return NS_VK_HOME;
+        case AKEYCODE_MOVE_END:           return NS_VK_END;
+        case AKEYCODE_INSERT:             return NS_VK_INSERT;
         // KEYCODE_FORWARD (125) ... KEYCODE_MEDIA_RECORD (130)
-        case AndroidKeyEvent::KEYCODE_F1:                 return NS_VK_F1;
-        case AndroidKeyEvent::KEYCODE_F2:                 return NS_VK_F2;
-        case AndroidKeyEvent::KEYCODE_F3:                 return NS_VK_F3;
-        case AndroidKeyEvent::KEYCODE_F4:                 return NS_VK_F4;
-        case AndroidKeyEvent::KEYCODE_F5:                 return NS_VK_F5;
-        case AndroidKeyEvent::KEYCODE_F6:                 return NS_VK_F6;
-        case AndroidKeyEvent::KEYCODE_F7:                 return NS_VK_F7;
-        case AndroidKeyEvent::KEYCODE_F8:                 return NS_VK_F8;
-        case AndroidKeyEvent::KEYCODE_F9:                 return NS_VK_F9;
-        case AndroidKeyEvent::KEYCODE_F10:                return NS_VK_F10;
-        case AndroidKeyEvent::KEYCODE_F11:                return NS_VK_F11;
-        case AndroidKeyEvent::KEYCODE_F12:                return NS_VK_F12;
-        case AndroidKeyEvent::KEYCODE_NUM_LOCK:           return NS_VK_NUM_LOCK;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_0:           return NS_VK_NUMPAD0;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_1:           return NS_VK_NUMPAD1;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_2:           return NS_VK_NUMPAD2;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_3:           return NS_VK_NUMPAD3;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_4:           return NS_VK_NUMPAD4;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_5:           return NS_VK_NUMPAD5;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_6:           return NS_VK_NUMPAD6;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_7:           return NS_VK_NUMPAD7;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_8:           return NS_VK_NUMPAD8;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_9:           return NS_VK_NUMPAD9;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_DIVIDE:      return NS_VK_DIVIDE;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_MULTIPLY:    return NS_VK_MULTIPLY;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_SUBTRACT:    return NS_VK_SUBTRACT;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_ADD:         return NS_VK_ADD;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_DOT:         return NS_VK_DECIMAL;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_COMMA:       return NS_VK_SEPARATOR;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_ENTER:       return NS_VK_RETURN;
-        case AndroidKeyEvent::KEYCODE_NUMPAD_EQUALS:      return NS_VK_EQUALS;
+        case AKEYCODE_F1:                 return NS_VK_F1;
+        case AKEYCODE_F2:                 return NS_VK_F2;
+        case AKEYCODE_F3:                 return NS_VK_F3;
+        case AKEYCODE_F4:                 return NS_VK_F4;
+        case AKEYCODE_F5:                 return NS_VK_F5;
+        case AKEYCODE_F6:                 return NS_VK_F6;
+        case AKEYCODE_F7:                 return NS_VK_F7;
+        case AKEYCODE_F8:                 return NS_VK_F8;
+        case AKEYCODE_F9:                 return NS_VK_F9;
+        case AKEYCODE_F10:                return NS_VK_F10;
+        case AKEYCODE_F11:                return NS_VK_F11;
+        case AKEYCODE_F12:                return NS_VK_F12;
+        case AKEYCODE_NUM_LOCK:           return NS_VK_NUM_LOCK;
+        case AKEYCODE_NUMPAD_0:           return NS_VK_NUMPAD0;
+        case AKEYCODE_NUMPAD_1:           return NS_VK_NUMPAD1;
+        case AKEYCODE_NUMPAD_2:           return NS_VK_NUMPAD2;
+        case AKEYCODE_NUMPAD_3:           return NS_VK_NUMPAD3;
+        case AKEYCODE_NUMPAD_4:           return NS_VK_NUMPAD4;
+        case AKEYCODE_NUMPAD_5:           return NS_VK_NUMPAD5;
+        case AKEYCODE_NUMPAD_6:           return NS_VK_NUMPAD6;
+        case AKEYCODE_NUMPAD_7:           return NS_VK_NUMPAD7;
+        case AKEYCODE_NUMPAD_8:           return NS_VK_NUMPAD8;
+        case AKEYCODE_NUMPAD_9:           return NS_VK_NUMPAD9;
+        case AKEYCODE_NUMPAD_DIVIDE:      return NS_VK_DIVIDE;
+        case AKEYCODE_NUMPAD_MULTIPLY:    return NS_VK_MULTIPLY;
+        case AKEYCODE_NUMPAD_SUBTRACT:    return NS_VK_SUBTRACT;
+        case AKEYCODE_NUMPAD_ADD:         return NS_VK_ADD;
+        case AKEYCODE_NUMPAD_DOT:         return NS_VK_DECIMAL;
+        case AKEYCODE_NUMPAD_COMMA:       return NS_VK_SEPARATOR;
+        case AKEYCODE_NUMPAD_ENTER:       return NS_VK_RETURN;
+        case AKEYCODE_NUMPAD_EQUALS:      return NS_VK_EQUALS;
         // KEYCODE_NUMPAD_LEFT_PAREN (162) ... KEYCODE_CALCULATOR (210)
 
         default:
             ALOG("ConvertAndroidKeyCodeToDOMKeyCode: "
                  "No DOM keycode for Android keycode %d", androidKeyCode);
         return 0;
     }
 }
@@ -1484,51 +1484,51 @@ nsWindow::InitKeyEvent(nsKeyEvent& event
         gMenuConsumed = true;
 }
 
 void
 nsWindow::HandleSpecialKey(AndroidGeckoEvent *ae)
 {
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     nsCOMPtr<nsIAtom> command;
-    bool isDown = ae->Action() == AndroidKeyEvent::ACTION_DOWN;
-    bool isLongPress = !!(ae->Flags() & AndroidKeyEvent::FLAG_LONG_PRESS);
+    bool isDown = ae->Action() == AKEY_EVENT_ACTION_DOWN;
+    bool isLongPress = !!(ae->Flags() & AKEY_EVENT_FLAG_LONG_PRESS);
     bool doCommand = false;
     uint32_t keyCode = ae->KeyCode();
 
     if (isDown) {
         switch (keyCode) {
-            case AndroidKeyEvent::KEYCODE_BACK:
+            case AKEYCODE_BACK:
                 if (isLongPress) {
                     command = nsGkAtoms::Clear;
                     doCommand = true;
                 }
                 break;
-            case AndroidKeyEvent::KEYCODE_MENU:
+            case AKEYCODE_MENU:
                 gMenu = true;
                 gMenuConsumed = isLongPress;
                 break;
         }
     } else {
         switch (keyCode) {
-            case AndroidKeyEvent::KEYCODE_BACK: {
+            case AKEYCODE_BACK: {
                 nsKeyEvent pressEvent(true, NS_KEY_PRESS, this);
                 ANPEvent pluginEvent;
                 InitKeyEvent(pressEvent, *ae, &pluginEvent);
                 DispatchEvent(&pressEvent);
                 return;
             }
-            case AndroidKeyEvent::KEYCODE_MENU:
+            case AKEYCODE_MENU:
                 gMenu = false;
                 if (!gMenuConsumed) {
                     command = nsGkAtoms::Menu;
                     doCommand = true;
                 }
                 break;
-            case AndroidKeyEvent::KEYCODE_SEARCH:
+            case AKEYCODE_SEARCH:
                 command = nsGkAtoms::Search;
                 doCommand = true;
                 break;
             default:
                 ALOG("Unknown special key code!");
                 return;
         }
     }
@@ -1541,47 +1541,47 @@ nsWindow::HandleSpecialKey(AndroidGeckoE
 
 void
 nsWindow::OnKeyEvent(AndroidGeckoEvent *ae)
 {
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     RemoveIMEComposition();
     uint32_t msg;
     switch (ae->Action()) {
-    case AndroidKeyEvent::ACTION_DOWN:
+    case AKEY_EVENT_ACTION_DOWN:
         msg = NS_KEY_DOWN;
         break;
-    case AndroidKeyEvent::ACTION_UP:
+    case AKEY_EVENT_ACTION_UP:
         msg = NS_KEY_UP;
         break;
-    case AndroidKeyEvent::ACTION_MULTIPLE:
+    case AKEY_EVENT_ACTION_MULTIPLE:
         {
             nsTextEvent event(true, NS_TEXT_TEXT, this);
             event.theText.Assign(ae->Characters());
             DispatchEvent(&event);
         }
         return;
     default:
         ALOG("Unknown key action event!");
         return;
     }
 
-    bool firePress = ae->Action() == AndroidKeyEvent::ACTION_DOWN;
+    bool firePress = ae->Action() == AKEY_EVENT_ACTION_DOWN;
     switch (ae->KeyCode()) {
-    case AndroidKeyEvent::KEYCODE_SHIFT_LEFT:
-    case AndroidKeyEvent::KEYCODE_SHIFT_RIGHT:
-    case AndroidKeyEvent::KEYCODE_ALT_LEFT:
-    case AndroidKeyEvent::KEYCODE_ALT_RIGHT:
-    case AndroidKeyEvent::KEYCODE_CTRL_LEFT:
-    case AndroidKeyEvent::KEYCODE_CTRL_RIGHT:
+    case AKEYCODE_SHIFT_LEFT:
+    case AKEYCODE_SHIFT_RIGHT:
+    case AKEYCODE_ALT_LEFT:
+    case AKEYCODE_ALT_RIGHT:
+    case AKEYCODE_CTRL_LEFT:
+    case AKEYCODE_CTRL_RIGHT:
         firePress = false;
         break;
-    case AndroidKeyEvent::KEYCODE_BACK:
-    case AndroidKeyEvent::KEYCODE_MENU:
-    case AndroidKeyEvent::KEYCODE_SEARCH:
+    case AKEYCODE_BACK:
+    case AKEYCODE_MENU:
+    case AKEYCODE_SEARCH:
         HandleSpecialKey(ae);
         return;
     }
 
     nsEventStatus status;
     nsKeyEvent event(true, msg, this);
     ANPEvent pluginEvent;
     InitKeyEvent(event, *ae, &pluginEvent);
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -13,17 +13,16 @@
 #include "AndroidJavaWrappers.h"
 
 class gfxASurface;
 
 struct ANPEvent;
 
 namespace mozilla {
     class AndroidGeckoEvent;
-    class AndroidKeyEvent;
 
     namespace layers {
         class CompositorParent;
         class CompositorChild;
         class LayerManager;
         class AsyncPanZoomController;
     }
 }