• 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 #include "core/interfaces/native/node/node_api.h"
17 
18 #include <securec.h>
19 #include <vector>
20 
21 #include "core/components_ng/base/observer_handler.h"
22 #include "core/components_ng/base/view_stack_model.h"
23 #include "core/components_ng/pattern/navigation/navigation_stack.h"
24 #include "core/components_ng/pattern/text/span/span_string.h"
25 #include "core/interfaces/native/node/alphabet_indexer_modifier.h"
26 #include "core/interfaces/native/node/calendar_picker_modifier.h"
27 #include "core/interfaces/native/node/canvas_rendering_context_2d_modifier.h"
28 #include "core/interfaces/native/node/custom_dialog_model.h"
29 #include "core/interfaces/native/node/drag_adapter_impl.h"
30 #include "core/interfaces/native/node/grid_modifier.h"
31 #include "core/interfaces/native/node/image_animator_modifier.h"
32 #include "core/interfaces/native/node/node_adapter_impl.h"
33 #include "core/interfaces/native/node/node_animate.h"
34 #include "core/interfaces/native/node/node_api_multi_thread.h"
35 #include "core/interfaces/native/node/node_canvas_modifier.h"
36 #include "core/interfaces/native/node/node_checkbox_modifier.h"
37 #include "core/interfaces/native/node/node_common_modifier.h"
38 #include "core/interfaces/native/node/node_custom_node_ext_modifier.h"
39 #include "core/interfaces/native/node/node_drag_modifier.h"
40 #include "core/interfaces/native/node/node_date_picker_modifier.h"
41 #include "core/interfaces/native/node/node_image_modifier.h"
42 #include "core/interfaces/native/node/node_image_span_modifier.h"
43 #include "core/interfaces/native/node/node_list_item_modifier.h"
44 #include "core/interfaces/native/node/node_list_modifier.h"
45 #include "core/interfaces/native/node/node_refresh_modifier.h"
46 #include "core/interfaces/native/node/node_scroll_modifier.h"
47 #include "core/interfaces/native/node/node_slider_modifier.h"
48 #include "core/interfaces/native/node/node_swiper_modifier.h"
49 #include "core/interfaces/native/node/node_span_modifier.h"
50 #include "core/interfaces/native/node/node_text_area_modifier.h"
51 #include "core/interfaces/native/node/node_text_input_modifier.h"
52 #include "core/interfaces/native/node/node_text_modifier.h"
53 #include "core/interfaces/native/node/node_textpicker_modifier.h"
54 #include "core/interfaces/native/node/node_timepicker_modifier.h"
55 #include "core/interfaces/native/node/node_toggle_modifier.h"
56 #include "core/interfaces/native/node/radio_modifier.h"
57 #include "core/interfaces/native/node/search_modifier.h"
58 #include "core/interfaces/native/node/select_modifier.h"
59 #include "core/interfaces/native/node/util_modifier.h"
60 #include "core/interfaces/native/node/view_model.h"
61 #include "core/interfaces/native/node/water_flow_modifier.h"
62 #include "core/interfaces/native/runtime/runtime_init.h"
63 #include "core/pipeline_ng/pipeline_context.h"
64 #include "core/text/html_utils.h"
65 #include "interfaces/native/native_type.h"
66 #include "core/interfaces/native/node/checkboxgroup_modifier.h"
67 #include "frameworks/bridge/common/utils/engine_helper.h"
68 
69 namespace OHOS::Ace::NG {
70 namespace {
71 constexpr int32_t INVLID_VALUE = -1;
72 
WriteStringToBuffer(const std::string & src,char * buffer,int32_t bufferSize,int32_t * writeLen)73 int32_t WriteStringToBuffer(const std::string& src, char* buffer, int32_t bufferSize, int32_t* writeLen)
74 {
75     CHECK_NULL_RETURN(buffer, ERROR_CODE_PARAM_INVALID);
76     CHECK_NULL_RETURN(writeLen, ERROR_CODE_PARAM_INVALID);
77     if (src.empty()) {
78         return ERROR_CODE_NO_ERROR;
79     }
80     int32_t srcLength = static_cast<int32_t>(src.length());
81     if (bufferSize - 1 < srcLength) {
82         *writeLen = srcLength == INT32_MAX ? INT32_MAX : srcLength + 1;
83         return ERROR_CODE_NATIVE_IMPL_BUFFER_SIZE_ERROR;
84     }
85     src.copy(buffer, srcLength);
86     buffer[srcLength] = '\0';
87     *writeLen = srcLength;
88     return ERROR_CODE_NO_ERROR;
89 }
90 
GetNavDestinationInfoByNode(ArkUINodeHandle node)91 std::shared_ptr<NavDestinationInfo> GetNavDestinationInfoByNode(ArkUINodeHandle node)
92 {
93     FrameNode* currentNode = reinterpret_cast<FrameNode*>(node);
94     CHECK_NULL_RETURN(currentNode, nullptr);
95     return NG::UIObserverHandler::GetInstance().GetNavigationState(Ace::AceType::Claim<FrameNode>(currentNode));
96 }
97 
GetRouterPageInfoByNode(ArkUINodeHandle node)98 std::shared_ptr<RouterPageInfoNG> GetRouterPageInfoByNode(ArkUINodeHandle node)
99 {
100     FrameNode* currentNode = reinterpret_cast<FrameNode*>(node);
101     CHECK_NULL_RETURN(currentNode, nullptr);
102     return NG::UIObserverHandler::GetInstance().GetRouterPageState(Ace::AceType::Claim<FrameNode>(currentNode));
103 }
104 
GetNavigationStackByNode(ArkUINodeHandle node)105 RefPtr<NavigationStack> GetNavigationStackByNode(ArkUINodeHandle node)
106 {
107     FrameNode* currentNode = reinterpret_cast<FrameNode*>(node);
108     CHECK_NULL_RETURN(currentNode, nullptr);
109     auto pipeline = currentNode->GetContext();
110     CHECK_NULL_RETURN(pipeline, nullptr);
111     auto navigationMgr = pipeline->GetNavigationManager();
112     CHECK_NULL_RETURN(navigationMgr, nullptr);
113     auto result = navigationMgr->GetNavigationInfo(Ace::AceType::Claim<FrameNode>(currentNode));
114     CHECK_NULL_RETURN(result, nullptr);
115     return result->pathStack.Upgrade();
116 }
117 
SetDebugBoundary(ArkUINodeHandle node)118 void SetDebugBoundary(ArkUINodeHandle node)
119 {
120     UINode* uiNode = reinterpret_cast<UINode*>(node);
121     CHECK_NULL_VOID(uiNode);
122     RefPtr<UINode> refNode = Ace::AceType::Claim<UINode>(uiNode);
123     CHECK_NULL_VOID(refNode);
124     auto frameNode = Ace::AceType::DynamicCast<FrameNode>(refNode);
125     if (frameNode) {
126         auto renderContext = frameNode->GetRenderContext();
127         if (renderContext) {
128             renderContext->SetNeedDebugBoundary(true);
129         }
130     }
131 }
132 } // namespace
133 
GetUIState(ArkUINodeHandle node)134 ArkUI_Int64 GetUIState(ArkUINodeHandle node)
135 {
136     auto* frameNode = reinterpret_cast<FrameNode*>(node);
137     CHECK_NULL_RETURN(frameNode, 0);
138     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
139     CHECK_NULL_RETURN(eventHub, 0);
140     return eventHub->GetCurrentUIState();
141 }
142 
SetSupportedUIState(ArkUINodeHandle node,ArkUI_Int64 state)143 void SetSupportedUIState(ArkUINodeHandle node, ArkUI_Int64 state)
144 {
145     auto* frameNode = reinterpret_cast<FrameNode*>(node);
146     CHECK_NULL_VOID(frameNode);
147     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
148     CHECK_NULL_VOID(eventHub);
149     eventHub->AddSupportedState(static_cast<uint64_t>(state));
150 }
151 
AddSupportedUIState(ArkUINodeHandle node,ArkUI_Int64 state,void * callback,ArkUI_Bool isExcludeInner)152 void AddSupportedUIState(ArkUINodeHandle node, ArkUI_Int64 state, void* callback, ArkUI_Bool isExcludeInner)
153 {
154     auto* frameNode = reinterpret_cast<FrameNode*>(node);
155     CHECK_NULL_VOID(frameNode);
156     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
157     CHECK_NULL_VOID(eventHub);
158     std::function<void(uint64_t)>* func = reinterpret_cast<std::function<void(uint64_t)>*>(callback);
159     eventHub->AddSupportedUIStateWithCallback(static_cast<uint64_t>(state), *func, false, isExcludeInner);
160     func = nullptr;
161 }
162 
RemoveSupportedUIState(ArkUINodeHandle node,ArkUI_Int64 state)163 void RemoveSupportedUIState(ArkUINodeHandle node, ArkUI_Int64 state)
164 {
165     auto* frameNode = reinterpret_cast<FrameNode*>(node);
166     CHECK_NULL_VOID(frameNode);
167     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
168     CHECK_NULL_VOID(eventHub);
169     eventHub->RemoveSupportedUIState(static_cast<uint64_t>(state), false);
170 }
171 
172 namespace NodeModifier {
GetUIStateModifier()173 const ArkUIStateModifier* GetUIStateModifier()
174 {
175     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
176     static const ArkUIStateModifier modifier = {
177         .getUIState = GetUIState,
178         .setSupportedUIState = SetSupportedUIState,
179         .addSupportedUIState = AddSupportedUIState,
180         .removeSupportedUIState = RemoveSupportedUIState
181     };
182     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
183     return &modifier;
184 }
185 
GetCJUIStateModifier()186 const CJUIStateModifier* GetCJUIStateModifier()
187 {
188     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
189     static const CJUIStateModifier modifier = {
190         .getUIState = GetUIState,
191         .setSupportedUIState = SetSupportedUIState,
192     };
193     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
194     return &modifier;
195 }
196 } // namespace NodeModifier
197 
198 namespace NodeEvent {
199 
200 static EventReceiver globalEventReceiver = nullptr;
201 
SendArkUISyncEvent(ArkUINodeEvent * event)202 void SendArkUISyncEvent(ArkUINodeEvent* event)
203 {
204     if (globalEventReceiver) {
205         globalEventReceiver(event);
206     }
207 }
208 } // namespace NodeEvent
209 
210 namespace CustomNodeEvent {
211 
212 void (*g_fliter)(ArkUICustomNodeEvent* event) = nullptr;
SendArkUISyncEvent(ArkUICustomNodeEvent * event)213 void SendArkUISyncEvent(ArkUICustomNodeEvent* event)
214 {
215     if (g_fliter) {
216         g_fliter(event);
217     }
218 }
219 } // namespace CustomNodeEvent
220 
221 namespace {
222 
SetCustomCallback(ArkUIVMContext context,ArkUINodeHandle node,ArkUI_Int32 callback)223 void SetCustomCallback(ArkUIVMContext context, ArkUINodeHandle node, ArkUI_Int32 callback)
224 {
225     ViewModel::SetCustomCallback(context, node, callback);
226 }
227 
CreateNode(ArkUINodeType type,int peerId,ArkUI_Int32 flags)228 ArkUINodeHandle CreateNode(ArkUINodeType type, int peerId, ArkUI_Int32 flags)
229 {
230     ArkUINodeHandle node = nullptr;
231     if (flags == ARKUI_NODE_FLAG_C) {
232         ContainerScope Scope(Container::CurrentIdSafelyWithCheck());
233         node = reinterpret_cast<ArkUINodeHandle>(ViewModel::CreateNode(type, peerId));
234         auto* uiNode = reinterpret_cast<UINode*>(node);
235         if (uiNode) {
236             uiNode->setIsCNode(true);
237         }
238         SetDebugBoundary(node);
239     } else {
240         node = reinterpret_cast<ArkUINodeHandle>(ViewModel::CreateNode(type, peerId));
241     }
242     return node;
243 }
244 
CreateNodeWithParams(ArkUINodeType type,int peerId,ArkUI_Int32 flags,const ArkUI_Params & params)245 ArkUINodeHandle CreateNodeWithParams(ArkUINodeType type, int peerId, ArkUI_Int32 flags, const ArkUI_Params& params)
246 {
247     auto* node = reinterpret_cast<ArkUINodeHandle>(ViewModel::CreateNodeWithParams(type, peerId, params));
248     return node;
249 }
250 
GetNodeByViewStack()251 ArkUINodeHandle GetNodeByViewStack()
252 {
253     auto node = ViewStackProcessor::GetInstance()->Finish();
254     node->IncRefCount();
255     return reinterpret_cast<ArkUINodeHandle>(AceType::RawPtr(node));
256 }
257 
GetTopNodeByViewStack()258 ArkUINodeHandle GetTopNodeByViewStack()
259 {
260     auto node = ViewStackProcessor::GetInstance()->GetMainFrameNode();
261     CHECK_NULL_RETURN(node, nullptr);
262     return reinterpret_cast<ArkUINodeHandle>(node);
263 }
264 
CreateCustomNode(ArkUI_CharPtr tag)265 ArkUINodeHandle CreateCustomNode(ArkUI_CharPtr tag)
266 {
267     return reinterpret_cast<ArkUINodeHandle>(ViewModel::CreateCustomNode(tag));
268 }
269 
GetOrCreateCustomNode(ArkUI_CharPtr tag)270 ArkUINodeHandle GetOrCreateCustomNode(ArkUI_CharPtr tag)
271 {
272     return reinterpret_cast<ArkUINodeHandle>(ViewModel::GetOrCreateCustomNode(tag));
273 }
274 
CreateCustomNodeByNodeId(ArkUI_CharPtr tag,ArkUI_Int32 nodeId)275 ArkUINodeHandle CreateCustomNodeByNodeId(ArkUI_CharPtr tag, ArkUI_Int32 nodeId)
276 {
277     return reinterpret_cast<ArkUINodeHandle>(ViewModel::CreateCustomNodeByNodeId(tag, nodeId));
278 }
279 
IsRightToLeft()280 ArkUI_Bool IsRightToLeft()
281 {
282     return AceApplicationInfo::GetInstance().IsRightToLeft();
283 }
284 
CreateNewScope()285 void CreateNewScope()
286 {
287     ViewStackModel::GetInstance()->NewScope();
288 }
289 
GetRSNodeByNode(ArkUINodeHandle node)290 ArkUIRSNodeHandle GetRSNodeByNode(ArkUINodeHandle node)
291 {
292     auto* frameNode = reinterpret_cast<FrameNode*>(node);
293     CHECK_NULL_RETURN(frameNode, nullptr);
294     auto rsNode = frameNode->GetExtraCustomProperty("RS_NODE");
295     CHECK_NULL_RETURN(rsNode, nullptr);
296     return reinterpret_cast<ArkUIRSNodeHandle>(rsNode);
297 }
298 
RegisterOEMVisualEffect(ArkUIOEMVisualEffectFuncHandle func)299 void RegisterOEMVisualEffect(ArkUIOEMVisualEffectFuncHandle func)
300 {
301     OEMVisualEffectFunc oemFunc = reinterpret_cast<OEMVisualEffectFunc>(func);
302     ViewAbstract::RegisterOEMVisualEffect(oemFunc);
303 }
304 
SetOnNodeDestroyCallback(ArkUINodeHandle node,void (* onDestroy)(ArkUINodeHandle node))305 void SetOnNodeDestroyCallback(ArkUINodeHandle node, void (*onDestroy)(ArkUINodeHandle node))
306 {
307     auto* uiNode = reinterpret_cast<UINode*>(node);
308     CHECK_NULL_VOID(uiNode);
309     auto onDestroyCallback = [node, onDestroy](int32_t nodeId) {
310         onDestroy(node);
311     };
312     uiNode->SetOnNodeDestroyCallback(std::move(onDestroyCallback));
313 }
314 
DisposeNode(ArkUINodeHandle node)315 void DisposeNode(ArkUINodeHandle node)
316 {
317     ViewModel::DisposeNode(node);
318 }
319 
GetName(ArkUINodeHandle node)320 ArkUI_CharPtr GetName(ArkUINodeHandle node)
321 {
322     return ViewModel::GetName(node);
323 }
324 
DumpTree(ArkUINodeHandle node,int indent)325 static void DumpTree(ArkUINodeHandle node, int indent) {}
326 
DumpTreeNode(ArkUINodeHandle node)327 void DumpTreeNode(ArkUINodeHandle node)
328 {
329     DumpTree(node, 0);
330 }
331 
AddChild(ArkUINodeHandle parent,ArkUINodeHandle child)332 ArkUI_Int32 AddChild(ArkUINodeHandle parent, ArkUINodeHandle child)
333 {
334     auto* nodeAdapter = NodeAdapter::GetNodeAdapterAPI()->getNodeAdapter(parent);
335     if (nodeAdapter) {
336         return ERROR_CODE_NATIVE_IMPL_NODE_ADAPTER_EXIST;
337     }
338     ViewModel::AddChild(parent, child);
339     return ERROR_CODE_NO_ERROR;
340 }
341 
InsertChildAt(ArkUINodeHandle parent,ArkUINodeHandle child,int32_t position)342 ArkUI_Int32 InsertChildAt(ArkUINodeHandle parent, ArkUINodeHandle child, int32_t position)
343 {
344     auto* nodeAdapter = NodeAdapter::GetNodeAdapterAPI()->getNodeAdapter(parent);
345     if (nodeAdapter) {
346         return ERROR_CODE_NATIVE_IMPL_NODE_ADAPTER_EXIST;
347     }
348     ViewModel::InsertChildAt(parent, child, position);
349     return ERROR_CODE_NO_ERROR;
350 }
351 
RemoveChild(ArkUINodeHandle parent,ArkUINodeHandle child)352 void RemoveChild(ArkUINodeHandle parent, ArkUINodeHandle child)
353 {
354     ViewModel::RemoveChild(parent, child);
355 }
356 
InsertChildAfter(ArkUINodeHandle parent,ArkUINodeHandle child,ArkUINodeHandle sibling)357 ArkUI_Int32 InsertChildAfter(ArkUINodeHandle parent, ArkUINodeHandle child, ArkUINodeHandle sibling)
358 {
359     auto* nodeAdapter = NodeAdapter::GetNodeAdapterAPI()->getNodeAdapter(parent);
360     if (nodeAdapter) {
361         return ERROR_CODE_NATIVE_IMPL_NODE_ADAPTER_EXIST;
362     }
363     ViewModel::InsertChildAfter(parent, child, sibling);
364     return ERROR_CODE_NO_ERROR;
365 }
366 
IsBuilderNode(ArkUINodeHandle node)367 ArkUI_Bool IsBuilderNode(ArkUINodeHandle node)
368 {
369     return ViewModel::IsBuilderNode(node);
370 }
371 
ConvertLengthMetricsUnit(ArkUI_Float64 value,ArkUI_Int32 originUnit,ArkUI_Int32 targetUnit)372 ArkUI_Float64 ConvertLengthMetricsUnit(ArkUI_Float64 value, ArkUI_Int32 originUnit, ArkUI_Int32 targetUnit)
373 {
374     Dimension lengthMetric(value, static_cast<DimensionUnit>(originUnit));
375     return lengthMetric.GetNativeValue(static_cast<DimensionUnit>(targetUnit));
376 }
377 
InsertChildBefore(ArkUINodeHandle parent,ArkUINodeHandle child,ArkUINodeHandle sibling)378 ArkUI_Int32 InsertChildBefore(ArkUINodeHandle parent, ArkUINodeHandle child, ArkUINodeHandle sibling)
379 {
380     auto* nodeAdapter = NodeAdapter::GetNodeAdapterAPI()->getNodeAdapter(parent);
381     if (nodeAdapter) {
382         return ERROR_CODE_NATIVE_IMPL_NODE_ADAPTER_EXIST;
383     }
384     ViewModel::InsertChildBefore(parent, child, sibling);
385     return ERROR_CODE_NO_ERROR;
386 }
387 
SetAttribute(ArkUINodeHandle node,ArkUI_CharPtr attribute,ArkUI_CharPtr value)388 void SetAttribute(ArkUINodeHandle node, ArkUI_CharPtr attribute, ArkUI_CharPtr value) {}
389 
GetAttribute(ArkUINodeHandle node,ArkUI_CharPtr attribute)390 ArkUI_CharPtr GetAttribute(ArkUINodeHandle node, ArkUI_CharPtr attribute)
391 {
392     return "";
393 }
394 
ResetAttribute(ArkUINodeHandle nodePtr,ArkUI_CharPtr attribute)395 void ResetAttribute(ArkUINodeHandle nodePtr, ArkUI_CharPtr attribute)
396 {
397     TAG_LOGI(AceLogTag::ACE_NATIVE_NODE, "Reset attribute %{public}s", attribute);
398 }
399 
400 typedef void (*ComponentAsyncEventHandler)(ArkUINodeHandle node, void* extraParam);
401 
402 typedef void (*ResetComponentAsyncEventHandler)(ArkUINodeHandle node);
403 
404 /**
405  * IMPORTANT!!!
406  * the order of declaring the handler must be same as the in the ArkUIEventSubKind enum
407  */
408 /* clang-format off */
409 const ComponentAsyncEventHandler commonNodeAsyncEventHandlers[] = {
410     NodeModifier::SetOnAppear,
411     NodeModifier::SetOnDisappear,
412     NodeModifier::SetOnTouch,
413     NodeModifier::SetOnClick,
414     NodeModifier::SetOnHover,
415     NodeModifier::SetOnBlur,
416     NodeModifier::SetOnKeyEvent,
417     NodeModifier::SetOnMouse,
418     NodeModifier::SetOnAreaChange,
419     nullptr,
420     nullptr,
421     NodeModifier::SetOnFocus,
422     NodeModifier::SetOnTouchIntercept,
423     NodeModifier::SetOnAttach,
424     NodeModifier::SetOnDetach,
425     NodeModifier::SetOnAccessibilityActions,
426     NodeModifier::SetOnDragStart,
427     NodeModifier::SetOnDragEnter,
428     NodeModifier::SetOnDragDrop,
429     NodeModifier::SetOnDragMove,
430     NodeModifier::SetOnDragLeave,
431     NodeModifier::SetOnDragEnd,
432     NodeModifier::SetOnPreDrag,
433     NodeModifier::SetOnKeyPreIme,
434     NodeModifier::SetOnFocusAxisEvent,
435     NodeModifier::SetOnKeyEventDispatch,
436     nullptr,
437     NodeModifier::SetOnAxisEvent,
438     NodeModifier::SetOnClick,
439     NodeModifier::SetOnHover,
440     NodeModifier::SetOnHoverMove,
441 };
442 
443 const ComponentAsyncEventHandler scrollNodeAsyncEventHandlers[] = {
444     NodeModifier::SetOnScroll,
445     NodeModifier::SetOnScrollFrameBegin,
446     NodeModifier::SetScrollOnWillScroll,
447     NodeModifier::SetScrollOnDidScroll,
448     NodeModifier::SetOnScrollStart,
449     NodeModifier::SetOnScrollStop,
450     NodeModifier::SetOnScrollEdge,
451     NodeModifier::SetOnScrollReachStart,
452     NodeModifier::SetOnScrollReachEnd,
453     NodeModifier::SetOnWillStopDragging,
454     NodeModifier::SetOnDidZoom,
455     NodeModifier::SetOnZoomStart,
456     NodeModifier::SetOnZoomStop,
457 };
458 
459 const ComponentAsyncEventHandler TEXT_NODE_ASYNC_EVENT_HANDLERS[] = {
460     NodeModifier::SetOnDetectResultUpdate,
461     NodeModifier::SetOnTextSpanLongPress,
462 };
463 
464 const ComponentAsyncEventHandler textInputNodeAsyncEventHandlers[] = {
465     NodeModifier::SetOnTextInputEditChange,
466     NodeModifier::SetTextInputOnSubmit,
467     NodeModifier::SetOnTextInputChange,
468     NodeModifier::SetOnTextInputCut,
469     NodeModifier::SetOnTextInputPaste,
470     NodeModifier::SetOnTextInputSelectionChange,
471     NodeModifier::SetOnTextInputContentSizeChange,
472     NodeModifier::SetOnTextInputInputFilterError,
473     NodeModifier::SetTextInputOnTextContentScroll,
474     NodeModifier::SetTextInputOnWillInsert,
475     NodeModifier::SetTextInputOnDidInsert,
476     NodeModifier::SetTextInputOnWillDelete,
477     NodeModifier::SetTextInputOnDidDelete,
478     NodeModifier::SetOnTextInputChangeWithPreviewText,
479     NodeModifier::SetOnTextInputWillChange,
480 };
481 
482 const ComponentAsyncEventHandler textAreaNodeAsyncEventHandlers[] = {
483     NodeModifier::SetOnTextAreaEditChange,
484     nullptr,
485     NodeModifier::SetOnTextAreaChange,
486     NodeModifier::SetOnTextAreaPaste,
487     NodeModifier::SetOnTextAreaSelectionChange,
488     NodeModifier::SetTextAreaOnSubmit,
489     NodeModifier::SetOnTextAreaContentSizeChange,
490     NodeModifier::SetOnTextAreaInputFilterError,
491     NodeModifier::SetTextAreaOnTextContentScroll,
492     NodeModifier::SetTextAreaOnWillInsertValue,
493     NodeModifier::SetTextAreaOnDidInsertValue,
494     NodeModifier::SetTextAreaOnWillDeleteValue,
495     NodeModifier::SetTextAreaOnDidDeleteValue,
496     NodeModifier::SetOnTextAreaChangeWithPreviewText,
497     NodeModifier::SetOnTextAreaWillChange,
498 };
499 
500 const ComponentAsyncEventHandler refreshNodeAsyncEventHandlers[] = {
501     NodeModifier::SetRefreshOnStateChange,
502     NodeModifier::SetOnRefreshing,
503     NodeModifier::SetRefreshOnOffsetChange,
504     NodeModifier::SetRefreshChangeEvent,
505 };
506 
507 const ComponentAsyncEventHandler TOGGLE_NODE_ASYNC_EVENT_HANDLERS[] = {
508     NodeModifier::SetOnToggleChange,
509 };
510 
511 const ComponentAsyncEventHandler imageNodeAsyncEventHandlers[] = {
512     NodeModifier::SetImageOnComplete,
513     NodeModifier::SetImageOnError,
514     NodeModifier::SetImageOnSvgPlayFinish,
515     NodeModifier::SetImageOnDownloadProgress,
516 };
517 
518 const ComponentAsyncEventHandler IMAGE_SPAN_NODE_ASYNC_EVENT_HANDLERS[] = {
519     NodeModifier::SetImageSpanOnCompleteEvent,
520     NodeModifier::SetImageSpanOnErrorEvent,
521 };
522 
523 const ComponentAsyncEventHandler DATE_PICKER_NODE_ASYNC_EVENT_HANDLERS[] = {
524     NodeModifier::SetDatePickerOnDateChange,
525 };
526 
527 const ComponentAsyncEventHandler TIME_PICKER_NODE_ASYNC_EVENT_HANDLERS[] = {
528     NodeModifier::SetTimePickerOnChange,
529 };
530 
531 const ComponentAsyncEventHandler TEXT_PICKER_NODE_ASYNC_EVENT_HANDLERS[] = {
532     NodeModifier::SetTextPickerOnChange,
533     NodeModifier::SetTextPickerOnScrollStop,
534 };
535 
536 #ifndef ARKUI_WEARABLE
537 const ComponentAsyncEventHandler CALENDAR_PICKER_NODE_ASYNC_EVENT_HANDLERS[] = {
538     NodeModifier::SetCalendarPickerOnChange,
539 };
540 #endif
541 
542 const ComponentAsyncEventHandler CHECKBOX_NODE_ASYNC_EVENT_HANDLERS[] = {
543     NodeModifier::SetCheckboxChange,
544 };
545 
546 const ComponentAsyncEventHandler CHECKBOX_GROUP_NODE_ASYNC_EVENT_HANDLERS[] = {
547     NodeModifier::SetCheckboxGroupChange,
548 };
549 
550 const ComponentAsyncEventHandler SLIDER_NODE_ASYNC_EVENT_HANDLERS[] = {
551     NodeModifier::SetSliderChange,
552 };
553 
554 const ComponentAsyncEventHandler SWIPER_NODE_ASYNC_EVENT_HANDLERS[] = {
555     NodeModifier::SetSwiperChange,
556     NodeModifier::SetSwiperAnimationStart,
557     NodeModifier::SetSwiperAnimationEnd,
558     NodeModifier::SetSwiperGestureSwipe,
559     NodeModifier::SetSwiperOnContentDidScroll,
560     NodeModifier::SetSwiperSelected,
561     NodeModifier::SetSwiperUnselected,
562     NodeModifier::SetSwiperContentWillScroll,
563     NodeModifier::SetSwiperScrollStateChanged,
564 };
565 
566 const ComponentAsyncEventHandler CANVAS_NODE_ASYNC_EVENT_HANDLERS[] = {
567     NodeModifier::SetCanvasOnReady,
568 };
569 
570 const ComponentAsyncEventHandler listNodeAsyncEventHandlers[] = {
571     NodeModifier::SetOnListScroll,
572     NodeModifier::SetOnListScrollIndex,
573     NodeModifier::SetOnListScrollStart,
574     NodeModifier::SetOnListScrollStop,
575     NodeModifier::SetOnListScrollFrameBegin,
576     NodeModifier::SetOnListWillScroll,
577     NodeModifier::SetOnListDidScroll,
578     NodeModifier::SetOnListReachStart,
579     NodeModifier::SetOnListReachEnd,
580     NodeModifier::SetOnListScrollVisibleContentChange,
581 };
582 
583 const ComponentAsyncEventHandler LIST_ITEM_NODE_ASYNC_EVENT_HANDLERS[] = {
584     NodeModifier::SetListItemOnSelect,
585 };
586 
587 const ComponentAsyncEventHandler WATER_FLOW_NODE_ASYNC_EVENT_HANDLERS[] = {
588     NodeModifier::SetOnWillScroll,
589     NodeModifier::SetOnWaterFlowReachEnd,
590     NodeModifier::SetOnDidScroll,
591     NodeModifier::SetOnWaterFlowScrollStart,
592     NodeModifier::SetOnWaterFlowScrollStop,
593     NodeModifier::SetOnWaterFlowScrollFrameBegin,
594     NodeModifier::SetOnWaterFlowScrollIndex,
595     NodeModifier::SetOnWaterFlowReachStart,
596 };
597 
598 const ComponentAsyncEventHandler GRID_NODE_ASYNC_EVENT_HANDLERS[] = {
599     nullptr,
600     nullptr,
601     nullptr,
602     NodeModifier::SetOnGridScrollIndex,
603 };
604 
605 const ComponentAsyncEventHandler ALPHABET_INDEXER_NODE_ASYNC_EVENT_HANDLERS[] = {
606     NodeModifier::SetOnIndexerSelected,
607     NodeModifier::SetOnIndexerRequestPopupData,
608     NodeModifier::SetOnIndexerPopupSelected,
609     NodeModifier::SetIndexerChangeEvent,
610     NodeModifier::SetIndexerCreatChangeEvent,
611 };
612 
613 const ComponentAsyncEventHandler SEARCH_NODE_ASYNC_EVENT_HANDLERS[] = {
614     NodeModifier::SetOnSearchSubmit,
615     NodeModifier::SetOnSearchChange,
616     NodeModifier::SetOnSearchCopy,
617     NodeModifier::SetOnSearchCut,
618     NodeModifier::SetOnSearchPaste,
619 };
620 
621 const ComponentAsyncEventHandler RADIO_NODE_ASYNC_EVENT_HANDLERS[] = {
622     NodeModifier::SetOnRadioChange,
623 };
624 
625 const ComponentAsyncEventHandler SELECT_NODE_ASYNC_EVENT_HANDLERS[] = {
626     NodeModifier::SetOnSelectSelect,
627 };
628 
629 const ComponentAsyncEventHandler IMAGE_ANIMATOR_NODE_ASYNC_EVENT_HANDLERS[] = {
630     NodeModifier::SetImageAnimatorOnStart,
631     NodeModifier::SetImageAnimatorOnPause,
632     NodeModifier::SetImageAnimatorOnRepeat,
633     NodeModifier::SetImageAnimatorOnCancel,
634     NodeModifier::SetImageAnimatorOnFinish,
635 };
636 
637 const ResetComponentAsyncEventHandler COMMON_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
638     NodeModifier::ResetOnAppear,
639     NodeModifier::ResetOnDisappear,
640     NodeModifier::ResetOnTouch,
641     NodeModifier::ResetOnClick,
642     NodeModifier::ResetOnHover,
643     NodeModifier::ResetOnBlur,
644     NodeModifier::ResetOnKeyEvent,
645     NodeModifier::ResetOnMouse,
646     NodeModifier::ResetOnAreaChange,
647     NodeModifier::ResetOnVisibleAreaChange,
648     nullptr,
649     NodeModifier::ResetOnFocus,
650     NodeModifier::ResetOnTouchIntercept,
651     NodeModifier::ResetOnAttach,
652     NodeModifier::ResetOnDetach,
653     nullptr,
654     NodeModifier::ResetOnDragStart,
655     NodeModifier::ResetOnDragEnter,
656     NodeModifier::ResetOnDragDrop,
657     NodeModifier::ResetOnDragMove,
658     NodeModifier::ResetOnDragLeave,
659     NodeModifier::ResetOnDragEnd,
660     NodeModifier::ResetOnPreDrag,
661     NodeModifier::ResetOnKeyPreIme,
662     NodeModifier::ResetOnFocusAxisEvent,
663     nullptr,
664     nullptr,
665     NodeModifier::ResetOnAxisEvent,
666     NodeModifier::ResetOnClick,
667     nullptr,
668     NodeModifier::ResetOnHoverMove,
669 };
670 
671 const ResetComponentAsyncEventHandler SCROLL_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
672     NodeModifier::ResetOnScroll,
673     NodeModifier::ResetOnScrollFrameBegin,
674     NodeModifier::ResetScrollOnWillScroll,
675     NodeModifier::ResetScrollOnDidScroll,
676     NodeModifier::ResetOnScrollStart,
677     NodeModifier::ResetOnScrollStop,
678     NodeModifier::ResetOnScrollEdge,
679     NodeModifier::ResetOnScrollReachStart,
680     NodeModifier::ResetOnScrollReachEnd,
681     NodeModifier::ResetOnWillStopDragging,
682     NodeModifier::ResetOnDidZoom,
683     NodeModifier::ResetOnZoomStart,
684     NodeModifier::ResetOnZoomStop,
685 };
686 
687 const ResetComponentAsyncEventHandler TEXT_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
688     NodeModifier::ResetOnDetectResultUpdate,
689     NodeModifier::ResetOnTextSpanLongPress,
690 };
691 
692 const ResetComponentAsyncEventHandler TEXT_INPUT_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
693     NodeModifier::ResetOnTextInputEditChange,
694     NodeModifier::ResetTextInputOnSubmit,
695     NodeModifier::ResetOnTextInputChange,
696     NodeModifier::ResetOnTextInputCut,
697     NodeModifier::ResetOnTextInputPaste,
698     NodeModifier::ResetOnTextInputSelectionChange,
699     NodeModifier::ResetOnTextInputContentSizeChange,
700     NodeModifier::ResetOnTextInputInputFilterError,
701     NodeModifier::ResetTextInputOnTextContentScroll,
702     nullptr,
703     nullptr,
704     nullptr,
705     nullptr,
706     NodeModifier::ResetOnTextInputChangeWithPreviewText,
707     NodeModifier::ResetOnTextInputWillChange,
708 };
709 
710 const ResetComponentAsyncEventHandler TEXT_AREA_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
711     NodeModifier::ResetOnTextAreaEditChange,
712     nullptr,
713     NodeModifier::ResetOnTextAreaChange,
714     NodeModifier::ResetOnTextAreaPaste,
715     NodeModifier::ResetOnTextAreaSelectionChange,
716     NodeModifier::ResetTextAreaOnSubmit,
717     NodeModifier::ResetOnTextAreaContentSizeChange,
718     NodeModifier::ResetOnTextAreaInputFilterError,
719     NodeModifier::ResetTextAreaOnTextContentScroll,
720     nullptr,
721     nullptr,
722     nullptr,
723     nullptr,
724     NodeModifier::ResetOnTextAreaChangeWithPreviewText,
725     NodeModifier::ResetOnTextAreaWillChange,
726 };
727 
728 const ResetComponentAsyncEventHandler REFRESH_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
729     NodeModifier::ResetRefreshOnStateChange,
730     NodeModifier::ResetOnRefreshing,
731     NodeModifier::ResetRefreshOnOffsetChange,
732     NodeModifier::ResetRefreshChangeEvent,
733 };
734 
735 const ResetComponentAsyncEventHandler TOGGLE_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
736     NodeModifier::ResetOnToggleChange,
737 };
738 
739 const ResetComponentAsyncEventHandler IMAGE_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
740     NodeModifier::ResetImageOnComplete,
741     NodeModifier::ResetImageOnError,
742     NodeModifier::ResetImageOnSvgPlayFinish,
743     NodeModifier::ResetImageOnDownloadProgress,
744 };
745 
746 const ResetComponentAsyncEventHandler DATE_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
747     nullptr,
748 };
749 
750 const ResetComponentAsyncEventHandler TIME_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
751     nullptr,
752 };
753 
754 const ResetComponentAsyncEventHandler TEXT_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
755     nullptr,
756 };
757 
758 const ResetComponentAsyncEventHandler CALENDAR_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
759     nullptr,
760 };
761 
762 const ResetComponentAsyncEventHandler CHECKBOX_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
763     nullptr,
764 };
765 
766 const ResetComponentAsyncEventHandler CHECKBOX_GROUP_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
767     NodeModifier::ResetCheckboxGroupChange,
768 };
769 
770 const ResetComponentAsyncEventHandler SLIDER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
771     nullptr,
772 };
773 
774 const ResetComponentAsyncEventHandler SWIPER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
775     nullptr,
776     nullptr,
777     nullptr,
778     nullptr,
779     nullptr,
780     nullptr,
781     nullptr,
782     nullptr,
783     nullptr,
784 };
785 
786 const ResetComponentAsyncEventHandler CANVAS_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
787     nullptr,
788 };
789 
790 const ResetComponentAsyncEventHandler LIST_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
791     NodeModifier::ResetOnListScroll,
792     NodeModifier::ResetOnListScrollIndex,
793     NodeModifier::ResetOnListScrollStart,
794     NodeModifier::ResetOnListScrollStop,
795     NodeModifier::ResetOnListScrollFrameBegin,
796     NodeModifier::ResetOnListWillScroll,
797     NodeModifier::ResetOnListDidScroll,
798     NodeModifier::ResetOnListReachStart,
799     NodeModifier::ResetOnListReachEnd,
800     NodeModifier::ResetOnScrollVisibleContentChange,
801 };
802 
803 const ResetComponentAsyncEventHandler LIST_ITEM_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
804     NodeModifier::ResetListItemOnSelect,
805 };
806 
807 const ResetComponentAsyncEventHandler WATERFLOW_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
808     NodeModifier::ResetOnWillScroll,
809     NodeModifier::ResetOnWaterFlowReachEnd,
810     NodeModifier::ResetOnDidScroll,
811     NodeModifier::ResetOnWaterFlowScrollStart,
812     NodeModifier::ResetOnWaterFlowScrollStop,
813     NodeModifier::ResetOnWaterFlowScrollFrameBegin,
814     NodeModifier::ResetOnWaterFlowScrollIndex,
815     NodeModifier::ResetOnWaterFlowReachStart,
816 };
817 
818 const ResetComponentAsyncEventHandler GRID_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
819     nullptr,
820     nullptr,
821     nullptr,
822     NodeModifier::ResetOnGridScrollIndex,
823 };
824 
825 const ResetComponentAsyncEventHandler ALPHABET_INDEXER_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
826     nullptr,
827     nullptr,
828     nullptr,
829     nullptr,
830     nullptr,
831 };
832 
833 const ResetComponentAsyncEventHandler SEARCH_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
834     nullptr,
835     nullptr,
836     nullptr,
837     nullptr,
838     nullptr,
839 };
840 
841 const ResetComponentAsyncEventHandler RADIO_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
842     nullptr,
843 };
844 
845 const ResetComponentAsyncEventHandler SELECT_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
846     nullptr,
847 };
848 
849 const ResetComponentAsyncEventHandler IMAGE_ANIMATOR_NODE_RESET_ASYNC_EVENT_HANDLERS[] = {
850     NodeModifier::ResetImageAnimatorOnStart,
851     NodeModifier::ResetImageAnimatorOnPause,
852     NodeModifier::ResetImageAnimatorOnRepeat,
853     NodeModifier::ResetImageAnimatorOnCancel,
854     NodeModifier::ResetImageAnimatorOnFinish,
855 };
856 
857 /* clang-format on */
NotifyComponentAsyncEvent(ArkUINodeHandle node,ArkUIEventSubKind kind,ArkUI_Int64 extraParam)858 void NotifyComponentAsyncEvent(ArkUINodeHandle node, ArkUIEventSubKind kind, ArkUI_Int64 extraParam)
859 {
860     unsigned int subClassType = kind / ARKUI_MAX_EVENT_NUM;
861     unsigned int subKind = kind % ARKUI_MAX_EVENT_NUM;
862     ComponentAsyncEventHandler eventHandle = nullptr;
863     switch (subClassType) {
864         case 0: {
865             // common event type.
866             if (subKind >= sizeof(commonNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
867                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
868                 return;
869             }
870             eventHandle = commonNodeAsyncEventHandlers[subKind];
871             break;
872         }
873         case ARKUI_IMAGE: {
874             if (subKind >= sizeof(imageNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
875                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
876                 return;
877             }
878             eventHandle = imageNodeAsyncEventHandlers[subKind];
879             break;
880         }
881         case ARKUI_IMAGE_SPAN: {
882             if (subKind >= sizeof(IMAGE_SPAN_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
883                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
884                 return;
885             }
886             eventHandle = IMAGE_SPAN_NODE_ASYNC_EVENT_HANDLERS[subKind];
887             break;
888         }
889         case ARKUI_SCROLL: {
890             // scroll event type.
891             if (subKind >= sizeof(scrollNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
892                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
893                 return;
894             }
895             eventHandle = scrollNodeAsyncEventHandlers[subKind];
896             break;
897         }
898         case ARKUI_TEXT: {
899             // text event type.
900             if (subKind >= sizeof(TEXT_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
901                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
902                 return;
903             }
904             eventHandle = TEXT_NODE_ASYNC_EVENT_HANDLERS[subKind];
905             break;
906         }
907         case ARKUI_TEXT_INPUT: {
908             // text input event type.
909             if (subKind >= sizeof(textInputNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
910                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
911                 return;
912             }
913             eventHandle = textInputNodeAsyncEventHandlers[subKind];
914             break;
915         }
916         case ARKUI_TEXTAREA: {
917             // textarea event type.
918             if (subKind >= sizeof(textAreaNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
919                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
920                 return;
921             }
922             eventHandle = textAreaNodeAsyncEventHandlers[subKind];
923             break;
924         }
925         case ARKUI_REFRESH: {
926             // refresh event type.
927             if (subKind >= sizeof(refreshNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
928                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
929                 return;
930             }
931             eventHandle = refreshNodeAsyncEventHandlers[subKind];
932             break;
933         }
934         case ARKUI_TOGGLE: {
935             // toggle event type.
936             if (subKind >= sizeof(TOGGLE_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
937                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
938                 return;
939             }
940             eventHandle = TOGGLE_NODE_ASYNC_EVENT_HANDLERS[subKind];
941             break;
942         }
943         case ARKUI_DATE_PICKER: {
944             // datepicker event type.
945             if (subKind >= sizeof(DATE_PICKER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
946                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
947                 return;
948             }
949             eventHandle = DATE_PICKER_NODE_ASYNC_EVENT_HANDLERS[subKind];
950             break;
951         }
952         case ARKUI_TIME_PICKER: {
953             // timepicker event type.
954             if (subKind >= sizeof(TIME_PICKER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
955                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
956                 return;
957             }
958             eventHandle = TIME_PICKER_NODE_ASYNC_EVENT_HANDLERS[subKind];
959             break;
960         }
961         case ARKUI_TEXT_PICKER: {
962             if (subKind >= sizeof(TEXT_PICKER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
963                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
964                 return;
965             }
966             eventHandle = TEXT_PICKER_NODE_ASYNC_EVENT_HANDLERS[subKind];
967             break;
968         }
969         case ARKUI_CALENDAR_PICKER: {
970             // calendar picker event type.
971 #ifndef ARKUI_WEARABLE
972             if (subKind >= sizeof(CALENDAR_PICKER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
973                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
974                 return;
975             }
976             eventHandle = CALENDAR_PICKER_NODE_ASYNC_EVENT_HANDLERS[subKind];
977 #endif
978             break;
979         }
980         case ARKUI_CHECKBOX: {
981             // timepicker event type.
982             if (subKind >= sizeof(CHECKBOX_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
983                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
984                 return;
985             }
986             eventHandle = CHECKBOX_NODE_ASYNC_EVENT_HANDLERS[subKind];
987             break;
988         }
989         case ARKUI_SLIDER: {
990             // timepicker event type.
991             if (subKind >= sizeof(SLIDER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
992                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
993                 return;
994             }
995             eventHandle = SLIDER_NODE_ASYNC_EVENT_HANDLERS[subKind];
996             break;
997         }
998         case ARKUI_SWIPER: {
999             // swiper event type.
1000             if (subKind >= sizeof(SWIPER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1001                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1002                 return;
1003             }
1004             eventHandle = SWIPER_NODE_ASYNC_EVENT_HANDLERS[subKind];
1005             break;
1006         }
1007         case ARKUI_CANVAS: {
1008             if (subKind >= sizeof(CANVAS_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1009                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1010                 return;
1011             }
1012             eventHandle = CANVAS_NODE_ASYNC_EVENT_HANDLERS[subKind];
1013             break;
1014         }
1015         case ARKUI_LIST: {
1016             // list event type.
1017             if (subKind >= sizeof(listNodeAsyncEventHandlers) / sizeof(ComponentAsyncEventHandler)) {
1018                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1019                 return;
1020             }
1021             eventHandle = listNodeAsyncEventHandlers[subKind];
1022             break;
1023         }
1024         case ARKUI_LIST_ITEM: {
1025             // list item event type.
1026             if (subKind >= sizeof(LIST_ITEM_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1027                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1028                 return;
1029             }
1030             eventHandle = LIST_ITEM_NODE_ASYNC_EVENT_HANDLERS[subKind];
1031             break;
1032         }
1033         case ARKUI_WATER_FLOW: {
1034             // swiper event type.
1035             if (subKind >= sizeof(WATER_FLOW_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1036                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1037                 return;
1038             }
1039             eventHandle = WATER_FLOW_NODE_ASYNC_EVENT_HANDLERS[subKind];
1040             break;
1041         }
1042         case ARKUI_GRID: {
1043             // grid event type.
1044             if (subKind >= sizeof(GRID_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1045                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1046                 return;
1047             }
1048             eventHandle = GRID_NODE_ASYNC_EVENT_HANDLERS[subKind];
1049             break;
1050         }
1051         case ARKUI_ALPHABET_INDEXER: {
1052             // alphabet indexer event type.
1053             if (subKind >= sizeof(ALPHABET_INDEXER_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1054                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1055                 return;
1056             }
1057             eventHandle = ALPHABET_INDEXER_NODE_ASYNC_EVENT_HANDLERS[subKind];
1058             break;
1059         }
1060         case ARKUI_SEARCH: {
1061             // search event type.
1062             if (subKind >= sizeof(SEARCH_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1063                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1064                 return;
1065             }
1066             eventHandle = SEARCH_NODE_ASYNC_EVENT_HANDLERS[subKind];
1067             break;
1068         }
1069         case ARKUI_RADIO: {
1070             // search event type.
1071             if (subKind >= sizeof(RADIO_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1072                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1073                 return;
1074             }
1075             eventHandle = RADIO_NODE_ASYNC_EVENT_HANDLERS[subKind];
1076             break;
1077         }
1078         case ARKUI_SELECT: {
1079             // select event type.
1080             if (subKind >= sizeof(SELECT_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1081                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1082                 return;
1083             }
1084             eventHandle = SELECT_NODE_ASYNC_EVENT_HANDLERS[subKind];
1085             break;
1086         }
1087         case ARKUI_IMAGE_ANIMATOR: {
1088             // imageAnimator event type.
1089             if (subKind >= sizeof(IMAGE_ANIMATOR_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1090                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1091                 return;
1092             }
1093             eventHandle = IMAGE_ANIMATOR_NODE_ASYNC_EVENT_HANDLERS[subKind];
1094             break;
1095         }
1096         case ARKUI_CHECK_BOX_GROUP: {
1097             if (subKind >= sizeof(CHECKBOX_GROUP_NODE_ASYNC_EVENT_HANDLERS) / sizeof(ComponentAsyncEventHandler)) {
1098                 TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1099                 return;
1100             }
1101             eventHandle = CHECKBOX_GROUP_NODE_ASYNC_EVENT_HANDLERS[subKind];
1102             break;
1103         }
1104         default: {
1105             TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1106         }
1107     }
1108     if (eventHandle) {
1109         // TODO: fix handlers.
1110         eventHandle(node, reinterpret_cast<void*>(static_cast<intptr_t>(extraParam)));
1111     } else {
1112         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyComponentAsyncEvent kind:%{public}d EMPTY IMPLEMENT", kind);
1113     }
1114 }
1115 
NotifyResetComponentAsyncEvent(ArkUINodeHandle node,ArkUIEventSubKind kind)1116 void NotifyResetComponentAsyncEvent(ArkUINodeHandle node, ArkUIEventSubKind kind)
1117 {
1118     unsigned int subClassType = kind / ARKUI_MAX_EVENT_NUM;
1119     unsigned int subKind = kind % ARKUI_MAX_EVENT_NUM;
1120     ResetComponentAsyncEventHandler eventHandle = nullptr;
1121     switch (subClassType) {
1122         case 0: {
1123             // common event type.
1124             if (subKind >= sizeof(COMMON_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1125                 TAG_LOGE(
1126                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1127                 return;
1128             }
1129             eventHandle = COMMON_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1130             break;
1131         }
1132         case ARKUI_IMAGE: {
1133             if (subKind >= sizeof(IMAGE_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1134                 TAG_LOGE(
1135                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1136                 return;
1137             }
1138             eventHandle = IMAGE_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1139             break;
1140         }
1141         case ARKUI_SCROLL: {
1142             // scroll event type.
1143             if (subKind >= sizeof(SCROLL_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1144                 TAG_LOGE(
1145                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1146                 return;
1147             }
1148             eventHandle = SCROLL_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1149             break;
1150         }
1151         case ARKUI_TEXT: {
1152             // text event type.
1153             if (subKind >= sizeof(TEXT_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1154                 TAG_LOGE(
1155                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1156                 return;
1157             }
1158             eventHandle = TEXT_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1159             break;
1160         }
1161         case ARKUI_TEXT_INPUT: {
1162             // text input event type.
1163             if (subKind >=
1164                 sizeof(TEXT_INPUT_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1165                 TAG_LOGE(
1166                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1167                 return;
1168             }
1169             eventHandle = TEXT_INPUT_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1170             break;
1171         }
1172         case ARKUI_TEXTAREA: {
1173             // textarea event type.
1174             if (subKind >=
1175                 sizeof(TEXT_AREA_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1176                 TAG_LOGE(
1177                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1178                 return;
1179             }
1180             eventHandle = TEXT_AREA_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1181             break;
1182         }
1183         case ARKUI_REFRESH: {
1184             // refresh event type.
1185             if (subKind >= sizeof(REFRESH_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1186                 TAG_LOGE(
1187                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1188                 return;
1189             }
1190             eventHandle = REFRESH_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1191             break;
1192         }
1193         case ARKUI_TOGGLE: {
1194             // toggle event type.
1195             if (subKind >= sizeof(TOGGLE_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1196                 TAG_LOGE(
1197                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1198                 return;
1199             }
1200             eventHandle = TOGGLE_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1201             break;
1202         }
1203         case ARKUI_DATE_PICKER: {
1204             // datepicker event type.
1205             if (subKind >=
1206                 sizeof(DATE_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1207                 TAG_LOGE(
1208                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1209                 return;
1210             }
1211             eventHandle = DATE_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1212             break;
1213         }
1214         case ARKUI_TIME_PICKER: {
1215             // timepicker event type.
1216             if (subKind >=
1217                 sizeof(TIME_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1218                 TAG_LOGE(
1219                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1220                 return;
1221             }
1222             eventHandle = TIME_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1223             break;
1224         }
1225         case ARKUI_TEXT_PICKER: {
1226             if (subKind >=
1227                 sizeof(TEXT_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1228                 TAG_LOGE(
1229                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1230                 return;
1231             }
1232             eventHandle = TEXT_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1233             break;
1234         }
1235         case ARKUI_CALENDAR_PICKER: {
1236             // calendar picker event type.
1237             if (subKind >= sizeof(CALENDAR_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(
1238                 ResetComponentAsyncEventHandler)) {
1239                 TAG_LOGE(
1240                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1241                 return;
1242             }
1243             eventHandle = CALENDAR_PICKER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1244             break;
1245         }
1246         case ARKUI_CHECKBOX: {
1247             // timepicker event type.
1248             if (subKind >= sizeof(CHECKBOX_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1249                 TAG_LOGE(
1250                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1251                 return;
1252             }
1253             eventHandle = CHECKBOX_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1254             break;
1255         }
1256         case ARKUI_SLIDER: {
1257             // timepicker event type.
1258             if (subKind >= sizeof(SLIDER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1259                 TAG_LOGE(
1260                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1261                 return;
1262             }
1263             eventHandle = SLIDER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1264             break;
1265         }
1266         case ARKUI_SWIPER: {
1267             // swiper event type.
1268             if (subKind >= sizeof(SWIPER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1269                 TAG_LOGE(
1270                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1271                 return;
1272             }
1273             eventHandle = SWIPER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1274             break;
1275         }
1276         case ARKUI_CANVAS: {
1277             if (subKind >= sizeof(CANVAS_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1278                 TAG_LOGE(
1279                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1280                 return;
1281             }
1282             eventHandle = CANVAS_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1283             break;
1284         }
1285         case ARKUI_LIST: {
1286             // list event type.
1287             if (subKind >= sizeof(LIST_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1288                 TAG_LOGE(
1289                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1290                 return;
1291             }
1292             eventHandle = LIST_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1293             break;
1294         }
1295         case ARKUI_LIST_ITEM: {
1296             // list item event type.
1297             if (subKind >=
1298                 sizeof(LIST_ITEM_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1299                 TAG_LOGE(
1300                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1301                 return;
1302             }
1303             eventHandle = LIST_ITEM_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1304             break;
1305         }
1306         case ARKUI_WATER_FLOW: {
1307             // swiper event type.
1308             if (subKind >=
1309                 sizeof(WATERFLOW_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1310                 TAG_LOGE(
1311                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1312                 return;
1313             }
1314             eventHandle = WATERFLOW_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1315             break;
1316         }
1317         case ARKUI_GRID: {
1318             // grid event type.
1319             if (subKind >= sizeof(GRID_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1320                 TAG_LOGE(
1321                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1322                 return;
1323             }
1324             eventHandle = GRID_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1325             break;
1326         }
1327         case ARKUI_ALPHABET_INDEXER: {
1328             // alphabet indexer event type.
1329             if (subKind >= sizeof(ALPHABET_INDEXER_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(
1330                 ResetComponentAsyncEventHandler)) {
1331                 TAG_LOGE(
1332                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1333                 return;
1334             }
1335             eventHandle = ALPHABET_INDEXER_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1336             break;
1337         }
1338         case ARKUI_SEARCH: {
1339             // search event type.
1340             if (subKind >= sizeof(SEARCH_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1341                 TAG_LOGE(
1342                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1343                 return;
1344             }
1345             eventHandle = SEARCH_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1346             break;
1347         }
1348         case ARKUI_RADIO: {
1349             // search event type.
1350             if (subKind >= sizeof(RADIO_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1351                 TAG_LOGE(
1352                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1353                 return;
1354             }
1355             eventHandle = RADIO_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1356             break;
1357         }
1358         case ARKUI_SELECT: {
1359             // select event type.
1360             if (subKind >= sizeof(SELECT_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1361                 TAG_LOGE(
1362                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1363                 return;
1364             }
1365             eventHandle = SELECT_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1366             break;
1367         }
1368         case ARKUI_IMAGE_ANIMATOR: {
1369             // imageAnimator event type.
1370             if (subKind >=
1371                 sizeof(IMAGE_ANIMATOR_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1372                 TAG_LOGE(
1373                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1374                 return;
1375             }
1376             eventHandle = IMAGE_ANIMATOR_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1377             break;
1378         }
1379         case ARKUI_CHECK_BOX_GROUP: {
1380             if (subKind >=
1381                 sizeof(CHECKBOX_GROUP_NODE_RESET_ASYNC_EVENT_HANDLERS) / sizeof(ResetComponentAsyncEventHandler)) {
1382                 TAG_LOGE(
1383                     AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1384                 return;
1385             }
1386             eventHandle = CHECKBOX_GROUP_NODE_RESET_ASYNC_EVENT_HANDLERS[subKind];
1387             break;
1388         }
1389         default: {
1390             TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d NOT IMPLEMENT", kind);
1391         }
1392     }
1393     if (eventHandle) {
1394         eventHandle(node);
1395     } else {
1396         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "NotifyResetComponentAsyncEvent kind:%{public}d EMPTY IMPLEMENT", kind);
1397     }
1398 }
1399 
RegisterNodeAsyncEventReceiver(EventReceiver eventReceiver)1400 void RegisterNodeAsyncEventReceiver(EventReceiver eventReceiver)
1401 {
1402     NodeEvent::globalEventReceiver = eventReceiver;
1403 }
1404 
UnregisterNodeAsyncEventReceiver()1405 void UnregisterNodeAsyncEventReceiver()
1406 {
1407     NodeEvent::globalEventReceiver = nullptr;
1408 }
1409 
ApplyModifierFinish(ArkUINodeHandle nodePtr)1410 void ApplyModifierFinish(ArkUINodeHandle nodePtr)
1411 {
1412     auto* uiNode = reinterpret_cast<UINode*>(nodePtr);
1413     auto* frameNode = AceType::DynamicCast<FrameNode>(uiNode);
1414     if (frameNode) {
1415         frameNode->MarkModifyDone();
1416     }
1417 }
1418 
MarkDirty(ArkUINodeHandle nodePtr,ArkUI_Uint32 flag)1419 void MarkDirty(ArkUINodeHandle nodePtr, ArkUI_Uint32 flag)
1420 {
1421     auto* uiNode = reinterpret_cast<UINode*>(nodePtr);
1422     if (uiNode) {
1423         uiNode->MarkDirtyNode(flag);
1424     }
1425 }
1426 
SetCallbackMethod(ArkUIAPICallbackMethod * method)1427 static void SetCallbackMethod(ArkUIAPICallbackMethod* method)
1428 {
1429     ViewModel::SetCallbackMethod(method);
1430 }
1431 
GetArkUIAPICallbackMethod()1432 ArkUIAPICallbackMethod* GetArkUIAPICallbackMethod()
1433 {
1434     return ViewModel::GetCallbackMethod();
1435 }
1436 
GetPipelineContext(ArkUINodeHandle node)1437 ArkUIPipelineContext GetPipelineContext(ArkUINodeHandle node)
1438 {
1439     auto frameNode = reinterpret_cast<FrameNode*>(node);
1440     return reinterpret_cast<ArkUIPipelineContext>(frameNode->GetContext());
1441 }
1442 
SetVsyncCallback(ArkUIVMContext vmContext,ArkUIPipelineContext pipelineContext,ArkUI_Int32 callbackId)1443 void SetVsyncCallback(ArkUIVMContext vmContext, ArkUIPipelineContext pipelineContext, ArkUI_Int32 callbackId)
1444 {
1445     static int vsyncCount = 1;
1446     auto vsync = [vmContext, callbackId]() {
1447         ArkUIEventCallbackArg args[] = { {.i32 =vsyncCount++ } };
1448         ArkUIAPICallbackMethod* cbs = GetArkUIAPICallbackMethod();
1449         CHECK_NULL_VOID(vmContext);
1450         CHECK_NULL_VOID(cbs);
1451         cbs->CallInt(vmContext, callbackId, 1, &args[0]);
1452     };
1453 
1454     reinterpret_cast<PipelineContext*>(pipelineContext)->SetVsyncListener(vsync);
1455 }
1456 
UnblockVsyncWait(ArkUIVMContext vmContext,ArkUIPipelineContext pipelineContext)1457 void UnblockVsyncWait(ArkUIVMContext vmContext, ArkUIPipelineContext pipelineContext)
1458 {
1459     reinterpret_cast<PipelineContext*>(pipelineContext)->RequestFrame();
1460 }
1461 
MeasureNode(ArkUIVMContext vmContext,ArkUINodeHandle node,ArkUI_Float32 * data)1462 ArkUI_Int32 MeasureNode(ArkUIVMContext vmContext, ArkUINodeHandle node, ArkUI_Float32* data)
1463 {
1464     return ViewModel::MeasureNode(vmContext, node, data);
1465 }
1466 
LayoutNode(ArkUIVMContext vmContext,ArkUINodeHandle node,ArkUI_Float32 (* data)[2])1467 ArkUI_Int32 LayoutNode(ArkUIVMContext vmContext, ArkUINodeHandle node, ArkUI_Float32 (*data)[2])
1468 {
1469     return ViewModel::LayoutNode(vmContext, node, data);
1470 }
1471 
DrawNode(ArkUIVMContext vmContext,ArkUINodeHandle node,ArkUI_Float32 * data)1472 ArkUI_Int32 DrawNode(ArkUIVMContext vmContext, ArkUINodeHandle node, ArkUI_Float32* data)
1473 {
1474     return ViewModel::DrawNode(vmContext, node, data);
1475 }
1476 
SetAttachNodePtr(ArkUINodeHandle node,void * value)1477 void SetAttachNodePtr(ArkUINodeHandle node, void* value)
1478 {
1479     return ViewModel::SetAttachNodePtr(node, value);
1480 }
1481 
GetAttachNodePtr(ArkUINodeHandle node)1482 void* GetAttachNodePtr(ArkUINodeHandle node)
1483 {
1484     return ViewModel::GetAttachNodePtr(node);
1485 }
1486 
MeasureLayoutAndDraw(ArkUIVMContext vmContext,ArkUINodeHandle rootPtr)1487 ArkUI_Int32 MeasureLayoutAndDraw(ArkUIVMContext vmContext, ArkUINodeHandle rootPtr)
1488 {
1489     auto* root = reinterpret_cast<FrameNode*>(rootPtr);
1490     auto geometryNode = root->GetGeometryNode();
1491     if (!geometryNode) {
1492         LOGW("WARNING geometryNode is nullptr");
1493         return 0;
1494     }
1495     float width = geometryNode->GetFrameSize().Width();
1496     float height = geometryNode->GetFrameSize().Height();
1497     // measure
1498     ArkUI_Float32 measureData[] = { width, height, width, height, width, height };
1499     MeasureNode(vmContext, rootPtr, &measureData[0]);
1500     // layout
1501     ArkUI_Float32 layoutData[] = { 0, 0 };
1502     LayoutNode(vmContext, rootPtr, &layoutData);
1503     // draw
1504     ArkUI_Float32 drawData[] = { 0, 0, 0, 0 };
1505     DrawNode(vmContext, rootPtr, &drawData[0]);
1506 
1507     return 0;
1508 }
1509 
RegisterCustomNodeAsyncEvent(ArkUINodeHandle node,int32_t eventType,void * extraParam)1510 void RegisterCustomNodeAsyncEvent(ArkUINodeHandle node, int32_t eventType, void* extraParam)
1511 {
1512     auto companion = ViewModel::GetCompanion(node);
1513     if (!companion) {
1514         ViewModel::RegisterCompanion(node, -1, eventType);
1515         auto companion = ViewModel::GetCompanion(node);
1516         CHECK_NULL_VOID(companion);
1517         companion->SetExtraParam(eventType, extraParam);
1518     } else {
1519         auto originEventType = companion->GetFlags();
1520         companion->SetFlags(static_cast<uint32_t>(originEventType) | static_cast<uint32_t>(eventType));
1521         companion->SetExtraParam(eventType, extraParam);
1522     }
1523 }
1524 
RegisterCustomSpanAsyncEvent(ArkUINodeHandle node,int32_t eventType,void * extraParam)1525 void RegisterCustomSpanAsyncEvent(ArkUINodeHandle node, int32_t eventType, void* extraParam)
1526 {
1527     switch (eventType) {
1528         case ArkUIAPINodeFlags::CUSTOM_MEASURE:
1529             NodeModifier::SetCustomSpanOnMeasure(node, extraParam);
1530             break;
1531         case ArkUIAPINodeFlags::CUSTOM_DRAW:
1532             NodeModifier::SetCustomSpanOnDraw(node, extraParam);
1533             break;
1534         default:
1535             break;
1536     }
1537 }
1538 
UnregisterCustomNodeEvent(ArkUINodeHandle node,ArkUI_Int32 eventType)1539 ArkUI_Int32 UnregisterCustomNodeEvent(ArkUINodeHandle node, ArkUI_Int32 eventType)
1540 {
1541     auto companion = ViewModel::GetCompanion(node);
1542     CHECK_NULL_RETURN(companion, -1);
1543     auto originEventType = static_cast<uint32_t>(companion->GetFlags());
1544     //check is Contains
1545     if ((originEventType & static_cast<uint32_t>(eventType)) != static_cast<uint32_t>(eventType)) {
1546         return -1;
1547     }
1548     companion->SetFlags(static_cast<uint32_t>(originEventType) ^ static_cast<uint32_t>(eventType));
1549     companion->EraseExtraParam(eventType);
1550     return 0;
1551 }
1552 
RegisterCustomNodeEventReceiver(void (* eventReceiver)(ArkUICustomNodeEvent * event))1553 void RegisterCustomNodeEventReceiver(void (*eventReceiver)(ArkUICustomNodeEvent* event))
1554 {
1555     CustomNodeEvent::g_fliter = eventReceiver;
1556 }
1557 
SetMeasureWidth(ArkUINodeHandle node,ArkUI_Int32 value)1558 void SetMeasureWidth(ArkUINodeHandle node, ArkUI_Int32 value)
1559 {
1560     // directly set frameNode measure width.
1561     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1562     if (!frameNode) {
1563         return;
1564     }
1565     auto geometryNode = frameNode->GetGeometryNode();
1566     if (!geometryNode) {
1567         LOGW("WARNING geometryNode is nullptr");
1568         return;
1569     }
1570     geometryNode->SetFrameWidth(value);
1571 }
1572 
GetMeasureWidth(ArkUINodeHandle node)1573 ArkUI_Int32 GetMeasureWidth(ArkUINodeHandle node)
1574 {
1575     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1576     if (!frameNode) {
1577         return 0;
1578     }
1579     auto geometryNode = frameNode->GetGeometryNode();
1580     if (!geometryNode) {
1581         LOGW("WARNING geometryNode is nullptr");
1582         return 0;
1583     }
1584     return geometryNode->GetFrameSize().Width();
1585 }
1586 
SetMeasureHeight(ArkUINodeHandle node,ArkUI_Int32 value)1587 void SetMeasureHeight(ArkUINodeHandle node, ArkUI_Int32 value)
1588 {
1589     // directly set frameNode measure height.
1590     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1591     if (!frameNode) {
1592         return;
1593     }
1594     auto geometryNode = frameNode->GetGeometryNode();
1595     if (!geometryNode) {
1596         LOGW("WARNING geometryNode is nullptr");
1597         return;
1598     }
1599     geometryNode->SetFrameHeight(value);
1600 }
1601 
GetMeasureHeight(ArkUINodeHandle node)1602 ArkUI_Int32 GetMeasureHeight(ArkUINodeHandle node)
1603 {
1604     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1605     if (!frameNode) {
1606         return 0;
1607     }
1608     auto geometryNode = frameNode->GetGeometryNode();
1609     if (!geometryNode) {
1610         LOGW("WARNING geometryNode is nullptr");
1611         return 0;
1612     }
1613     return geometryNode->GetFrameSize().Height();
1614 }
1615 
SetX(ArkUINodeHandle node,ArkUI_Int32 value)1616 void SetX(ArkUINodeHandle node, ArkUI_Int32 value)
1617 {
1618     // directly set frameNode measure postionX.
1619     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1620     if (!frameNode) {
1621         return;
1622     }
1623     auto geometryNode = frameNode->GetGeometryNode();
1624     if (!geometryNode) {
1625         LOGW("WARNING geometryNode is nullptr");
1626         return;
1627     }
1628     geometryNode->SetMarginFrameOffsetX(value);
1629 }
1630 
SetY(ArkUINodeHandle node,ArkUI_Int32 value)1631 void SetY(ArkUINodeHandle node, ArkUI_Int32 value)
1632 {
1633     // directly set frameNode measure postionY.
1634     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1635     if (!frameNode) {
1636         return;
1637     }
1638     auto geometryNode = frameNode->GetGeometryNode();
1639     if (!geometryNode) {
1640         LOGW("WARNING geometryNode is nullptr");
1641         return;
1642     }
1643     geometryNode->SetMarginFrameOffsetY(value);
1644 }
1645 
GetX(ArkUINodeHandle node)1646 ArkUI_Int32 GetX(ArkUINodeHandle node)
1647 {
1648     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1649     if (!frameNode) {
1650         return 0;
1651     }
1652     auto geometryNode = frameNode->GetGeometryNode();
1653     if (!geometryNode) {
1654         LOGW("WARNING geometryNode is nullptr");
1655         return 0;
1656     }
1657     return geometryNode->GetMarginFrameOffset().GetX();
1658 }
1659 
GetY(ArkUINodeHandle node)1660 ArkUI_Int32 GetY(ArkUINodeHandle node)
1661 {
1662     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1663     if (!frameNode) {
1664         return 0;
1665     }
1666     auto geometryNode = frameNode->GetGeometryNode();
1667     if (!geometryNode) {
1668         LOGW("WARNING geometryNode is nullptr");
1669         return 0;
1670     }
1671     return geometryNode->GetMarginFrameOffset().GetY();
1672 }
1673 
SetCustomMethodFlag(ArkUINodeHandle node,ArkUI_Int32 flag)1674 void SetCustomMethodFlag(ArkUINodeHandle node, ArkUI_Int32 flag)
1675 {
1676     auto* companion = ViewModel::GetCompanion(node);
1677     CHECK_NULL_VOID(companion);
1678     companion->SetFlags(flag);
1679 }
1680 
GetCustomMethodFlag(ArkUINodeHandle node)1681 ArkUI_Int32 GetCustomMethodFlag(ArkUINodeHandle node)
1682 {
1683     auto* companion = ViewModel::GetCompanion(node);
1684     CHECK_NULL_RETURN(companion, 0);
1685     return companion->GetFlags();
1686 }
1687 
SetAlignment(ArkUINodeHandle node,ArkUI_Int32 value)1688 void SetAlignment(ArkUINodeHandle node, ArkUI_Int32 value)
1689 {
1690     auto* companion = ViewModel::GetCompanion(node);
1691     CHECK_NULL_VOID(companion);
1692     companion->SetAlignmentValue(value);
1693 }
1694 
GetAlignment(ArkUINodeHandle node)1695 ArkUI_Int32 GetAlignment(ArkUINodeHandle node)
1696 {
1697     auto* companion = ViewModel::GetCompanion(node);
1698     CHECK_NULL_RETURN(companion, 0);
1699     return companion->GetAlignmentValue();
1700 }
1701 
GetLayoutConstraint(ArkUINodeHandle node,ArkUI_Int32 * value)1702 void GetLayoutConstraint(ArkUINodeHandle node, ArkUI_Int32* value)
1703 {
1704     auto* frameNode = AceType::DynamicCast<FrameNode>(reinterpret_cast<UINode*>(node));
1705     CHECK_NULL_VOID(frameNode);
1706     auto layoutConstraint = frameNode->GetLayoutProperty()->GetContentLayoutConstraint();
1707     if (layoutConstraint.has_value()) {
1708         //min
1709         value[0] = static_cast<ArkUI_Int32>(layoutConstraint.value().minSize.Width());
1710         //min
1711         value[1] = static_cast<ArkUI_Int32>(layoutConstraint.value().minSize.Height());
1712         //.max
1713         value[2] = static_cast<ArkUI_Int32>(layoutConstraint.value().maxSize.Width());
1714         //.max
1715         value[3] = static_cast<ArkUI_Int32>(layoutConstraint.value().maxSize.Height());
1716         //percentReference
1717         value[4] = static_cast<ArkUI_Int32>(layoutConstraint.value().percentReference.Width());
1718         //percentReference
1719         value[5] = static_cast<ArkUI_Int32>(layoutConstraint.value().percentReference.Height());
1720     }
1721 }
1722 
1723 
1724 
GetNavigationId(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1725 ArkUI_Int32 GetNavigationId(
1726     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1727 {
1728     auto navDesInfo = GetNavDestinationInfoByNode(node);
1729     CHECK_NULL_RETURN(navDesInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1730     std::string navigationId = navDesInfo->navigationId;
1731     return WriteStringToBuffer(navigationId, buffer, bufferSize, writeLen);
1732 }
1733 
GetNavDestinationName(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1734 ArkUI_Int32 GetNavDestinationName(
1735     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1736 {
1737     auto navDesInfo = GetNavDestinationInfoByNode(node);
1738     CHECK_NULL_RETURN(navDesInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1739     std::string name = navDesInfo->name;
1740     return WriteStringToBuffer(name, buffer, bufferSize, writeLen);
1741 }
1742 
GetStackLength(ArkUINodeHandle node)1743 ArkUI_Int32 GetStackLength(ArkUINodeHandle node)
1744 {
1745     auto navigationStack = GetNavigationStackByNode(node);
1746     CHECK_NULL_RETURN(navigationStack, INVLID_VALUE);
1747     return navigationStack->Size();
1748 }
1749 
GetNavDesNameByIndex(ArkUINodeHandle node,ArkUI_Int32 index,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1750 ArkUI_Int32 GetNavDesNameByIndex(
1751     ArkUINodeHandle node, ArkUI_Int32 index, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1752 {
1753     auto navigationStack = GetNavigationStackByNode(node);
1754     CHECK_NULL_RETURN(navigationStack, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1755     if (index < 0 || index >= navigationStack->Size()) {
1756         return ERROR_CODE_NATIVE_IMPL_NODE_INDEX_INVALID;
1757     }
1758 
1759     std::string name = navigationStack->GetNavDesNameByIndex(index);
1760     return WriteStringToBuffer(name, buffer, bufferSize, writeLen);
1761 }
1762 
GetNavDestinationId(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1763 ArkUI_Int32 GetNavDestinationId(
1764     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1765 {
1766     auto navDesInfo = GetNavDestinationInfoByNode(node);
1767     CHECK_NULL_RETURN(navDesInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1768     std::string navDestinationId = navDesInfo->navDestinationId;
1769     return WriteStringToBuffer(navDestinationId, buffer, bufferSize, writeLen);
1770 }
1771 
GetNavDestinationState(ArkUINodeHandle node)1772 ArkUI_Int32 GetNavDestinationState(ArkUINodeHandle node)
1773 {
1774     auto navDesInfo = GetNavDestinationInfoByNode(node);
1775     CHECK_NULL_RETURN(navDesInfo, INVLID_VALUE);
1776     return static_cast<int32_t>(navDesInfo->state);
1777 }
1778 
GetNavDestinationIndex(ArkUINodeHandle node)1779 ArkUI_Int32 GetNavDestinationIndex(ArkUINodeHandle node)
1780 {
1781     auto navDesInfo = GetNavDestinationInfoByNode(node);
1782     CHECK_NULL_RETURN(navDesInfo, INVLID_VALUE);
1783     return navDesInfo->index;
1784 }
1785 
GetNavDestinationParam(ArkUINodeHandle node)1786 void* GetNavDestinationParam(ArkUINodeHandle node)
1787 {
1788     auto navDesInfo = GetNavDestinationInfoByNode(node);
1789     CHECK_NULL_RETURN(navDesInfo, nullptr);
1790     return reinterpret_cast<void*>(navDesInfo->param);
1791 }
1792 
GetRouterPageIndex(ArkUINodeHandle node)1793 ArkUI_Int32 GetRouterPageIndex(ArkUINodeHandle node)
1794 {
1795     auto routerInfo = GetRouterPageInfoByNode(node);
1796     CHECK_NULL_RETURN(routerInfo, INVLID_VALUE);
1797     return routerInfo->index;
1798 }
1799 
GetRouterPageName(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1800 ArkUI_Int32 GetRouterPageName(
1801     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1802 {
1803     auto routerInfo = GetRouterPageInfoByNode(node);
1804     CHECK_NULL_RETURN(routerInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1805     std::string name = routerInfo->name;
1806     return WriteStringToBuffer(name, buffer, bufferSize, writeLen);
1807 }
1808 
GetRouterPagePath(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1809 ArkUI_Int32 GetRouterPagePath(
1810     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1811 {
1812     auto routerInfo = GetRouterPageInfoByNode(node);
1813     CHECK_NULL_RETURN(routerInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1814     std::string path = routerInfo->path;
1815     return WriteStringToBuffer(path, buffer, bufferSize, writeLen);
1816 }
1817 
GetRouterPageState(ArkUINodeHandle node)1818 ArkUI_Int32 GetRouterPageState(ArkUINodeHandle node)
1819 {
1820     auto routerInfo = GetRouterPageInfoByNode(node);
1821     CHECK_NULL_RETURN(routerInfo, INVLID_VALUE);
1822     return static_cast<int32_t>(routerInfo->state);
1823 }
1824 
GetRouterPageId(ArkUINodeHandle node,char * buffer,ArkUI_Int32 bufferSize,ArkUI_Int32 * writeLen)1825 ArkUI_Int32 GetRouterPageId(
1826     ArkUINodeHandle node, char* buffer, ArkUI_Int32 bufferSize, ArkUI_Int32* writeLen)
1827 {
1828     auto routerInfo = GetRouterPageInfoByNode(node);
1829     CHECK_NULL_RETURN(routerInfo, ERROR_CODE_NATIVE_IMPL_GET_INFO_FAILED);
1830     std::string pageId = routerInfo->pageId;
1831     return WriteStringToBuffer(pageId, buffer, bufferSize, writeLen);
1832 }
1833 
GetContextByNode(ArkUINodeHandle node)1834 int32_t GetContextByNode(ArkUINodeHandle node)
1835 {
1836     int32_t instanceId = -1;
1837     FrameNode* currentNode = reinterpret_cast<FrameNode*>(node);
1838     CHECK_NULL_RETURN(currentNode, instanceId);
1839     auto pipeline = currentNode->GetContext();
1840     CHECK_NULL_RETURN(pipeline, instanceId);
1841     instanceId = pipeline->GetInstanceId();
1842     return instanceId;
1843 }
1844 
PostFrameCallback(ArkUI_Int32 instanceId,void * userData,void (* callback)(uint64_t nanoTimestamp,uint32_t frameCount,void * userData))1845 ArkUI_Int32 PostFrameCallback(ArkUI_Int32 instanceId, void* userData,
1846     void (*callback)(uint64_t nanoTimestamp, uint32_t frameCount, void* userData))
1847 {
1848     auto pipeline = PipelineContext::GetContextByContainerId(instanceId);
1849     if (pipeline == nullptr) {
1850         LOGW("Cannot find pipeline context by contextHandle ID");
1851         return ARKUI_ERROR_CODE_UI_CONTEXT_INVALID;
1852     }
1853     if (!pipeline->CheckThreadSafe()) {
1854         return ERROR_CODE_NATIVE_IMPL_NOT_MAIN_THREAD;
1855     }
1856     auto onframeCallbackFuncFromCAPI = [userData, callback](uint64_t nanoTimestamp, uint32_t frameCount) -> void {
1857         callback(nanoTimestamp, frameCount, userData);
1858     };
1859 
1860     pipeline->AddCAPIFrameCallback(std::move(onframeCallbackFuncFromCAPI));
1861     return ERROR_CODE_NO_ERROR;
1862 }
1863 
PostIdleCallback(ArkUI_Int32 instanceId,void * userData,void (* callback)(uint64_t nanoTimeLeft,uint32_t frameCount,void * userData))1864 ArkUI_Int32 PostIdleCallback(ArkUI_Int32 instanceId, void* userData,
1865     void (*callback)(uint64_t nanoTimeLeft, uint32_t frameCount, void* userData))
1866 {
1867     auto pipeline = PipelineContext::GetContextByContainerId(instanceId);
1868     if (pipeline == nullptr) {
1869         LOGW("Cannot find pipeline context by contextHandle ID");
1870         return ARKUI_ERROR_CODE_UI_CONTEXT_INVALID;
1871     }
1872     if (!pipeline->CheckThreadSafe()) {
1873         return ERROR_CODE_NATIVE_IMPL_NOT_MAIN_THREAD;
1874     }
1875     auto onidleCallbackFuncFromCAPI = [userData, callback](uint64_t nanoTimeLeft, uint32_t frameCount) -> void {
1876         callback(nanoTimeLeft, frameCount, userData);
1877     };
1878 
1879     pipeline->AddFrameCallback(nullptr, std::move(onidleCallbackFuncFromCAPI), 0);
1880     return ERROR_CODE_NO_ERROR;
1881 }
1882 
GreatOrEqualTargetAPIVersion(ArkUI_Int32 version)1883 ArkUI_Int32 GreatOrEqualTargetAPIVersion(ArkUI_Int32 version)
1884 {
1885     auto platformVersion = static_cast<PlatformVersion>(version);
1886     return AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(platformVersion);
1887 }
1888 
GetBasicAPI()1889 const ArkUIBasicAPI* GetBasicAPI()
1890 {
1891     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
1892     static const ArkUIBasicAPI basicImpl = {
1893         .createNode = CreateNode,
1894         .createNodeWithParams = CreateNodeWithParams,
1895         .getNodeByViewStack = GetNodeByViewStack,
1896         .disposeNode = DisposeNode,
1897         .getName = GetName,
1898         .dump = DumpTreeNode,
1899         .addChild = AddChild,
1900         .removeChild = RemoveChild,
1901         .insertChildAfter = InsertChildAfter,
1902         .insertChildBefore = InsertChildBefore,
1903         .insertChildAt = InsertChildAt,
1904         .getAttribute = GetAttribute,
1905         .setAttribute = SetAttribute,
1906         .resetAttribute = ResetAttribute,
1907         .registerNodeAsyncEvent = NotifyComponentAsyncEvent,
1908         .unRegisterNodeAsyncEvent = NotifyResetComponentAsyncEvent,
1909         .registerNodeAsyncEventReceiver = RegisterNodeAsyncEventReceiver,
1910         .unRegisterNodeAsyncEventReceiver = UnregisterNodeAsyncEventReceiver,
1911         .checkAsyncEvent = nullptr,
1912         .applyModifierFinish = ApplyModifierFinish,
1913         .markDirty = MarkDirty,
1914         .isBuilderNode = IsBuilderNode,
1915         .convertLengthMetricsUnit = ConvertLengthMetricsUnit,
1916         .getContextByNode = GetContextByNode,
1917         .postFrameCallback = PostFrameCallback,
1918         .postIdleCallback = PostIdleCallback,
1919         .greatOrEqualTargetAPIVersion = GreatOrEqualTargetAPIVersion,
1920     };
1921     CHECK_INITIALIZED_FIELDS_END(basicImpl, 0, 0, 0); // don't move this line
1922     return &basicImpl;
1923 }
1924 
GetCJUIBasicAPI()1925 const CJUIBasicAPI* GetCJUIBasicAPI()
1926 {
1927     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
1928     static const CJUIBasicAPI basicImpl = {
1929         .createNode = CreateNode,
1930         .disposeNode = DisposeNode,
1931         .getName = GetName,
1932         .dump = DumpTreeNode,
1933         .addChild = AddChild,
1934         .removeChild = RemoveChild,
1935         .insertChildAfter = InsertChildAfter,
1936         .insertChildBefore = InsertChildBefore,
1937         .insertChildAt = InsertChildAt,
1938         .getAttribute = GetAttribute,
1939         .setAttribute = SetAttribute,
1940         .resetAttribute = ResetAttribute,
1941         .registerNodeAsyncEvent = NotifyComponentAsyncEvent,
1942         .unRegisterNodeAsyncEvent = NotifyResetComponentAsyncEvent,
1943         .registerNodeAsyncEventReceiver = RegisterNodeAsyncEventReceiver,
1944         .unRegisterNodeAsyncEventReceiver = UnregisterNodeAsyncEventReceiver,
1945         .checkAsyncEvent = nullptr,
1946         .applyModifierFinish = ApplyModifierFinish,
1947         .markDirty = MarkDirty,
1948         .isBuilderNode = IsBuilderNode,
1949         .convertLengthMetricsUnit = ConvertLengthMetricsUnit,
1950         .getContextByNode = GetContextByNode,
1951     };
1952     CHECK_INITIALIZED_FIELDS_END(basicImpl, 0, 0, 0); // don't move this line
1953     return &basicImpl;
1954 }
1955 
CreateDialog()1956 ArkUIDialogHandle CreateDialog()
1957 {
1958     return CustomDialog::CreateDialog();
1959 }
1960 
DisposeDialog(ArkUIDialogHandle handle)1961 void DisposeDialog(ArkUIDialogHandle handle)
1962 {
1963     CustomDialog::DisposeDialog(handle);
1964 }
1965 
SetDialogContent(ArkUIDialogHandle handle,ArkUINodeHandle contentNode)1966 ArkUI_Int32 SetDialogContent(ArkUIDialogHandle handle, ArkUINodeHandle contentNode)
1967 {
1968     return CustomDialog::SetDialogContent(handle, contentNode);
1969 }
1970 
RemoveDialogContent(ArkUIDialogHandle handle)1971 ArkUI_Int32 RemoveDialogContent(ArkUIDialogHandle handle)
1972 {
1973     return CustomDialog::RemoveDialogContent(handle);
1974 }
1975 
SetDialogContentAlignment(ArkUIDialogHandle handle,ArkUI_Int32 alignment,ArkUI_Float32 offsetX,ArkUI_Float32 offsetY)1976 ArkUI_Int32 SetDialogContentAlignment(
1977     ArkUIDialogHandle handle, ArkUI_Int32 alignment, ArkUI_Float32 offsetX, ArkUI_Float32 offsetY)
1978 {
1979     return CustomDialog::SetDialogContentAlignment(handle, alignment, offsetX, offsetY);
1980 }
1981 
ResetDialogContentAlignment(ArkUIDialogHandle handle)1982 ArkUI_Int32 ResetDialogContentAlignment(ArkUIDialogHandle handle)
1983 {
1984     return CustomDialog::ResetDialogContentAlignment(handle);
1985 }
1986 
SetDialogModalMode(ArkUIDialogHandle handle,ArkUI_Bool isModal)1987 ArkUI_Int32 SetDialogModalMode(ArkUIDialogHandle handle, ArkUI_Bool isModal)
1988 {
1989     return CustomDialog::SetDialogModalMode(handle, isModal);
1990 }
1991 
SetDialogAutoCancel(ArkUIDialogHandle handle,ArkUI_Bool autoCancel)1992 ArkUI_Int32 SetDialogAutoCancel(ArkUIDialogHandle handle, ArkUI_Bool autoCancel)
1993 {
1994     return CustomDialog::SetDialogAutoCancel(handle, autoCancel);
1995 }
1996 
SetDialogMask(ArkUIDialogHandle handle,ArkUI_Uint32 maskColor,ArkUIRect * rect)1997 ArkUI_Int32 SetDialogMask(ArkUIDialogHandle handle, ArkUI_Uint32 maskColor, ArkUIRect* rect)
1998 {
1999     return CustomDialog::SetDialogMask(handle, maskColor, rect);
2000 }
2001 
SetDialogBackgroundColor(ArkUIDialogHandle handle,uint32_t backgroundColor)2002 ArkUI_Int32 SetDialogBackgroundColor(ArkUIDialogHandle handle, uint32_t backgroundColor)
2003 {
2004     return CustomDialog::SetDialogBackgroundColor(handle, backgroundColor);
2005 }
2006 
SetDialogBackgroundColorWithColorSpace(ArkUIDialogHandle handle,uint32_t backgroundColor,int32_t ColorSpace)2007 ArkUI_Int32 SetDialogBackgroundColorWithColorSpace(
2008     ArkUIDialogHandle handle, uint32_t backgroundColor, int32_t ColorSpace)
2009 {
2010     return CustomDialog::SetDialogBackgroundColor(handle, backgroundColor);
2011 }
2012 
SetDialogCornerRadius(ArkUIDialogHandle handle,float topLeft,float topRight,float bottomLeft,float bottomRight)2013 ArkUI_Int32 SetDialogCornerRadius(
2014     ArkUIDialogHandle handle, float topLeft, float topRight, float bottomLeft, float bottomRight)
2015 {
2016     return CustomDialog::SetDialogCornerRadius(handle, topLeft, topRight, bottomLeft, bottomRight);
2017 }
2018 
SetDialogGridColumnCount(ArkUIDialogHandle handle,int32_t gridCount)2019 ArkUI_Int32 SetDialogGridColumnCount(ArkUIDialogHandle handle, int32_t gridCount)
2020 {
2021     return CustomDialog::SetDialogGridColumnCount(handle, gridCount);
2022 }
2023 
EnableDialogCustomStyle(ArkUIDialogHandle handle,ArkUI_Bool enableCustomStyle)2024 ArkUI_Int32 EnableDialogCustomStyle(ArkUIDialogHandle handle, ArkUI_Bool enableCustomStyle)
2025 {
2026     return CustomDialog::EnableDialogCustomStyle(handle, enableCustomStyle);
2027 }
2028 
EnableDialogCustomAnimation(ArkUIDialogHandle handle,ArkUI_Bool enableCustomAnimation)2029 ArkUI_Int32 EnableDialogCustomAnimation(ArkUIDialogHandle handle, ArkUI_Bool enableCustomAnimation)
2030 {
2031     return CustomDialog::EnableDialogCustomAnimation(handle, enableCustomAnimation);
2032 }
2033 
ShowDialog(ArkUIDialogHandle handle,ArkUI_Bool showInSubWindow)2034 ArkUI_Int32 ShowDialog(ArkUIDialogHandle handle, ArkUI_Bool showInSubWindow)
2035 {
2036     return CustomDialog::ShowDialog(handle, showInSubWindow);
2037 }
2038 
CloseDialog(ArkUIDialogHandle handle)2039 ArkUI_Int32 CloseDialog(ArkUIDialogHandle handle)
2040 {
2041     return CustomDialog::CloseDialog(handle);
2042 }
2043 
2044 // Register closing event
RegisterOnWillDialogDismiss(ArkUIDialogHandle handle,bool (* eventHandler)(ArkUI_Int32))2045 ArkUI_Int32 RegisterOnWillDialogDismiss(ArkUIDialogHandle handle, bool (*eventHandler)(ArkUI_Int32))
2046 {
2047     return CustomDialog::RegisterOnWillDialogDismiss(handle, eventHandler);
2048 }
2049 
2050 // Register closing event
RegisterOnWillDismissWithUserData(ArkUIDialogHandle handler,void * userData,void (* callback)(ArkUI_DialogDismissEvent * event))2051 ArkUI_Int32 RegisterOnWillDismissWithUserData(
2052     ArkUIDialogHandle handler, void* userData, void (*callback)(ArkUI_DialogDismissEvent* event))
2053 {
2054     return CustomDialog::RegisterOnWillDialogDismissWithUserData(handler, userData, callback);
2055 }
2056 
SetKeyboardAvoidDistance(ArkUIDialogHandle handle,float distance,ArkUI_Int32 unit)2057 ArkUI_Int32 SetKeyboardAvoidDistance(ArkUIDialogHandle handle, float distance, ArkUI_Int32 unit)
2058 {
2059     return CustomDialog::SetKeyboardAvoidDistance(handle, distance, unit);
2060 }
2061 
SetDialogLevelMode(ArkUIDialogHandle handle,ArkUI_Int32 mode)2062 ArkUI_Int32 SetDialogLevelMode(ArkUIDialogHandle handle, ArkUI_Int32 mode)
2063 {
2064     return CustomDialog::SetLevelMode(handle, mode);
2065 }
2066 
SetDialogLevelUniqueId(ArkUIDialogHandle handle,ArkUI_Int32 uniqueId)2067 ArkUI_Int32 SetDialogLevelUniqueId(ArkUIDialogHandle handle, ArkUI_Int32 uniqueId)
2068 {
2069     return CustomDialog::SetLevelUniqueId(handle, uniqueId);
2070 }
2071 
SetDialogImmersiveMode(ArkUIDialogHandle handle,ArkUI_Int32 mode)2072 ArkUI_Int32 SetDialogImmersiveMode(ArkUIDialogHandle handle, ArkUI_Int32 mode)
2073 {
2074     return CustomDialog::SetImmersiveMode(handle, mode);
2075 }
2076 
SetLevelOrder(ArkUIDialogHandle handle,ArkUI_Float64 levelOrder)2077 ArkUI_Int32 SetLevelOrder(ArkUIDialogHandle handle, ArkUI_Float64 levelOrder)
2078 {
2079     return CustomDialog::SetLevelOrder(handle, levelOrder);
2080 }
2081 
RegisterOnWillAppear(ArkUIDialogHandle handle,void * userData,void (* callback)(void * userData))2082 ArkUI_Int32 RegisterOnWillAppear(ArkUIDialogHandle handle, void* userData, void (*callback)(void* userData))
2083 {
2084     return CustomDialog::RegisterOnWillAppearDialog(handle, userData, callback);
2085 }
2086 
RegisterOnDidAppear(ArkUIDialogHandle handle,void * userData,void (* callback)(void * userData))2087 ArkUI_Int32 RegisterOnDidAppear(ArkUIDialogHandle handle, void* userData, void (*callback)(void* userData))
2088 {
2089     return CustomDialog::RegisterOnDidAppearDialog(handle, userData, callback);
2090 }
2091 
RegisterOnWillDisappear(ArkUIDialogHandle handle,void * userData,void (* callback)(void * userData))2092 ArkUI_Int32 RegisterOnWillDisappear(ArkUIDialogHandle handle, void* userData, void (*callback)(void* userData))
2093 {
2094     return CustomDialog::RegisterOnWillDisappearDialog(handle, userData, callback);
2095 }
2096 
RegisterOnDidDisappear(ArkUIDialogHandle handle,void * userData,void (* callback)(void * userData))2097 ArkUI_Int32 RegisterOnDidDisappear(ArkUIDialogHandle handle, void* userData, void (*callback)(void* userData))
2098 {
2099     return CustomDialog::RegisterOnDidDisappearDialog(handle, userData, callback);
2100 }
2101 
SetDialogBorderWidth(ArkUIDialogHandle handle,ArkUI_Float32 top,ArkUI_Float32 right,ArkUI_Float32 bottom,ArkUI_Float32 left,ArkUI_Int32 unit)2102 ArkUI_Int32 SetDialogBorderWidth(ArkUIDialogHandle handle, ArkUI_Float32 top, ArkUI_Float32 right, ArkUI_Float32 bottom,
2103     ArkUI_Float32 left, ArkUI_Int32 unit)
2104 {
2105     return CustomDialog::SetDialogBorderWidth(handle, top, right, bottom, left, unit);
2106 }
2107 
SetDialogBorderColor(ArkUIDialogHandle handle,uint32_t top,uint32_t right,uint32_t bottom,uint32_t left)2108 ArkUI_Int32 SetDialogBorderColor(ArkUIDialogHandle handle, uint32_t top, uint32_t right, uint32_t bottom, uint32_t left)
2109 {
2110     return CustomDialog::SetDialogBorderColor(handle, top, right, bottom, left);
2111 }
2112 
SetDialogBorderStyle(ArkUIDialogHandle handle,int32_t top,int32_t right,int32_t bottom,int32_t left)2113 ArkUI_Int32 SetDialogBorderStyle(ArkUIDialogHandle handle, int32_t top, int32_t right, int32_t bottom, int32_t left)
2114 {
2115     return CustomDialog::SetDialogBorderStyle(handle, top, right, bottom, left);
2116 }
2117 
SetDialogWidth(ArkUIDialogHandle handle,float width,ArkUI_Int32 unit)2118 ArkUI_Int32 SetDialogWidth(ArkUIDialogHandle handle, float width, ArkUI_Int32 unit)
2119 {
2120     return CustomDialog::SetWidth(handle, width, unit);
2121 }
2122 
SetDialogHeight(ArkUIDialogHandle handle,float height,ArkUI_Int32 unit)2123 ArkUI_Int32 SetDialogHeight(ArkUIDialogHandle handle, float height, ArkUI_Int32 unit)
2124 {
2125     return CustomDialog::SetHeight(handle, height, unit);
2126 }
2127 
SetDialogShadow(ArkUIDialogHandle handle,ArkUI_Int32 shadow)2128 ArkUI_Int32 SetDialogShadow(ArkUIDialogHandle handle, ArkUI_Int32 shadow)
2129 {
2130     return CustomDialog::SetShadow(handle, shadow);
2131 }
2132 
SetDialogCustomShadow(ArkUIDialogHandle handle,const ArkUIInt32orFloat32 * shadows,ArkUI_Int32 length)2133 ArkUI_Int32 SetDialogCustomShadow(ArkUIDialogHandle handle, const ArkUIInt32orFloat32* shadows, ArkUI_Int32 length)
2134 {
2135     return CustomDialog::SetDialogCustomShadow(handle, shadows, length);
2136 }
2137 
SetDialogBackgroundBlurStyle(ArkUIDialogHandle handle,ArkUI_Int32 blurStyle)2138 ArkUI_Int32 SetDialogBackgroundBlurStyle(ArkUIDialogHandle handle, ArkUI_Int32 blurStyle)
2139 {
2140     return CustomDialog::SetBackgroundBlurStyle(handle, blurStyle);
2141 }
2142 
SetDialogKeyboardAvoidMode(ArkUIDialogHandle handle,ArkUI_Int32 keyboardAvoidMode)2143 ArkUI_Int32 SetDialogKeyboardAvoidMode(ArkUIDialogHandle handle, ArkUI_Int32 keyboardAvoidMode)
2144 {
2145     return CustomDialog::SetKeyboardAvoidMode(handle, keyboardAvoidMode);
2146 }
2147 
EnableDialogHoverMode(ArkUIDialogHandle handle,ArkUI_Bool enableHoverMode)2148 ArkUI_Int32 EnableDialogHoverMode(ArkUIDialogHandle handle, ArkUI_Bool enableHoverMode)
2149 {
2150     return CustomDialog::EnableHoverMode(handle, enableHoverMode);
2151 }
2152 
SetDialogHoverModeArea(ArkUIDialogHandle handle,ArkUI_Int32 hoverModeAreaType)2153 ArkUI_Int32 SetDialogHoverModeArea(ArkUIDialogHandle handle, ArkUI_Int32 hoverModeAreaType)
2154 {
2155     return CustomDialog::SetHoverModeArea(handle, hoverModeAreaType);
2156 }
2157 
SetDialogFocusable(ArkUIDialogHandle handle,ArkUI_Bool focusable)2158 ArkUI_Int32 SetDialogFocusable(ArkUIDialogHandle handle, ArkUI_Bool focusable)
2159 {
2160     return CustomDialog::SetFocusable(handle, focusable);
2161 }
2162 
GetDialogState(ArkUIDialogHandle handle,ArkUI_Int32 * dialogState)2163 ArkUI_Int32 GetDialogState(ArkUIDialogHandle handle, ArkUI_Int32* dialogState)
2164 {
2165     return CustomDialog::GetDialogState(handle, dialogState);
2166 }
2167 
OpenCustomDialog(ArkUIDialogHandle handle,void (* callback)(ArkUI_Int32 dialogId))2168 ArkUI_Int32 OpenCustomDialog(ArkUIDialogHandle handle, void(*callback)(ArkUI_Int32 dialogId))
2169 {
2170     return CustomDialog::OpenCustomDialog(handle, callback);
2171 }
2172 
UpdateCustomDialog(ArkUIDialogHandle handle,void (* callback)(int32_t dialogId))2173 ArkUI_Int32 UpdateCustomDialog(ArkUIDialogHandle handle, void(*callback)(int32_t dialogId))
2174 {
2175     return CustomDialog::UpdateCustomDialog(handle, callback);
2176 }
2177 
CloseCustomDialog(ArkUI_Int32 dialogId)2178 ArkUI_Int32 CloseCustomDialog(ArkUI_Int32 dialogId)
2179 {
2180     return CustomDialog::CloseCustomDialog(dialogId);
2181 }
2182 
SetDialogSubwindowMode(ArkUIDialogHandle handle,ArkUI_Bool showInSubWindow)2183 ArkUI_Int32 SetDialogSubwindowMode(ArkUIDialogHandle handle, ArkUI_Bool showInSubWindow)
2184 {
2185     return CustomDialog::SetDialogSubwindowMode(handle, showInSubWindow);
2186 }
2187 
SetBackgroundBlurStyleOptions(ArkUIDialogHandle handle,ArkUI_Int32 (* intArray)[3],ArkUI_Float32 scale,ArkUI_Uint32 (* uintArray)[3],ArkUI_Bool isValidColor)2188 ArkUI_Int32 SetBackgroundBlurStyleOptions(ArkUIDialogHandle handle, ArkUI_Int32 (*intArray)[3], ArkUI_Float32 scale,
2189     ArkUI_Uint32 (*uintArray)[3], ArkUI_Bool isValidColor)
2190 {
2191     return CustomDialog::SetBackgroundBlurStyleOptions(handle, intArray, scale, uintArray, isValidColor);
2192 }
2193 
SetBackgroundEffect(ArkUIDialogHandle handle,ArkUI_Float32 (* floatArray)[3],ArkUI_Int32 (* intArray)[2],ArkUI_Uint32 (* uintArray)[4],ArkUI_Bool isValidColor)2194 ArkUI_Int32 SetBackgroundEffect(ArkUIDialogHandle handle, ArkUI_Float32 (*floatArray)[3], ArkUI_Int32 (*intArray)[2],
2195     ArkUI_Uint32 (*uintArray)[4], ArkUI_Bool isValidColor)
2196 {
2197     return CustomDialog::SetBackgroundEffect(handle, floatArray, intArray, uintArray, isValidColor);
2198 }
2199 
GetDialogAPI()2200 const ArkUIDialogAPI* GetDialogAPI()
2201 {
2202     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2203     static const ArkUIDialogAPI dialogImpl = {
2204         .create = CreateDialog,
2205         .dispose = DisposeDialog,
2206         .setContent = SetDialogContent,
2207         .removeContent = RemoveDialogContent,
2208         .setContentAlignment = SetDialogContentAlignment,
2209         .resetContentAlignment = ResetDialogContentAlignment,
2210         .setModalMode = SetDialogModalMode,
2211         .setAutoCancel = SetDialogAutoCancel,
2212         .setMask = SetDialogMask,
2213         .setBackgroundColor = SetDialogBackgroundColor,
2214         .setBackgroundColorWIthColorSpace = SetDialogBackgroundColorWithColorSpace,
2215         .setCornerRadius = SetDialogCornerRadius,
2216         .setGridColumnCount = SetDialogGridColumnCount,
2217         .enableCustomStyle = EnableDialogCustomStyle,
2218         .enableCustomAnimation = EnableDialogCustomAnimation,
2219         .show = ShowDialog,
2220         .close = CloseDialog,
2221         .registerOnWillDismiss = RegisterOnWillDialogDismiss,
2222         .registerOnWillDismissWithUserData = RegisterOnWillDismissWithUserData,
2223         .getState = GetDialogState,
2224         .setKeyboardAvoidDistance = SetKeyboardAvoidDistance,
2225         .setLevelMode = SetDialogLevelMode,
2226         .setLevelUniqueId = SetDialogLevelUniqueId,
2227         .setImmersiveMode = SetDialogImmersiveMode,
2228         .setLevelOrder = SetLevelOrder,
2229         .registerOnWillAppear = RegisterOnWillAppear,
2230         .registerOnDidAppear = RegisterOnDidAppear,
2231         .registerOnWillDisappear = RegisterOnWillDisappear,
2232         .registerOnDidDisappear = RegisterOnDidDisappear,
2233         .setBorderWidth = SetDialogBorderWidth,
2234         .setBorderColor = SetDialogBorderColor,
2235         .setBorderStyle = SetDialogBorderStyle,
2236         .setWidth = SetDialogWidth,
2237         .setHeight = SetDialogHeight,
2238         .setShadow = SetDialogShadow,
2239         .setCustomShadow = SetDialogCustomShadow,
2240         .setBackgroundBlurStyle = SetDialogBackgroundBlurStyle,
2241         .setKeyboardAvoidMode = SetDialogKeyboardAvoidMode,
2242         .enableHoverMode = EnableDialogHoverMode,
2243         .setHoverModeArea = SetDialogHoverModeArea,
2244         .setFocusable = SetDialogFocusable,
2245         .openCustomDialog = OpenCustomDialog,
2246         .updateCustomDialog = UpdateCustomDialog,
2247         .closeCustomDialog = CloseCustomDialog,
2248         .setSubwindowMode = SetDialogSubwindowMode,
2249         .setBackgroundBlurStyleOptions = SetBackgroundBlurStyleOptions,
2250         .setBackgroundEffect = SetBackgroundEffect
2251     };
2252     CHECK_INITIALIZED_FIELDS_END(dialogImpl, 0, 0, 0); // don't move this line
2253     return &dialogImpl;
2254 }
2255 
ShowCrash(ArkUI_CharPtr message)2256 void ShowCrash(ArkUI_CharPtr message)
2257 {
2258     TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "Arkoala crash: %{public}s", message);
2259 }
2260 
2261 /* clang-format off */
2262 ArkUIExtendedNodeAPI impl_extended = {
2263     .version = ARKUI_EXTENDED_API_VERSION,
2264     .getUtilsModifier = NodeModifier::GetUtilsModifier, // getUtilsModifier
2265     .getCanvasRenderingContext2DModifier = NodeModifier::GetCanvasRenderingContext2DModifier,
2266     .setCallbackMethod = SetCallbackMethod,
2267     .setCustomMethodFlag = SetCustomMethodFlag,
2268     .getCustomMethodFlag = GetCustomMethodFlag,
2269     .registerCustomNodeAsyncEvent = RegisterCustomNodeAsyncEvent,
2270     .registerCustomSpanAsyncEvent = RegisterCustomSpanAsyncEvent,
2271     .unregisterCustomNodeAsyncEvent = UnregisterCustomNodeEvent,
2272     .registerCustomNodeAsyncEventReceiver = RegisterCustomNodeEventReceiver,
2273     .setCustomCallback = SetCustomCallback, // setCustomCallback
2274     .measureLayoutAndDraw = MeasureLayoutAndDraw,
2275     .measureNode = MeasureNode,
2276     .layoutNode = LayoutNode,
2277     .drawNode = DrawNode,
2278     .setAttachNodePtr = SetAttachNodePtr,
2279     .getAttachNodePtr = GetAttachNodePtr,
2280     .setMeasureWidth = SetMeasureWidth, // setMeasureWidth
2281     .getMeasureWidth = GetMeasureWidth, // getMeasureWidth
2282     .setMeasureHeight = SetMeasureHeight, // setMeasureHeight
2283     .getMeasureHeight = GetMeasureHeight, // getMeasureHeight
2284     .setX = SetX, // setX
2285     .setY = SetY, // setY
2286     .getX = GetX, // getX
2287     .getY = GetY, // getY
2288     .getLayoutConstraint = GetLayoutConstraint,
2289     .setAlignment = SetAlignment,
2290     .getAlignment = GetAlignment,
2291     .indexerChecker = nullptr, // indexerChecker
2292     .setRangeUpdater = nullptr, // setRangeUpdater
2293     .setLazyItemIndexer = nullptr, // setLazyItemIndexer
2294     .getPipelineContext = GetPipelineContext,
2295     .setVsyncCallback = SetVsyncCallback,
2296     .unblockVsyncWait = UnblockVsyncWait,
2297     .sendEvent = NodeEvent::SendArkUISyncEvent, // sendEvent
2298     .callContinuation = nullptr, // callContinuation
2299     .setChildTotalCount = nullptr, // setChildTotalCount
2300     .showCrash = ShowCrash,
2301     .getTopNodeFromViewStack = GetTopNodeByViewStack,
2302     .createCustomNode = CreateCustomNode,
2303     .getOrCreateCustomNode = GetOrCreateCustomNode,
2304     .getRSNodeByNode = GetRSNodeByNode,
2305     .isRightToLeft = IsRightToLeft,
2306     .createNewScope = CreateNewScope,
2307     .registerOEMVisualEffect = RegisterOEMVisualEffect,
2308     .setOnNodeDestroyCallback = SetOnNodeDestroyCallback,
2309     .createCustomNodeByNodeId = CreateCustomNodeByNodeId,
2310 };
2311 /* clang-format on */
2312 
CanvasDrawRect(ArkUICanvasHandle canvas,ArkUI_Float32 left,ArkUI_Float32 top,ArkUI_Float32 right,ArkUI_Float32 bottom,ArkUIPaintHandle paint)2313 void CanvasDrawRect(ArkUICanvasHandle canvas, ArkUI_Float32 left, ArkUI_Float32 top, ArkUI_Float32 right,
2314     ArkUI_Float32 bottom, ArkUIPaintHandle paint) {}
2315 
GetCanvasAPI()2316 const ArkUIGraphicsCanvas* GetCanvasAPI()
2317 {
2318     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2319     static const ArkUIGraphicsCanvas modifier = {
2320         .finalize = nullptr,
2321         .drawPoint = nullptr,
2322         .drawPoints = nullptr,
2323         .drawLine = nullptr,
2324         .drawArc = nullptr,
2325         .drawRect = CanvasDrawRect,
2326         .drawOval = nullptr,
2327         .drawCircle = nullptr,
2328         .drawRRect = nullptr,
2329         .drawDRRect = nullptr,
2330         .drawString = nullptr,
2331     };
2332     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2333     return &modifier;
2334 }
2335 
2336 struct DummyPaint {
2337     ArkUI_Int32 color;
2338 };
2339 
PaintMake()2340 ArkUIPaintHandle PaintMake()
2341 {
2342     return reinterpret_cast<ArkUIPaintHandle>(new DummyPaint());
2343 }
2344 
PaintFinalize(ArkUIPaintHandle paintPtr)2345 void PaintFinalize(ArkUIPaintHandle paintPtr)
2346 {
2347     auto* paint = reinterpret_cast<DummyPaint*>(paintPtr);
2348     delete paint;
2349 }
2350 
GetPaintAPI()2351 const ArkUIGraphicsPaint* GetPaintAPI()
2352 {
2353     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2354     static const ArkUIGraphicsPaint modifier = {
2355         .make = PaintMake,
2356         .finalize = PaintFinalize,
2357         .setColor = nullptr,
2358         .getColor = nullptr,
2359         .setAlpha = nullptr,
2360         .getAlpha = nullptr
2361     };
2362     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2363     return &modifier;
2364 }
2365 
GetFontAPI()2366 const ArkUIGraphicsFont* GetFontAPI()
2367 {
2368     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2369     static const ArkUIGraphicsFont modifier = {
2370         .makeDefault = nullptr,
2371         .finalize = nullptr,
2372     };
2373     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2374     return &modifier;
2375 }
2376 
GetGraphicsAPI()2377 const ArkUIGraphicsAPI* GetGraphicsAPI()
2378 {
2379     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2380     static const ArkUIGraphicsAPI api = {
2381         .version = ARKUI_NODE_GRAPHICS_API_VERSION,
2382         .setCallbackMethod = SetCallbackMethod,
2383         .getCanvasAPI = GetCanvasAPI,
2384         .getPaintAPI = GetPaintAPI,
2385         .getFontAPI = GetFontAPI
2386     };
2387     CHECK_INITIALIZED_FIELDS_END(api, 0, 0, 0); // don't move this line
2388     return &api;
2389 }
2390 
AnimateTo(ArkUIContext * context,ArkUIAnimateOption option,void * event,void * user)2391 void AnimateTo(ArkUIContext* context, ArkUIAnimateOption option, void* event, void* user)
2392 {
2393     ViewAnimate::AnimateTo(context, option, reinterpret_cast<void (*)(void*)>(event), user);
2394 }
2395 
KeyframeAnimateTo(ArkUIContext * context,ArkUIKeyframeAnimateOption * animateOption)2396 void KeyframeAnimateTo(ArkUIContext* context, ArkUIKeyframeAnimateOption* animateOption)
2397 {
2398     ViewAnimate::KeyframeAnimateTo(context, animateOption);
2399 }
2400 
CreateAnimator(ArkUIContext * context,ArkUIAnimatorOption * animateOption)2401 ArkUIAnimatorHandle CreateAnimator(ArkUIContext* context, ArkUIAnimatorOption* animateOption)
2402 {
2403     return ViewAnimate::CreateAnimator(context, animateOption);
2404 }
2405 
DisposeAnimator(ArkUIAnimatorHandle animator)2406 void DisposeAnimator(ArkUIAnimatorHandle animator)
2407 {
2408     ViewAnimate::DisposeAnimator(animator);
2409 }
2410 
AnimatorReset(ArkUIAnimatorHandle animator,ArkUIAnimatorOption * option)2411 ArkUI_Int32 AnimatorReset(ArkUIAnimatorHandle animator, ArkUIAnimatorOption* option)
2412 {
2413     return ViewAnimate::AnimatorReset(animator, option);
2414 }
2415 
AnimatorPlay(ArkUIAnimatorHandle animator)2416 ArkUI_Int32 AnimatorPlay(ArkUIAnimatorHandle animator)
2417 {
2418     return ViewAnimate::AnimatorPlay(animator);
2419 }
2420 
AnimatorFinish(ArkUIAnimatorHandle animator)2421 ArkUI_Int32 AnimatorFinish(ArkUIAnimatorHandle animator)
2422 {
2423     return ViewAnimate::AnimatorFinish(animator);
2424 }
2425 
AnimatorPause(ArkUIAnimatorHandle animator)2426 ArkUI_Int32 AnimatorPause(ArkUIAnimatorHandle animator)
2427 {
2428     return ViewAnimate::AnimatorPause(animator);
2429 }
2430 
AnimatorCancel(ArkUIAnimatorHandle animator)2431 ArkUI_Int32 AnimatorCancel(ArkUIAnimatorHandle animator)
2432 {
2433     return ViewAnimate::AnimatorCancel(animator);
2434 }
2435 
AnimatorReverse(ArkUIAnimatorHandle animator)2436 ArkUI_Int32 AnimatorReverse(ArkUIAnimatorHandle animator)
2437 {
2438     return ViewAnimate::AnimatorReverse(animator);
2439 }
2440 
CreateCurve(ArkUI_Int32 curve)2441 ArkUICurveHandle CreateCurve(ArkUI_Int32 curve)
2442 {
2443     return ViewAnimate::CreateCurve(curve);
2444 }
2445 
CreateStepsCurve(ArkUI_Int32 count,ArkUI_Bool end)2446 ArkUICurveHandle CreateStepsCurve(ArkUI_Int32 count, ArkUI_Bool end)
2447 {
2448     return ViewAnimate::CreateStepsCurve(count, end);
2449 }
2450 
CreateCubicBezierCurve(ArkUI_Float32 x1,ArkUI_Float32 y1,ArkUI_Float32 x2,ArkUI_Float32 y2)2451 ArkUICurveHandle CreateCubicBezierCurve(ArkUI_Float32 x1, ArkUI_Float32 y1, ArkUI_Float32 x2, ArkUI_Float32 y2)
2452 {
2453     return ViewAnimate::CreateCubicBezierCurve(x1, y1, x2, y2);
2454 }
2455 
CreateSpringCurve(ArkUI_Float32 velocity,ArkUI_Float32 mass,ArkUI_Float32 stiffness,ArkUI_Float32 damping)2456 ArkUICurveHandle CreateSpringCurve(
2457     ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
2458 {
2459     return ViewAnimate::CreateSpringCurve(velocity, mass, stiffness, damping);
2460 }
2461 
CreateSpringMotion(ArkUI_Float32 response,ArkUI_Float32 dampingFraction,ArkUI_Float32 overlapDuration)2462 ArkUICurveHandle CreateSpringMotion(
2463     ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
2464 {
2465     return ViewAnimate::CreateSpringMotion(response, dampingFraction, overlapDuration);
2466 }
2467 
CreateResponsiveSpringMotion(ArkUI_Float32 response,ArkUI_Float32 dampingFraction,ArkUI_Float32 overlapDuration)2468 ArkUICurveHandle CreateResponsiveSpringMotion(
2469     ArkUI_Float32 response, ArkUI_Float32 dampingFraction, ArkUI_Float32 overlapDuration)
2470 {
2471     return ViewAnimate::CreateResponsiveSpringMotion(response, dampingFraction, overlapDuration);
2472 }
2473 
CreateInterpolatingSpring(ArkUI_Float32 velocity,ArkUI_Float32 mass,ArkUI_Float32 stiffness,ArkUI_Float32 damping)2474 ArkUICurveHandle CreateInterpolatingSpring(
2475     ArkUI_Float32 velocity, ArkUI_Float32 mass, ArkUI_Float32 stiffness, ArkUI_Float32 damping)
2476 {
2477     return ViewAnimate::CreateInterpolatingSpring(velocity, mass, stiffness, damping);
2478 }
2479 
CreateCustomCurve(ArkUI_Float32 (* interpolate)(ArkUI_Float32 fraction,void * userData),void * userData)2480 ArkUICurveHandle CreateCustomCurve(ArkUI_Float32 (*interpolate)(ArkUI_Float32 fraction, void* userData), void* userData)
2481 {
2482     return ViewAnimate::CreateCustomCurve(interpolate, userData);
2483 }
2484 
DisposeCurve(ArkUICurveHandle curve)2485 void DisposeCurve(ArkUICurveHandle curve)
2486 {
2487     return ViewAnimate::DisposeCurve(curve);
2488 }
2489 
GetAnimationAPI()2490 const ArkUIAnimation* GetAnimationAPI()
2491 {
2492     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2493     static const ArkUIAnimation modifier = {
2494         .startAnimation = nullptr,
2495         .openImplicitAnimation = nullptr,
2496         .closeImplicitAnimation = nullptr,
2497         .animateTo = AnimateTo,
2498         .keyframeAnimateTo = KeyframeAnimateTo,
2499         .createAnimator = CreateAnimator,
2500         .disposeAnimator = DisposeAnimator,
2501         .animatorReset = AnimatorReset,
2502         .animatorPlay = AnimatorPlay,
2503         .animatorFinish = AnimatorFinish,
2504         .animatorPause = AnimatorPause,
2505         .animatorCancel = AnimatorCancel,
2506         .animatorReverse = AnimatorReverse,
2507         .initCurve = CreateCurve,
2508         .stepsCurve = CreateStepsCurve,
2509         .cubicBezierCurve = CreateCubicBezierCurve,
2510         .springCurve = CreateSpringCurve,
2511         .springMotion = CreateSpringMotion,
2512         .responsiveSpringMotion = CreateResponsiveSpringMotion,
2513         .interpolatingSpring = CreateInterpolatingSpring,
2514         .customCurve = CreateCustomCurve,
2515         .disposeCurve = DisposeCurve,
2516     };
2517     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2518     return &modifier;
2519 }
2520 
GetNavigationAPI()2521 const ArkUINavigation* GetNavigationAPI()
2522 {
2523     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2524     static const ArkUINavigation modifier = {
2525         .popPageToIndex = nullptr,
2526         .setNavDestinationBackPressed = nullptr,
2527         .getNavigationId = GetNavigationId,
2528         .getNavDestinationName = GetNavDestinationName,
2529         .getStackLength = GetStackLength,
2530         .getNavDesNameByIndex = GetNavDesNameByIndex,
2531         .getNavDestinationId = GetNavDestinationId,
2532         .getNavDestinationState = GetNavDestinationState,
2533         .getNavDestinationIndex = GetNavDestinationIndex,
2534         .getNavDestinationParam = GetNavDestinationParam,
2535         .getRouterPageIndex = GetRouterPageIndex,
2536         .getRouterPageName = GetRouterPageName,
2537         .getRouterPagePath = GetRouterPagePath,
2538         .getRouterPageState = GetRouterPageState,
2539         .getRouterPageId = GetRouterPageId,
2540     };
2541     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2542     return &modifier;
2543 }
2544 
GetExtendedAPI()2545 const ArkUIExtendedNodeAPI* GetExtendedAPI()
2546 {
2547     return &impl_extended;
2548 }
2549 
CreateArkUIStyledStringDescriptor()2550 ArkUI_StyledString_Descriptor* CreateArkUIStyledStringDescriptor()
2551 {
2552     TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "ArkUI_StyledString_Descriptor create");
2553     return new ArkUI_StyledString_Descriptor;
2554 }
2555 
DestroyArkUIStyledStringDescriptor(ArkUI_StyledString_Descriptor * descriptor)2556 void DestroyArkUIStyledStringDescriptor(ArkUI_StyledString_Descriptor* descriptor)
2557 {
2558     TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "ArkUI_StyledString_Descriptor destroy");
2559     CHECK_NULL_VOID(descriptor);
2560     if (descriptor->html) {
2561         delete descriptor->html;
2562         descriptor->html = nullptr;
2563     }
2564     if (descriptor->spanString) {
2565         auto* spanString = reinterpret_cast<SpanString*>(descriptor->spanString);
2566         delete spanString;
2567         descriptor->spanString = nullptr;
2568     }
2569     delete descriptor;
2570     descriptor = nullptr;
2571 }
2572 
UnmarshallStyledStringDescriptor(uint8_t * buffer,size_t bufferSize,ArkUI_StyledString_Descriptor * descriptor)2573 ArkUI_Int32 UnmarshallStyledStringDescriptor(
2574     uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor)
2575 {
2576     TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "UnmarshallStyledStringDescriptor");
2577     CHECK_NULL_RETURN(buffer && descriptor && bufferSize > 0, ARKUI_ERROR_CODE_PARAM_INVALID);
2578     std::vector<uint8_t> vec(buffer, buffer + bufferSize);
2579     SpanString* spanString = new SpanString(u"");
2580     std::function<RefPtr<ExtSpan>(const std::vector<uint8_t>&, int32_t, int32_t)> unmarshallCallback;
2581     spanString->DecodeTlvExt(vec, spanString, std::move(unmarshallCallback));
2582     descriptor->spanString = reinterpret_cast<void*>(spanString);
2583     return ARKUI_ERROR_CODE_NO_ERROR;
2584 }
2585 
MarshallStyledStringDescriptor(uint8_t * buffer,size_t bufferSize,ArkUI_StyledString_Descriptor * descriptor,size_t * resultSize)2586 ArkUI_Int32 MarshallStyledStringDescriptor(
2587     uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor, size_t* resultSize)
2588 {
2589     TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "MarshallStyledStringDescriptor");
2590     CHECK_NULL_RETURN(buffer && resultSize && descriptor, ARKUI_ERROR_CODE_PARAM_INVALID);
2591     CHECK_NULL_RETURN(descriptor->spanString, ARKUI_ERROR_CODE_INVALID_STYLED_STRING);
2592     auto spanStringRawPtr = reinterpret_cast<SpanString*>(descriptor->spanString);
2593     std::vector<uint8_t> tlvData;
2594     spanStringRawPtr->EncodeTlv(tlvData);
2595     *resultSize = tlvData.size();
2596     if (bufferSize < *resultSize) {
2597         return ARKUI_ERROR_CODE_PARAM_INVALID;
2598     }
2599     auto data = tlvData.data();
2600     std::copy(data, data + *resultSize, buffer);
2601     return ARKUI_ERROR_CODE_NO_ERROR;
2602 }
2603 
ConvertToHtml(ArkUI_StyledString_Descriptor * descriptor)2604 const char* ConvertToHtml(ArkUI_StyledString_Descriptor* descriptor)
2605 {
2606     TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "ConvertToHtml");
2607     CHECK_NULL_RETURN(descriptor && descriptor->spanString, "");
2608     auto spanStringRawPtr = reinterpret_cast<SpanString*>(descriptor->spanString);
2609     auto htmlStr = HtmlUtils::ToHtml(spanStringRawPtr);
2610     char* html = new char[htmlStr.length() + 1];
2611     CHECK_NULL_RETURN(html, "");
2612     std::copy(htmlStr.begin(), htmlStr.end(), html);
2613     html[htmlStr.length()] = '\0';
2614     descriptor->html = html;
2615     return descriptor->html;
2616 }
2617 
GetStyledStringAPI()2618 const ArkUIStyledStringAPI* GetStyledStringAPI()
2619 {
2620     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2621     static const ArkUIStyledStringAPI impl {
2622         .createArkUIStyledStringDescriptor = CreateArkUIStyledStringDescriptor,
2623         .destroyArkUIStyledStringDescriptor = DestroyArkUIStyledStringDescriptor,
2624         .unmarshallStyledStringDescriptor = UnmarshallStyledStringDescriptor,
2625         .marshallStyledStringDescriptor = MarshallStyledStringDescriptor,
2626         .convertToHtml = ConvertToHtml
2627     };
2628     CHECK_INITIALIZED_FIELDS_END(impl, 0, 0, 0); // don't move this line
2629     return &impl;
2630 }
2631 
CreateSnapshotOptions()2632 ArkUISnapshotOptions* CreateSnapshotOptions()
2633 {
2634     ArkUISnapshotOptions* snapshotOptions = new ArkUISnapshotOptions();
2635     snapshotOptions->scale = 1.0f;
2636     return snapshotOptions;
2637 }
2638 
DestroySnapshotOptions(ArkUISnapshotOptions * snapshotOptions)2639 void DestroySnapshotOptions(ArkUISnapshotOptions* snapshotOptions)
2640 {
2641     if (snapshotOptions != nullptr) {
2642         delete snapshotOptions;
2643         snapshotOptions = nullptr;
2644     }
2645 }
2646 
SnapshotOptionsSetScale(ArkUISnapshotOptions * snapshotOptions,ArkUI_Float32 scale)2647 ArkUI_Int32 SnapshotOptionsSetScale(ArkUISnapshotOptions* snapshotOptions, ArkUI_Float32 scale)
2648 {
2649     if (snapshotOptions == nullptr || !OHOS::Ace::GreatNotEqual(scale, 0.0)) {
2650         return ArkUI_ErrorCode::ARKUI_ERROR_CODE_PARAM_INVALID;
2651     }
2652     snapshotOptions->scale = scale;
2653     return ArkUI_ErrorCode::ARKUI_ERROR_CODE_NO_ERROR;
2654 }
2655 
GetNodeSnapshot(ArkUINodeHandle node,ArkUISnapshotOptions * snapshotOptions,void * mediaPixel)2656 ArkUI_Int32 GetNodeSnapshot(ArkUINodeHandle node, ArkUISnapshotOptions* snapshotOptions, void* mediaPixel)
2657 {
2658     auto frameNode =
2659         OHOS::Ace::AceType::Claim<OHOS::Ace::NG::FrameNode>(reinterpret_cast<OHOS::Ace::NG::FrameNode*>(node));
2660     auto delegate = EngineHelper::GetCurrentDelegateSafely();
2661     NG::SnapshotOptions options;
2662     options.scale = snapshotOptions != nullptr ? snapshotOptions->scale : 1.0f;
2663     options.waitUntilRenderFinished = true;
2664     auto result = delegate->GetSyncSnapshot(frameNode, options);
2665     *reinterpret_cast<std::shared_ptr<Media::PixelMap>*>(mediaPixel) = result.second;
2666     return result.first;
2667 }
2668 
GetComponentSnapshotAPI()2669 const ArkUISnapshotAPI* GetComponentSnapshotAPI()
2670 {
2671     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2672     static const ArkUISnapshotAPI impl {
2673         .createSnapshotOptions = CreateSnapshotOptions,
2674         .destroySnapshotOptions = DestroySnapshotOptions,
2675         .snapshotOptionsSetScale = SnapshotOptionsSetScale,
2676         .getSyncSnapshot = GetNodeSnapshot
2677     };
2678     CHECK_INITIALIZED_FIELDS_END(impl, 0, 0, 0); // don't move this line
2679     return &impl;
2680 }
2681 
2682 /* clang-format off */
2683 ArkUIFullNodeAPI impl_full = {
2684     .version = ARKUI_NODE_API_VERSION,
2685     .setCallbackMethod = SetCallbackMethod,      // CallbackMethod
2686     .getBasicAPI = GetBasicAPI,            // BasicAPI
2687     .getNodeModifiers = GetArkUINodeModifiers,  // NodeModifiers
2688     .getAnimation = GetAnimationAPI,        // Animation
2689     .getNavigation = GetNavigationAPI,       // Navigation
2690     .getGraphicsAPI = GetGraphicsAPI,         // Graphics
2691     .getDialogAPI = GetDialogAPI,
2692     .getExtendedAPI = GetExtendedAPI,         // Extended
2693     .getNodeAdapterAPI = NodeAdapter::GetNodeAdapterAPI,         // adapter.
2694     .getDragAdapterAPI = DragAdapter::GetDragAdapterAPI,        // drag adapter.
2695     .getStyledStringAPI = GetStyledStringAPI,     // StyledStringAPI
2696     .getSnapshotAPI = GetComponentSnapshotAPI,     // SyncSnapshot
2697     .getMultiThreadManagerAPI = GetMultiThreadManagerAPI, // MultiThreadManagerAPI
2698     .getRuntimeInit = RuntimeInit::GetRuntimeInit, // RuntimeInit
2699 };
2700 /* clang-format on */
2701 
GetCJUIAnimationAPI()2702 const CJUIAnimation* GetCJUIAnimationAPI()
2703 {
2704     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2705     static const CJUIAnimation modifier = {
2706         .startAnimation = nullptr,
2707         .openImplicitAnimation = nullptr,
2708         .closeImplicitAnimation = nullptr,
2709         .animateTo = AnimateTo,
2710         .keyframeAnimateTo = KeyframeAnimateTo,
2711         .createAnimator = CreateAnimator,
2712         .disposeAnimator = DisposeAnimator,
2713         .animatorReset = AnimatorReset,
2714         .animatorPlay = AnimatorPlay,
2715         .animatorFinish = AnimatorFinish,
2716         .animatorPause = AnimatorPause,
2717         .animatorCancel = AnimatorCancel,
2718         .animatorReverse = AnimatorReverse,
2719         .initCurve = CreateCurve,
2720         .stepsCurve = CreateStepsCurve,
2721         .cubicBezierCurve = CreateCubicBezierCurve,
2722         .springCurve = CreateSpringCurve,
2723         .springMotion = CreateSpringMotion,
2724         .responsiveSpringMotion = CreateResponsiveSpringMotion,
2725         .interpolatingSpring = CreateInterpolatingSpring,
2726         .customCurve = CreateCustomCurve,
2727         .disposeCurve = DisposeCurve,
2728     };
2729     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2730     return &modifier;
2731 }
2732 
GetCJUINavigationAPI()2733 const CJUINavigation* GetCJUINavigationAPI()
2734 {
2735     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2736     static const CJUINavigation modifier = {
2737         .popPageToIndex = nullptr,
2738         .setNavDestinationBackPressed = nullptr,
2739         .getNavigationId = GetNavigationId,
2740         .getNavDestinationName = GetNavDestinationName,
2741         .getStackLength = GetStackLength,
2742         .getNavDesNameByIndex = GetNavDesNameByIndex,
2743         .getNavDestinationId = GetNavDestinationId,
2744         .getNavDestinationState = GetNavDestinationState,
2745         .getNavDestinationIndex =GetNavDestinationIndex,
2746         .getNavDestinationParam = GetNavDestinationParam,
2747         .getRouterPageIndex = GetRouterPageIndex,
2748         .getRouterPageName = GetRouterPageName,
2749         .getRouterPagePath = GetRouterPagePath,
2750         .getRouterPageState = GetRouterPageState,
2751         .getRouterPageId = GetRouterPageId,
2752     };
2753     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2754     return &modifier;
2755 }
2756 
GetCJUIGraphicsAPI()2757 const CJUIGraphicsAPI* GetCJUIGraphicsAPI()
2758 {
2759     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2760     static const CJUIGraphicsAPI api = {
2761         .version = ARKUI_NODE_GRAPHICS_API_VERSION,
2762         .setCallbackMethod = SetCallbackMethod,
2763         .getCanvasAPI = GetCanvasAPI,
2764         .getPaintAPI = GetPaintAPI,
2765         .getFontAPI = GetFontAPI
2766     };
2767     CHECK_INITIALIZED_FIELDS_END(api, 0, 0, 0); // don't move this line
2768     return &api;
2769 }
2770 
GetCJUIDialogAPI()2771 const CJUIDialogAPI* GetCJUIDialogAPI()
2772 {
2773     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2774     static const CJUIDialogAPI dialogImpl = {
2775         .create = CreateDialog,
2776         .dispose = DisposeDialog,
2777         .setContent = SetDialogContent,
2778         .removeContent = RemoveDialogContent,
2779         .setContentAlignment = SetDialogContentAlignment,
2780         .resetContentAlignment = ResetDialogContentAlignment,
2781         .setModalMode = SetDialogModalMode,
2782         .setAutoCancel = SetDialogAutoCancel,
2783         .setMask = SetDialogMask,
2784         .setBackgroundColor = SetDialogBackgroundColor,
2785         .setBackgroundColorWithColorSpace = SetDialogBackgroundColorWithColorSpace,
2786         .setCornerRadius = SetDialogCornerRadius,
2787         .setGridColumnCount = SetDialogGridColumnCount,
2788         .enableCustomStyle = EnableDialogCustomStyle,
2789         .enableCustomAnimation = EnableDialogCustomAnimation,
2790         .show = ShowDialog,
2791         .close = CloseDialog,
2792         .registerOnWillDismiss = RegisterOnWillDialogDismiss,
2793     };
2794     CHECK_INITIALIZED_FIELDS_END(dialogImpl, 0, 0, 0); // don't move this line
2795     return &dialogImpl;
2796 }
2797 
GetCJUIExtendedAPI()2798 const CJUIExtendedNodeAPI* GetCJUIExtendedAPI()
2799 {
2800     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2801     static CJUIExtendedNodeAPI impl_extended = {
2802         .version = ARKUI_EXTENDED_API_VERSION,
2803         .getUtilsModifier = NodeModifier::GetUtilsModifier,
2804         .getCanvasRenderingContext2DModifier = NodeModifier::GetCanvasRenderingContext2DModifier,
2805         .setCallbackMethod = SetCallbackMethod,
2806         .setCustomMethodFlag = SetCustomMethodFlag,
2807         .getCustomMethodFlag = GetCustomMethodFlag,
2808         .registerCustomNodeAsyncEvent = RegisterCustomNodeAsyncEvent,
2809         .unregisterCustomNodeAsyncEvent = UnregisterCustomNodeEvent,
2810         .registerCustomNodeAsyncEventReceiver = RegisterCustomNodeEventReceiver,
2811         .setCustomCallback = SetCustomCallback, // setCustomCallback
2812         .measureLayoutAndDraw = MeasureLayoutAndDraw,
2813         .measureNode = MeasureNode,
2814         .layoutNode = LayoutNode,
2815         .drawNode = DrawNode,
2816         .setAttachNodePtr = SetAttachNodePtr,
2817         .getAttachNodePtr = GetAttachNodePtr,
2818         .setMeasureWidth = SetMeasureWidth, // setMeasureWidth
2819         .getMeasureWidth = GetMeasureWidth, // getMeasureWidth
2820         .setMeasureHeight = SetMeasureHeight, // setMeasureHeight
2821         .getMeasureHeight = GetMeasureHeight, // getMeasureHeight
2822         .setX = SetX, // setX
2823         .setY = SetY, // setY
2824         .getX = GetX, // getX
2825         .getY = GetY, // getY
2826         .getLayoutConstraint = GetLayoutConstraint,
2827         .setAlignment = SetAlignment,
2828         .getAlignment = GetAlignment,
2829         .indexerChecker = nullptr, // indexerChecker
2830         .setRangeUpdater = nullptr, // setRangeUpdater
2831         .setLazyItemIndexer = nullptr, // setLazyItemIndexer
2832         .getPipelineContext = GetPipelineContext,
2833         .setVsyncCallback = SetVsyncCallback,
2834         .unblockVsyncWait = UnblockVsyncWait,
2835         .sendEvent = NodeEvent::SendArkUISyncEvent,
2836         .callContinuation = nullptr, // callContinuation
2837         .setChildTotalCount = nullptr, // setChildTotalCount
2838         .showCrash = ShowCrash,
2839     };
2840     CHECK_INITIALIZED_FIELDS_END(impl_extended, 0, 0, 0); // don't move this line
2841     return &impl_extended;
2842 }
2843 
2844 CJUIFullNodeAPI fullCJUIApi {
2845     .setCallbackMethod = SetCallbackMethod,
2846     .getBasicAPI = GetCJUIBasicAPI,            // BasicAPI
2847     .getNodeModifiers = GetCJUINodeModifiers,       // NodeModifiers
2848     .getAnimation = GetCJUIAnimationAPI,        // Animation
2849     .getNavigation = GetCJUINavigationAPI,       // Navigation
2850     .getGraphicsAPI = GetCJUIGraphicsAPI,         // Graphics
2851     .getDialogAPI = GetCJUIDialogAPI,
2852     .getExtendedAPI = GetCJUIExtendedAPI,         // Extended
2853     .getNodeAdapterAPI = NodeAdapter::GetCJUINodeAdapterAPI,         // adapter.
2854 };
2855 } // namespace
2856 
2857 } // namespace OHOS::Ace::NG
2858 
2859 extern "C" {
2860 
GetCJUIFullNodeAPI()2861 ACE_FORCE_EXPORT CJUIFullNodeAPI* GetCJUIFullNodeAPI()
2862 {
2863     return &OHOS::Ace::NG::fullCJUIApi;
2864 }
2865 
GetArkUIAnyFullNodeAPI(int version)2866 ACE_FORCE_EXPORT ArkUIAnyAPI* GetArkUIAnyFullNodeAPI(int version)
2867 {
2868     switch (version) {
2869         case ARKUI_NODE_API_VERSION:
2870             return reinterpret_cast<ArkUIAnyAPI*>(&OHOS::Ace::NG::impl_full);
2871         default: {
2872             TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE,
2873                 "Requested version %{public}d is not supported, we're version %{public}d", version,
2874                 ARKUI_NODE_API_VERSION);
2875             return nullptr;
2876         }
2877     }
2878 }
2879 
GetArkUIFullNodeAPI()2880 const ArkUIFullNodeAPI* GetArkUIFullNodeAPI()
2881 {
2882     return &OHOS::Ace::NG::impl_full;
2883 }
2884 
SendArkUISyncEvent(ArkUINodeEvent * event)2885 void SendArkUISyncEvent(ArkUINodeEvent* event)
2886 {
2887     OHOS::Ace::NG::NodeEvent::SendArkUISyncEvent(event);
2888 }
2889 
SendArkUIAsyncCustomEvent(ArkUICustomNodeEvent * event)2890 void SendArkUIAsyncCustomEvent(ArkUICustomNodeEvent* event)
2891 {
2892     OHOS::Ace::NG::CustomNodeEvent::SendArkUISyncEvent(event);
2893 }
2894 
GetArkUIAPI(ArkUIAPIVariantKind kind,ArkUI_Int32 version)2895 ACE_FORCE_EXPORT const ArkUIAnyAPI* GetArkUIAPI(ArkUIAPIVariantKind kind, ArkUI_Int32 version)
2896 {
2897     switch (kind) {
2898         case ArkUIAPIVariantKind::BASIC: {
2899             switch (version) {
2900                 case ARKUI_BASIC_API_VERSION:
2901                     return reinterpret_cast<const ArkUIAnyAPI*>(OHOS::Ace::NG::GetBasicAPI());
2902                 default: {
2903                     TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE,
2904                         "Requested basic version %{public}d is not supported, we're version %{public}d\n", version,
2905                         ARKUI_BASIC_API_VERSION);
2906 
2907                     return nullptr;
2908                 }
2909             }
2910         }
2911         case ArkUIAPIVariantKind::FULL: {
2912             switch (version) {
2913                 case ARKUI_FULL_API_VERSION:
2914                     return reinterpret_cast<const ArkUIAnyAPI*>(&OHOS::Ace::NG::impl_full);
2915                 default: {
2916                     TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE,
2917                         "Requested full version %{public}d is not supported, we're version %{public}d\n", version,
2918                         ARKUI_FULL_API_VERSION);
2919 
2920                     return nullptr;
2921                 }
2922             }
2923         }
2924         case ArkUIAPIVariantKind::GRAPHICS: {
2925             switch (version) {
2926                 case ARKUI_NODE_GRAPHICS_API_VERSION:
2927                     return reinterpret_cast<const ArkUIAnyAPI*>(OHOS::Ace::NG::GetGraphicsAPI());
2928                 default: {
2929                     TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE,
2930                         "Requested graphics version %{public}d is not supported, we're version %{public}d\n", version,
2931                         ARKUI_NODE_GRAPHICS_API_VERSION);
2932 
2933                     return nullptr;
2934                 }
2935             }
2936         }
2937         case ArkUIAPIVariantKind::EXTENDED: {
2938             switch (version) {
2939                 case ARKUI_EXTENDED_API_VERSION:
2940                     return reinterpret_cast<const ArkUIAnyAPI*>(&OHOS::Ace::NG::impl_extended);
2941                 default: {
2942                     TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE,
2943                         "Requested extended version %{public}d is not supported, we're version %{public}d\n", version,
2944                         ARKUI_EXTENDED_API_VERSION);
2945 
2946                     return nullptr;
2947                 }
2948             }
2949         }
2950         default: {
2951             TAG_LOGE(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "API kind %{public}d is not supported\n",
2952                 static_cast<int>(kind));
2953 
2954             return nullptr;
2955         }
2956     }
2957 }
2958 
provideEntryPoint(void)2959 __attribute__((constructor)) static void provideEntryPoint(void)
2960 {
2961 #ifdef WINDOWS_PLATFORM
2962     // mingw has no setenv :(.
2963     static char entryPointString[64];
2964     if (snprintf_s(entryPointString, sizeof entryPointString, sizeof entryPointString - 1,
2965         "__LIBACE_ENTRY_POINT=%llx", static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(&GetArkUIAPI))) < 0) {
2966         return;
2967     }
2968     putenv(entryPointString);
2969 #else
2970     char entryPointString[64];
2971     if (snprintf_s(entryPointString, sizeof entryPointString, sizeof entryPointString - 1,
2972         "%llx", static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(&GetArkUIAPI))) < 0) {
2973         return;
2974     }
2975     setenv("__LIBACE_ENTRY_POINT", entryPointString, 1);
2976 #endif
2977 }
2978 }
2979