!38500 [bugfix]:[修复popup错误移除targetNode的onAreaChange事件问题]

Merge pull request !38500 from miaoyu/onareachangenew
This commit is contained in:
openharmony_ci 2024-07-24 03:38:22 +00:00 committed by Gitee
commit 1bb9f201f0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 19 additions and 1 deletions

View File

@ -112,6 +112,9 @@ void BubblePattern::OnAttachToFrameNode()
auto targetNode = FrameNode::GetFrameNode(targetTag_, targetNodeId_);
CHECK_NULL_VOID(targetNode);
auto pipelineContext = host->GetContextRefPtr();
CHECK_NULL_VOID(pipelineContext);
hasOnAreaChange_ = pipelineContext->HasOnAreaChangeNode(targetNode->GetId());
auto eventHub = targetNode->GetEventHub<EventHub>();
CHECK_NULL_VOID(eventHub);
OnAreaChangedFunc onAreaChangedFunc = [popupNodeWk = WeakPtr<FrameNode>(host)](const RectF& oldRect,
@ -148,7 +151,9 @@ void BubblePattern::OnDetachFromFrameNode(FrameNode* frameNode)
pipeline->RemoveWindowStateChangedCallback(frameNode->GetId());
auto targetNode = FrameNode::GetFrameNode(targetTag_, targetNodeId_);
CHECK_NULL_VOID(targetNode);
pipeline->RemoveOnAreaChangeNode(targetNode->GetId());
if (!hasOnAreaChange_) {
pipeline->RemoveOnAreaChangeNode(targetNode->GetId());
}
}
void BubblePattern::InitTouchEvent()

View File

@ -291,6 +291,7 @@ private:
ACE_DISALLOW_COPY_AND_MOVE(BubblePattern);
bool hasTransition_ = false;
bool hasOnAreaChange_ = false;
};
} // namespace OHOS::Ace::NG

View File

@ -2935,6 +2935,11 @@ void PipelineContext::RemoveOnAreaChangeNode(int32_t nodeId)
isOnAreaChangeNodesCacheVaild_ = false;
}
bool PipelineContext::HasOnAreaChangeNode(int32_t nodeId)
{
return onAreaChangeNodeIds_.find(nodeId) != onAreaChangeNodeIds_.end();
}
void PipelineContext::HandleOnAreaChangeEvent(uint64_t nanoTimestamp)
{
ACE_FUNCTION_TRACE();

View File

@ -193,6 +193,8 @@ public:
return {};
}
bool HasOnAreaChangeNode(int32_t nodeId);
void AddOnAreaChangeNode(int32_t nodeId);
void RemoveOnAreaChangeNode(int32_t nodeId);

View File

@ -709,6 +709,11 @@ void PipelineContext::FlushNodeChangeFlag() {}
void PipelineContext::CleanNodeChangeFlag() {}
bool PipelineContext::HasOnAreaChangeNode(int32_t nodeId)
{
return false;
}
} // namespace OHOS::Ace::NG
// pipeline_context ============================================================