1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_ShortcutKeys_h
6 #define mozilla_ShortcutKeys_h
8 #include "nsIObserver.h"
13 class KeyEventHandler
;
14 class WidgetKeyboardEvent
;
16 struct ShortcutKeyData
{
17 const char16_t
* event
;
18 const char16_t
* keycode
;
20 const char16_t
* modifiers
;
21 const char16_t
* command
;
24 enum class HandlerType
{
31 class ShortcutKeys
: public nsIObserver
{
36 // Returns a pointer to the first handler for the given type.
37 static KeyEventHandler
* GetHandlers(HandlerType aType
);
39 // Gets the event type for a widget keyboard event.
40 static nsAtom
* ConvertEventToDOMEventType(
41 const WidgetKeyboardEvent
* aWidgetKeyboardEvent
);
43 static void Shutdown();
47 virtual ~ShortcutKeys();
49 // Returns a pointer to the first handler for the given type.
50 KeyEventHandler
* EnsureHandlers(HandlerType aType
);
52 // Maintains a strong reference to the only instance.
53 static StaticRefPtr
<ShortcutKeys
> sInstance
;
55 // Shortcut keys for different elements.
56 static ShortcutKeyData sBrowserHandlers
[];
57 static ShortcutKeyData sEditorHandlers
[];
58 static ShortcutKeyData sInputHandlers
[];
59 static ShortcutKeyData sTextAreaHandlers
[];
61 // Cached event handlers generated from the above data.
62 KeyEventHandler
* mBrowserHandlers
;
63 KeyEventHandler
* mEditorHandlers
;
64 KeyEventHandler
* mInputHandlers
;
65 KeyEventHandler
* mTextAreaHandlers
;
68 } // namespace mozilla
70 #endif // #ifndef mozilla_ShortcutKeys_h