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