Line data Source code
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/. */
4 :
5 : #ifndef mozilla_textinputdispatcherlistener_h_
6 : #define mozilla_textinputdispatcherlistener_h_
7 :
8 : #include "nsWeakReference.h"
9 :
10 : namespace mozilla {
11 : namespace widget {
12 :
13 : class TextEventDispatcher;
14 : struct IMENotification;
15 : struct IMENotificationRequests;
16 :
17 : #define NS_TEXT_INPUT_PROXY_LISTENER_IID \
18 : { 0xf2226f55, 0x6ddb, 0x40d5, \
19 : { 0x8a, 0x24, 0xce, 0x4d, 0x5b, 0x38, 0x15, 0xf0 } };
20 :
21 3 : class TextEventDispatcherListener : public nsSupportsWeakReference
22 : {
23 : public:
24 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_TEXT_INPUT_PROXY_LISTENER_IID)
25 :
26 : /**
27 : * NotifyIME() is called by TextEventDispatcher::NotifyIME(). This is a
28 : * notification or request to IME. See document of nsIWidget::NotifyIME()
29 : * for the detail.
30 : */
31 : NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher,
32 : const IMENotification& aNotification) = 0;
33 :
34 : /**
35 : * Returns preference for which IME notification are received by NotifyIME().
36 : */
37 : NS_IMETHOD_(IMENotificationRequests) GetIMENotificationRequests() = 0;
38 :
39 : /**
40 : * OnRemovedFrom() is called when the TextEventDispatcher stops working and
41 : * is releasing the listener.
42 : */
43 : NS_IMETHOD_(void) OnRemovedFrom(
44 : TextEventDispatcher* aTextEventDispatcher) = 0;
45 :
46 : /**
47 : * WillDispatchKeyboardEvent() may be called immediately before
48 : * TextEventDispatcher dispatching a keyboard event. This is called only
49 : * during calling TextEventDispatcher::DispatchKeyboardEvent() or
50 : * TextEventDispatcher::MaybeDispatchKeypressEvents(). But this may not
51 : * be called if TextEventDispatcher thinks that the keyboard event doesn't
52 : * need alternative char codes.
53 : *
54 : * This method can overwrite any members of aKeyboardEvent which is already
55 : * initialized by TextEventDispatcher. If it's necessary, this method should
56 : * overwrite the charCode when Control key is pressed. TextEventDispatcher
57 : * computes charCode from mKeyValue. However, when Control key is pressed,
58 : * charCode should be an ASCII char. In such case, this method needs to
59 : * overwrite it properly.
60 : *
61 : * @param aTextEventDispatcher Pointer to the caller.
62 : * @param aKeyboardEvent The event trying to dispatch.
63 : * This is already initialized, but if it's
64 : * necessary, this method should overwrite the
65 : * members and set alternative char codes.
66 : * @param aIndexOfKeypress When aKeyboardEvent is eKeyPress event,
67 : * it may be a sequence of keypress events
68 : * if the key causes multiple characters.
69 : * In such case, this indicates the index from
70 : * first keypress event.
71 : * If aKeyboardEvent is the first eKeyPress or
72 : * other events, this value is 0.
73 : * @param aData The pointer which was specified at calling
74 : * the method of TextEventDispatcher.
75 : * For example, if you do:
76 : * |TextEventDispatcher->DispatchKeyboardEvent(
77 : * eKeyDown, event, status, this);|
78 : * Then, aData of this method becomes |this|.
79 : * Finally, you can use it like:
80 : * |static_cast<NativeEventHandler*>(aData)|
81 : */
82 : NS_IMETHOD_(void) WillDispatchKeyboardEvent(
83 : TextEventDispatcher* aTextEventDispatcher,
84 : WidgetKeyboardEvent& aKeyboardEvent,
85 : uint32_t aIndexOfKeypress,
86 : void* aData) = 0;
87 : };
88 :
89 : NS_DEFINE_STATIC_IID_ACCESSOR(TextEventDispatcherListener,
90 : NS_TEXT_INPUT_PROXY_LISTENER_IID)
91 :
92 : } // namespace widget
93 : } // namespace mozilla
94 :
95 : #endif // #ifndef mozilla_textinputdispatcherlistener_h_
|