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"
17 enum class NativeKeyBindingsType
: uint8_t;
25 typedef nsTHashMap
<nsPtrHashKey
<objc_selector
>, Command
>
26 SelectorCommandHashtable
;
28 class NativeKeyBindings final
{
30 static NativeKeyBindings
* GetInstance(NativeKeyBindingsType aType
);
31 static void Shutdown();
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
);
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
65 } // namespace mozilla
67 #endif // NativeKeyBindings_h