Bug 977959 part.4 Remove nsINativeKeyBindings r=roc+karlt
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 14 Mar 2014 22:13:32 +0900
changeset 191879 b9daeea8712a87fd52634caf11d6596286c26689
parent 191878 704b766676beffabe2c187829a3b5395cf98ca5b
child 191880 8e7dd50fde879b9633a1db115e76d62f0d43c322
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
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.4 Remove nsINativeKeyBindings r=roc+karlt
widget/cocoa/NativeKeyBindings.h
widget/cocoa/NativeKeyBindings.mm
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.mm
widget/cocoa/nsWidgetFactory.mm
widget/gtk/NativeKeyBindings.cpp
widget/gtk/NativeKeyBindings.h
widget/gtk/moz.build
widget/gtk/nsNativeKeyBindings.cpp
widget/gtk/nsNativeKeyBindings.h
widget/gtk/nsWidgetFactory.cpp
widget/gtk/nsWindow.cpp
widget/moz.build
widget/nsINativeKeyBindings.h
--- a/widget/cocoa/NativeKeyBindings.h
+++ b/widget/cocoa/NativeKeyBindings.h
@@ -1,69 +1,51 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 NativeKeyBindings_h_
-#define NativeKeyBindings_h_
-
-#include "nsINativeKeyBindings.h"
-#include "nsIWidget.h"
+#ifndef mozilla_widget_NativeKeyBindings_h_
+#define mozilla_widget_NativeKeyBindings_h_
 
 #import <Cocoa/Cocoa.h>
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "nsDataHashtable.h"
-
-// 8477f934-febf-4c79-b7fe-bb7f9ebb9b4f
-#define NS_NATIVEKEYBINDINGS_INPUT_CID \
-  { 0x8477f934, 0xfebf, 0x4c79, \
-    { 0xb7, 0xfe, 0xbb, 0x7f, 0x9e, 0xbb, 0x9b, 0x4f } }
-
-// 13a6e56f-f00b-4e19-8cf6-1a51ee7cc4bf
-#define NS_NATIVEKEYBINDINGS_TEXTAREA_CID \
-  { 0x13a6e56f, 0xf00b, 0x4e19, \
-    { 0x8c, 0xf6, 0x1a, 0x51, 0xee, 0x7c, 0xc4, 0xbf } }
-
-// 36bfbd29-4e02-40f4-8fff-094f1a9ec97c
-#define NS_NATIVEKEYBINDINGS_EDITOR_CID \
-  { 0x36bfbd29, 0x4e02, 0x40f4, \
-    { 0x8f, 0xff, 0x09, 0x4f, 0x1a, 0x9e, 0xc9, 0x7c } }
+#include "nsIWidget.h"
 
 namespace mozilla {
 namespace widget {
 
 typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, CommandInt>
   SelectorCommandHashtable;
 
-class NativeKeyBindings MOZ_FINAL : public nsINativeKeyBindings
+class NativeKeyBindings MOZ_FINAL
 {
   typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
   typedef nsIWidget::DoCommandCallback DoCommandCallback;
 
+  NS_INLINE_DECL_REFCOUNTING(NativeKeyBindings)
+
 public:
   static already_AddRefed<NativeKeyBindings>
     GetInstance(NativeKeyBindingsType aType);
   static void Shutdown();
 
+  void Init(NativeKeyBindingsType aType);
+
+  bool Execute(const WidgetKeyboardEvent& aEvent,
+               DoCommandCallback aCallback,
+               void* aCallbackData);
+
+private:
   NativeKeyBindings();
 
-  NS_DECL_ISUPPORTS
-
-  NS_IMETHOD Init(NativeKeyBindingsType aType);
-
-  // nsINativeKeyBindings
-  NS_IMETHOD_(bool) KeyPress(const WidgetKeyboardEvent& aEvent,
-                             DoCommandCallback aCallback,
-                             void* aCallbackData);
-
-private:
   SelectorCommandHashtable mSelectorToCommand;
 
   static NativeKeyBindings* sInstanceForSingleLineEditor;
   static NativeKeyBindings* sInstanceForMultiLineEditor;
 }; // NativeKeyBindings
 
 } // namespace widget
 } // namespace mozilla
 
