Backout 4e26b559d215, d74da7b4bf10 & d91d3787a3ef (bug 742036) for xul android failures; a=backout
authorEd Morley <emorley@mozilla.com>
Thu, 19 Apr 2012 12:50:46 -0700
changeset 95309 029dae90f2ccccc1783b5da609b43a9031475e9e
parent 95308 078f22017c69479e83fe7e37b27bba2cce8d9017
child 95310 41aa31e62e7b0a02dbf033dc228e1ac454d3d236
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs742036
milestone14.0a1
backs out4e26b559d215890bc9b5cc720c9f72b7913779a1
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
Backout 4e26b559d215, d74da7b4bf10 & d91d3787a3ef (bug 742036) for xul android failures; a=backout
dom/plugins/base/android/Makefile.in
dom/plugins/base/nsPluginInstanceOwner.cpp
mobile/android/base/GeckoEvent.java
widget/android/AndroidJavaWrappers.cpp
widget/android/AndroidJavaWrappers.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/dom/plugins/base/android/Makefile.in
+++ b/dom/plugins/base/android/Makefile.in
@@ -48,17 +48,16 @@ LIBRARY_NAME	= gkpluginandroid_s
 LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
 EXPORT_LIBRARY = 1
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 EXPORTS = \
-  ANPKeyCodes.h \
   android_npapi.h \
   $(NULL)
 
 CPPSRCS += ANPAudio.cpp    \
            ANPEvent.cpp    \
            ANPMatrix.cpp   \
            ANPSystem.cpp   \
            ANPWindow.cpp   \
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -120,16 +120,17 @@ static NS_DEFINE_CID(kAppShellCID, NS_AP
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #include <gtk/gtk.h>
 #include "gfxXlibNativeRenderer.h"
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "ANPBase.h"
+#include "android_npapi.h"
 #include "AndroidBridge.h"
 #include "AndroidMediaLayer.h"
 using namespace mozilla::dom;
 
 #include <android/log.h>
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
 #endif
 
@@ -2711,23 +2712,43 @@ nsEventStatus nsPluginInstanceOwner::Pro
           }
       }
       break;
 
     case NS_KEY_EVENT:
      {
        const nsKeyEvent& keyEvent = static_cast<const nsKeyEvent&>(anEvent);
        LOG("Firing NS_KEY_EVENT %d %d\n", keyEvent.keyCode, keyEvent.charCode);
-       // pluginEvent is initialized by nsWindow::InitKeyEvent().
-       ANPEvent* pluginEvent = reinterpret_cast<ANPEvent*>(keyEvent.pluginEvent);
-       if (pluginEvent) {
-         MOZ_ASSERT(pluginEvent->inSize == sizeof(ANPEvent));
-         MOZ_ASSERT(pluginEvent->eventType == kKey_ANPEventType);
-         mInstance->HandleEvent(pluginEvent, nsnull);
-       }
+       
+       int modifiers = 0;
+       if (keyEvent.isShift)
+         modifiers |= kShift_ANPKeyModifier;
+       if (keyEvent.isAlt)
+         modifiers |= kAlt_ANPKeyModifier;
+
+       ANPEvent event;
+       event.inSize = sizeof(ANPEvent);
+       event.eventType = kKey_ANPEventType;
+       event.data.key.nativeCode = keyEvent.keyCode;
+       event.data.key.virtualCode = keyEvent.charCode;
+       event.data.key.modifiers = modifiers;
+       event.data.key.repeatCount = 0;
+       event.data.key.unichar = 0;
+       switch (anEvent.message)
+         {
+         case NS_KEY_DOWN:
+           event.data.key.action = kDown_ANPKeyAction;
+           mInstance->HandleEvent(&event, nsnull);
+           break;
+           
+         case NS_KEY_UP:
+           event.data.key.action = kUp_ANPKeyAction;
+           mInstance->HandleEvent(&event, nsnull);
+           break;
+         }
      }
     }
     rv = nsEventStatus_eConsumeNoDefault;
 #endif
  
   return rv;
 }
 
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -127,17 +127,16 @@ public class GeckoEvent {
     public float[] mOrientations;
     public float[] mPressures;
     public Point[] mPointRadii;
     public Rect mRect;
     public double mX, mY, mZ;
 
     public int mMetaState, mFlags;
     public int mKeyCode, mUnicodeChar;
-    public int mRepeatCount;
     public int mOffset, mCount;
     public String mCharacters, mCharactersExtra;
     public int mRangeType, mRangeStyles;
     public int mRangeForeColor, mRangeBackColor;
     public Location mLocation;
     public Address  mAddress;
 
     public double mBandwidth;
@@ -199,17 +198,16 @@ public class GeckoEvent {
 
     private void initKeyEvent(KeyEvent k) {
         mAction = k.getAction();
         mTime = k.getEventTime();
         mMetaState = k.getMetaState();
         mFlags = k.getFlags();
         mKeyCode = k.getKeyCode();
         mUnicodeChar = k.getUnicodeChar();
-        mRepeatCount = k.getRepeatCount();
         mCharacters = k.getCharacters();
     }
 
     public static GeckoEvent createMotionEvent(MotionEvent m) {
         GeckoEvent event = new GeckoEvent(MOTION_EVENT);
         event.initMotionEvent(m);
         return event;
     }
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -57,17 +57,16 @@ jfieldID AndroidGeckoEvent::jRectField =
 jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
 
 jfieldID AndroidGeckoEvent::jCharactersField = 0;
 jfieldID AndroidGeckoEvent::jCharactersExtraField = 0;
 jfieldID AndroidGeckoEvent::jKeyCodeField = 0;
 jfieldID AndroidGeckoEvent::jMetaStateField = 0;
 jfieldID AndroidGeckoEvent::jFlagsField = 0;
 jfieldID AndroidGeckoEvent::jUnicodeCharField = 0;
-jfieldID AndroidGeckoEvent::jRepeatCountField = 0;
 jfieldID AndroidGeckoEvent::jOffsetField = 0;
 jfieldID AndroidGeckoEvent::jCountField = 0;
 jfieldID AndroidGeckoEvent::jPointerIndexField = 0;
 jfieldID AndroidGeckoEvent::jRangeTypeField = 0;
 jfieldID AndroidGeckoEvent::jRangeStylesField = 0;
 jfieldID AndroidGeckoEvent::jRangeForeColorField = 0;
 jfieldID AndroidGeckoEvent::jRangeBackColorField = 0;
 jfieldID AndroidGeckoEvent::jLocationField = 0;
@@ -169,17 +168,16 @@ AndroidGeckoEvent::InitGeckoEventClass(J
     jRectField = getField("mRect", "Landroid/graphics/Rect;");
 
     jCharactersField = getField("mCharacters", "Ljava/lang/String;");
     jCharactersExtraField = getField("mCharactersExtra", "Ljava/lang/String;");
     jKeyCodeField = getField("mKeyCode", "I");
     jMetaStateField = getField("mMetaState", "I");
     jFlagsField = getField("mFlags", "I");
     jUnicodeCharField = getField("mUnicodeChar", "I");
-    jRepeatCountField = getField("mRepeatCount", "I");
     jOffsetField = getField("mOffset", "I");
     jCountField = getField("mCount", "I");
     jPointerIndexField = getField("mPointerIndex", "I");
     jRangeTypeField = getField("mRangeType", "I");
     jRangeStylesField = getField("mRangeStyles", "I");
     jRangeForeColorField = getField("mRangeForeColor", "I");
     jRangeBackColorField = getField("mRangeBackColor", "I");
     jLocationField = getField("mLocation", "Landroid/location/Location;");
@@ -427,17 +425,16 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jo
             break;
 
         case KEY_EVENT:
             mTime = jenv->GetLongField(jobj, jTimeField);
             mMetaState = jenv->GetIntField(jobj, jMetaStateField);
             mFlags = jenv->GetIntField(jobj, jFlagsField);
             mKeyCode = jenv->GetIntField(jobj, jKeyCodeField);
             mUnicodeChar = jenv->GetIntField(jobj, jUnicodeCharField);
-            mRepeatCount = jenv->GetIntField(jobj, jRepeatCountField);
             ReadCharactersField(jenv);
             break;
 
         case MOTION_EVENT:
             mTime = jenv->GetLongField(jobj, jTimeField);
             mMetaState = jenv->GetIntField(jobj, jMetaStateField);
             mCount = jenv->GetIntField(jobj, jCountField);
             mPointerIndex = jenv->GetIntField(jobj, jPointerIndexField);
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -355,147 +355,25 @@ public:
         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,
-
         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_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,
@@ -588,21 +466,18 @@ public:
     double X() { return mX; }
     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; }
-    bool IsAltPressed() const { return (mMetaState & AndroidKeyEvent::META_ALT_MASK) != 0; }
-    bool IsShiftPressed() const { return (mMetaState & AndroidKeyEvent::META_SHIFT_MASK) != 0; }
     int Flags() { return mFlags; }
     int UnicodeChar() { return mUnicodeChar; }
-    int RepeatCount() const { return mRepeatCount; }
     int Offset() { return mOffset; }
     int Count() { return mCount; }
     int PointerIndex() { return mPointerIndex; }
     int RangeType() { return mRangeType; }
     int RangeStyles() { return mRangeStyles; }
     int RangeForeColor() { return mRangeForeColor; }
     int RangeBackColor() { return mRangeBackColor; }
     nsGeoPosition* GeoPosition() { return mGeoPosition; }
@@ -617,17 +492,16 @@ protected:
     nsTArray<nsIntPoint> mPoints;
     nsTArray<nsIntPoint> mPointRadii;
     nsTArray<int> mPointIndicies;
     nsTArray<float> mOrientations;
     nsTArray<float> mPressures;
     nsIntRect mRect;
     int mFlags, mMetaState;
     int mKeyCode, mUnicodeChar;
-    int mRepeatCount;
     int mOffset, mCount;
     int mRangeType, mRangeStyles;
     int mRangeForeColor, mRangeBackColor;
     double mX, mY, mZ;
     int mPointerIndex;
     nsString mCharacters, mCharactersExtra;
     nsRefPtr<nsGeoPosition> mGeoPosition;
     double mBandwidth;
@@ -670,17 +544,16 @@ protected:
     static jfieldID jCharactersExtraField;
     static jfieldID jKeyCodeField;
     static jfieldID jMetaStateField;
     static jfieldID jFlagsField;
     static jfieldID jOffsetField;
     static jfieldID jCountField;
     static jfieldID jPointerIndexField;
     static jfieldID jUnicodeCharField;
-    static jfieldID jRepeatCountField;
     static jfieldID jRangeTypeField;
     static jfieldID jRangeStylesField;
     static jfieldID jRangeForeColorField;
     static jfieldID jRangeBackColorField;
     static jfieldID jLocationField;
 
     static jfieldID jBandwidthField;
     static jfieldID jCanBeMeteredField;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -72,17 +72,16 @@ using mozilla::unused;
 #include "BasicLayers.h"
 #include "LayerManagerOGL.h"
 #include "GLContext.h"
 #include "GLContextProvider.h"
 
 #include "nsTArray.h"
 
 #include "AndroidBridge.h"
-#include "android_npapi.h"
 
 #include "imgIEncoder.h"
 
 #include "nsStringGlue.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
@@ -1605,171 +1604,184 @@ nsWindow::DispatchMotionEvent(nsInputEve
 
     // XXX possibly bound the range of event.refPoint here.
     //     some code may get confused.
     event.refPoint = refPoint - offset;
 
     DispatchEvent(&event);
 }
 
-static unsigned int ConvertAndroidKeyCodeToDOMKeyCode(int androidKeyCode)
+void
+nsWindow::InitKeyEvent(nsKeyEvent& event, AndroidGeckoEvent& key)
 {
-    // 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 >= AndroidKeyEvent::KEYCODE_0 &&
-        androidKeyCode <= AndroidKeyEvent::KEYCODE_9) {
-        return androidKeyCode - AndroidKeyEvent::KEYCODE_0 + NS_VK_0;
+    switch (key.KeyCode()) {
+    case AndroidKeyEvent::KEYCODE_UNKNOWN:
+    case AndroidKeyEvent::KEYCODE_HOME:
+        break;
+    case AndroidKeyEvent::KEYCODE_BACK:
+        event.keyCode = NS_VK_ESCAPE;
+        break;
+    case AndroidKeyEvent::KEYCODE_CALL:
+    case AndroidKeyEvent::KEYCODE_ENDCALL:
+        break;
+    case AndroidKeyEvent::KEYCODE_0:
+    case AndroidKeyEvent::KEYCODE_1:
+    case AndroidKeyEvent::KEYCODE_2:
+    case AndroidKeyEvent::KEYCODE_3:
+    case AndroidKeyEvent::KEYCODE_4:
+    case AndroidKeyEvent::KEYCODE_5:
+    case AndroidKeyEvent::KEYCODE_6:
+    case AndroidKeyEvent::KEYCODE_7:
+    case AndroidKeyEvent::KEYCODE_8:
+    case AndroidKeyEvent::KEYCODE_9:
+        event.keyCode = key.KeyCode() - AndroidKeyEvent::KEYCODE_0 + NS_VK_0;
+        break;
+    case AndroidKeyEvent::KEYCODE_STAR:
+        event.keyCode = NS_VK_MULTIPLY;
+        break;
+    case AndroidKeyEvent::KEYCODE_POUND:
+        break;
+    case AndroidKeyEvent::KEYCODE_DPAD_UP:
+        event.keyCode = NS_VK_UP;
+        break;
+    case AndroidKeyEvent::KEYCODE_DPAD_DOWN:
+        event.keyCode = NS_VK_DOWN;
+        break;
+    case AndroidKeyEvent::KEYCODE_SOFT_LEFT:
+    case AndroidKeyEvent::KEYCODE_DPAD_LEFT:
+        event.keyCode = NS_VK_LEFT;
+        break;
+    case AndroidKeyEvent::KEYCODE_SOFT_RIGHT:
+    case AndroidKeyEvent::KEYCODE_DPAD_RIGHT:
+        event.keyCode = NS_VK_RIGHT;
+        break;
+    case AndroidKeyEvent::KEYCODE_VOLUME_UP:
+    case AndroidKeyEvent::KEYCODE_VOLUME_DOWN:
+    case AndroidKeyEvent::KEYCODE_POWER:
+    case AndroidKeyEvent::KEYCODE_CAMERA:
+    case AndroidKeyEvent::KEYCODE_CLEAR:
+        break;
+    case AndroidKeyEvent::KEYCODE_A:
+    case AndroidKeyEvent::KEYCODE_B:
+    case AndroidKeyEvent::KEYCODE_C:
+    case AndroidKeyEvent::KEYCODE_D:
+    case AndroidKeyEvent::KEYCODE_E:
+    case AndroidKeyEvent::KEYCODE_F:
+    case AndroidKeyEvent::KEYCODE_G:
+    case AndroidKeyEvent::KEYCODE_H:
+    case AndroidKeyEvent::KEYCODE_I:
+    case AndroidKeyEvent::KEYCODE_J:
+    case AndroidKeyEvent::KEYCODE_K:
+    case AndroidKeyEvent::KEYCODE_L:
+    case AndroidKeyEvent::KEYCODE_M:
+    case AndroidKeyEvent::KEYCODE_N:
+    case AndroidKeyEvent::KEYCODE_O:
+    case AndroidKeyEvent::KEYCODE_P:
+    case AndroidKeyEvent::KEYCODE_Q:
+    case AndroidKeyEvent::KEYCODE_R:
+    case AndroidKeyEvent::KEYCODE_S:
+    case AndroidKeyEvent::KEYCODE_T:
+    case AndroidKeyEvent::KEYCODE_U:
+    case AndroidKeyEvent::KEYCODE_V:
+    case AndroidKeyEvent::KEYCODE_W:
+    case AndroidKeyEvent::KEYCODE_X:
+    case AndroidKeyEvent::KEYCODE_Y:
+    case AndroidKeyEvent::KEYCODE_Z:
+        event.keyCode = key.KeyCode() - AndroidKeyEvent::KEYCODE_A + NS_VK_A;
+        break;
+    case AndroidKeyEvent::KEYCODE_COMMA:
+        event.keyCode = NS_VK_COMMA;
+        break;
+    case AndroidKeyEvent::KEYCODE_PERIOD:
+        event.keyCode = NS_VK_PERIOD;
+        break;
+    case AndroidKeyEvent::KEYCODE_ALT_LEFT:
+    case AndroidKeyEvent::KEYCODE_ALT_RIGHT:
+    case AndroidKeyEvent::KEYCODE_SHIFT_LEFT:
+    case AndroidKeyEvent::KEYCODE_SHIFT_RIGHT:
+        break;
+    case AndroidKeyEvent::KEYCODE_TAB:
+        event.keyCode = NS_VK_TAB;
+        break;
+    case AndroidKeyEvent::KEYCODE_SPACE:
+        event.keyCode = NS_VK_SPACE;
+        break;
+    case AndroidKeyEvent::KEYCODE_SYM:
+    case AndroidKeyEvent::KEYCODE_EXPLORER:
+    case AndroidKeyEvent::KEYCODE_ENVELOPE:
+        break;
+    case AndroidKeyEvent::KEYCODE_DPAD_CENTER:
+        event.keyCode = NS_VK_ENTER;
+        break;
+    case AndroidKeyEvent::KEYCODE_ENTER:
+        event.keyCode = NS_VK_RETURN;
+        break;
+    case AndroidKeyEvent::KEYCODE_DEL:
+        event.keyCode = NS_VK_BACK;
+        break;
+    case AndroidKeyEvent::KEYCODE_GRAVE:
+        break;
+    case AndroidKeyEvent::KEYCODE_MINUS:
+        event.keyCode = NS_VK_SUBTRACT;
+        break;
+    case AndroidKeyEvent::KEYCODE_EQUALS:
+        event.keyCode = NS_VK_EQUALS;
+        break;
+    case AndroidKeyEvent::KEYCODE_LEFT_BRACKET:
+        event.keyCode = NS_VK_OPEN_BRACKET;
+        break;
+    case AndroidKeyEvent::KEYCODE_RIGHT_BRACKET:
+        event.keyCode = NS_VK_CLOSE_BRACKET;
+        break;
+    case AndroidKeyEvent::KEYCODE_BACKSLASH:
+        event.keyCode = NS_VK_BACK_SLASH;
+        break;
+    case AndroidKeyEvent::KEYCODE_SEMICOLON:
+        event.keyCode = NS_VK_SEMICOLON;
+        break;
+    case AndroidKeyEvent::KEYCODE_APOSTROPHE:
+        event.keyCode = NS_VK_QUOTE;
+        break;
+    case AndroidKeyEvent::KEYCODE_SLASH:
+        event.keyCode = NS_VK_SLASH;
+        break;
+    case AndroidKeyEvent::KEYCODE_AT:
+    case AndroidKeyEvent::KEYCODE_NUM:
+    case AndroidKeyEvent::KEYCODE_HEADSETHOOK:
+    case AndroidKeyEvent::KEYCODE_FOCUS:
+        break;
+    case AndroidKeyEvent::KEYCODE_PLUS:
+        event.keyCode = NS_VK_ADD;
+        break;
+    case AndroidKeyEvent::KEYCODE_MENU:
+    case AndroidKeyEvent::KEYCODE_NOTIFICATION:
+    case AndroidKeyEvent::KEYCODE_SEARCH:
+    case AndroidKeyEvent::KEYCODE_MEDIA_PLAY_PAUSE:
+    case AndroidKeyEvent::KEYCODE_MEDIA_STOP:
+    case AndroidKeyEvent::KEYCODE_MEDIA_NEXT:
+    case AndroidKeyEvent::KEYCODE_MEDIA_PREVIOUS:
+    case AndroidKeyEvent::KEYCODE_MEDIA_REWIND:
+    case AndroidKeyEvent::KEYCODE_MEDIA_FAST_FORWARD:
+    case AndroidKeyEvent::KEYCODE_MUTE:
+        break;
+    default:
+        ALOG("Unknown key code!");
+        break;
     }
 
-    switch (androidKeyCode) {
-        // KEYCODE_UNKNOWN (0) ... 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;
-        // KEYCODE_VOLUME_UP (24) ... 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;
-        // 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;
-        // 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;
-        // KEYCODE_APOSTROPHE (75)
-        case AndroidKeyEvent::KEYCODE_SLASH:              return NS_VK_SLASH;
-        // KEYCODE_AT (77) ... KEYCODE_MUTE (91)
-        case AndroidKeyEvent::KEYCODE_PAGE_UP:            return NS_VK_PAGE_UP;
-        case AndroidKeyEvent::KEYCODE_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;
-        // 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;
-        // 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;
-        // KEYCODE_NUMPAD_LEFT_PAREN (162) ... KEYCODE_CALCULATOR (210)
-
-        default:
-            ALOG("ConvertAndroidKeyCodeToDOMKeyCode: "
-                 "No DOM keycode for Android keycode %d", androidKeyCode);
-        return 0;
+    // Android gives us \n, so filter out some control characters.
+    if (event.message == NS_KEY_PRESS &&
+        key.UnicodeChar() >= ' ') {
+        event.charCode = key.UnicodeChar();
+        if (key.UnicodeChar())
+            event.keyCode = 0;
     }
-}
-
-static void InitPluginEvent(ANPEvent* pluginEvent, ANPKeyActions keyAction,
-                            AndroidGeckoEvent& key)
-{
-    int androidKeyCode = key.KeyCode();
-    PRUint32 domKeyCode = ConvertAndroidKeyCodeToDOMKeyCode(androidKeyCode);
-
-    int modifiers = 0;
-    if (key.IsAltPressed())
-      modifiers |= kAlt_ANPKeyModifier;
-    if (key.IsShiftPressed())
-      modifiers |= kShift_ANPKeyModifier;
-
-    pluginEvent->inSize = sizeof(ANPEvent);
-    pluginEvent->eventType = kKey_ANPEventType;
-    pluginEvent->data.key.action = keyAction;
-    pluginEvent->data.key.nativeCode = androidKeyCode;
-    pluginEvent->data.key.virtualCode = domKeyCode;
-    pluginEvent->data.key.unichar = key.UnicodeChar();
-    pluginEvent->data.key.modifiers = modifiers;
-    pluginEvent->data.key.repeatCount = key.RepeatCount();
-}
-
-void
-nsWindow::InitKeyEvent(nsKeyEvent& event, AndroidGeckoEvent& key,
-                       ANPEvent* pluginEvent)
-{
-    int androidKeyCode = key.KeyCode();
-    PRUint32 domKeyCode = ConvertAndroidKeyCodeToDOMKeyCode(androidKeyCode);
-
-    if (event.message == NS_KEY_PRESS) {
-        // Android gives us \n, so filter out some control characters.
-        event.isChar = (key.UnicodeChar() >= ' ');
-        event.charCode = event.isChar ? key.UnicodeChar() : 0;
-        event.keyCode = (event.charCode > 0) ? 0 : domKeyCode;
-        event.pluginEvent = NULL;
-    } else {
-#ifdef DEBUG
-        if (event.message != NS_KEY_DOWN && event.message != NS_KEY_UP) {
-            ALOG("InitKeyEvent: unexpected event.message %d", event.message);
-        }
-#endif // DEBUG
-
-        // Flash will want a pluginEvent for keydown and keyup events.
-        ANPKeyActions action = event.message == NS_KEY_DOWN
-                             ? kDown_ANPKeyAction
-                             : kUp_ANPKeyAction;
-        InitPluginEvent(pluginEvent, action, key);
-
-        event.isChar = false;
-        event.charCode = 0;
-        event.keyCode = domKeyCode;
-        event.pluginEvent = pluginEvent;
-    }
-
-    event.isShift = key.IsShiftPressed();
+    event.isShift = !!(key.MetaState() & AndroidKeyEvent::META_SHIFT_ON);
     event.isControl = gMenu;
-    event.isAlt = key.IsAltPressed();
+    event.isAlt = !!(key.MetaState() & AndroidKeyEvent::META_ALT_ON);
     event.isMeta = false;
     event.time = key.Time();
 
     if (gMenu)
         gMenuConsumed = true;
 }
 
 void
@@ -1802,18 +1814,17 @@ nsWindow::HandleSpecialKey(AndroidGeckoE
                 gMenu = true;
                 gMenuConsumed = isLongPress;
                 break;
         }
     } else {
         switch (keyCode) {
             case AndroidKeyEvent::KEYCODE_BACK: {
                 nsKeyEvent pressEvent(true, NS_KEY_PRESS, this);
-                ANPEvent pluginEvent;
-                InitKeyEvent(pressEvent, *ae, &pluginEvent);
+                InitKeyEvent(pressEvent, *ae);
                 DispatchEvent(&pressEvent);
                 return;
             }
             case AndroidKeyEvent::KEYCODE_MENU:
                 gMenu = false;
                 if (!gMenuConsumed) {
                     command = nsGkAtoms::Menu;
                     doCommand = true;
@@ -1873,27 +1884,26 @@ nsWindow::OnKeyEvent(AndroidGeckoEvent *
     case AndroidKeyEvent::KEYCODE_VOLUME_UP:
     case AndroidKeyEvent::KEYCODE_VOLUME_DOWN:
         HandleSpecialKey(ae);
         return;
     }
 
     nsEventStatus status;
     nsKeyEvent event(true, msg, this);
-    ANPEvent pluginEvent;
-    InitKeyEvent(event, *ae, &pluginEvent);
+    InitKeyEvent(event, *ae);
     DispatchEvent(&event, status);
 
     if (Destroyed())
         return;
     if (!firePress)
         return;
 
     nsKeyEvent pressEvent(true, NS_KEY_PRESS, this);
-    InitKeyEvent(pressEvent, *ae, &pluginEvent);
+    InitKeyEvent(pressEvent, *ae);
     if (status == nsEventStatus_eConsumeNoDefault) {
         pressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
     }
 #ifdef DEBUG_ANDROID_WIDGET
     __android_log_print(ANDROID_LOG_INFO, "Gecko", "Dispatching key pressEvent with keyCode %d charCode %d shift %d alt %d sym/ctrl %d metamask %d", pressEvent.keyCode, pressEvent.charCode, pressEvent.isShift, pressEvent.isAlt, pressEvent.isControl, ae->MetaState());
 #endif
     DispatchEvent(&pressEvent);
 }
@@ -2008,21 +2018,20 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                 AndroidBridge::Bridge()->ReturnIMEQueryResult(
                     event.mReply.mString.get(), 
                     event.mReply.mString.Length(), 0, 0);
             }
             //ALOGIME("IME:     -> l=%u", event.mReply.mString.Length());
         }
         return;
     case AndroidGeckoEvent::IME_DELETE_TEXT:
-        {
+        {   
             ALOGIME("IME: IME_DELETE_TEXT");
             nsKeyEvent event(true, NS_KEY_PRESS, this);
-            ANPEvent pluginEvent;
-            InitKeyEvent(event, *ae, &pluginEvent);
+            InitEvent(event, nsnull);
             event.keyCode = NS_VK_BACK;
             DispatchEvent(&event);
         }
         return;
     case AndroidGeckoEvent::IME_SET_SELECTION:
         {
             ALOGIME("IME: IME_SET_SELECTION: o=%u, l=%d", ae->Offset(), ae->Count());
 
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -46,18 +46,16 @@
 #ifdef MOZ_JAVA_COMPOSITOR
 #include "AndroidJavaWrappers.h"
 #include "Layers.h"
 #endif
 
 class gfxASurface;
 class nsIdleService;
 
-struct ANPEvent;
-
 namespace mozilla {
     class AndroidGeckoEvent;
     class AndroidKeyEvent;
 
     namespace layers {
         class CompositorParent;
         class CompositorChild;
     }
@@ -228,18 +226,17 @@ protected:
 
     InputContext mInputContext;
 
     static void DumpWindows();
     static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
     static void LogWindow(nsWindow *win, int index, int indent);
 
 private:
-    void InitKeyEvent(nsKeyEvent& event, mozilla::AndroidGeckoEvent& key,
-                      ANPEvent* pluginEvent);
+    void InitKeyEvent(nsKeyEvent& event, mozilla::AndroidGeckoEvent& key);
     bool DispatchMultitouchEvent(nsTouchEvent &event,
                              mozilla::AndroidGeckoEvent *ae);
     void DispatchMotionEvent(nsInputEvent &event,
                              mozilla::AndroidGeckoEvent *ae,
                              const nsIntPoint &refPoint);
     void DispatchGestureEvent(PRUint32 msg, PRUint32 direction, double delta,
                               const nsIntPoint &refPoint, PRUint64 time);
     void HandleSpecialKey(mozilla::AndroidGeckoEvent *ae);