Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / uikit / TextInputHandler.h
blob1f27bf11f0ca99917d4d81073b9d3afedbac34aa
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef TextInputHandler_h_
8 #define TextInputHandler_h_
10 #import <UIKit/UITextInput.h>
12 #include "mozilla/EventForwards.h"
13 #include "mozilla/TextEventDispatcherListener.h"
14 #include "mozilla/widget/IMEData.h"
15 #include "nsCOMPtr.h"
17 class nsWindow;
19 namespace mozilla::widget {
20 class TextEventDispatcher;
22 // This is the temporary input class. When implementing UITextInpt protocol, we
23 // should share this class with Cocoa's version.
24 class TextInputHandler final : public TextEventDispatcherListener {
25 public:
26 explicit TextInputHandler(nsWindow* aWidget);
27 TextInputHandler() = delete;
29 NS_DECL_ISUPPORTS
31 NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher,
32 const IMENotification& aNotification) override;
33 NS_IMETHOD_(IMENotificationRequests) GetIMENotificationRequests() override;
34 NS_IMETHOD_(void)
35 OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) override;
36 NS_IMETHOD_(void)
37 WillDispatchKeyboardEvent(TextEventDispatcher* aTextEventDispatcher,
38 WidgetKeyboardEvent& aKeyboardEvent,
39 uint32_t aIndexOfKeypress, void* aData) override;
41 // UIKeyInput delegation
42 bool InsertText(NSString* aText);
43 bool HandleCommand(Command aCommand);
45 void OnDestroyed();
47 private:
48 virtual ~TextInputHandler() = default;
50 bool DispatchKeyDownEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex,
51 char16_t aCharCode, nsEventStatus& aStatus);
52 bool DispatchKeyUpEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex,
53 char16_t aCharCode, nsEventStatus& aStatus);
54 bool DispatchKeyPressEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex,
55 char16_t aCharCode, nsEventStatus& aStatus);
57 bool EmulateKeyboardEvent(uint32_t aKeyCode, KeyNameIndex aKeyNameIndex,
58 char16_t charCode);
60 bool Destroyed() { return !mWidget; }
62 nsWindow* mWidget; // weak ref
63 RefPtr<TextEventDispatcher> mDispatcher;
66 } // namespace mozilla::widget
67 #endif