Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / cocoa / NativeKeyBindings.h
blob6ab885fd9546c8809cc5c04725c041ff2cd74b6b
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/. */
6 #ifndef NativeKeyBindings_h
7 #define NativeKeyBindings_h
9 #include "mozilla/Attributes.h"
10 #include "mozilla/EventForwards.h"
11 #include "nsTHashMap.h"
12 #include "nsIWidget.h"
14 struct objc_selector;
16 namespace mozilla {
17 enum class NativeKeyBindingsType : uint8_t;
19 class WritingMode;
20 template <typename T>
21 class Maybe;
23 namespace widget {
25 typedef nsTHashMap<nsPtrHashKey<objc_selector>, Command>
26 SelectorCommandHashtable;
28 class NativeKeyBindings final {
29 public:
30 static NativeKeyBindings* GetInstance(NativeKeyBindingsType aType);
31 static void Shutdown();
33 /**
34 * GetEditCommandsForTests() returns commands performed in native widget
35 * in typical environment. I.e., this does NOT refer customized shortcut
36 * key mappings of the environment.
38 static void GetEditCommandsForTests(NativeKeyBindingsType aType,
39 const WidgetKeyboardEvent& aEvent,
40 const Maybe<WritingMode>& aWritingMode,
41 nsTArray<CommandInt>& aCommands);
43 void Init(NativeKeyBindingsType aType);
45 void GetEditCommands(const WidgetKeyboardEvent& aEvent,
46 const Maybe<WritingMode>& aWritingMode,
47 nsTArray<CommandInt>& aCommands);
49 private:
50 NativeKeyBindings();
52 void AppendEditCommandsForSelector(objc_selector* aSelector,
53 nsTArray<CommandInt>& aCommands) const;
55 void LogEditCommands(const nsTArray<CommandInt>& aCommands,
56 const char* aDescription) const;
58 SelectorCommandHashtable mSelectorToCommand;
60 static NativeKeyBindings* sInstanceForSingleLineEditor;
61 static NativeKeyBindings* sInstanceForMultiLineEditor;
62 }; // NativeKeyBindings
64 } // namespace widget
65 } // namespace mozilla
67 #endif // NativeKeyBindings_h