Bug 907612 part.2 Get rid of nsNativeKeyEvent r=roc+gps, sr=jst
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 24 Aug 2013 16:24:32 +0900
changeset 158052 0a198e8168be51bcabb72d2af642145771ebe918
parent 158051 0cd3864c919350d7f0e7c01495cd3a15243c47b4
child 158053 4d3e221584a08614ede7bf9738cd19cc0cb6bffe
push id407
push userlsblakk@mozilla.com
push dateTue, 03 Dec 2013 03:32:50 +0000
treeherdermozilla-release@babf8c9ebc52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, jst
bugs907612
milestone26.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 907612 part.2 Get rid of nsNativeKeyEvent r=roc+gps, sr=jst
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/html/content/src/nsTextEditorState.cpp
content/xbl/src/nsXBLWindowKeyHandler.cpp
editor/libeditor/html/tests/test_bug674770-2.html
layout/generic/test/Makefile.in
widget/cocoa/NativeKeyBindings.h
widget/cocoa/NativeKeyBindings.mm
widget/gtk2/nsNativeKeyBindings.cpp
widget/gtk2/nsNativeKeyBindings.h
widget/nsINativeKeyBindings.h
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -91,17 +91,16 @@ class nsStringHashKey;
 class nsTextFragment;
 class nsViewportInfo;
 class nsWrapperCache;
 
 struct JSContext;
 struct JSPropertyDescriptor;
 struct JSRuntime;
 struct nsIntMargin;
-struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
 
 template<class E> class nsCOMArray;
 template<class E> class nsTArray;
 template<class K, class V> class nsDataHashtable;
 template<class K, class V> class nsRefPtrHashtable;
 template<class T> class nsReadingIterator;
 
 namespace JS {
@@ -1381,24 +1380,21 @@ public:
   static nsIWidget* GetTopLevelWidget(nsIWidget* aWidget);
 
   /**
    * Return the localized ellipsis for UI.
    */
   static const nsDependentString GetLocalizedEllipsis();
 
   /**
-   * The routine GetNativeEvent is used to fill nsNativeKeyEvent.
-   * It's also used in DOMEventToNativeKeyEvent.
-   * See bug 406407 for details.
+   * The routine GetNativeEvent returns the result of
+   * aDOMEvent->GetInternalNSEvent().
+   * XXX Is this necessary?
    */
   static nsEvent* GetNativeEvent(nsIDOMEvent* aDOMEvent);
-  static bool DOMEventToNativeKeyEvent(nsIDOMKeyEvent* aKeyEvent,
-                                         nsNativeKeyEvent* aNativeEvent,
-                                         bool aGetCharCode);
 
   /**
    * Get the candidates for accelkeys for aDOMKeyEvent.
    *
    * @param aDOMKeyEvent [in] the key event for accelkey handling.
    * @param aCandidates [out] the candidate shortcut key combination list.
    *                          the first item is most preferred.
    */
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -111,17 +111,16 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIIOService.h"
 #include "nsIJSRuntimeService.h"
 #include "nsILineBreaker.h"
 #include "nsILoadContext.h"
 #include "nsILoadGroup.h"
 #include "nsIMEStateManager.h"
 #include "nsIMIMEService.h"
-#include "nsINativeKeyBindings.h"
 #include "nsINode.h"
 #include "nsINodeInfo.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsIParser.h"
 #include "nsIParserService.h"
@@ -4546,49 +4545,16 @@ nsContentUtils::GetLocalizedEllipsis()
 
 //static
 nsEvent*
 nsContentUtils::GetNativeEvent(nsIDOMEvent* aDOMEvent)
 {
   return aDOMEvent ? aDOMEvent->GetInternalNSEvent() : nullptr;
 }
 
-//static
-bool
-nsContentUtils::DOMEventToNativeKeyEvent(nsIDOMKeyEvent* aKeyEvent,
-                                         nsNativeKeyEvent* aNativeEvent,
-                                         bool aGetCharCode)
-{
-  bool defaultPrevented;
-  aKeyEvent->GetDefaultPrevented(&defaultPrevented);
-  if (defaultPrevented)
-    return false;
-
-  bool trusted = false;
-  aKeyEvent->GetIsTrusted(&trusted);
-  if (!trusted)
-    return false;
-
-  if (aGetCharCode) {
-    aKeyEvent->GetCharCode(&aNativeEvent->charCode);
-  } else {
-    aNativeEvent->charCode = 0;
-  }
-  aKeyEvent->GetKeyCode(&aNativeEvent->keyCode);
-  aKeyEvent->GetAltKey(&aNativeEvent->altKey);
-  aKeyEvent->GetCtrlKey(&aNativeEvent->ctrlKey);
-  aKeyEvent->GetShiftKey(&aNativeEvent->shiftKey);
-  aKeyEvent->GetMetaKey(&aNativeEvent->metaKey);
-
-  aNativeEvent->mGeckoEvent =
-    static_cast<nsKeyEvent*>(GetNativeEvent(aKeyEvent));
-
-  return true;
-}
-
 static bool
 HasASCIIDigit(const nsTArray<nsShortcutCandidate>& aCandidates)
 {
   for (uint32_t i = 0; i < aCandidates.Length(); ++i) {
     uint32_t ch = aCandidates[i].mCharCode;
     if (ch >= '0' && ch <= '9')
       return true;
   }
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -804,39 +804,51 @@ DoCommandCallback(const char *aCommand, 
   if (commandEnabled) {
     controller->DoCommand(aCommand);
   }
 }
 
 NS_IMETHODIMP
 nsTextInputListener::HandleEvent(nsIDOMEvent* aEvent)
 {
-  nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
-  NS_ENSURE_TRUE(keyEvent, NS_ERROR_INVALID_ARG);
-
-  nsAutoString eventType;
-  aEvent->GetType(eventType);
+  bool defaultPrevented = false;
+  nsresult rv = aEvent->GetDefaultPrevented(&defaultPrevented);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (defaultPrevented) {
+    return NS_OK;
+  }
 
-  nsNativeKeyEvent nativeEvent;
+  bool isTrusted = false;
+  rv = aEvent->GetIsTrusted(&isTrusted);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!isTrusted) {
+    return NS_OK;
+  }
+
+  nsKeyEvent* keyEvent =
+    static_cast<nsKeyEvent*>(aEvent->GetInternalNSEvent());
+  if (keyEvent->eventStructType != NS_KEY_EVENT) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
   nsINativeKeyBindings *bindings = GetKeyBindings();
-  if (bindings &&
-      nsContentUtils::DOMEventToNativeKeyEvent(keyEvent, &nativeEvent, false)) {
-
+  if (bindings) {
     bool handled = false;
-    if (eventType.EqualsLiteral("keydown")) {
-      handled = bindings->KeyDown(nativeEvent, DoCommandCallback, mFrame);
-    }
-    else if (eventType.EqualsLiteral("keyup")) {
-      handled = bindings->KeyUp(nativeEvent, DoCommandCallback, mFrame);
-    }
-    else if (eventType.EqualsLiteral("keypress")) {
-      handled = bindings->KeyPress(nativeEvent, DoCommandCallback, mFrame);
-    }
-    else {
-      NS_ABORT();
+    switch (keyEvent->message) {
+      case NS_KEY_DOWN:
+        handled = bindings->KeyDown(*keyEvent, DoCommandCallback, mFrame);
+        break;
+      case NS_KEY_UP:
+        handled = bindings->KeyUp(*keyEvent, DoCommandCallback, mFrame);
+        break;
+      case NS_KEY_PRESS:
+        handled = bindings->KeyPress(*keyEvent, DoCommandCallback, mFrame);
+        break;
+      default:
+        MOZ_CRASH("Unknown key message");
     }
     if (handled) {
       aEvent->PreventDefault();
     }
   }
 
   return NS_OK;
 }
--- a/content/xbl/src/nsXBLWindowKeyHandler.cpp
+++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp
@@ -340,38 +340,47 @@ nsXBLWindowKeyHandler::WalkHandlers(nsID
   if (content && content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
                                       nsGkAtoms::_true, eCaseMatters)) {
     return NS_OK;
   }
 
   WalkHandlersInternal(aKeyEvent, aEventType, mHandler);
 
   if (isEditor && GetEditorKeyBindings()) {
-    nsNativeKeyEvent nativeEvent;
     // get the DOM window we're attached to
     nsCOMPtr<nsIControllers> controllers;
     nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(mTarget);
     if (root) {
       root->GetControllers(getter_AddRefs(controllers));
     }
 
+    nsKeyEvent* keyEvent =
+      static_cast<nsKeyEvent*>(aKeyEvent->GetInternalNSEvent());
+    MOZ_ASSERT(keyEvent->eventStructType == NS_KEY_EVENT,
+               "DOM key event's internal event must be nsKeyEvent");
+
     bool handled = false;
-    if (aEventType == nsGkAtoms::keypress) {
-      if (nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, true))
-        handled = sNativeEditorBindings->KeyPress(nativeEvent,
-                                                  DoCommandCallback, controllers);
-    } else if (aEventType == nsGkAtoms::keyup) {
-      if (nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, false))
-        handled = sNativeEditorBindings->KeyUp(nativeEvent,
-                                               DoCommandCallback, controllers);
-    } else {
-      NS_ASSERTION(aEventType == nsGkAtoms::keydown, "unknown key event type");
-      if (nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, false))
-        handled = sNativeEditorBindings->KeyDown(nativeEvent,
-                                                 DoCommandCallback, controllers);
+    switch (keyEvent->message) {
+      case NS_KEY_PRESS:
+        handled = sNativeEditorBindings->KeyPress(*keyEvent,
+                                                  DoCommandCallback,
+                                                  controllers);
+        break;
+      case NS_KEY_UP:
+        handled = sNativeEditorBindings->KeyUp(*keyEvent,
+                                               DoCommandCallback,
+                                               controllers);
+        break;
+      case NS_KEY_DOWN:
+        handled = sNativeEditorBindings->KeyDown(*keyEvent,
+                                                 DoCommandCallback,
+                                                 controllers);
+        break;
+      default:
+        MOZ_CRASH("Unknown key message");
     }
 
     if (handled)
       aKeyEvent->PreventDefault();
 
   }
   
   return NS_OK;
--- a/editor/libeditor/html/tests/test_bug674770-2.html
+++ b/editor/libeditor/html/tests/test_bug674770-2.html
@@ -59,17 +59,21 @@ SimpleTest.waitForFocus(function() {
   frameDocument.getElementById("editor1").addEventListener("click", clickEventHnalder, false);
   frameDocument.getElementById("editor2").addEventListener("click", clickEventHnalder, false);
 
   var text = frameDocument.getElementById("text");
 
   text.focus();
 
   SimpleTest.executeSoon(function() {
-    synthesizeKey("a", { accelKey: true }, frameWindow);
+    if (navigator.platform.indexOf("Linux") == 0) {
+      synthesizeKey("a", { altKey: true }, frameWindow);
+    } else {
+      synthesizeKey("a", { accelKey: true }, frameWindow);
+    }
     // Windows and Mac don't have primary selection, we should copy the text to
     // the global clipboard.
     if (!SpecialPowers.supportsSelectionClipboard()) {
       SimpleTest.waitForClipboard("pasted",
         function() { synthesizeKey("c", { accelKey: true }, frameWindow); },
         function() { SimpleTest.executeSoon(runInputTests1) },
         cleanup);
     } else {
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -61,17 +61,16 @@ MOCHITEST_FILES = \
   test_bug579767.html \
   test_bug597333.html \
   test_bug666225.html \
   test_bug904810.html \
   test_image_selection.html \
   test_image_selection_2.html \
   test_invalidate_during_plugin_paint.html \
   test_movement_by_characters.html \
-  test_movement_by_words.html \
   test_page_scroll_with_fixed_pos.html \
     page_scroll_with_fixed_pos_window.html \
   test_plugin_clipping.xhtml \
   test_plugin_clipping2.xhtml \
   test_plugin_clipping_transformed.xhtml \
   test_plugin_clipping_table.xhtml \
   test_plugin_focus.html \
   test_plugin_mouse_coords.html \
@@ -104,16 +103,24 @@ MOCHITEST_FILES = \
   test_bug748961.html \
   test_bug784410.html \
   test_bug785324.html \
   test_bug791616.html \
   test_bug831780.html \
   test_bug841361.html \
   $(NULL)
 
+# Disable the caret movement by word test on Linux because the shortcut keys
+# are defined in system level.  So, it depends on the environment.
+ifndef MOZ_WIDGET_GTK
+MOCHITEST_FILES += \
+  test_movement_by_words.html \
+  $(NULL)
+endif
+
 MOCHITEST_CHROME_FILES = \
   frame_selection_underline.xhtml \
   frame_selection_underline-ref.xhtml \
   frame_selection_underline.css \
   test_selection_underline.html \
   test_bug632379.xul \
   test_bug508115.xul \
   test_bug469613.xul \
--- a/widget/cocoa/NativeKeyBindings.h
+++ b/widget/cocoa/NativeKeyBindings.h
@@ -45,25 +45,25 @@ class NativeKeyBindings MOZ_FINAL : publ
 public:
   NativeKeyBindings();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Init(NativeKeyBindingsType aType);
 
   // nsINativeKeyBindings
-  NS_IMETHOD_(bool) KeyDown(const nsNativeKeyEvent& aEvent,
+  NS_IMETHOD_(bool) KeyDown(const nsKeyEvent& aEvent,
                             DoCommandCallback aCallback,
                             void* aCallbackData);
 
-  NS_IMETHOD_(bool) KeyPress(const nsNativeKeyEvent& aEvent,
+  NS_IMETHOD_(bool) KeyPress(const nsKeyEvent& aEvent,
                              DoCommandCallback aCallback,
                              void* aCallbackData);
 
-  NS_IMETHOD_(bool) KeyUp(const nsNativeKeyEvent& aEvent,
+  NS_IMETHOD_(bool) KeyUp(const nsKeyEvent& aEvent,
                           DoCommandCallback aCallback,
                           void* aCallbackData);
 
 private:
   SelectorCommandHashtable mSelectorToCommand;
 }; // NativeKeyBindings
 
 } // namespace widget
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
@@ -164,36 +164,33 @@ NativeKeyBindings::Init(NativeKeyBinding
   return NS_OK;
 }
 
 #undef SEL_TO_COMMAND
 
 NS_IMPL_ISUPPORTS1(NativeKeyBindings, nsINativeKeyBindings)
 
 NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyDown(const nsNativeKeyEvent& aEvent,
+NativeKeyBindings::KeyDown(const nsKeyEvent& aEvent,
                            DoCommandCallback aCallback, void* aCallbackData)
 {
   return false;
 }
 
 NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyPress(const nsNativeKeyEvent& aEvent,
+NativeKeyBindings::KeyPress(const nsKeyEvent& aEvent,
                             DoCommandCallback aCallback, void* aCallbackData)
 {
   PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
     ("%p NativeKeyBindings::KeyPress", this));
 
   // Recover the current event, which should always be the key down we are
   // responding to.
-  nsKeyEvent* geckoEvent = aEvent.mGeckoEvent;
 
-  MOZ_ASSERT(geckoEvent);
-
-  NSEvent* cocoaEvent = reinterpret_cast<NSEvent*>(geckoEvent->mNativeKeyEvent);
+  NSEvent* cocoaEvent = reinterpret_cast<NSEvent*>(aEvent.mNativeKeyEvent);
 
   if (!cocoaEvent || [cocoaEvent type] != NSKeyDown) {
     PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
       ("%p NativeKeyBindings::KeyPress, no Cocoa key down event", this));
 
     return false;
   }
 
@@ -265,13 +262,13 @@ NativeKeyBindings::KeyPress(const nsNati
 
   PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
     ("%p NativeKeyBindings::KeyPress, handled=true", this));
 
   return true;
 }
 
 NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyUp(const nsNativeKeyEvent& aEvent,
+NativeKeyBindings::KeyUp(const nsKeyEvent& aEvent,
                          DoCommandCallback aCallback, void* aCallbackData)
 {
   return false;
 }
--- a/widget/gtk2/nsNativeKeyBindings.cpp
+++ b/widget/gtk2/nsNativeKeyBindings.cpp
@@ -231,90 +231,84 @@ nsNativeKeyBindings::~nsNativeKeyBinding
 {
   gtk_widget_destroy(mNativeTarget);
   g_object_unref(mNativeTarget);
 }
 
 NS_IMPL_ISUPPORTS1(nsNativeKeyBindings, nsINativeKeyBindings)
 
 bool
-nsNativeKeyBindings::KeyDown(const nsNativeKeyEvent& aEvent,
+nsNativeKeyBindings::KeyDown(const nsKeyEvent& aEvent,
                              DoCommandCallback aCallback, void *aCallbackData)
 {
   return false;
 }
 
 bool
-nsNativeKeyBindings::KeyPress(const nsNativeKeyEvent& aEvent,
+nsNativeKeyBindings::KeyPress(const nsKeyEvent& aEvent,
                               DoCommandCallback aCallback, void *aCallbackData)
 {
   // If the native key event is set, it must be synthesized for tests.
   // We just ignore such events because this behavior depends on system
   // settings.
-  if (!aEvent.mGeckoEvent->mNativeKeyEvent) {
+  if (!aEvent.mNativeKeyEvent) {
     // It must be synthesized event or dispatched DOM event from chrome.
     return false;
   }
 
   guint keyval;
 
   if (aEvent.charCode) {
     keyval = gdk_unicode_to_keyval(aEvent.charCode);
   } else {
     keyval =
-      static_cast<GdkEventKey*>(aEvent.mGeckoEvent->mNativeKeyEvent)->keyval;
+      static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->keyval;
   }
 
   if (KeyPressInternal(aEvent, aCallback, aCallbackData, keyval)) {
     return true;
   }
 
-  nsKeyEvent *nativeKeyEvent = aEvent.mGeckoEvent;
-  if (!nativeKeyEvent ||
-      (nativeKeyEvent->eventStructType != NS_KEY_EVENT &&
-       nativeKeyEvent->message != NS_KEY_PRESS)) {
-    return false;
-  }
-
-  for (uint32_t i = 0; i < nativeKeyEvent->alternativeCharCodes.Length(); ++i) {
-    uint32_t ch = nativeKeyEvent->IsShift() ?
-        nativeKeyEvent->alternativeCharCodes[i].mShiftedCharCode :
-        nativeKeyEvent->alternativeCharCodes[i].mUnshiftedCharCode;
+  for (uint32_t i = 0; i < aEvent.alternativeCharCodes.Length(); ++i) {
+    uint32_t ch = aEvent.IsShift() ?
+      aEvent.alternativeCharCodes[i].mShiftedCharCode :
+      aEvent.alternativeCharCodes[i].mUnshiftedCharCode;
     if (ch && ch != aEvent.charCode) {
       keyval = gdk_unicode_to_keyval(ch);
       if (KeyPressInternal(aEvent, aCallback, aCallbackData, keyval)) {
         return true;
       }
     }
   }
 
-/* gtk_bindings_activate_event is preferable, but it has unresolved bug: http://bugzilla.gnome.org/show_bug.cgi?id=162726
-Also gtk_bindings_activate may work with some non-shortcuts operations (todo: check it)
-See bugs 411005 406407
+/*
+gtk_bindings_activate_event is preferable, but it has unresolved bug:
+http://bugzilla.gnome.org/show_bug.cgi?id=162726
+The bug was already marked as FIXED.  However, somebody reports that the
+bug still exists.
+Also gtk_bindings_activate may work with some non-shortcuts operations
+(todo: check it). See bug 411005 and bug 406407.
 
-  Code, which should be used after fixing http://bugzilla.gnome.org/show_bug.cgi?id=162726:
-  const nsGUIEvent *guiEvent = aEvent.mGeckoEvent;
-  if (guiEvent &&
-     (guiEvent->message == NS_KEY_PRESS || guiEvent->message == NS_KEY_UP || guiEvent->message == NS_KEY_DOWN) &&
-      guiEvent->pluginEvent)
-        gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),
-                                    static_cast<GdkEventKey*>(guiEvent->pluginEvent));
+Code, which should be used after fixing GNOME bug 162726:
+
+  gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),
+    static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent));
 */
 
   return false;
 }
 
 bool
-nsNativeKeyBindings::KeyPressInternal(const nsNativeKeyEvent& aEvent,
+nsNativeKeyBindings::KeyPressInternal(const nsKeyEvent& aEvent,
                                       DoCommandCallback aCallback,
                                       void *aCallbackData,
                                       guint aKeyval)
 {
   guint modifiers =
-    static_cast<GdkEventKey*>(aEvent.mGeckoEvent->mNativeKeyEvent)->state;
+    static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->state;
 
   gCurrentCallback = aCallback;
   gCurrentCallbackData = aCallbackData;
 
   gHandled = false;
 #if (MOZ_WIDGET_GTK == 2)
   gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
                         aKeyval, GdkModifierType(modifiers));
@@ -325,13 +319,13 @@ nsNativeKeyBindings::KeyPressInternal(co
 
   gCurrentCallback = nullptr;
   gCurrentCallbackData = nullptr;
 
   return gHandled;
 }
 
 bool
-nsNativeKeyBindings::KeyUp(const nsNativeKeyEvent& aEvent,
+nsNativeKeyBindings::KeyUp(const nsKeyEvent& aEvent,
                            DoCommandCallback aCallback, void *aCallbackData)
 {
   return false;
 }
--- a/widget/gtk2/nsNativeKeyBindings.h
+++ b/widget/gtk2/nsNativeKeyBindings.h
@@ -32,32 +32,32 @@ enum NativeKeyBindingsType {
 class nsNativeKeyBindings MOZ_FINAL : public nsINativeKeyBindings
 {
 public:
   NS_HIDDEN_(void) Init(NativeKeyBindingsType aType);
 
   NS_DECL_ISUPPORTS
 
   // nsINativeKeyBindings
-  virtual NS_HIDDEN_(bool) KeyDown(const nsNativeKeyEvent& aEvent,
-                                     DoCommandCallback aCallback,
-                                     void *aCallbackData);
-
-  virtual NS_HIDDEN_(bool) KeyPress(const nsNativeKeyEvent& aEvent,
-                                      DoCommandCallback aCallback,
-                                      void *aCallbackData);
-
-  virtual NS_HIDDEN_(bool) KeyUp(const nsNativeKeyEvent& aEvent,
+  virtual NS_HIDDEN_(bool) KeyDown(const nsKeyEvent& aEvent,
                                    DoCommandCallback aCallback,
                                    void *aCallbackData);
 
+  virtual NS_HIDDEN_(bool) KeyPress(const nsKeyEvent& aEvent,
+                                    DoCommandCallback aCallback,
+                                    void *aCallbackData);
+
+  virtual NS_HIDDEN_(bool) KeyUp(const nsKeyEvent& aEvent,
+                                 DoCommandCallback aCallback,
+                                 void *aCallbackData);
+
 private:
   ~nsNativeKeyBindings() NS_HIDDEN;
 
-  bool KeyPressInternal(const nsNativeKeyEvent& aEvent,
-                          DoCommandCallback aCallback,
-                          void *aCallbackData,
-                          guint aKeyval);
+  bool KeyPressInternal(const nsKeyEvent& aEvent,
+                        DoCommandCallback aCallback,
+                        void *aCallbackData,
+                        guint aKeyval);
 
   GtkWidget *mNativeTarget;
 };
 
 #endif
--- a/widget/nsINativeKeyBindings.h
+++ b/widget/nsINativeKeyBindings.h
@@ -5,56 +5,45 @@
 
 #ifndef nsINativeKeyBindings_h_
 #define nsINativeKeyBindings_h_
 
 #include "nsISupports.h"
 #include "nsEvent.h"
 
 #define NS_INATIVEKEYBINDINGS_IID \
-{0x606c54e7, 0x0593, 0x4750, {0x99, 0xd9, 0x4e, 0x1b, 0xcc, 0xec, 0x98, 0xd9}}
+{0xc2baecc3, 0x1758, 0x4211, {0x96, 0xbe, 0xee, 0x1b, 0x1b, 0x7c, 0xd7, 0x6d}}
 
 #define NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX \
   "@mozilla.org/widget/native-key-bindings;1?type="
 
 #define NS_NATIVEKEYBINDINGSINPUT_CONTRACTID \
 NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "input"
 
 #define NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID \
 NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "textarea"
 
 #define NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID \
 NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "editor"
 
-struct nsNativeKeyEvent
-{
-  nsKeyEvent* mGeckoEvent; // see bug 406407 to see how this is used
-  uint32_t    keyCode;
-  uint32_t    charCode;
-  bool        altKey;
-  bool        ctrlKey;
-  bool        shiftKey;
-  bool        metaKey;
-};
-
 class nsINativeKeyBindings : public nsISupports
 {
  public:
   typedef void (*DoCommandCallback)(const char *, void*);
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INATIVEKEYBINDINGS_IID)
 
-  virtual NS_HIDDEN_(bool) KeyDown(const nsNativeKeyEvent& aEvent,
-                                     DoCommandCallback aCallback,
-                                     void *aCallbackData) = 0;
-
-  virtual NS_HIDDEN_(bool) KeyPress(const nsNativeKeyEvent& aEvent,
-                                      DoCommandCallback aCallback,
-                                      void *aCallbackData) = 0;
-
-  virtual NS_HIDDEN_(bool) KeyUp(const nsNativeKeyEvent& aEvent,
+  virtual NS_HIDDEN_(bool) KeyDown(const nsKeyEvent& aEvent,
                                    DoCommandCallback aCallback,
                                    void *aCallbackData) = 0;
+
+  virtual NS_HIDDEN_(bool) KeyPress(const nsKeyEvent& aEvent,
+                                    DoCommandCallback aCallback,
+                                    void *aCallbackData) = 0;
+
+  virtual NS_HIDDEN_(bool) KeyUp(const nsKeyEvent& aEvent,
+                                 DoCommandCallback aCallback,
+                                 void *aCallbackData) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINativeKeyBindings, NS_INATIVEKEYBINDINGS_IID)
 
 #endif