-#endif /* NativeKeyBindings_h_ */
+#endif // mozilla_widget_NativeKeyBindings_h_
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
@@ -5,18 +5,18 @@
 
 #include "NativeKeyBindings.h"
 
 #include "nsTArray.h"
 #include "nsCocoaUtils.h"
 #include "prlog.h"
 #include "mozilla/TextEvents.h"
 
-using namespace mozilla;
-using namespace mozilla::widget;
+namespace mozilla {
+namespace widget {
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gNativeKeyBindingsLog = nullptr;
 #endif
 
 NativeKeyBindings* NativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
 NativeKeyBindings* NativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
 
@@ -57,17 +57,17 @@ NativeKeyBindings::Shutdown()
 NativeKeyBindings::NativeKeyBindings()
 {
 }
 
 #define SEL_TO_COMMAND(aSel, aCommand) \
   mSelectorToCommand.Put( \
     reinterpret_cast<struct objc_selector *>(@selector(aSel)), aCommand)
 
-NS_IMETHODIMP
+void
 NativeKeyBindings::Init(NativeKeyBindingsType aType)
 {
 #ifdef PR_LOGGING
   if (!gNativeKeyBindingsLog) {
     gNativeKeyBindingsLog = PR_NewLogModule("NativeKeyBindings");
   }
 #endif
 
@@ -193,27 +193,24 @@ NativeKeyBindings::Init(NativeKeyBinding
   // SEL_TO_COMMAND(setMark:, );
   // SEL_TO_COMMAND(showContextHelp:, );
   // SEL_TO_COMMAND(supplementalTargetForAction:sender:, );
   // SEL_TO_COMMAND(swapWithMark:, );
   // SEL_TO_COMMAND(transpose:, );
   // SEL_TO_COMMAND(transposeWords:, );
   // SEL_TO_COMMAND(uppercaseWord:, );
   // SEL_TO_COMMAND(yank:, );
-
-  return NS_OK;
 }
 
 #undef SEL_TO_COMMAND
 
-NS_IMPL_ISUPPORTS1(NativeKeyBindings, nsINativeKeyBindings)
-
-NS_IMETHODIMP_(bool)
-NativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
-                            DoCommandCallback aCallback, void* aCallbackData)
+bool
+NativeKeyBindings::Execute(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.
 
   NSEvent* cocoaEvent = reinterpret_cast<NSEvent*>(aEvent.mNativeKeyEvent);
@@ -291,8 +288,11 @@ NativeKeyBindings::KeyPress(const Widget
     aCallback(geckoCommand, aCallbackData);
   }
 
   PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
     ("%p NativeKeyBindings::KeyPress, handled=true", this));
 
   return true;
 }
+
+} // namespace widget
+} // namespace mozilla
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1966,17 +1966,17 @@ nsChildView::GetInputContext()
 NS_IMETHODIMP_(bool)
 nsChildView::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
                                      const WidgetKeyboardEvent& aEvent,
                                      DoCommandCallback aCallback,
                                      void* aCallbackData)
 {
   nsRefPtr<NativeKeyBindings> keyBindings =
     NativeKeyBindings::GetInstance(aType);
-  return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
+  return keyBindings->Execute(aEvent, aCallback, aCallbackData);
 }
 
 nsIMEUpdatePreference
 nsChildView::GetIMEUpdatePreference()
 {
   return nsIMEUpdatePreference(nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE);
 }
 
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2167,17 +2167,17 @@ nsCocoaWindow::SetInputContext(const Inp
 NS_IMETHODIMP_(bool)
 nsCocoaWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
                                        const WidgetKeyboardEvent& aEvent,
                                        DoCommandCallback aCallback,
                                        void* aCallbackData)
 {
   nsRefPtr<NativeKeyBindings> keyBindings =
     NativeKeyBindings::GetInstance(aType);
-  return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
+  return keyBindings->Execute(aEvent, aCallback, aCallbackData);
 }
 
 
 @implementation WindowDelegate
 
 // We try to find a gecko menu bar to paint. If one does not exist, just paint
 // the application menu by itself so that a window doesn't have some other
 // window's menu bar.
