• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ARK_IMF_ADAPTER_H
17 #define ARK_IMF_ADAPTER_H
18 #pragma once
19 
20 #include "base/include/ark_web_base_ref_counted.h"
21 #include "base/include/ark_web_types.h"
22 
23 namespace OHOS::ArkWeb {
24 
25 /*--ark web(source=webcore)--*/
26 class ArkIMFCursorInfoAdapter : public virtual ArkWebBaseRefCounted {
27 public:
28     /*--ark web()--*/
29     virtual double GetLeft() = 0;
30 
31     /*--ark web()--*/
32     virtual double GetTop() = 0;
33 
34     /*--ark web()--*/
35     virtual double GetWidth() = 0;
36 
37     /*--ark web()--*/
38     virtual double GetHeight() = 0;
39 };
40 
41 /*--ark web(source=webcore)--*/
42 class ArkIMFInputAttributeAdapter : public virtual ArkWebBaseRefCounted {
43 public:
44     /*--ark web()--*/
45     virtual int32_t GetInputPattern() = 0;
46 
47     /*--ark web()--*/
48     virtual int32_t GetEnterKeyType() = 0;
49 };
50 
51 /*--ark web(source=webcore)--*/
52 class ArkIMFSelectionRangeAdapter : public virtual ArkWebBaseRefCounted {
53 public:
54     /*--ark web()--*/
55     virtual int32_t GetStart() = 0;
56 
57     /*--ark web()--*/
58     virtual int32_t GetEnd() = 0;
59 };
60 
61 /*--ark web(source=webcore)--*/
62 class ArkIMFTextConfigAdapter : public virtual ArkWebBaseRefCounted {
63 public:
64     /*--ark web()--*/
65     virtual ArkWebRefPtr<ArkIMFInputAttributeAdapter> GetInputAttribute() = 0;
66 
67     /*--ark web()--*/
68     virtual ArkWebRefPtr<ArkIMFCursorInfoAdapter> GetCursorInfo() = 0;
69 
70     /*--ark web()--*/
71     virtual ArkWebRefPtr<ArkIMFSelectionRangeAdapter> GetSelectionRange() = 0;
72 
73     /*--ark web()--*/
74     virtual uint32_t GetWindowId() = 0;
75 
76     /*--ark web()--*/
77     virtual double GetPositionY() = 0;
78 
79     /*--ark web()--*/
80     virtual double GetHeight() = 0;
81 };
82 
83 /*--ark web(source=webview)--*/
84 class ArkIMFAdapterFunctionKeyAdapter : public virtual ArkWebBaseRefCounted {
85 public:
86     /*--ark web()--*/
87     virtual int32_t GetEnterKeyType() = 0;
88 };
89 
90 /*--ark web(source=webcore)--*/
91 class ArkIMFTextListenerAdapter : public virtual ArkWebBaseRefCounted {
92 public:
93     /*--ark web()--*/
94     virtual void InsertText(const ArkWebU16String& text) = 0;
95 
96     /*--ark web()--*/
97     virtual void DeleteForward(int32_t length) = 0;
98 
99     /*--ark web()--*/
100     virtual void DeleteBackward(int32_t length) = 0;
101 
102     /*--ark web()--*/
103     virtual void SendKeyEventFromInputMethod() = 0;
104 
105     /*--ark web()--*/
106     virtual void SendKeyboardStatus(const int32_t& keyboardStatus) = 0;
107 
108     /*--ark web()--*/
109     virtual void SendFunctionKey(ArkWebRefPtr<ArkIMFAdapterFunctionKeyAdapter> functionKey) = 0;
110 
111     /*--ark web()--*/
112     virtual void SetKeyboardStatus(bool status) = 0;
113 
114     /*--ark web()--*/
115     virtual void MoveCursor(const uint32_t direction) = 0;
116 
117     /*--ark web()--*/
118     virtual void HandleSetSelection(int32_t start, int32_t end) = 0;
119 
120     /*--ark web()--*/
121     virtual void HandleExtendAction(int32_t action) = 0;
122 
123     /*--ark web()--*/
124     virtual void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) = 0;
125 
126     /*--ark web()--*/
127     virtual int32_t GetTextIndexAtCursor() = 0;
128 
129     /*--ark web()--*/
130     virtual ArkWebU16String GetLeftTextOfCursor(int32_t number) = 0;
131 
132     /*--ark web()--*/
133     virtual ArkWebU16String GetRightTextOfCursor(int32_t number) = 0;
134 
135     /*--ark web()--*/
136     virtual int32_t SetPreviewText(const ArkWebU16String& text, int32_t start, int32_t end) = 0;
137 
138     /*--ark web()--*/
139     virtual void FinishTextPreview() = 0;
140 
141     /*--ark web()--*/
142     virtual void SetNeedUnderLine(bool isNeedUnderline) = 0;
143 
144     /*--ark web()--*/
145     virtual void AutoFillWithIMFEvent(bool isUsername, bool isOtherAccount, bool isNewPassword,
146         const ArkWebString& content) = 0;
147 
148     /*--ark web()--*/
149     virtual void KeyboardUpperRightCornerHide() = 0;
150 };
151 
152 /*--ark web(source=webview)--*/
153 class ArkIMFAdapter : public virtual ArkWebBaseRefCounted {
154 public:
155     /*--ark web()--*/
156     virtual bool Attach(ArkWebRefPtr<ArkIMFTextListenerAdapter> listener, bool isShowKeyboard) = 0;
157 
158     /*--ark web()--*/
159     virtual bool Attach(ArkWebRefPtr<ArkIMFTextListenerAdapter> listener, bool isShowKeyboard,
160         ArkWebRefPtr<ArkIMFTextConfigAdapter> config, bool isResetListener) = 0;
161 
162     /*--ark web()--*/
163     virtual bool AttachWithRequestKeyboardReason(ArkWebRefPtr<ArkIMFTextListenerAdapter> listener, bool isShowKeyboard,
164         ArkWebRefPtr<ArkIMFTextConfigAdapter> config, bool isResetListener, int32_t requestKeyboardReason) = 0;
165 
166     /*--ark web()--*/
167     virtual void ShowCurrentInput(const int32_t& inputType) = 0;
168 
169     /*--ark web()--*/
170     virtual void HideTextInput() = 0;
171 
172     /*--ark web()--*/
173     virtual void Close() = 0;
174 
175     /*--ark web()--*/
176     virtual void OnCursorUpdate(ArkWebRefPtr<ArkIMFCursorInfoAdapter> cursorInfo) = 0;
177 
178     /*--ark web()--*/
179     virtual void OnSelectionChange(ArkWebU16String& text, int start, int end) = 0;
180 
181     /*--ark web()--*/
182     virtual bool SendPrivateCommand(const ArkWebString& commandKey, const ArkWebString& commandValue) = 0;
183 };
184 
185 } // namespace OHOS::ArkWeb
186 
187 #endif // ARK_IMF_ADAPTER_H
188