Bug 977959 part.2 Remove nsINativeKeyBindings::KeyDown() and nsINativeKeyBindings::KeyUp() r=roc, sr=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 14 Mar 2014 22:13:31 +0900
changeset 191877 ffcd85163a89862fb6f83babb1428e2bd1d9030e
parent 191876 74ba454a18212a62e73a77826c770658a5e8ff35
child 191878 704b766676beffabe2c187829a3b5395cf98ca5b
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, roc
bugs977959
milestone30.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 977959 part.2 Remove nsINativeKeyBindings::KeyDown() and nsINativeKeyBindings::KeyUp() r=roc, sr=roc
content/html/content/src/nsTextEditorState.cpp
editor/libeditor/base/nsEditorEventListener.cpp
widget/cocoa/NativeKeyBindings.h
widget/cocoa/NativeKeyBindings.mm
widget/gtk/nsNativeKeyBindings.cpp
widget/gtk/nsNativeKeyBindings.h
widget/nsINativeKeyBindings.h
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -855,37 +855,28 @@ nsTextInputListener::HandleEvent(nsIDOME
   }
 
   WidgetKeyboardEvent* keyEvent =
     aEvent->GetInternalNSEvent()->AsKeyboardEvent();
   if (!keyEvent) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  nsINativeKeyBindings *bindings = GetKeyBindings();
-  if (bindings) {
-    bool handled = false;
-    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();
-    }
+  if (keyEvent->message != NS_KEY_PRESS) {
+    return NS_OK;
   }
 
+  nsINativeKeyBindings *bindings = GetKeyBindings();
+  if (!bindings) {
+    return NS_OK;
+  }
+
+  if (bindings->KeyPress(*keyEvent, DoCommandCallback, mFrame)) {
+    aEvent->PreventDefault();
+  }
   return NS_OK;
 }
 
 // BEGIN nsIEditorObserver
 
 NS_IMETHODIMP
 nsTextInputListener::EditAction()
 {
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -525,19 +525,16 @@ nsEditorEventListener::KeyPress(nsIDOMEv
 
   aKeyEvent->GetDefaultPrevented(&defaultPrevented);
   if (defaultPrevented) {
     return NS_OK;
   }
 
   if (GetEditorKeyBindings() && ShouldHandleNativeKeyBindings(aKeyEvent)) {
     // Now, ask the native key bindings to handle the event.
-    // XXX Note that we're not passing the keydown/keyup events to the native
-    // key bindings, which should be OK since those events are only handled on
-    // Windows for now, where we don't have native key bindings.
     WidgetKeyboardEvent* keyEvent =
       aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
     MOZ_ASSERT(keyEvent,
                "DOM key event's internal event must be WidgetKeyboardEvent");
     nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
     bool handled = sNativeEditorBindings->KeyPress(*keyEvent,
                                                    DoCommandCallback,
                                                    doc);
--- a/widget/cocoa/NativeKeyBindings.h
+++ b/widget/cocoa/NativeKeyBindings.h
@@ -46,28 +46,20 @@ class NativeKeyBindings MOZ_FINAL : publ
 public:
   NativeKeyBindings();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Init(NativeKeyBindingsType aType);
 
   // nsINativeKeyBindings
-  NS_IMETHOD_(bool) KeyDown(const WidgetKeyboardEvent& aEvent,
-                            DoCommandCallback aCallback,
-                            void* aCallbackData);
-
   NS_IMETHOD_(bool) KeyPress(const WidgetKeyboardEvent& aEvent,
                              DoCommandCallback aCallback,
                              void* aCallbackData);
 
-  NS_IMETHOD_(bool) KeyUp(const WidgetKeyboardEvent& aEvent,
-                          DoCommandCallback aCallback,
-                          void* aCallbackData);
-
 private:
   SelectorCommandHashtable mSelectorToCommand;
 }; // NativeKeyBindings
 
 } // namespace widget
 } // namespace mozilla
 
 #endif /* NativeKeyBindings_h_ */
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
@@ -165,23 +165,16 @@ NativeKeyBindings::Init(NativeKeyBinding
   return NS_OK;
 }
 
 #undef SEL_TO_COMMAND
 
 NS_IMPL_ISUPPORTS1(NativeKeyBindings, nsINativeKeyBindings)
 
 NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyDown(const WidgetKeyboardEvent& aEvent,
-                           DoCommandCallback aCallback, void* aCallbackData)
-{
-  return false;
-}
-
-NS_IMETHODIMP_(bool)
 NativeKeyBindings::KeyPress(const WidgetKeyboardEvent& 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.
@@ -261,15 +254,8 @@ NativeKeyBindings::KeyPress(const Widget
     aCallback(geckoCommand, aCallbackData);
   }
 
   PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
     ("%p NativeKeyBindings::KeyPress, handled=true", this));
 
   return true;
 }
