NDK c-api ets node fix

Signed-off-by: liyi0309<liyi58@huawei.com>

Change-Id: I02b4ca3d2426b9eb1feda27b41bf79b6da1f3fe3
This commit is contained in:
firminly 2024-08-15 16:31:06 +08:00
parent 80e3453fc5
commit 62db2226e0
3 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,7 @@
#ifndef ARKUI_NATIVE_DIALOG_H
#define ARKUI_NATIVE_DIALOG_H
#include <stdbool.h>
#include "native_type.h"
#ifdef __cplusplus

View File

@ -853,7 +853,7 @@ typedef enum {
*/
ARKUI_SCROLL_NESTED_MODE_SELF_ONLY = 0,
/** The component scrolls first, and when it hits the boundary, the parent component scrolls.
* When the parent component hits the boundary, its edge effect is displayed. If no edge effect is specified for
* When the parent component hits the boundary, its edge effect is displayed. If no edge effect is specified for
* the parent component, the edge effect of the child component is displayed instead.
*/
ARKUI_SCROLL_NESTED_MODE_SELF_FIRST,

View File

@ -36,6 +36,7 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value value, ArkU
{
bool hasProperty = false;
auto result = napi_has_named_property(env, value, "nodePtr_", &hasProperty);
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
if (result == napi_ok && hasProperty) {
napi_value frameNodePtr = nullptr;
auto result = napi_get_named_property(env, value, "nodePtr_", &frameNodePtr);
@ -53,6 +54,9 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value value, ArkU
auto* uiNodePtr = reinterpret_cast<OHOS::Ace::NG::UINode*>(nativePtr);
uiNodePtr->IncRefCount();
*handle = new ArkUI_Node({ .type = -1, .uiNodeHandle = reinterpret_cast<ArkUINodeHandle>(nativePtr) });
if (impl) {
impl->getExtendedAPI()->setAttachNodePtr((*handle)->uiNodeHandle, reinterpret_cast<void*>(*handle));
}
return OHOS::Ace::ERROR_CODE_NO_ERROR;
}
result = napi_has_named_property(env, value, "builderNode_", &hasProperty);
@ -84,7 +88,6 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value value, ArkU
}
if (frameNode->GetTag() == "BuilderProxyNode") {
// need to get the really frameNode.
auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
if (!impl) {
return OHOS::Ace::ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND;
}
@ -98,6 +101,9 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value value, ArkU
}
frameNode->IncRefCount();
*handle = new ArkUI_Node({ .type = -1, .uiNodeHandle = reinterpret_cast<ArkUINodeHandle>(frameNode) });
if (impl) {
impl->getExtendedAPI()->setAttachNodePtr((*handle)->uiNodeHandle, reinterpret_cast<void*>(*handle));
}
return OHOS::Ace::ERROR_CODE_NO_ERROR;
}
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;