Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / events / ShortcutKeys.h
blob51d844bd079eac4dd8845b4a3f210a8da2a2723d
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"
10 class nsAtom;
12 namespace mozilla {
13 class KeyEventHandler;
14 class WidgetKeyboardEvent;
16 struct ShortcutKeyData {
17 const char16_t* event;
18 const char16_t* keycode;
19 const char16_t* key;
20 const char16_t* modifiers;
21 const char16_t* command;
24 enum class HandlerType {
25 eInput,
26 eTextArea,
27 eBrowser,
28 eEditor,
31 class ShortcutKeys : public nsIObserver {
32 public:
33 NS_DECL_ISUPPORTS
34 NS_DECL_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();
45 protected:
46 ShortcutKeys();
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