• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# arkweb_type.h
2
3## Overview
4
5Defines the native common types of ArkWeb.
6
7**Library**: libohweb.so
8
9**System capability**: SystemCapability.Web.Webview.Core
10
11**Since**: 12
12
13**Related module**: [Web](capi-web.md)
14
15## Summary
16
17### Structs
18
19| Name| typedef Keyword| Description|
20| -- | -- | -- |
21| [ArkWeb_JavaScriptBridgeData](capi-web-arkweb-javascriptbridgedata.md) | ArkWeb_JavaScriptBridgeData | Defines the JavaScript Bridge data.|
22| [ArkWeb_WebMessage*](capi-web-arkweb-webmessage8h.md) | ArkWeb_WebMessagePtr | Defines a pointer to the post message.|
23| [ArkWeb_JavaScriptValue*](capi-web-arkweb-javascriptvalue8h.md) | ArkWeb_JavaScriptValuePtr | Defines a pointer to the JavaScript data.|
24| [ArkWeb_WebMessagePort*](capi-web-arkweb-webmessageport8h.md) | ArkWeb_WebMessagePortPtr | Defines a pointer to the message port.|
25| [ArkWeb_JavaScriptObject](capi-web-arkweb-javascriptobject.md) | ArkWeb_JavaScriptObject | Defines a JavaScript object to be registered.|
26| [ArkWeb_ProxyMethod](capi-web-arkweb-proxymethod.md) | ArkWeb_ProxyMethod | Defines a proxy method to be registered.|
27| [ArkWeb_ProxyMethodWithResult](capi-web-arkweb-proxymethodwithresult.md) | ArkWeb_ProxyMethodWithResult | Defines a proxy method with result to be registered.|
28| [ArkWeb_ProxyObject](capi-web-arkweb-proxyobject.md) | ArkWeb_ProxyObject | Defines a proxy object to be registered.|
29| [ArkWeb_ProxyObjectWithResult](capi-web-arkweb-proxyobjectwithresult.md) | ArkWeb_ProxyObjectWithResult | Defines a proxy object with result to be registered.|
30| [ArkWeb_ControllerAPI](capi-web-arkweb-controllerapi.md) | ArkWeb_ControllerAPI | Defines a native controller API. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.|
31| [ArkWeb_ComponentAPI](capi-web-arkweb-componentapi.md) | ArkWeb_ComponentAPI | Defines a native component API.|
32| [ArkWeb_WebMessagePortAPI](capi-web-arkweb-webmessageportapi.md) | ArkWeb_WebMessagePortAPI | Defines a native message port API. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.|
33| [ArkWeb_WebMessageAPI](capi-web-arkweb-webmessageapi.md) | ArkWeb_WebMessageAPI | Defines a native post message API. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.|
34| [ArkWeb_CookieManagerAPI](capi-web-arkweb-cookiemanagerapi.md) | ArkWeb_CookieManagerAPI | Defines a native cookie manager API provided by ArkWeb. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.|
35| [ArkWeb_JavaScriptValueAPI](capi-web-arkweb-javascriptvalueapi.md) | ArkWeb_JavaScriptValueAPI | Defines a native ArkWeb **JavaScriptValue** API. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.|
36
37### Enums
38
39| Name| typedef Keyword| Description|
40| -- | -- | -- |
41| [ArkWeb_WebMessageType](#arkweb_webmessagetype) | ArkWeb_WebMessageType | Enumerates the data types of post message.|
42| [ArkWeb_JavaScriptValueType](#arkweb_javascriptvaluetype) | ArkWeb_JavaScriptValueType | Enumerates the JavaScript data types.|
43
44### Functions
45
46| Name                                                                                                                                                                                                                               | typedef Keyword                                | Description|
47|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------| -- |
48| [typedef void (\*ArkWeb_OnJavaScriptCallback)(const char* webTag, const ArkWeb_JavaScriptBridgeData* data, void* userData)](#arkweb_onjavascriptcallback)                                                                         | ArkWeb_OnJavaScriptCallback                | Called when the registered JavaScript is executed.|
49| [typedef void (\*ArkWeb_OnJavaScriptProxyCallback)(const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData)](#arkweb_onjavascriptproxycallback)                                        | ArkWeb_OnJavaScriptProxyCallback           | Called when the proxy method is executed.|
50| [typedef ArkWeb_JavaScriptValuePtr (\*ArkWeb_OnJavaScriptProxyCallbackWithResult)(const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData)](#arkweb_onjavascriptproxycallbackwithresult) | ArkWeb_OnJavaScriptProxyCallbackWithResult | Called when the proxy method is executed.|
51| [typedef void (\*ArkWeb_OnComponentCallback)(const char* webTag, void* userData)](#arkweb_oncomponentcallback)                                                                                                                    | ArkWeb_OnComponentCallback                 | Called when a component event notification is sent.|
52| [typedef void (\*ArkWeb_OnScrollCallback)(const char* webTag, void* userData, double x, double y)](#arkweb_onscrollcallback)                                                                                                      | ArkWeb_OnScrollCallback                    | Called when the **Web** component is scrolled.|
53| [typedef void (\*ArkWeb_OnMessageEventHandler)(const char* webTag, const ArkWeb_WebMessagePortPtr port, const ArkWeb_WebMessagePtr message, void* userData)](#arkweb_onmessageeventhandler)                                       | ArkWeb_OnMessageEventHandler               | Called when a post message is sent from the HTML page.|
54
55### Macros
56
57| Name| Description|
58| ---- | ---- |
59| ARKWEB_MEMBER_EXISTS(s, f)&nbsp;&nbsp;&nbsp;&nbsp;((intptr_t) &amp; ((s)-&gt;f) - (intptr_t)(s) + sizeof((s)-&gt;f) &lt;= \*reinterpret_cast&lt;size_t\*&gt;(s)) | Whether a member variable exists in the struct.<br>**Since**: 12|
60| ARKWEB_MEMBER_MISSING(s, f)&nbsp;&nbsp;&nbsp;(\!ARKWEB_MEMBER_EXISTS(s, f) \|\| !((s)-&gt;f)) | If the member variable exists in the struct, **false** is returned. Otherwise, **true** is returned.<br>**Since**: 12|
61
62## Enum Description
63
64### ArkWeb_WebMessageType
65
66```
67enum ArkWeb_WebMessageType
68```
69
70**Description**
71
72Enumerates the data types of post message.
73
74**Since**: 12
75
76| Enumerated Value| Description|
77| -- | -- |
78| ARKWEB_NONE = 0 | Error data.|
79| ARKWEB_STRING | String data.|
80| ARKWEB_BUFFER | Byte stream data.|
81
82### ArkWeb_JavaScriptValueType
83
84```
85enum ArkWeb_JavaScriptValueType
86```
87
88**Description**
89
90Enumerates the JavaScript data types.
91
92**Since**: 18
93
94| Enumerated Value| Description|
95| -- | -- |
96| ARKWEB_JAVASCRIPT_NONE = 0 | Error data.|
97| ARKWEB_JAVASCRIPT_STRING | String data.|
98| ARKWEB_JAVASCRIPT_BOOL | Boolean data.|
99
100
101## Function Description
102
103### ArkWeb_OnJavaScriptCallback()
104
105```
106typedef void (*ArkWeb_OnJavaScriptCallback)(const char* webTag, const ArkWeb_JavaScriptBridgeData* data, void* userData)
107```
108
109**Description**
110
111Called when the registered JavaScript is executed.
112
113**Since**: 12
114
115
116**Parameters**
117
118| Name                                        | Description|
119|---------------------------------------------| -- |
120| const char* webTag                          | Name of the **Web** component.|
121| const [ArkWeb_JavaScriptBridgeData](capi-web-arkweb-javascriptbridgedata.md)* data | JavaScriptBridge data.|
122| void* userData                              | Pointer to user-defined data.|
123
124### ArkWeb_OnJavaScriptProxyCallback()
125
126```
127typedef void (*ArkWeb_OnJavaScriptProxyCallback)(const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData)
128```
129
130**Description**
131
132Called when the proxy method is executed.
133
134**Since**: 12
135
136
137**Parameters**
138
139| Name| Description|
140| -- | -- |
141| const char* webTag | Name of the **Web** component.|
142|  const [ArkWeb_JavaScriptBridgeData](capi-web-arkweb-javascriptbridgedata.md)* dataArray | Pointer to data array.|
143|  size_t arraySize | Array size.|
144|  void* userData | Pointer to user-defined data.|
145
146### ArkWeb_OnJavaScriptProxyCallbackWithResult()
147
148```
149typedef ArkWeb_JavaScriptValuePtr (*ArkWeb_OnJavaScriptProxyCallbackWithResult)(const char* webTag, const ArkWeb_JavaScriptBridgeData* dataArray, size_t arraySize, void* userData)
150```
151
152**Description**
153
154Called when the proxy method is executed.
155
156**Since**: 18
157
158
159**Parameters**
160
161| Name| Description|
162| -- | -- |
163| const char* webTag | Name of the **Web** component.|
164|  const [ArkWeb_JavaScriptBridgeData](capi-web-arkweb-javascriptbridgedata.md)* dataArray | Pointer to data array.|
165|  size_t arraySize | Array size.|
166|  void* userData | Pointer to user-defined data.|
167
168### ArkWeb_OnComponentCallback()
169
170```
171typedef void (*ArkWeb_OnComponentCallback)(const char* webTag, void* userData)
172```
173
174**Description**
175
176Called when a component event notification is sent.
177
178**Since**: 12
179
180
181**Parameters**
182
183| Name| Description|
184| -- | -- |
185| const char* webTag | Name of the **Web** component.|
186|  void* userData | Pointer to user-defined data.|
187
188### ArkWeb_OnScrollCallback()
189
190```
191typedef void (*ArkWeb_OnScrollCallback)(const char* webTag, void* userData, double x, double y)
192```
193
194**Description**
195
196Called when the **Web** component is scrolled.
197
198**Since**: 18
199
200
201**Parameters**
202
203| Name| Description|
204| -- | -- |
205| const char* webTag | Name of the **Web** component.|
206|  void* userData | Pointer to user-defined data.|
207|  double x | Scrolling offset of the X axis.|
208|  double y | Scrolling offset of the Y axis.|
209
210### ArkWeb_OnMessageEventHandler()
211
212```
213typedef void (*ArkWeb_OnMessageEventHandler)(const char* webTag, const ArkWeb_WebMessagePortPtr port, const ArkWeb_WebMessagePtr message, void* userData)
214```
215
216**Description**
217
218Called when a post message is sent from the HTML page.
219
220**Since**: 12
221
222**Parameters**
223
224| Name                                                                   | Description|
225|------------------------------------------------------------------------| -- |
226| const char* webTag                                                     | Name of the **Web** component.|
227| const [ArkWeb_WebMessagePortPtr](capi-web-arkweb-webmessageport8h.md) port | Post message port.|
228| const [ArkWeb_WebMessagePtr](capi-web-arkweb-webmessage8h.md) message                                 | Post message data.|
229| void* userData                                                         | Pointer to user-defined data.|
230