--- a/widget/cocoa/nsWidgetFactory.mm
+++ b/widget/cocoa/nsWidgetFactory.mm
@@ -23,28 +23,30 @@
 #include "nsHTMLFormatConverter.h"
 #include "nsDragService.h"
 #include "nsToolkit.h"
 
 #include "nsLookAndFeel.h"
 
 #include "nsSound.h"
 #include "nsIdleServiceX.h"
+#include "NativeKeyBindings.h"
 #include "OSXNotificationCenter.h"
 
 #include "nsScreenManagerCocoa.h"
 #include "nsDeviceContextSpecX.h"
 #include "nsPrintOptionsX.h"
 #include "nsPrintDialogX.h"
 #include "nsPrintSession.h"
 #include "nsToolkitCompsCID.h"
 
 #include "mozilla/Module.h"
 
 using namespace mozilla;
+using namespace mozilla::widget;
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
@@ -80,50 +82,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandal
 #include "GfxInfo.h"
 namespace mozilla {
 namespace widget {
 // This constructor should really be shared with all platforms.
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
 }
 }
 
-#include "NativeKeyBindings.h"
-namespace mozilla {
-namespace widget {
-
-static nsresult
-NativeKeyBindingsInputConstructor(nsISupports* aOuter, REFNSIID aIID,
-                                  void** aResult)
-{
-  *aResult = NativeKeyBindings::GetInstance(
-               nsIWidget::NativeKeyBindingsForSingleLineEditor).get();
-  return NS_OK;
-}
-
-static nsresult
-NativeKeyBindingsTextAreaConstructor(nsISupports* aOuter, REFNSIID aIID,
-                                     void** aResult)
-{
-  *aResult = NativeKeyBindings::GetInstance(
-               nsIWidget::NativeKeyBindingsForMultiLineEditor).get();
-  return NS_OK;
-}
-
-static nsresult
-NativeKeyBindingsEditorConstructor(nsISupports* aOuter, REFNSIID aIID,
-                                   void** aResult)
-{
-  *aResult = NativeKeyBindings::GetInstance(
-               nsIWidget::NativeKeyBindingsForRichTextEditor).get();
-  return NS_OK;
-}
-
-} // namespace widget
-} // namespace mozilla
-
 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
 NS_DEFINE_NAMED_CID(NS_POPUP_CID);
 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
 NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
@@ -140,20 +108,16 @@ NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERV
 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_NATIVEMENUSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_MACDOCKSUPPORT_CID);
 NS_DEFINE_NAMED_CID(NS_MACWEBAPPUTILS_CID);
 NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEMENU_CID);
 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_INPUT_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_TEXTAREA_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_EDITOR_CID);
