• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 
17 #include <cstdlib>
18 #include "node_model.h"
19 #include "node_extened.h"
20 
21 #include "base/utils/utils.h"
22 #include "base/error/error_code.h"
23 #include "core/components_v2/inspector/inspector_constants.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
OH_ArkUI_NodeUtils_GetLayoutSize(ArkUI_NodeHandle node,ArkUI_IntSize * size)29 int32_t OH_ArkUI_NodeUtils_GetLayoutSize(ArkUI_NodeHandle node, ArkUI_IntSize* size)
30 {
31     if (node == nullptr) {
32         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
33     }
34     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
35     ArkUI_Int32* tempSize = new ArkUI_Int32[2];
36     impl->getNodeModifiers()->getFrameNodeModifier()->getLayoutSize(node->uiNodeHandle, tempSize);
37     size->width = tempSize[0];
38     size->height = tempSize[1];
39     return OHOS::Ace::ERROR_CODE_NO_ERROR;
40 }
41 
OH_ArkUI_NodeUtils_GetLayoutPosition(ArkUI_NodeHandle node,ArkUI_IntOffset * localOffset)42 int32_t OH_ArkUI_NodeUtils_GetLayoutPosition(ArkUI_NodeHandle node, ArkUI_IntOffset* localOffset)
43 {
44     if (node == nullptr) {
45         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
46     }
47     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
48     auto value = impl->getNodeModifiers()->getFrameNodeModifier()->getLayoutPositionWithoutMargin(node->uiNodeHandle);
49     localOffset->x = static_cast<int32_t>(value[0]);
50     localOffset->y = static_cast<int32_t>(value[1]);
51 
52     return OHOS::Ace::ERROR_CODE_NO_ERROR;
53 }
54 
OH_ArkUI_NodeUtils_GetLayoutPositionInWindow(ArkUI_NodeHandle node,ArkUI_IntOffset * globalOffset)55 int32_t OH_ArkUI_NodeUtils_GetLayoutPositionInWindow(ArkUI_NodeHandle node, ArkUI_IntOffset* globalOffset)
56 {
57     if (node == nullptr) {
58         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
59     }
60     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
61     ArkUI_Float32 tempOffset[2];
62     impl->getNodeModifiers()->getFrameNodeModifier()->getPositionToWindow(node->uiNodeHandle, &tempOffset, false);
63     globalOffset->x = tempOffset[0];
64     globalOffset->y = tempOffset[1];
65 
66     return OHOS::Ace::ERROR_CODE_NO_ERROR;
67 }
68 
OH_ArkUI_NodeUtils_GetLayoutPositionInScreen(ArkUI_NodeHandle node,ArkUI_IntOffset * screenOffset)69 int32_t OH_ArkUI_NodeUtils_GetLayoutPositionInScreen(ArkUI_NodeHandle node, ArkUI_IntOffset* screenOffset)
70 {
71     if (node == nullptr) {
72         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
73     }
74     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
75     ArkUI_Float32 tempOffset[2];
76     impl->getNodeModifiers()->getFrameNodeModifier()->getPositionToScreen(node->uiNodeHandle, &tempOffset, false);
77     screenOffset->x = tempOffset[0];
78     screenOffset->y = tempOffset[1];
79 
80     return OHOS::Ace::ERROR_CODE_NO_ERROR;
81 }
82 
OH_ArkUI_NodeUtils_GetPositionWithTranslateInWindow(ArkUI_NodeHandle node,ArkUI_IntOffset * translateOffset)83 int32_t OH_ArkUI_NodeUtils_GetPositionWithTranslateInWindow(ArkUI_NodeHandle node, ArkUI_IntOffset* translateOffset)
84 {
85     if (node == nullptr) {
86         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
87     }
88     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
89     ArkUI_Float32 tempOffset[2];
90     impl->getNodeModifiers()->getFrameNodeModifier()->getPositionToWindowWithTransform(
91         node->uiNodeHandle, &tempOffset, false);
92     translateOffset->x = tempOffset[0];
93     translateOffset->y = tempOffset[1];
94 
95     return OHOS::Ace::ERROR_CODE_NO_ERROR;
96 }
97 
OH_ArkUI_NodeUtils_GetPositionWithTranslateInScreen(ArkUI_NodeHandle node,ArkUI_IntOffset * translateOffset)98 int32_t OH_ArkUI_NodeUtils_GetPositionWithTranslateInScreen(ArkUI_NodeHandle node, ArkUI_IntOffset* translateOffset)
99 {
100     if (node == nullptr) {
101         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
102     }
103     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
104     ArkUI_Float32 tempOffset[2];
105     impl->getNodeModifiers()->getFrameNodeModifier()->getPositionToScreenWithTransform(
106         node->uiNodeHandle, &tempOffset, false);
107     translateOffset->x = tempOffset[0];
108     translateOffset->y = tempOffset[1];
109 
110     return OHOS::Ace::ERROR_CODE_NO_ERROR;
111 }
112 
OH_ArkUI_RegisterSystemColorModeChangeEvent(ArkUI_NodeHandle node,void * userData,void (* onColorModeChange)(ArkUI_SystemColorMode colorMode,void * userData))113 int32_t OH_ArkUI_RegisterSystemColorModeChangeEvent(
114     ArkUI_NodeHandle node, void* userData, void (*onColorModeChange)(ArkUI_SystemColorMode colorMode, void* userData))
115 {
116     if (node == nullptr) {
117         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
118     }
119     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
120     impl->getNodeModifiers()->getFrameNodeModifier()->setSystemColorModeChangeEvent(
121         node->uiNodeHandle, userData, reinterpret_cast<void*>(onColorModeChange));
122 
123     return OHOS::Ace::ERROR_CODE_NO_ERROR;
124 }
125 
OH_ArkUI_UnregisterSystemColorModeChangeEvent(ArkUI_NodeHandle node)126 void OH_ArkUI_UnregisterSystemColorModeChangeEvent(ArkUI_NodeHandle node)
127 {
128     if (node == nullptr) {
129         return;
130     }
131     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
132     impl->getNodeModifiers()->getFrameNodeModifier()->resetSystemColorModeChangeEvent(node->uiNodeHandle);
133 }
134 
OH_ArkUI_RegisterDrawCallbackOnNodeHandle(ArkUI_NodeHandle node,void * userData,void (* onDrawCompleted)(void * userData))135 int32_t OH_ArkUI_RegisterDrawCallbackOnNodeHandle(
136     ArkUI_NodeHandle node, void* userData, void (*onDrawCompleted)(void* userData))
137 {
138     if (node == nullptr) {
139         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
140     }
141     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
142     impl->getNodeModifiers()->getFrameNodeModifier()->setDrawCompleteEvent(
143         node->uiNodeHandle, userData, reinterpret_cast<void*>(onDrawCompleted));
144 
145     return OHOS::Ace::ERROR_CODE_NO_ERROR;
146 }
147 
148 
OH_ArkUI_UnregisterDrawCallbackOnNodeHandle(ArkUI_NodeHandle node)149 int32_t OH_ArkUI_UnregisterDrawCallbackOnNodeHandle(ArkUI_NodeHandle node)
150 {
151     if (node == nullptr) {
152         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
153     }
154     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
155     impl->getNodeModifiers()->getFrameNodeModifier()->resetDrawCompleteEvent(node->uiNodeHandle);
156     return OHOS::Ace::ERROR_CODE_NO_ERROR;
157 }
158 
OH_ArkUI_RegisterLayoutCallbackOnNodeHandle(ArkUI_NodeHandle node,void * userData,void (* onLayoutCompleted)(void * userData))159 int32_t OH_ArkUI_RegisterLayoutCallbackOnNodeHandle(
160     ArkUI_NodeHandle node, void* userData, void (*onLayoutCompleted)(void* userData))
161 {
162     if (node == nullptr) {
163         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
164     }
165     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
166     impl->getNodeModifiers()->getFrameNodeModifier()->setLayoutEvent(
167         node->uiNodeHandle, userData, reinterpret_cast<void*>(onLayoutCompleted));
168 
169     return OHOS::Ace::ERROR_CODE_NO_ERROR;
170 }
171 
172 
OH_ArkUI_UnregisterLayoutCallbackOnNodeHandle(ArkUI_NodeHandle node)173 int32_t OH_ArkUI_UnregisterLayoutCallbackOnNodeHandle(ArkUI_NodeHandle node)
174 {
175     if (node == nullptr) {
176         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
177     }
178     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
179     impl->getNodeModifiers()->getFrameNodeModifier()->resetLayoutEvent(node->uiNodeHandle);
180     return OHOS::Ace::ERROR_CODE_NO_ERROR;
181 }
182 
OH_ArkUI_RegisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node,void * userData,void (* onFontStyleChange)(ArkUI_SystemFontStyleEvent * event,void * userData))183 int32_t OH_ArkUI_RegisterSystemFontStyleChangeEvent(
184     ArkUI_NodeHandle node, void* userData, void (*onFontStyleChange)(ArkUI_SystemFontStyleEvent* event, void* userData))
185 {
186     if (node == nullptr) {
187         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
188     }
189     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
190     impl->getNodeModifiers()->getFrameNodeModifier()->setSystemFontStyleChangeEvent(
191         node->uiNodeHandle, userData, reinterpret_cast<void*>(onFontStyleChange));
192 
193     return OHOS::Ace::ERROR_CODE_NO_ERROR;
194 }
195 
OH_ArkUI_UnregisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node)196 void OH_ArkUI_UnregisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node)
197 {
198     if (node == nullptr) {
199         return;
200     }
201     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
202     impl->getNodeModifiers()->getFrameNodeModifier()->resetSystemFontStyleChangeEvent(node->uiNodeHandle);
203 }
204 
OH_ArkUI_SystemFontStyleEvent_GetFontSizeScale(const ArkUI_SystemFontStyleEvent * event)205 float OH_ArkUI_SystemFontStyleEvent_GetFontSizeScale(const ArkUI_SystemFontStyleEvent* event)
206 {
207     return event->fontSize;
208 }
209 
OH_ArkUI_SystemFontStyleEvent_GetFontWeightScale(const ArkUI_SystemFontStyleEvent * event)210 float OH_ArkUI_SystemFontStyleEvent_GetFontWeightScale(const ArkUI_SystemFontStyleEvent* event)
211 {
212     return event->fontWeight;
213 }
214 
OH_ArkUI_NodeUtils_AddCustomProperty(ArkUI_NodeHandle node,const char * name,const char * value)215 void OH_ArkUI_NodeUtils_AddCustomProperty(ArkUI_NodeHandle node, const char* name, const char* value)
216 {
217     if (node == nullptr || !OHOS::Ace::NodeModel::CheckIsCNode(node)) {
218         return;
219     }
220     if (name == nullptr || value == nullptr) {
221         LOGF_ABORT("AddCustomProperty input params name or value is nullptr");
222     }
223     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
224     impl->getNodeModifiers()->getFrameNodeModifier()->addCustomProperty(node->uiNodeHandle, name, value);
225 }
226 
OH_ArkUI_NodeUtils_RemoveCustomProperty(ArkUI_NodeHandle node,const char * name)227 void OH_ArkUI_NodeUtils_RemoveCustomProperty(ArkUI_NodeHandle node, const char* name)
228 {
229     if (node == nullptr) {
230         return;
231     }
232     if (name == nullptr) {
233         LOGF_ABORT("RemoveCustomProperty input params name is nullptr");
234     }
235     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
236     impl->getNodeModifiers()->getFrameNodeModifier()->removeCustomProperty(node->uiNodeHandle, name);
237 }
238 
OH_ArkUI_NodeUtils_GetCustomProperty(ArkUI_NodeHandle node,const char * name,ArkUI_CustomProperty ** handle)239 int32_t OH_ArkUI_NodeUtils_GetCustomProperty(ArkUI_NodeHandle node, const char* name, ArkUI_CustomProperty** handle)
240 {
241     if (node == nullptr || name == nullptr) {
242         return ARKUI_ERROR_CODE_PARAM_INVALID;
243     }
244     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
245     char* value = nullptr;
246     impl->getNodeModifiers()->getFrameNodeModifier()->getCustomProperty(node->uiNodeHandle, name, &value);
247     *handle  = new ArkUI_CustomProperty({ .value = value });
248 
249     return OHOS::Ace::ERROR_CODE_NO_ERROR;
250 }
251 
OH_ArkUI_NodeUtils_GetActiveChildrenInfo(ArkUI_NodeHandle head,ArkUI_ActiveChildrenInfo ** handle)252 int32_t OH_ArkUI_NodeUtils_GetActiveChildrenInfo(ArkUI_NodeHandle head, ArkUI_ActiveChildrenInfo** handle)
253 {
254     CHECK_NULL_RETURN(head, ARKUI_ERROR_CODE_PARAM_INVALID);
255     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
256     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
257     ArkUINodeHandle* innerNodes = nullptr;
258     int32_t totalSize = 0;
259     impl->getNodeModifiers()->getFrameNodeModifier()->getActiveChildrenInfo(
260         head->uiNodeHandle, &innerNodes, &totalSize);
261     *handle = new ArkUI_ActiveChildrenInfo({ .nodeList = nullptr, .nodeCount = totalSize });
262     (*handle)->nodeCount = totalSize;
263     if (totalSize > 0) {
264         (*handle)->nodeList = new ArkUI_NodeHandle[totalSize] {};
265         for (int32_t i = 0; i < totalSize; i++) {
266             ((*handle)->nodeList[i]) = OHOS::Ace::NodeModel::GetArkUINode(innerNodes[i]);
267         }
268     }
269     delete[] innerNodes;
270     return OHOS::Ace::ERROR_CODE_NO_ERROR;
271 }
272 
OH_ArkUI_NodeUtils_GetParentInPageTree(ArkUI_NodeHandle node)273 ArkUI_NodeHandle OH_ArkUI_NodeUtils_GetParentInPageTree(ArkUI_NodeHandle node)
274 {
275     if (node == nullptr) {
276         return nullptr;
277     }
278     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
279     auto* attachNode = impl->getNodeModifiers()->getFrameNodeModifier()->getParent(node->uiNodeHandle);
280     return OHOS::Ace::NodeModel::GetArkUINode(attachNode);
281 }
282 
OH_ArkUI_NodeUtils_GetCurrentPageRootNode(ArkUI_NodeHandle node)283 ArkUI_NodeHandle OH_ArkUI_NodeUtils_GetCurrentPageRootNode(ArkUI_NodeHandle node)
284 {
285     if (node == nullptr) {
286         return nullptr;
287     }
288     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
289     auto* attachNode = impl->getNodeModifiers()->getFrameNodeModifier()->getCurrentPageRootNode(node->uiNodeHandle);
290     return OHOS::Ace::NodeModel::GetArkUINode(attachNode);
291 }
292 
OH_ArkUI_NodeUtils_IsCreatedByNDK(ArkUI_NodeHandle node)293 bool OH_ArkUI_NodeUtils_IsCreatedByNDK(ArkUI_NodeHandle node)
294 {
295     if (node == nullptr) {
296         return 0;
297     }
298     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
299     return impl->getNodeModifiers()->getFrameNodeModifier()->getNodeTag(node->uiNodeHandle);
300 }
301 
OH_ArkUI_NodeUtils_GetNodeType(ArkUI_NodeHandle node)302 int32_t OH_ArkUI_NodeUtils_GetNodeType(ArkUI_NodeHandle node)
303 {
304     if (node == nullptr) {
305         return -1;
306     }
307     if (node->type != -1) {
308         return node->type;
309     }
310 
311     return OHOS::Ace::NodeModel::GetNodeTypeByTag(node);
312 }
313 
OH_ArkUI_NodeUtils_GetWindowInfo(ArkUI_NodeHandle node,ArkUI_HostWindowInfo ** info)314 int32_t OH_ArkUI_NodeUtils_GetWindowInfo(ArkUI_NodeHandle node, ArkUI_HostWindowInfo** info)
315 {
316     CHECK_NULL_RETURN(node, ARKUI_ERROR_CODE_PARAM_INVALID);
317     CHECK_NULL_RETURN(info, ARKUI_ERROR_CODE_PARAM_INVALID);
318     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
319     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
320     char* name = nullptr;
321     int32_t error = impl->getNodeModifiers()->getFrameNodeModifier()->getWindowInfoByNode(node->uiNodeHandle, &name);
322     *info = new ArkUI_HostWindowInfo({ .name = name });
323     return error;
324 }
325 
OH_ArkUI_HostWindowInfo_GetName(ArkUI_HostWindowInfo * info)326 const char* OH_ArkUI_HostWindowInfo_GetName(ArkUI_HostWindowInfo* info)
327 {
328     if (!info) {
329         LOGF_ABORT("HostWindowInfo is nullptr");
330     }
331     return info->name;
332 }
333 
OH_ArkUI_HostWindowInfo_Destroy(ArkUI_HostWindowInfo * info)334 void OH_ArkUI_HostWindowInfo_Destroy(ArkUI_HostWindowInfo* info)
335 {
336     delete[] info->name;
337     info->name = nullptr;
338     delete info;
339     info = nullptr;
340 }
341 
OH_ArkUI_CustomProperty_Destroy(ArkUI_CustomProperty * handle)342 void OH_ArkUI_CustomProperty_Destroy(ArkUI_CustomProperty* handle)
343 {
344     delete[] handle->value;
345     handle->value = nullptr;
346     delete handle;
347     handle = nullptr;
348 }
349 
OH_ArkUI_CustomProperty_GetStringValue(ArkUI_CustomProperty * handle)350 const char* OH_ArkUI_CustomProperty_GetStringValue(ArkUI_CustomProperty* handle)
351 {
352     if (!handle) {
353         LOGF_ABORT("CustomProperty is nullptr");
354     }
355     return handle->value;
356 }
357 
OH_ArkUI_ActiveChildrenInfo_Destroy(ArkUI_ActiveChildrenInfo * handle)358 void OH_ArkUI_ActiveChildrenInfo_Destroy(ArkUI_ActiveChildrenInfo* handle)
359 {
360     delete[] handle->nodeList;
361     handle->nodeList = nullptr;
362     delete handle;
363     handle = nullptr;
364 }
365 
OH_ArkUI_ActiveChildrenInfo_GetNodeByIndex(ArkUI_ActiveChildrenInfo * handle,int32_t index)366 ArkUI_NodeHandle OH_ArkUI_ActiveChildrenInfo_GetNodeByIndex(ArkUI_ActiveChildrenInfo* handle, int32_t index)
367 {
368     if (!handle) {
369         LOGF_ABORT("ActiveChildrenInfo is nullptr");
370     }
371     if (index < handle->nodeCount && index >= 0) {
372         return handle->nodeList[index];
373     }
374     return nullptr;
375 }
376 
OH_ArkUI_ActiveChildrenInfo_GetCount(ArkUI_ActiveChildrenInfo * handle)377 int32_t OH_ArkUI_ActiveChildrenInfo_GetCount(ArkUI_ActiveChildrenInfo* handle)
378 {
379     if (!handle) {
380         LOGF_ABORT("ActiveChildrenInfo is nullptr");
381     }
382     return handle->nodeCount;
383 }
384 
OH_ArkUI_NodeUtils_GetAttachedNodeHandleById(const char * id,ArkUI_NodeHandle * node)385 int32_t OH_ArkUI_NodeUtils_GetAttachedNodeHandleById(const char* id, ArkUI_NodeHandle* node)
386 {
387     CHECK_NULL_RETURN(id, ARKUI_ERROR_CODE_PARAM_INVALID);
388     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
389     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
390     auto nodePtr = impl->getNodeModifiers()->getFrameNodeModifier()->getAttachedFrameNodeById(id);
391     CHECK_NULL_RETURN(nodePtr, ARKUI_ERROR_CODE_PARAM_INVALID);
392     *node = OHOS::Ace::NodeModel::GetArkUINode(nodePtr);
393     return ARKUI_ERROR_CODE_NO_ERROR;
394 }
395 
OH_ArkUI_NodeUtils_SetCrossLanguageOption(ArkUI_NodeHandle node,ArkUI_CrossLanguageOption * option)396 int32_t OH_ArkUI_NodeUtils_SetCrossLanguageOption(ArkUI_NodeHandle node, ArkUI_CrossLanguageOption* option)
397 {
398     if (node == nullptr || option == nullptr || node->cNode == false) {
399         return ARKUI_ERROR_CODE_PARAM_INVALID;
400     }
401     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
402     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
403     auto errorCode = impl->getNodeModifiers()->getFrameNodeModifier()->setCrossLanguageOptions(
404         node->uiNodeHandle, option->attributeSetting);
405     return errorCode;
406 }
407 
OH_ArkUI_NodeUtils_GetCrossLanguageOption(ArkUI_NodeHandle node,ArkUI_CrossLanguageOption * option)408 int32_t OH_ArkUI_NodeUtils_GetCrossLanguageOption(ArkUI_NodeHandle node, ArkUI_CrossLanguageOption* option)
409 {
410     if (node == nullptr || option == nullptr) {
411         return ARKUI_ERROR_CODE_PARAM_INVALID;
412     }
413     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
414     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
415     bool isCross = impl->getNodeModifiers()->getFrameNodeModifier()->getCrossLanguageOptions(node->uiNodeHandle);
416     option->attributeSetting = isCross;
417     return ARKUI_ERROR_CODE_NO_ERROR;
418 }
419 
OH_ArkUI_CrossLanguageOption_Create(void)420 ArkUI_CrossLanguageOption* OH_ArkUI_CrossLanguageOption_Create(void)
421 {
422     ArkUI_CrossLanguageOption* option = new ArkUI_CrossLanguageOption {
423         .attributeSetting = false
424     };
425     return option;
426 }
427 
OH_ArkUI_CrossLanguageOption_Destroy(ArkUI_CrossLanguageOption * option)428 void OH_ArkUI_CrossLanguageOption_Destroy(ArkUI_CrossLanguageOption* option)
429 {
430     if (option == nullptr) {
431         return;
432     }
433     delete option;
434 }
435 
OH_ArkUI_CrossLanguageOption_SetAttributeSettingStatus(ArkUI_CrossLanguageOption * option,bool enable)436 void OH_ArkUI_CrossLanguageOption_SetAttributeSettingStatus(ArkUI_CrossLanguageOption* option, bool enable)
437 {
438     if (option == nullptr) {
439         return;
440     }
441     option->attributeSetting = enable;
442 }
443 
OH_ArkUI_CrossLanguageOption_GetAttributeSettingStatus(ArkUI_CrossLanguageOption * option)444 bool OH_ArkUI_CrossLanguageOption_GetAttributeSettingStatus(ArkUI_CrossLanguageOption* option)
445 {
446     if (option == nullptr) {
447         return false;
448     }
449     return option->attributeSetting;
450 }
451 
OH_ArkUI_NodeUtils_MoveTo(ArkUI_NodeHandle node,ArkUI_NodeHandle target_parent,int32_t index)452 int32_t OH_ArkUI_NodeUtils_MoveTo(ArkUI_NodeHandle node, ArkUI_NodeHandle target_parent, int32_t index)
453 {
454     if (node == nullptr || target_parent == nullptr
455         || !OHOS::Ace::NodeModel::CheckIsCNode(node) || !OHOS::Ace::NodeModel::CheckIsCNode(target_parent)) {
456         return ARKUI_ERROR_CODE_PARAM_INVALID;
457     }
458     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
459     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_CAPI_INIT_ERROR);
460     int32_t errorCode = impl->getNodeModifiers()->getFrameNodeModifier()->moveNodeTo(node->uiNodeHandle,
461         target_parent->uiNodeHandle, index);
462     return errorCode;
463 }
464 
OH_ArkUI_NodeUtils_GetFirstChildIndexWithoutExpand(ArkUI_NodeHandle node,uint32_t * index)465 int32_t OH_ArkUI_NodeUtils_GetFirstChildIndexWithoutExpand(ArkUI_NodeHandle node, uint32_t* index)
466 {
467     if (node == nullptr) {
468         return ARKUI_ERROR_CODE_PARAM_INVALID;
469     }
470     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
471     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
472     int32_t errorCode = impl->getNodeModifiers()->getFrameNodeModifier()->getFirstChildIndexWithoutExpand(
473         node->uiNodeHandle, index);
474     return errorCode;
475 }
476 
OH_ArkUI_NodeUtils_GetLastChildIndexWithoutExpand(ArkUI_NodeHandle node,uint32_t * index)477 int32_t OH_ArkUI_NodeUtils_GetLastChildIndexWithoutExpand(ArkUI_NodeHandle node, uint32_t* index)
478 {
479     if (node == nullptr) {
480         return ARKUI_ERROR_CODE_PARAM_INVALID;
481     }
482     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
483     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
484     int32_t errorCode = impl->getNodeModifiers()->getFrameNodeModifier()->getLastChildIndexWithoutExpand(
485         node->uiNodeHandle, index);
486     return errorCode;
487 }
488 
OH_ArkUI_NodeUtils_GetChildWithExpandMode(ArkUI_NodeHandle node,int32_t position,ArkUI_NodeHandle * subnode,uint32_t expandMode)489 int32_t OH_ArkUI_NodeUtils_GetChildWithExpandMode(ArkUI_NodeHandle node, int32_t position,
490     ArkUI_NodeHandle* subnode, uint32_t expandMode)
491 {
492     if (node == nullptr) {
493         return ARKUI_ERROR_CODE_PARAM_INVALID;
494     }
495     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
496     CHECK_NULL_RETURN(impl, ARKUI_ERROR_CODE_PARAM_INVALID);
497     auto nodePtr = impl->getNodeModifiers()->getFrameNodeModifier()->getChild(
498         node->uiNodeHandle, position, expandMode);
499     CHECK_NULL_RETURN(nodePtr, ARKUI_ERROR_CODE_PARAM_INVALID);
500     *subnode = OHOS::Ace::NodeModel::GetArkUINode(nodePtr);
501     return ARKUI_ERROR_CODE_NO_ERROR;
502 }
503 
OH_ArkUI_NodeUtils_GetPositionToParent(ArkUI_NodeHandle node,ArkUI_IntOffset * globalOffset)504 int32_t OH_ArkUI_NodeUtils_GetPositionToParent(ArkUI_NodeHandle node, ArkUI_IntOffset* globalOffset)
505 {
506     if (node == nullptr) {
507         return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
508     }
509     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
510     ArkUI_Float32 tempOffset[2];
511     impl->getNodeModifiers()->getFrameNodeModifier()->getPositionToParent(node->uiNodeHandle, &tempOffset, false);
512     globalOffset->x = tempOffset[0];
513     globalOffset->y = tempOffset[1];
514 
515     return OHOS::Ace::ERROR_CODE_NO_ERROR;
516 }
517 
518 #ifdef __cplusplus
519 };
520 #endif
521