1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef NativeKeyBindings_h 7 #define NativeKeyBindings_h 8 9 #include "mozilla/Attributes.h" 10 #include "mozilla/EventForwards.h" 11 #include "nsIWidget.h" 12 13 #include <glib.h> // for guint 14 15 using GtkWidget = struct _GtkWidget; 16 17 namespace mozilla { 18 19 class WritingMode; 20 template <typename T> 21 class Maybe; 22 23 namespace widget { 24 25 class NativeKeyBindings final { 26 typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType; 27 28 public: 29 static NativeKeyBindings* GetInstance(NativeKeyBindingsType aType); 30 static void Shutdown(); 31 32 /** 33 * GetEditCommandsForTests() returns commands performed in native widget 34 * in typical environment. I.e., this does NOT refer customized shortcut 35 * key mappings of the environment. 36 */ 37 static void GetEditCommandsForTests(NativeKeyBindingsType aType, 38 const WidgetKeyboardEvent& aEvent, 39 const Maybe<WritingMode>& aWritingMode, 40 nsTArray<CommandInt>& aCommands); 41 42 void Init(NativeKeyBindingsType aType); 43 44 void GetEditCommands(const WidgetKeyboardEvent& aEvent, 45 const Maybe<WritingMode>& aWritingMode, 46 nsTArray<CommandInt>& aCommands); 47 48 private: 49 ~NativeKeyBindings(); 50 51 bool GetEditCommandsInternal(const WidgetKeyboardEvent& aEvent, 52 nsTArray<CommandInt>& aCommands, guint aKeyval); 53 54 GtkWidget* mNativeTarget; 55 56 static NativeKeyBindings* sInstanceForSingleLineEditor; 57 static NativeKeyBindings* sInstanceForMultiLineEditor; 58 }; 59 60 } // namespace widget 61 } // namespace mozilla 62 63 #endif // NativeKeyBindings_h 64