diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /widget/uikit/TextInputHandler.h | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/uikit/TextInputHandler.h')
-rw-r--r-- | widget/uikit/TextInputHandler.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/widget/uikit/TextInputHandler.h b/widget/uikit/TextInputHandler.h new file mode 100644 index 0000000000..1f27bf11f0 --- /dev/null +++ b/widget/uikit/TextInputHandler.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 sw=2 et tw=80: */ +/* 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 TextInputHandler_h_ +#define TextInputHandler_h_ + +#import <UIKit/UITextInput.h> + +#include "mozilla/EventForwards.h" +#include "mozilla/TextEventDispatcherListener.h" +#include "mozilla/widget/IMEData.h" +#include "nsCOMPtr.h" + +class nsWindow; + +namespace mozilla::widget { +class TextEventDispatcher; + +// This is the temporary input class. When implementing UITextInpt protocol, we +// should share this class with Cocoa's version. +class TextInputHandler final : public TextEventDispatcherListener { + public: + explicit TextInputHandler(nsWindow* aWidget); + TextInputHandler() = delete; + + NS_DECL_ISUPPORTS + + NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher, + const IMENotification& aNotification) override; + NS_IMETHOD_(IMENotificationRequests) GetIMENotificationRequests() override; + NS_IMETHOD_(void) + OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) override; + NS_IMETHOD_(void) + WillDispatchKeyboardEvent(TextEventDispatcher* aTextEventDispatcher, + WidgetKeyboardEvent& aKeyboardEvent, + uint32_t aIndexOfKeypress, void* aData) override; + + // UIKeyInput delegation + bool InsertText(NSString* aText); + bool HandleCommand(Command aCommand); + + void OnDestroyed(); + + private: + virtual ~TextInputHandler() = default; + + bool DispatchKeyDownEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex, + char16_t aCharCode, nsEventStatus& aStatus); + bool DispatchKeyUpEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex, + char16_t aCharCode, nsEventStatus& aStatus); + bool DispatchKeyPressEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex, + char16_t aCharCode, nsEventStatus& aStatus); + + bool EmulateKeyboardEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex, + char16_t charCode); + + bool Destroyed() { return !mWidget; } + + nsWindow* mWidget; // weak ref + RefPtr<TextEventDispatcher> mDispatcher; +}; + +} // namespace mozilla::widget +#endif |