-
-NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyUp(const WidgetKeyboardEvent& aEvent,
-                         DoCommandCallback aCallback, void* aCallbackData)
-{
-  return false;
-}
--- a/widget/gtk/nsNativeKeyBindings.cpp
+++ b/widget/gtk/nsNativeKeyBindings.cpp
@@ -237,23 +237,16 @@ nsNativeKeyBindings::~nsNativeKeyBinding
 {
   gtk_widget_destroy(mNativeTarget);
   g_object_unref(mNativeTarget);
 }
 
 NS_IMPL_ISUPPORTS1(nsNativeKeyBindings, nsINativeKeyBindings)
 
 bool
-nsNativeKeyBindings::KeyDown(const WidgetKeyboardEvent& aEvent,
-                             DoCommandCallback aCallback, void *aCallbackData)
-{
-  return false;
-}
-
-bool
 nsNativeKeyBindings::KeyPress(const WidgetKeyboardEvent& 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.mNativeKeyEvent) {
     // It must be synthesized event or dispatched DOM event from chrome.
@@ -323,15 +316,8 @@ nsNativeKeyBindings::KeyPressInternal(co
                         aKeyval, GdkModifierType(modifiers));
 #endif
 
   gCurrentCallback = nullptr;
   gCurrentCallbackData = nullptr;
 
   return gHandled;
 }
-
-bool
-nsNativeKeyBindings::KeyUp(const WidgetKeyboardEvent& aEvent,
-                           DoCommandCallback aCallback, void *aCallbackData)
-{
-  return false;
-}
--- a/widget/gtk/nsNativeKeyBindings.h
+++ b/widget/gtk/nsNativeKeyBindings.h
@@ -33,28 +33,20 @@ 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 mozilla::WidgetKeyboardEvent& aEvent,
-                                   DoCommandCallback aCallback,
-                                   void *aCallbackData);
-
   virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
                                     DoCommandCallback aCallback,
                                     void *aCallbackData);
 
-  virtual NS_HIDDEN_(bool) KeyUp(const mozilla::WidgetKeyboardEvent& aEvent,
-                                 DoCommandCallback aCallback,
-                                 void *aCallbackData);
-
 private:
   ~nsNativeKeyBindings() NS_HIDDEN;
 
   bool KeyPressInternal(const mozilla::WidgetKeyboardEvent& aEvent,
                         DoCommandCallback aCallback,
                         void *aCallbackData,
                         guint aKeyval);
 
--- a/widget/nsINativeKeyBindings.h
+++ b/widget/nsINativeKeyBindings.h
@@ -5,17 +5,18 @@
 
 #ifndef nsINativeKeyBindings_h_
 #define nsINativeKeyBindings_h_
 
 #include "nsISupports.h"
 #include "mozilla/EventForwards.h"
 
 #define NS_INATIVEKEYBINDINGS_IID \
-{0xc2baecc3, 0x1758, 0x4211, {0x96, 0xbe, 0xee, 0x1b, 0x1b, 0x7c, 0xd7, 0x6d}}
+{ 0x98290677, 0xfdac, 0x414a, \
+  { 0x81, 0x5c, 0x20, 0xe2, 0xd4, 0xcd, 0x8c, 0x47 } }
 
 #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 \
@@ -26,24 +27,16 @@ NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "
 
 class nsINativeKeyBindings : public nsISupports
 {
  public:
   typedef void (*DoCommandCallback)(mozilla::Command, void*);
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INATIVEKEYBINDINGS_IID)
 
-  virtual NS_HIDDEN_(bool) KeyDown(const mozilla::WidgetKeyboardEvent& aEvent,
-                                   DoCommandCallback aCallback,
-                                   void *aCallbackData) = 0;
-
   virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
                                     DoCommandCallback aCallback,
                                     void *aCallbackData) = 0;
-
-  virtual NS_HIDDEN_(bool) KeyUp(const mozilla::WidgetKeyboardEvent& aEvent,
-                                 DoCommandCallback aCallback,
-                                 void *aCallbackData) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINativeKeyBindings, NS_INATIVEKEYBINDINGS_IID)
 
 #endif