!34459 修復lazyforeach、自定义组件下节点查询的bug

Merge pull request !34459 from wangchensu/0531
This commit is contained in:
openharmony_ci 2024-05-31 22:57:36 +00:00 committed by Gitee
commit d0317ed313
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 192 additions and 56 deletions

View File

@ -136,9 +136,9 @@ class FrameNode {
if (node === null) {
return;
}
let child = node.getFirstChild();
let child = node.getFirstChildWithoutExpand();
FrameNode.disposeTreeRecursively(child);
let sibling = node.getNextSibling();
let sibling = node.getNextSiblingWithoutExpand();
FrameNode.disposeTreeRecursively(sibling);
node.dispose();
}
@ -288,6 +288,19 @@ class FrameNode {
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getFirstChildWithoutExpand(): FrameNode | null {
const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), false);
const nodeId = result?.nodeId;
if (nodeId === undefined || nodeId === -1) {
return null;
}
if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
return frameNode === undefined ? null : frameNode;
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getNextSibling(): FrameNode | null {
const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr());
const nodeId = result?.nodeId;
@ -301,6 +314,19 @@ class FrameNode {
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getNextSiblingWithoutExpand(): FrameNode | null {
const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), false);
const nodeId = result?.nodeId;
if (nodeId === undefined || nodeId === -1) {
return null;
}
if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
return frameNode === undefined ? null : frameNode;
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getPreviousSibling(): FrameNode | null {
const result = getUINativeModule().frameNode.getPreviousSibling(this.getNodePtr());
const nodeId = result?.nodeId;

View File

@ -725,9 +725,9 @@ class FrameNode {
if (node === null) {
return;
}
let child = node.getFirstChild();
let child = node.getFirstChildWithoutExpand();
FrameNode.disposeTreeRecursively(child);
let sibling = node.getNextSibling();
let sibling = node.getNextSiblingWithoutExpand();
FrameNode.disposeTreeRecursively(sibling);
node.dispose();
}
@ -868,6 +868,18 @@ class FrameNode {
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getFirstChildWithoutExpand() {
const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), false);
const nodeId = result?.nodeId;
if (nodeId === undefined || nodeId === -1) {
return null;
}
if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
return frameNode === undefined ? null : frameNode;
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getNextSibling() {
const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr());
const nodeId = result?.nodeId;
@ -880,6 +892,18 @@ class FrameNode {
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getNextSiblingWithoutExpand() {
const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), false);
const nodeId = result?.nodeId;
if (nodeId === undefined || nodeId === -1) {
return null;
}
if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
return frameNode === undefined ? null : frameNode;
}
return this.convertToFrameNode(result.nodePtr, result.nodeId);
}
getPreviousSibling() {
const result = getUINativeModule().frameNode.getPreviousSibling(this.getNodePtr());
const nodeId = result?.nodeId;

View File

@ -38,6 +38,13 @@ constexpr double VISIBLE_RATIO_MIN = 0.0;
constexpr double VISIBLE_RATIO_MAX = 1.0;
constexpr int32_t INDEX_OF_INTERVAL = 4;
constexpr int32_t INDEX_OF_OPTION_OF_VISIBLE = 3;
ArkUI_Bool GetIsExpanded(ArkUIRuntimeCallInfo* runtimeCallInfo, ArkUI_Int32 index)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
Local<JSValueRef> isExpandedArg = runtimeCallInfo->GetCallArgRef(index);
return isExpandedArg->IsBoolean() ? isExpandedArg->ToBoolean(vm)->Value() : true;
}
} // namespace
ArkUI_Bool FrameNodeBridge::IsCustomFrameNode(FrameNode* node)
{
@ -372,15 +379,18 @@ ArkUINativeModuleValue FrameNodeBridge::ClearChildren(ArkUIRuntimeCallInfo* runt
GetArkUINodeModifiers()->getFrameNodeModifier()->clearChildren(nativeNode);
return panda::JSValueRef::Undefined(vm);
}
ArkUINativeModuleValue FrameNodeBridge::GetChildrenCount(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
CHECK_NULL_RETURN(!firstArg.IsNull(), panda::NumberRef::New(vm, 0));
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
auto number = GetArkUINodeModifiers()->getFrameNodeModifier()->getChildrenCount(nativeNode);
int isExpanded = GetIsExpanded(runtimeCallInfo, 1);
auto number = GetArkUINodeModifiers()->getFrameNodeModifier()->getChildrenCount(nativeNode, isExpanded);
return panda::NumberRef::New(vm, number);
}
ArkUINativeModuleValue FrameNodeBridge::GetChild(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
@ -389,40 +399,48 @@ ArkUINativeModuleValue FrameNodeBridge::GetChild(ArkUIRuntimeCallInfo* runtimeCa
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
int index = secondArg->ToNumber(vm)->Value();
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getChild(nativeNode, index);
int isExpanded = GetIsExpanded(runtimeCallInfo, 2);
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getChild(nativeNode, index, isExpanded);
CHECK_NULL_RETURN(nodePtr, panda::JSValueRef::Undefined(vm));
return FrameNodeBridge::MakeFrameNodeInfo(vm, nodePtr);
}
ArkUINativeModuleValue FrameNodeBridge::GetFirst(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getFirst(nativeNode);
int isExpanded = GetIsExpanded(runtimeCallInfo, 1);
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getFirst(nativeNode, isExpanded);
CHECK_NULL_RETURN(nodePtr, panda::JSValueRef::Undefined(vm));
return FrameNodeBridge::MakeFrameNodeInfo(vm, nodePtr);
}
ArkUINativeModuleValue FrameNodeBridge::GetNextSibling(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getNextSibling(nativeNode);
int isExpanded = GetIsExpanded(runtimeCallInfo, 1);
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getNextSibling(nativeNode, isExpanded);
CHECK_NULL_RETURN(nodePtr, panda::JSValueRef::Undefined(vm));
return FrameNodeBridge::MakeFrameNodeInfo(vm, nodePtr);
}
ArkUINativeModuleValue FrameNodeBridge::GetPreviousSibling(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getPreviousSibling(nativeNode);
int isExpanded = GetIsExpanded(runtimeCallInfo, 1);
auto nodePtr = GetArkUINodeModifiers()->getFrameNodeModifier()->getPreviousSibling(nativeNode, isExpanded);
CHECK_NULL_RETURN(nodePtr, panda::JSValueRef::Undefined(vm));
return FrameNodeBridge::MakeFrameNodeInfo(vm, nodePtr);
}
ArkUINativeModuleValue FrameNodeBridge::GetParent(ArkUIRuntimeCallInfo* runtimeCallInfo)
{
EcmaVM* vm = runtimeCallInfo->GetVM();

View File

@ -3557,9 +3557,10 @@ RefPtr<LayoutWrapper> FrameNode::GetChildByIndex(uint32_t index, bool isCache)
return frameProxy_->GetFrameNodeByIndex(index, false, isCache, false);
}
FrameNode* FrameNode::GetFrameNodeChildByIndex(uint32_t index, bool isCache)
FrameNode* FrameNode::GetFrameNodeChildByIndex(uint32_t index, bool isCache, bool isExpand)
{
auto frameNode = DynamicCast<FrameNode>(frameProxy_->GetFrameNodeByIndex(index, true, isCache, false));
auto frameNode = isExpand ? DynamicCast<FrameNode>(frameProxy_->GetFrameNodeByIndex(index, true, isCache, false))
: DynamicCast<FrameNode>(UINode::GetFrameChildByIndexWithoutExpanded(index));
return RawPtr(frameNode);
}
@ -3680,6 +3681,11 @@ RefPtr<UINode> FrameNode::GetFrameChildByIndex(uint32_t index, bool needBuild, b
return Claim(this);
}
RefPtr<UINode> FrameNode::GetFrameChildByIndexWithoutExpanded(uint32_t index)
{
return GetFrameChildByIndex(index, false);
}
const RefPtr<LayoutAlgorithmWrapper>& FrameNode::GetLayoutAlgorithm(bool needReset)
{
if ((!layoutAlgorithm_ || (needReset && layoutAlgorithm_->IsExpire())) && pattern_) {

View File

@ -99,6 +99,11 @@ public:
return 1;
}
int32_t CurrentFrameCount() const override
{
return 1;
}
void SetCheckboxFlag(const bool checkboxFlag)
{
checkboxFlag_ = checkboxFlag;
@ -647,6 +652,11 @@ public:
return UINode::TotalChildCount();
}
int32_t GetTotalChildCountWithoutExpanded() const
{
return UINode::CurrentFrameCount();
}
const RefPtr<GeometryNode>& GetGeometryNode() const override
{
return geometryNode_;
@ -667,8 +677,7 @@ public:
uint32_t index, bool addToRenderTree = true, bool isCache = false) override;
RefPtr<LayoutWrapper> GetChildByIndex(uint32_t index, bool isCache = false) override;
FrameNode* GetFrameNodeChildByIndex(uint32_t index, bool isCache = false);
FrameNode* GetFrameNodeChildByIndex(uint32_t index, bool isCache = false, bool isExpand = true);
/**
* @brief Get the index of Child among all FrameNode children of [this].
* Handles intermediate SyntaxNodes like LazyForEach.
@ -720,6 +729,7 @@ public:
void SyncGeometryNode(bool needSyncRsNode, const DirtySwapConfig& config);
RefPtr<UINode> GetFrameChildByIndex(
uint32_t index, bool needBuild, bool isCache = false, bool addToRenderTree = false) override;
RefPtr<UINode> GetFrameChildByIndexWithoutExpanded(uint32_t index) override;
bool CheckNeedForceMeasureAndLayout() override;
bool SetParentLayoutConstraint(const SizeF& size) const override;

View File

@ -853,6 +853,15 @@ int32_t UINode::TotalChildCount() const
return count;
}
int32_t UINode::CurrentFrameCount() const
{
int32_t count = 0;
for (const auto& child : GetChildren()) {
count += child->CurrentFrameCount();
}
return count;
}
int32_t UINode::GetChildIndexById(int32_t id)
{
int32_t pos = 0;
@ -1150,22 +1159,32 @@ RefPtr<UINode> UINode::GetFrameChildByIndex(uint32_t index, bool needBuild, bool
return nullptr;
}
int32_t UINode::GetFrameNodeIndex(RefPtr<FrameNode> node)
RefPtr<UINode> UINode::GetFrameChildByIndexWithoutExpanded(uint32_t index)
{
for (const auto& child : GetChildren()) {
uint32_t count = static_cast<uint32_t>(child->CurrentFrameCount());
if (count > index) {
return child->GetFrameChildByIndexWithoutExpanded(index);
}
index -= count;
}
return nullptr;
}
int32_t UINode::GetFrameNodeIndex(RefPtr<FrameNode> node, bool isExpanded)
{
int32_t index = 0;
for (const auto& child : GetChildren()) {
if (InstanceOf<FrameNode>(child)) {
if (child == node) {
return index;
} else {
return -1;
}
}
int32_t childIndex = child->GetFrameNodeIndex(node);
int32_t childIndex = child->GetFrameNodeIndex(node, isExpanded);
if (childIndex >= 0) {
return index + childIndex;
}
index += child->FrameCount();
index += isExpanded ? child->FrameCount() : child->CurrentFrameCount();
}
return -1;
}

View File

@ -71,7 +71,7 @@ public:
virtual void DetachContext(bool recursive = false);
virtual int32_t FrameCount() const;
virtual int32_t CurrentFrameCount() const;
virtual RefPtr<LayoutWrapperNode> CreateLayoutWrapper(bool forceMeasure = false, bool forceLayout = false);
// Tree operation start.
@ -405,8 +405,9 @@ public:
virtual void FastPreviewUpdateChildDone() {}
virtual RefPtr<UINode> GetFrameChildByIndex(uint32_t index, bool needBuild, bool isCache = false,
bool addToRenderTree = false);
virtual int32_t GetFrameNodeIndex(RefPtr<FrameNode> node);
virtual RefPtr<UINode> GetFrameChildByIndexWithoutExpanded(uint32_t index);
// Get current frameNode index with or without expanded all LazyForEachNode;
virtual int32_t GetFrameNodeIndex(RefPtr<FrameNode> node, bool isExpanded = true);
void SetDebugLine(const std::string& line)
{
debugLine_ = line;

View File

@ -59,6 +59,11 @@ public:
return 1;
}
int32_t CurrentFrameCount() const override
{
return 1;
}
void Render();
void SetCompleteReloadFunc(RenderFunction&& func) override

View File

@ -469,11 +469,16 @@ RefPtr<FrameNode> LazyForEachNode::GetFrameNode(int32_t index)
CHECK_NULL_RETURN(child.second, nullptr);
return AceType::DynamicCast<FrameNode>(child.second->GetFrameChildByIndex(0, true));
}
int32_t LazyForEachNode::GetFrameNodeIndex(RefPtr<FrameNode> node)
int32_t LazyForEachNode::GetFrameNodeIndex(RefPtr<FrameNode> node, bool isExpanded)
{
if (!isExpanded) {
return UINode::GetFrameNodeIndex(node, false);
}
CHECK_NULL_RETURN(builder_, -1);
return builder_->GetChildIndex(node);
}
void LazyForEachNode::InitDragManager(const RefPtr<FrameNode>& childNode)
{
CHECK_NULL_VOID(childNode);

View File

@ -160,7 +160,7 @@ public:
void MoveData(int32_t from, int32_t to) override;
void FireOnMove(int32_t from, int32_t to) override;
RefPtr<FrameNode> GetFrameNode(int32_t index) override;
int32_t GetFrameNodeIndex(RefPtr<FrameNode> node) override;
int32_t GetFrameNodeIndex(RefPtr<FrameNode> node, bool isExpanded = true) override;
void InitDragManager(const RefPtr<FrameNode>& childNode);
void InitAllChilrenDragManager(bool init);
private:

View File

@ -3945,11 +3945,11 @@ struct ArkUIFrameNodeModifier {
ArkUI_Bool (*insertChildAfter)(ArkUINodeHandle node, ArkUINodeHandle child, ArkUINodeHandle sibling);
void (*removeChild)(ArkUINodeHandle node, ArkUINodeHandle child);
void (*clearChildren)(ArkUINodeHandle node);
ArkUI_Uint32 (*getChildrenCount)(ArkUINodeHandle node);
ArkUINodeHandle (*getChild)(ArkUINodeHandle node, ArkUI_Int32 index);
ArkUINodeHandle (*getFirst)(ArkUINodeHandle node);
ArkUINodeHandle (*getNextSibling)(ArkUINodeHandle node);
ArkUINodeHandle (*getPreviousSibling)(ArkUINodeHandle node);
ArkUI_Uint32 (*getChildrenCount)(ArkUINodeHandle node, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getChild)(ArkUINodeHandle node, ArkUI_Int32 index, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getFirst)(ArkUINodeHandle node, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getNextSibling)(ArkUINodeHandle node, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getPreviousSibling)(ArkUINodeHandle node, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getParent)(ArkUINodeHandle node);
ArkUI_Int32 (*getIdByNodePtr)(ArkUINodeHandle node);
void (*getPositionToParent)(ArkUINodeHandle node, ArkUI_Float32* parentOffset, ArkUI_Bool useVp);
@ -3969,7 +3969,7 @@ struct ArkUIFrameNodeModifier {
ArkUINodeHandle (*getFrameNodeByUniqueId)(ArkUI_Int32 uniqueId);
ArkUINodeHandle (*getFrameNodeByKey)(ArkUI_CharPtr key);
void (*propertyUpdate)(ArkUINodeHandle node);
ArkUINodeHandle (*getLast)(ArkUINodeHandle node);
ArkUINodeHandle (*getLast)(ArkUINodeHandle node, ArkUI_Bool isExpanded);
ArkUINodeHandle (*getFirstUINode)(ArkUINodeHandle node);
void (*getLayoutSize)(ArkUINodeHandle node, ArkUI_Int32* size);
ArkUI_Float32* (*getLayoutPositionWithoutMargin)(ArkUINodeHandle node);

View File

@ -116,57 +116,77 @@ void ClearChildrenInFrameNode(ArkUINodeHandle node)
currentNode->MarkNeedFrameFlushDirty(NG::PROPERTY_UPDATE_MEASURE);
}
ArkUI_Uint32 GetChildrenCount(ArkUINodeHandle node)
ArkUI_Uint32 GetChildrenCount(ArkUINodeHandle node, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(currentNode, 0);
auto* frameNode = AceType::DynamicCast<FrameNode>(currentNode);
CHECK_NULL_RETURN(frameNode, 0);
return frameNode->GetAllChildrenWithBuild(false).size();
if (isExpanded) {
frameNode->GetAllChildrenWithBuild(false);
}
return isExpanded ? frameNode->GetAllChildrenWithBuild(false).size()
: frameNode->GetTotalChildCountWithoutExpanded();
}
ArkUINodeHandle GetChild(ArkUINodeHandle node, ArkUI_Int32 index)
ArkUINodeHandle GetChild(ArkUINodeHandle node, ArkUI_Int32 index, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(currentNode, nullptr);
auto* frameNode = AceType::DynamicCast<FrameNode>(currentNode);
CHECK_NULL_RETURN(frameNode, nullptr);
frameNode->GetAllChildrenWithBuild(false);
auto child = frameNode->GetFrameNodeChildByIndex(index);
CHECK_NULL_RETURN(index >= 0, nullptr);
if (isExpanded) {
frameNode->GetAllChildrenWithBuild(false);
}
auto child = frameNode->GetFrameNodeChildByIndex(index, false, isExpanded);
return reinterpret_cast<ArkUINodeHandle>(child);
}
ArkUINodeHandle GetFirst(ArkUINodeHandle node)
ArkUINodeHandle GetFirst(ArkUINodeHandle node, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
auto* frameNode = AceType::DynamicCast<FrameNode>(currentNode);
CHECK_NULL_RETURN(frameNode, nullptr);
frameNode->GetAllChildrenWithBuild(false);
auto child = frameNode->GetFrameNodeChildByIndex(0);
if (isExpanded) {
frameNode->GetAllChildrenWithBuild(false);
}
auto child = frameNode->GetFrameNodeChildByIndex(0, false, isExpanded);
return reinterpret_cast<ArkUINodeHandle>(child);
}
ArkUINodeHandle GetNextSibling(ArkUINodeHandle node)
ArkUINodeHandle GetNextSibling(ArkUINodeHandle node, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(currentNode, nullptr);
auto parent = GetParentNode(currentNode);
CHECK_NULL_RETURN(parent, nullptr);
parent->GetAllChildrenWithBuild(false);
auto index = parent->GetChildTrueIndex(Referenced::Claim<FrameNode>(currentNode));
auto sibling = parent->GetFrameNodeChildByIndex(index + 1);
auto index = -1;
if (isExpanded) {
parent->GetAllChildrenWithBuild(false);
index = parent->GetChildTrueIndex(Referenced::Claim<FrameNode>(currentNode));
} else {
index = parent->GetFrameNodeIndex(Referenced::Claim<FrameNode>(currentNode), false);
}
CHECK_NULL_RETURN(index > -1, nullptr);
auto sibling = parent->GetFrameNodeChildByIndex(index + 1, false, isExpanded);
return reinterpret_cast<ArkUINodeHandle>(sibling);
}
ArkUINodeHandle GetPreviousSibling(ArkUINodeHandle node)
ArkUINodeHandle GetPreviousSibling(ArkUINodeHandle node, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(currentNode, nullptr);
auto parent = GetParentNode(currentNode);
CHECK_NULL_RETURN(parent, nullptr);
parent->GetAllChildrenWithBuild(false);
auto index = parent->GetChildTrueIndex(Referenced::Claim<FrameNode>(currentNode));
auto sibling = parent->GetFrameNodeChildByIndex(index - 1);
auto index = -1;
if (isExpanded) {
parent->GetAllChildrenWithBuild(false);
index = parent->GetChildTrueIndex(Referenced::Claim<FrameNode>(currentNode));
} else {
index = parent->GetFrameNodeIndex(Referenced::Claim<FrameNode>(currentNode), false);
}
CHECK_NULL_RETURN(index > 0, nullptr);
auto sibling = parent->GetFrameNodeChildByIndex(index - 1, false, isExpanded);
return reinterpret_cast<ArkUINodeHandle>(sibling);
}
@ -385,14 +405,16 @@ void PropertyUpdate(ArkUINodeHandle node)
}
}
ArkUINodeHandle GetLast(ArkUINodeHandle node)
ArkUINodeHandle GetLast(ArkUINodeHandle node, ArkUI_Bool isExpanded)
{
auto* currentNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(currentNode, nullptr);
auto* frameNode = AceType::DynamicCast<FrameNode>(currentNode);
CHECK_NULL_RETURN(frameNode, nullptr);
auto size = frameNode->GetAllChildrenWithBuild(false).size();
auto child = frameNode->GetFrameNodeChildByIndex(size - 1);
auto size =
isExpanded ? frameNode->GetAllChildrenWithBuild(false).size() : frameNode->GetTotalChildCountWithoutExpanded();
CHECK_NULL_RETURN(size > 0, nullptr);
auto child = frameNode->GetFrameNodeChildByIndex(size - 1, false, isExpanded);
return reinterpret_cast<ArkUINodeHandle>(child);
}

View File

@ -88,7 +88,7 @@ int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value value, ArkU
return OHOS::Ace::ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND;
}
auto* child = impl->getNodeModifiers()->getFrameNodeModifier()->getChild(
reinterpret_cast<ArkUINodeHandle>(frameNode), 0);
reinterpret_cast<ArkUINodeHandle>(frameNode), 0, true);
if (!child) {
LOGE("fail to get child in BuilderProxyNode");
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;

View File

@ -357,7 +357,7 @@ uint32_t GetTotalChildCount(ArkUI_NodeHandle node)
return 0;
}
auto* impl = GetFullImpl();
return impl->getNodeModifiers()->getFrameNodeModifier()->getChildrenCount(node->uiNodeHandle);
return impl->getNodeModifiers()->getFrameNodeModifier()->getChildrenCount(node->uiNodeHandle, true);
}
ArkUI_NodeHandle GetChildAt(ArkUI_NodeHandle node, int32_t position)
@ -366,7 +366,7 @@ ArkUI_NodeHandle GetChildAt(ArkUI_NodeHandle node, int32_t position)
return nullptr;
}
auto* impl = GetFullImpl();
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getChild(node->uiNodeHandle, position);
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getChild(node->uiNodeHandle, position, true);
void* attachNode = impl->getExtendedAPI()->getAttachNodePtr(value);
if (attachNode) {
return reinterpret_cast<ArkUI_NodeHandle>(attachNode);
@ -380,7 +380,7 @@ ArkUI_NodeHandle GetFirstChild(ArkUI_NodeHandle node)
return nullptr;
}
auto* impl = GetFullImpl();
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getFirst(node->uiNodeHandle);
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getFirst(node->uiNodeHandle, true);
void* attachNode = impl->getExtendedAPI()->getAttachNodePtr(value);
if (attachNode) {
return reinterpret_cast<ArkUI_NodeHandle>(attachNode);
@ -394,7 +394,7 @@ ArkUI_NodeHandle GetLastChild(ArkUI_NodeHandle node)
return nullptr;
}
auto* impl = GetFullImpl();
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getLast(node->uiNodeHandle);
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getLast(node->uiNodeHandle, true);
void* attachNode = impl->getExtendedAPI()->getAttachNodePtr(value);
if (attachNode) {
return reinterpret_cast<ArkUI_NodeHandle>(attachNode);
@ -408,7 +408,7 @@ ArkUI_NodeHandle GetPreviousSibling(ArkUI_NodeHandle node)
return nullptr;
}
auto* impl = GetFullImpl();
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getPreviousSibling(node->uiNodeHandle);
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getPreviousSibling(node->uiNodeHandle, true);
void* attachNode = impl->getExtendedAPI()->getAttachNodePtr(value);
if (attachNode) {
return reinterpret_cast<ArkUI_NodeHandle>(attachNode);
@ -422,7 +422,7 @@ ArkUI_NodeHandle GetNextSibling(ArkUI_NodeHandle node)
return nullptr;
}
auto* impl = GetFullImpl();
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getNextSibling(node->uiNodeHandle);
auto* value = impl->getNodeModifiers()->getFrameNodeModifier()->getNextSibling(node->uiNodeHandle, true);
void* attachNode = impl->getExtendedAPI()->getAttachNodePtr(value);
if (attachNode) {
return reinterpret_cast<ArkUI_NodeHandle>(attachNode);