gecko-dev/dom/events/ShortcutKeys.h
Dave Townsend df895249c6 Bug 1550058: Move most keyboard shortcut handling out of XBL. r=masayuki
Most of our keyboard shortcut handling is handled by nsXBLWindowKeyHandler along
with nsXBLPrototypeHandler. With the impending removal of XBL this needs to
change.

This patch moves nsXBLWindowKeyHandler to dom/events/GlobalKeyListener and copies
nsXBLPrototypeHandler to dom/events/KeyEventHandler. Windows, text elements and
XUL <keyset> are changed to use the new copies and anything unnecessary for
those is stripped out.

XBL handler elements still remain using the existing nsXBLPrototypeHandler path.
Some of the code is ripped out there to make it compile. There is probably a
lot more that can be removed but since the whole of XBL is likely gone soon I'm
not sure it is worth cleaning that up much.

Differential Revision: https://phabricator.services.mozilla.com/D42336

--HG--
rename : dom/xbl/nsXBLWindowKeyHandler.cpp => dom/events/GlobalKeyListener.cpp
rename : dom/xbl/nsXBLWindowKeyHandler.h => dom/events/GlobalKeyListener.h
rename : dom/xbl/nsXBLPrototypeHandler.cpp => dom/events/KeyEventHandler.cpp
rename : dom/xbl/nsXBLPrototypeHandler.h => dom/events/KeyEventHandler.h
rename : dom/xbl/builtin/ShortcutKeyDefinitionsForBrowserCommon.h => dom/events/ShortcutKeyDefinitionsForBrowserCommon.h
rename : dom/xbl/builtin/ShortcutKeyDefinitionsForEditorCommon.h => dom/events/ShortcutKeyDefinitionsForEditorCommon.h
rename : dom/xbl/builtin/ShortcutKeyDefinitionsForInputCommon.h => dom/events/ShortcutKeyDefinitionsForInputCommon.h
rename : dom/xbl/builtin/ShortcutKeyDefinitionsForInputCommon.h => dom/events/ShortcutKeyDefinitionsForTextAreaCommon.h
rename : dom/xbl/builtin/ShortcutKeys.cpp => dom/events/ShortcutKeys.cpp
rename : dom/xbl/builtin/ShortcutKeys.h => dom/events/ShortcutKeys.h
rename : dom/xbl/builtin/android/ShortcutKeyDefinitions.cpp => dom/events/android/ShortcutKeyDefinitions.cpp
rename : dom/xbl/builtin/android/moz.build => dom/events/android/moz.build
rename : dom/xbl/builtin/emacs/ShortcutKeyDefinitions.cpp => dom/events/emacs/ShortcutKeyDefinitions.cpp
rename : dom/xbl/builtin/android/moz.build => dom/events/emacs/moz.build
rename : dom/xbl/builtin/mac/ShortcutKeyDefinitions.cpp => dom/events/mac/ShortcutKeyDefinitions.cpp
rename : dom/xbl/builtin/android/moz.build => dom/events/mac/moz.build
rename : dom/xbl/builtin/unix/ShortcutKeyDefinitions.cpp => dom/events/unix/ShortcutKeyDefinitions.cpp
rename : dom/xbl/builtin/android/moz.build => dom/events/unix/moz.build
rename : dom/xbl/builtin/win/ShortcutKeyDefinitions.cpp => dom/events/win/ShortcutKeyDefinitions.cpp
rename : dom/xbl/builtin/android/moz.build => dom/events/win/moz.build
extra : moz-landing-system : lando
2019-09-06 17:10:40 +00:00

69 lines
1.7 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ShortcutKeys_h
#define mozilla_ShortcutKeys_h
#include "nsIObserver.h"
class nsAtom;
namespace mozilla {
class KeyEventHandler;
class WidgetKeyboardEvent;
typedef struct {
const char16_t* event;
const char16_t* keycode;
const char16_t* key;
const char16_t* modifiers;
const char16_t* command;
} ShortcutKeyData;
enum class HandlerType {
eInput,
eTextArea,
eBrowser,
eEditor,
};
class ShortcutKeys : public nsIObserver {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
// Returns a pointer to the first handler for the given type.
static KeyEventHandler* GetHandlers(HandlerType aType);
// Gets the event type for a widget keyboard event.
static nsAtom* ConvertEventToDOMEventType(
const WidgetKeyboardEvent* aWidgetKeyboardEvent);
protected:
ShortcutKeys();
virtual ~ShortcutKeys();
// Returns a pointer to the first handler for the given type.
KeyEventHandler* EnsureHandlers(HandlerType aType);
// Maintains a strong reference to the only instance.
static StaticRefPtr<ShortcutKeys> sInstance;
// Shortcut keys for different elements.
static ShortcutKeyData sBrowserHandlers[];
static ShortcutKeyData sEditorHandlers[];
static ShortcutKeyData sInputHandlers[];
static ShortcutKeyData sTextAreaHandlers[];
// Cached event handlers generated from the above data.
KeyEventHandler* mBrowserHandlers;
KeyEventHandler* mEditorHandlers;
KeyEventHandler* mInputHandlers;
KeyEventHandler* mTextAreaHandlers;
};
} // namespace mozilla
#endif // #ifndef mozilla_ShortcutKeys_h