gecko-dev/widget/headless/HeadlessKeyBindings.h
Masayuki Nakano a25988774a Bug 1685491 - part 5: Move the code remapping arrow keys in vertical content to NativeKeyBindings r=smaug,jfkthame
Currently, this feature is implemented only on Linux and macOS (see also
bug 1077515 and bug 1301497), and the code is really similar each other.
Additionally, it always tries to query selection to check whether the caret is
in vertical content or not if arrow keys are pressed.  For avoiding a lot of
query, this patch makes `TextEventDispatcher` cache writing mode at every
selection change notification.  However, unfortunately, it's not available when
non-editable content has focus, but it should be out of scope of this bug since
it requires a lot of changes.

Anyway, with this patch, we can write a mochitest only on Linux and macOS.
The following patch adds a test for this as a fix of bug 1103374.

Differential Revision: https://phabricator.services.mozilla.com/D102881
2021-02-02 03:29:31 +00:00

41 lines
1.1 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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_widget_HeadlessKeyBindings_h
#define mozilla_widget_HeadlessKeyBindings_h
#include "mozilla/TextEvents.h"
#include "nsIWidget.h"
#include "nsTArray.h"
namespace mozilla {
class WritingMode;
template <typename T>
class Maybe;
namespace widget {
/**
* Helper to emulate native key bindings. Currently only MacOS is supported.
*/
class HeadlessKeyBindings final {
public:
HeadlessKeyBindings() = default;
static HeadlessKeyBindings& GetInstance();
void GetEditCommands(nsIWidget::NativeKeyBindingsType aType,
const WidgetKeyboardEvent& aEvent,
const Maybe<WritingMode>& aWritingMode,
nsTArray<CommandInt>& aCommands);
[[nodiscard]] nsresult AttachNativeKeyEvent(WidgetKeyboardEvent& aEvent);
};
} // namespace widget
} // namespace mozilla
#endif // mozilla_widget_HeadlessKeyBindings_h