!48499 popUp&toast 修改context获取方式,由PipelineContext::GetCurrentContext改为GetContext

Merge pull request !48499 from 林昊/toast_241114
This commit is contained in:
openharmony_ci 2024-11-22 09:57:25 +00:00 committed by Gitee
commit a595cfc28e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 12 additions and 7 deletions

View File

@ -142,8 +142,7 @@ void BubblePattern::OnAttachToFrameNode()
void BubblePattern::OnDetachFromFrameNode(FrameNode* frameNode)
{
CHECK_NULL_VOID(frameNode);
auto pipeline = frameNode->GetContextRefPtr();
auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
CHECK_NULL_VOID(pipeline);
pipeline->RemoveWindowSizeChangeCallback(frameNode->GetId());
pipeline->RemoveWindowStateChangedCallback(frameNode->GetId());

View File

@ -219,9 +219,7 @@ Dimension ToastPattern::GetOffsetX(const RefPtr<LayoutWrapper>& layoutWrapper)
Dimension ToastPattern::GetOffsetY(const RefPtr<LayoutWrapper>& layoutWrapper)
{
auto host = GetHost();
CHECK_NULL_RETURN(host, Dimension(0.0));
auto context = IsDefaultToast() ? host->GetContextRefPtr() : GetMainPipelineContext();
auto context = GetToastContext();
CHECK_NULL_RETURN(context, Dimension(0.0));
auto text = layoutWrapper->GetOrCreateChildByIndex(0);
CHECK_NULL_RETURN(text, Dimension(0.0));
@ -446,10 +444,10 @@ void ToastPattern::OnAttachToFrameNode()
void ToastPattern::OnDetachFromFrameNode(FrameNode* node)
{
CHECK_NULL_VOID(node);
auto containerId = Container::CurrentId();
auto parentContainerId = SubwindowManager::GetInstance()->GetParentContainerId(containerId);
auto pipeline = parentContainerId < 0 ? node->GetContextRefPtr() : PipelineContext::GetMainPipelineContext();
auto current_context = PipelineContext::GetCurrentContextSafelyWithCheck();
auto pipeline = parentContainerId < 0 ? current_context : PipelineContext::GetMainPipelineContext();
CHECK_NULL_VOID(pipeline);
if (HasFoldDisplayModeChangedCallbackId()) {
pipeline->UnRegisterFoldDisplayModeChangedCallback(foldDisplayModeChangedCallbackId_.value_or(-1));
@ -664,4 +662,11 @@ NG::SizeF ToastPattern::GetSystemTopMostSubwindowSize() const
}
return windowSize;
}
RefPtr<PipelineContext> ToastPattern::GetToastContext()
{
auto host = GetHost();
CHECK_NULL_RETURN(host, nullptr);
auto context = IsDefaultToast() ? host->GetContextRefPtr() : GetMainPipelineContext();
return context;
}
} // namespace OHOS::Ace::NG

View File

@ -147,6 +147,7 @@ public:
void InitUIExtensionHostWindowRect();
RefPtr<PipelineContext> GetToastContext();
private:
void BeforeCreateLayoutWrapper() override;
void UpdateToastSize(const RefPtr<FrameNode>& toast);