-
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
   { &kNS_WINDOW_CID, false, NULL, nsCocoaWindowConstructor },
   { &kNS_POPUP_CID, false, NULL, nsCocoaWindowConstructor },
   { &kNS_CHILD_CID, false, NULL, nsChildViewConstructor },
   { &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { &kNS_COLORPICKER_CID, false, NULL, nsColorPickerConstructor,
@@ -180,22 +144,16 @@ static const mozilla::Module::CIDEntry k
     mozilla::Module::MAIN_PROCESS_ONLY },
   { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceXConstructor },
   { &kNS_SYSTEMALERTSSERVICE_CID, false, NULL, OSXNotificationCenterConstructor },
   { &kNS_NATIVEMENUSERVICE_CID, false, NULL, nsNativeMenuServiceXConstructor },
   { &kNS_MACDOCKSUPPORT_CID, false, NULL, nsMacDockSupportConstructor },
   { &kNS_MACWEBAPPUTILS_CID, false, NULL, nsMacWebAppUtilsConstructor },
   { &kNS_STANDALONENATIVEMENU_CID, false, NULL, nsStandaloneNativeMenuConstructor },
   { &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
-  { &kNS_NATIVEKEYBINDINGS_INPUT_CID, false, NULL,
-    mozilla::widget::NativeKeyBindingsInputConstructor },
-  { &kNS_NATIVEKEYBINDINGS_TEXTAREA_CID, false, NULL,
-    mozilla::widget::NativeKeyBindingsTextAreaConstructor },
-  { &kNS_NATIVEKEYBINDINGS_EDITOR_CID, false, NULL,
-    mozilla::widget::NativeKeyBindingsEditorConstructor },
   { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
   { "@mozilla.org/widgets/window/mac;1", &kNS_WINDOW_CID },
   { "@mozilla.org/widgets/popup/mac;1", &kNS_POPUP_CID },
   { "@mozilla.org/widgets/childwindow/mac;1", &kNS_CHILD_CID },
   { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
@@ -224,27 +182,23 @@ static const mozilla::Module::ContractID
     mozilla::Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
   { "@mozilla.org/system-alerts-service;1", &kNS_SYSTEMALERTSSERVICE_CID },
   { "@mozilla.org/widget/nativemenuservice;1", &kNS_NATIVEMENUSERVICE_CID },
   { "@mozilla.org/widget/macdocksupport;1", &kNS_MACDOCKSUPPORT_CID },
   { "@mozilla.org/widget/mac-web-app-utils;1", &kNS_MACWEBAPPUTILS_CID },
   { "@mozilla.org/widget/standalonenativemenu;1", &kNS_STANDALONENATIVEMENU_CID },
   { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
-  { NS_NATIVEKEYBINDINGSINPUT_CONTRACTID, &kNS_NATIVEKEYBINDINGS_INPUT_CID },
-  { NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID,
-    &kNS_NATIVEKEYBINDINGS_TEXTAREA_CID },
-  { NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID, &kNS_NATIVEKEYBINDINGS_EDITOR_CID },
   { NULL }
 };
 
 static void
 nsWidgetCocoaModuleDtor()
 {
-  mozilla::widget::NativeKeyBindings::Shutdown();
+  NativeKeyBindings::Shutdown();
   nsLookAndFeel::Shutdown();
   nsToolkit::Shutdown();
   nsAppShellShutdown();
 }
 
 static const mozilla::Module kWidgetModule = {
   mozilla::Module::kVersion,
   kWidgetCIDs,
rename from widget/gtk/nsNativeKeyBindings.cpp
rename to widget/gtk/NativeKeyBindings.cpp
--- a/widget/gtk/nsNativeKeyBindings.cpp
+++ b/widget/gtk/NativeKeyBindings.cpp
@@ -2,32 +2,27 @@
 /* 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/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/TextEvents.h"
 
-#include "nsNativeKeyBindings.h"
+#include "NativeKeyBindings.h"
 #include "nsString.h"
 #include "nsMemory.h"
 #include "nsGtkKeyUtils.h"
 
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdk.h>
 
-// X.h defines KeyPress
-#ifdef KeyPress
-#undef KeyPress
-#endif
-
-using namespace mozilla;
-using namespace mozilla::widget;
+namespace mozilla {
+namespace widget {
 
 static nsIWidget::DoCommandCallback gCurrentCallback;
 static void *gCurrentCallbackData;
 static bool gHandled;
 
 // Common GtkEntry and GtkTextView signals
 static void
 copy_clipboard_cb(GtkWidget *w, gpointer user_data)
@@ -193,58 +188,56 @@ paste_clipboard_cb(GtkWidget *w, gpointe
 static void
 select_all_cb(GtkWidget *w, gboolean select, gpointer user_data)
 {
   gCurrentCallback(CommandSelectAll, gCurrentCallbackData);
   g_signal_stop_emission_by_name(w, "select_all");
   gHandled = true;
 }
 
-nsNativeKeyBindings*
-  nsNativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
-nsNativeKeyBindings*
-  nsNativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
+NativeKeyBindings* NativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
+NativeKeyBindings* NativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
 
 // static
-already_AddRefed<nsNativeKeyBindings>
-nsNativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
+already_AddRefed<NativeKeyBindings>
+NativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
 {
   switch (aType) {
     case nsIWidget::NativeKeyBindingsForSingleLineEditor:
       if (!sInstanceForSingleLineEditor) {
-        NS_ADDREF(sInstanceForSingleLineEditor = new nsNativeKeyBindings());
+        NS_ADDREF(sInstanceForSingleLineEditor = new NativeKeyBindings());
         sInstanceForSingleLineEditor->Init(aType);
       }
       NS_ADDREF(sInstanceForSingleLineEditor);
       return sInstanceForSingleLineEditor;
 
     default:
       // fallback to multiline editor case in release build
       MOZ_ASSERT(false, "aType is invalid or not yet implemented");
     case nsIWidget::NativeKeyBindingsForMultiLineEditor:
     case nsIWidget::NativeKeyBindingsForRichTextEditor:
       if (!sInstanceForMultiLineEditor) {
-        NS_ADDREF(sInstanceForMultiLineEditor = new nsNativeKeyBindings());
+        NS_ADDREF(sInstanceForMultiLineEditor = new NativeKeyBindings());
         sInstanceForMultiLineEditor->Init(aType);
       }
       NS_ADDREF(sInstanceForMultiLineEditor);
       return sInstanceForMultiLineEditor;
   }
 }
 
 // static
 void
-nsNativeKeyBindings::Shutdown()
+NativeKeyBindings::Shutdown()
 {
   NS_IF_RELEASE(sInstanceForSingleLineEditor);
   NS_IF_RELEASE(sInstanceForMultiLineEditor);
 }
 
 void
-nsNativeKeyBindings::Init(NativeKeyBindingsType  aType)
+NativeKeyBindings::Init(NativeKeyBindingsType  aType)
 {
   switch (aType) {
   case nsIWidget::NativeKeyBindingsForSingleLineEditor:
     mNativeTarget = gtk_entry_new();
     break;
   default:
     mNativeTarget = gtk_text_view_new();
     if (gtk_major_version > 2 ||
@@ -268,27 +261,26 @@ nsNativeKeyBindings::Init(NativeKeyBindi
   g_signal_connect(mNativeTarget, "delete_from_cursor",
                    G_CALLBACK(delete_from_cursor_cb), this);
   g_signal_connect(mNativeTarget, "move_cursor",
                    G_CALLBACK(move_cursor_cb), this);
   g_signal_connect(mNativeTarget, "paste_clipboard",
                    G_CALLBACK(paste_clipboard_cb), this);
 }
 
-nsNativeKeyBindings::~nsNativeKeyBindings()
+NativeKeyBindings::~NativeKeyBindings()
 {
   gtk_widget_destroy(mNativeTarget);
   g_object_unref(mNativeTarget);
 }
 
-NS_IMPL_ISUPPORTS1(nsNativeKeyBindings, nsINativeKeyBindings)
-
 bool
-nsNativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
-                              DoCommandCallback aCallback, void *aCallbackData)
+NativeKeyBindings::Execute(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.
     return false;
   }
@@ -297,27 +289,27 @@ nsNativeKeyBindings::KeyPress(const Widg
 
   if (aEvent.charCode) {
     keyval = gdk_unicode_to_keyval(aEvent.charCode);
   } else {
     keyval =
       static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->keyval;
   }
 
-  if (KeyPressInternal(aEvent, aCallback, aCallbackData, keyval)) {
+  if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) {
     return true;
   }
 
   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)) {
+      if (ExecuteInternal(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
@@ -331,20 +323,20 @@ Code, which should be used after fixing 
   gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),
     static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent));
 */
 
   return false;
 }
 
 bool
-nsNativeKeyBindings::KeyPressInternal(const WidgetKeyboardEvent& aEvent,
-                                      DoCommandCallback aCallback,
-                                      void *aCallbackData,
-                                      guint aKeyval)
+NativeKeyBindings::ExecuteInternal(const WidgetKeyboardEvent& aEvent,
+                                   DoCommandCallback aCallback,
+                                   void* aCallbackData,
+                                   guint aKeyval)
 {
   guint modifiers =
     static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->state;
 
   gCurrentCallback = aCallback;
   gCurrentCallbackData = aCallbackData;
 
   gHandled = false;
@@ -356,8 +348,11 @@ nsNativeKeyBindings::KeyPressInternal(co
                         aKeyval, GdkModifierType(modifiers));
 #endif
 
   gCurrentCallback = nullptr;
   gCurrentCallbackData = nullptr;
 
   return gHandled;
 }
+
+} // namespace widget
+} // namespace mozilla
rename from widget/gtk/nsNativeKeyBindings.h
rename to widget/gtk/NativeKeyBindings.h
--- a/widget/gtk/nsNativeKeyBindings.h
+++ b/widget/gtk/NativeKeyBindings.h
@@ -1,61 +1,52 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 nsNativeKeyBindings_h_
-#define nsNativeKeyBindings_h_
+#ifndef mozilla_widget_NativeKeyBindings_h_
+#define mozilla_widget_NativeKeyBindings_h_
 
-// X.h defines KeyPress
-#ifdef KeyPress
-#undef KeyPress
-#endif
-
-#include "nsINativeKeyBindings.h"
+#include <gtk/gtk.h>
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
-#include <gtk/gtk.h>
-
-#define NS_NATIVEKEYBINDINGSINPUT_CID \
-{0x5c337258, 0xa580, 0x472e, {0x86, 0x15, 0xf2, 0x77, 0xdd, 0xc5, 0xbb, 0x06}}
+#include "nsIWidget.h"
 
-#define NS_NATIVEKEYBINDINGSTEXTAREA_CID \
-{0x2a898043, 0x180f, 0x4c8b, {0x8e, 0x54, 0x41, 0x0c, 0x7a, 0x54, 0x0f, 0x27}}
+namespace mozilla {
+namespace widget {
 
-#define NS_NATIVEKEYBINDINGSEDITOR_CID \
-{0xf916ebfb, 0x78ef, 0x464b, {0x94, 0xd0, 0xa6, 0xf2, 0xca, 0x32, 0x00, 0xae}}
-
-class nsNativeKeyBindings MOZ_FINAL : public nsINativeKeyBindings
+class NativeKeyBindings MOZ_FINAL
 {
   typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
   typedef nsIWidget::DoCommandCallback DoCommandCallback;
 
+  NS_INLINE_DECL_REFCOUNTING(NativeKeyBindings)
+
 public:
-  static already_AddRefed<nsNativeKeyBindings>
+  static already_AddRefed<NativeKeyBindings>
     GetInstance(NativeKeyBindingsType aType);
   static void Shutdown();
 
-  NS_HIDDEN_(void) Init(NativeKeyBindingsType aType);
-
-  NS_DECL_ISUPPORTS
+  void Init(NativeKeyBindingsType aType);
 
-  // nsINativeKeyBindings
-  virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
-                                    DoCommandCallback aCallback,
-                                    void *aCallbackData);
+  bool Execute(const WidgetKeyboardEvent& aEvent,
+               DoCommandCallback aCallback,
+               void* aCallbackData);
 
 private:
-  ~nsNativeKeyBindings() NS_HIDDEN;
+  ~NativeKeyBindings();
 
-  bool KeyPressInternal(const mozilla::WidgetKeyboardEvent& aEvent,
-                        DoCommandCallback aCallback,
-                        void *aCallbackData,
-                        guint aKeyval);
+  bool ExecuteInternal(const WidgetKeyboardEvent& aEvent,
+                       DoCommandCallback aCallback,
+                       void* aCallbackData,
+                       guint aKeyval);
 
-  GtkWidget *mNativeTarget;
+  GtkWidget* mNativeTarget;
 
-  static nsNativeKeyBindings* sInstanceForSingleLineEditor;
-  static nsNativeKeyBindings* sInstanceForMultiLineEditor;
+  static NativeKeyBindings* sInstanceForSingleLineEditor;
+  static NativeKeyBindings* sInstanceForMultiLineEditor;
 };
 
-#endif
+} // namespace widget
+} // namespace mozilla
+
+#endif // mozilla_widget_NativeKeyBindings_h_
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
@@ -12,23 +12,23 @@ else:
 EXPORTS += [
     'mozcontainer.h',
     'nsGTKToolkit.h',
     'nsIImageToPixbuf.h',
 ]
 
 UNIFIED_SOURCES += [
     'mozcontainer.c',
+    'NativeKeyBindings.cpp',
     'nsBidiKeyboard.cpp',
     'nsColorPicker.cpp',
     'nsFilePicker.cpp',
     'nsGtkKeyUtils.cpp',
     'nsImageToPixbuf.cpp',
     'nsLookAndFeel.cpp',
-    'nsNativeKeyBindings.cpp',
     'nsNativeThemeGTK.cpp',
     'nsScreenGtk.cpp',
     'nsScreenManagerGtk.cpp',
     'nsSound.cpp',
     'nsToolkit.cpp',
     'WidgetTraceEvent.cpp',
 ]
 
--- a/widget/gtk/nsWidgetFactory.cpp
+++ b/widget/gtk/nsWidgetFactory.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim:expandtab:shiftwidth=4:tabstop=4:
  */
 /* 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/. */
 
 #include "mozilla/ModuleUtils.h"
+#include "NativeKeyBindings.h"
 #include "nsWidgetsCID.h"
 #include "nsAppShell.h"
 #include "nsAppShellSingleton.h"
 #include "nsBaseWidget.h"
 #include "nsLookAndFeel.h"
 #include "nsWindow.h"
 #include "nsTransferable.h"
 #include "nsHTMLFormatConverter.h"
@@ -18,17 +19,16 @@
 #include "nsClipboardHelper.h"
 #include "nsClipboard.h"
 #include "nsDragService.h"
 #endif
 #include "nsColorPicker.h"
 #include "nsFilePicker.h"
 #include "nsSound.h"
 #include "nsBidiKeyboard.h"
-#include "nsNativeKeyBindings.h"
 #include "nsScreenManagerGtk.h"
 #include "nsGTKToolkit.h"
 
 #ifdef NS_PRINTING
 #include "nsPrintOptionsGTK.h"
 #include "nsPrintSession.h"
 #include "nsDeviceContextSpecG.h"
 #endif
@@ -47,16 +47,17 @@
 
 #include "nsIComponentRegistrar.h"
 #include "nsComponentManagerUtils.h"
 #include "nsAutoPtr.h"
 #include "mozilla/gfx/2D.h"
 #include <gtk/gtk.h>
 
 using namespace mozilla;
+using namespace mozilla::widget;
 
 /* from nsFilePicker.js */
 #define XULFILEPICKER_CID \
   { 0x54ae32f8, 0x1dd2, 0x11b2, \
     { 0xa2, 0x09, 0xdf, 0x7c, 0x50, 0x53, 0x70, 0xf8} }
 static NS_DEFINE_CID(kXULFilePickerCID, XULFILEPICKER_CID);
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
@@ -162,51 +163,30 @@ nsColorPickerConstructor(nsISupports *aO
 
     if (!picker) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     return picker->QueryInterface(aIID, aResult);
 }
 
-static nsresult
-nsNativeKeyBindingsInputConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                    void **aResult)
-{
-    *aResult = nsNativeKeyBindings::GetInstance(
-                   nsIWidget::NativeKeyBindingsForSingleLineEditor).get();
-    return NS_OK;
-}
-
-static nsresult
-nsNativeKeyBindingsTextAreaConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                       void **aResult)
-{
-    *aResult = nsNativeKeyBindings::GetInstance(
-                   nsIWidget::NativeKeyBindingsForMultiLineEditor).get();
-    return NS_OK;
-}
-
 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
 #ifdef MOZ_X11
 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSINPUT_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSTEXTAREA_CID);
-NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSEDITOR_CID);
 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
 #ifdef NS_PRINTING
 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
@@ -228,19 +208,16 @@ static const mozilla::Module::CIDEntry k
     { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
 #ifdef MOZ_X11
     { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor, Module::MAIN_PROCESS_ONLY },
     { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
     { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY },
 #endif
     { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
     { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor },
-    { &kNS_NATIVEKEYBINDINGSINPUT_CID, false, nullptr, nsNativeKeyBindingsInputConstructor },
-    { &kNS_NATIVEKEYBINDINGSTEXTAREA_CID, false, nullptr, nsNativeKeyBindingsTextAreaConstructor },
-    { &kNS_NATIVEKEYBINDINGSEDITOR_CID, false, nullptr, nsNativeKeyBindingsTextAreaConstructor },
     { &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerGtkConstructor },
     { &kNS_THEMERENDERER_CID, false, nullptr, nsNativeThemeGTKConstructor },
 #ifdef NS_PRINTING
     { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsGTKConstructor },
     { &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorGTKConstructor,
       Module::MAIN_PROCESS_ONLY },
     { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor,
       Module::MAIN_PROCESS_ONLY },
@@ -267,19 +244,16 @@ static const mozilla::Module::ContractID
     { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
 #ifdef MOZ_X11
     { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, Module::MAIN_PROCESS_ONLY },
     { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
     { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY },
 #endif
     { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
     { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
-    { NS_NATIVEKEYBINDINGSINPUT_CONTRACTID, &kNS_NATIVEKEYBINDINGSINPUT_CID },
-    { NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID, &kNS_NATIVEKEYBINDINGSTEXTAREA_CID },
-    { NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID, &kNS_NATIVEKEYBINDINGSEDITOR_CID },
     { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
     { "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
 #ifdef NS_PRINTING
     { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
     { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID,
       Module::MAIN_PROCESS_ONLY },
     { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID,
       Module::MAIN_PROCESS_ONLY },
@@ -294,17 +268,17 @@ static const mozilla::Module::ContractID
     { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
 #endif
     { nullptr }
 };
 
 static void
 nsWidgetGtk2ModuleDtor()
 {
-  nsNativeKeyBindings::Shutdown();
+  NativeKeyBindings::Shutdown();
   nsLookAndFeel::Shutdown();
   nsFilePicker::Shutdown();
   nsSound::Shutdown();
   nsWindow::ReleaseGlobals();
   nsGTKToolkit::Shutdown();
   nsAppShellShutdown();
 }
 
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -114,17 +114,17 @@ extern "C" {
 #include "gfxXlibSurface.h"
 #include "cairo-xlib.h"
 #endif
   
 #include "nsShmImage.h"
 
 #include "nsIDOMWheelEvent.h"
 
-#include "nsNativeKeyBindings.h"
+#include "NativeKeyBindings.h"
 #include "nsWindow.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::widget;
 using namespace mozilla::layers;
 using mozilla::gl::GLContext;
 
@@ -5975,19 +5975,19 @@ nsWindow::GetInputContext()
 }
 
 NS_IMETHODIMP_(bool)
 nsWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
                                   const WidgetKeyboardEvent& aEvent,
                                   DoCommandCallback aCallback,
                                   void* aCallbackData)
 {
-    nsRefPtr<nsNativeKeyBindings> keyBindings =
-        nsNativeKeyBindings::GetInstance(aType);
-    return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
+    nsRefPtr<NativeKeyBindings> keyBindings =
+        NativeKeyBindings::GetInstance(aType);
+    return keyBindings->Execute(aEvent, aCallback, aCallbackData);
 }
 
 NS_IMETHODIMP
 nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState)
 {
     NS_ENSURE_ARG_POINTER(aLEDState);
 
     KeymapWrapper::Modifiers modifier;
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -90,17 +90,16 @@ if CONFIG['MOZ_METRO']:
         'nsIWinMetroUtils.idl',
     ]
 
 XPIDL_MODULE = 'widget'
 
 EXPORTS += [
     'InputData.h',
     'nsIDeviceContextSpec.h',
-    'nsINativeKeyBindings.h',
     'nsIPluginWidget.h',
     'nsIRollupListener.h',
     'nsIWidget.h',
     'nsIWidgetListener.h',
     'nsWidgetInitData.h',
     'nsWidgetsCID.h',
 ]
 
deleted file mode 100644
--- a/widget/nsINativeKeyBindings.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 nsINativeKeyBindings_h_
-#define nsINativeKeyBindings_h_
-
-#include "nsISupports.h"
-#include "nsIWidget.h"
-#include "mozilla/EventForwards.h"
-
-#define NS_INATIVEKEYBINDINGS_IID \
-{ 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 \
-NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "textarea"
-
-#define NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID \
-NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "editor"
-
-class nsINativeKeyBindings : public nsISupports
-{
- public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_INATIVEKEYBINDINGS_IID)
-
-  virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
-                                    nsIWidget::DoCommandCallback aCallback,
-                                    void *aCallbackData) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsINativeKeyBindings, NS_INATIVEKEYBINDINGS_IID)
-
-#endif