mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
add SetVisibleChange from host to frs
Signed-off-by: huanghuahua <huanghuahua5@h-partners.com>
This commit is contained in:
parent
90f0b15d62
commit
46289ecfff
@ -3405,6 +3405,22 @@ void UIContentImpl::FocusMoveSearch(
|
||||
container->FocusMoveSearchNG(elementId, direction, baseParent, output);
|
||||
}
|
||||
|
||||
void UIContentImpl::ProcessFormVisibleChange(bool isVisible)
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
CHECK_NULL_VOID(container);
|
||||
ContainerScope scope(instanceId_);
|
||||
auto taskExecutor = Container::CurrentTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostTask(
|
||||
[container, isVisible]() {
|
||||
auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext());
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
pipeline->HandleFormVisibleChangeEvent(isVisible);
|
||||
},
|
||||
TaskExecutor::TaskType::UI,"ArkUIUIExtensionVisibleChange");
|
||||
}
|
||||
|
||||
bool UIContentImpl::NotifyExecuteAction(
|
||||
int64_t elementId, const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t offset)
|
||||
{
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
void HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose) override;
|
||||
void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) override;
|
||||
void UpdateMaximizeMode(OHOS::Rosen::MaximizeMode mode) override;
|
||||
void ProcessFormVisibleChange(bool isVisible) override;
|
||||
void UpdateTitleInTargetPos(bool isShow, int32_t height) override;
|
||||
void NotifyRotationAnimationEnd() override;
|
||||
|
||||
|
@ -4075,6 +4075,32 @@ void PipelineContext::UpdateFormLinkInfos()
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineContext::AddFormVisibleChangeNode(const RefPtr<FrameNode>& node, const std::function<void(bool)>& callback)
|
||||
{
|
||||
CHECK_NULL_VOID(node);
|
||||
onFormVisibleChangeNodeIds_.emplace(node->GetId());
|
||||
onFormVisibleChangeEvents_.insert_or_assign(node->GetId(), callback);
|
||||
}
|
||||
|
||||
void PipelineContext::RemoveFormVisibleChangeNode(int32_t nodeId)
|
||||
{
|
||||
onFormVisibleChangeNodeIds_.erase(nodeId);
|
||||
auto iter = onFormVisibleChangeEvents_.find(nodeId);
|
||||
if (iter != onFormVisibleChangeEvents_.end()) {
|
||||
onFormVisibleChangeEvents_.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineContext::HandleFormVisibleChangeEvent(bool isVisible)
|
||||
{
|
||||
auto nodes = FrameNode::GetNodesById(onFormVisibleChangeNodeIds_);
|
||||
for (auto& pair : onFormVisibleChangeEvents_) {
|
||||
if (pair.second) {
|
||||
pair.second(isVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PipelineContext::OnShow()
|
||||
{
|
||||
CHECK_RUN_ON(UI);
|
||||
|
@ -253,6 +253,10 @@ public:
|
||||
|
||||
void HandleVisibleAreaChangeEvent(uint64_t nanoTimestamp);
|
||||
|
||||
void AddFormVisibleChangeNode(const RefPtr<FrameNode>& node, const std::function<void(bool)>& callback);
|
||||
void RemoveFormVisibleChangeNode(int32_t nodeId);
|
||||
void HandleFormVisibleChangeEvent(bool isVisible);
|
||||
|
||||
void HandleSubwindow(bool isShow);
|
||||
|
||||
void Destroy() override;
|
||||
@ -1161,6 +1165,7 @@ private:
|
||||
std::vector<FrameNode*> onAreaChangeNodesCache_;
|
||||
std::unordered_set<int32_t> onAreaChangeNodeIds_;
|
||||
std::unordered_set<int32_t> onVisibleAreaChangeNodeIds_;
|
||||
std::unordered_set<int32_t> onFormVisibleChangeNodeIds_;
|
||||
std::unordered_map<int32_t, std::vector<MouseEvent>> historyMousePointsById_;
|
||||
std::unordered_map<int32_t, std::vector<PointerEvent>> historyPointsEventById_;
|
||||
RefPtr<AccessibilityManagerNG> accessibilityManagerNG_;
|
||||
@ -1229,6 +1234,7 @@ private:
|
||||
mutable std::mutex navigationMutex_;
|
||||
std::map<std::string, WeakPtr<FrameNode>> navigationNodes_;
|
||||
std::list<DelayedTask> delayedTasks_;
|
||||
std::map<int32_t, std::function<void(bool)>> onFormVisibleChangeEvents_;
|
||||
RefPtr<PostEventManager> postEventManager_;
|
||||
|
||||
std::unordered_map<int32_t, TouchEvent> idToTouchPoints_;
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
void RecycleForm(std::string& statusData);
|
||||
void RecoverForm(const std::string& statusData);
|
||||
void GetRectRelativeToWindow(int32_t &top, int32_t &left) const;
|
||||
void SetVisibleChange(bool isVisible);
|
||||
|
||||
private:
|
||||
void InitUIContent(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
|
||||
void AddForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
|
||||
void OnUnlock();
|
||||
void SetVisibleChange(bool isVisible);
|
||||
void UpdateForm(const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
|
||||
void DeleteForm();
|
||||
void DeleteForm(const std::string& compId);
|
||||
|
@ -492,5 +492,14 @@ void FormRenderer::RecoverForm(const std::string& statusData)
|
||||
}
|
||||
uiContent_->RecoverForm(statusData);
|
||||
}
|
||||
|
||||
void FormRenderer::SetVisibleChange(bool isVisible)
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
HILOG_ERROR("SetVisibleChange error, uiContent_ is null!");
|
||||
return;
|
||||
}
|
||||
uiContent_->ProcessFormVisibleChange(isVisible);
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -113,6 +113,15 @@ void FormRendererGroup::OnUnlock()
|
||||
InnerAddForm(currentFormRequest);
|
||||
}
|
||||
|
||||
void FormRendererGroup::SetVisibleChange(bool isVisible)
|
||||
{
|
||||
if (formRenderer_ == nullptr) {
|
||||
HILOG_ERROR("SetVisibleChange failed, formRenderer is null");
|
||||
return;
|
||||
}
|
||||
formRenderer_->SetVisibleChange(isVisible);
|
||||
}
|
||||
|
||||
void FormRendererGroup::InnerAddForm(const FormRequest& formRequest)
|
||||
{
|
||||
HILOG_DEBUG("InnerAddForm called");
|
||||
|
@ -236,6 +236,23 @@ HWTEST_F(FormRenderGroupTest, FormRenderGroupTest_011, TestSize.Level1)
|
||||
GTEST_LOG_(INFO) << "FormRenderGroupTest_011 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FormRenderGroupTest_012
|
||||
* @tc.desc: Test SetVisibleChange() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderGroupTest, FormRenderGroupTest_012, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FormRenderGroupTest_012 start";
|
||||
auto eventRunner = OHOS::AppExecFwk::EventRunner::Create("FormRenderGroupTest_012");
|
||||
ASSERT_TRUE(eventRunner);
|
||||
auto eventHandler = std::make_shared<OHOS::AppExecFwk::EventHandler>(eventRunner);
|
||||
auto group = FormRendererGroup::Create(nullptr, nullptr, eventHandler);
|
||||
EXPECT_TRUE(group);
|
||||
group->SetVisibleChange(true);
|
||||
GTEST_LOG_(INFO) << "FormRenderGroupTest_012 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FormRenderGroupTest_014
|
||||
* @tc.desc: Test OnUnlock() function.
|
||||
|
@ -806,4 +806,32 @@ HWTEST_F(FormRenderTest, FormRenderTest022, TestSize.Level1)
|
||||
formRenderer->OnSurfaceDetach();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FormRenderTest023
|
||||
* @tc.desc: test SetVisibleChange
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderTest, FormRenderTest023, TestSize.Level1)
|
||||
{
|
||||
auto eventRunner = OHOS::AppExecFwk::EventRunner::Create("formRenderTest023");
|
||||
ASSERT_TRUE(eventRunner);
|
||||
auto eventHandler = std::make_shared<OHOS::AppExecFwk::EventHandler>(eventRunner);
|
||||
auto formRendererGroup = FormRendererGroup::Create(nullptr, nullptr, eventHandler);
|
||||
EXPECT_TRUE(formRendererGroup);
|
||||
OHOS::AAFwk::Want want;
|
||||
want.SetParam(FORM_RENDERER_COMP_ID, FORM_COMPONENT_ID_1);
|
||||
want.SetParam(FORM_RENDERER_ALLOW_UPDATE, false);
|
||||
want.SetParam(FORM_RENDER_STATE, true);
|
||||
sptr<FormRendererDelegateImpl> renderDelegate = new FormRendererDelegateImpl();
|
||||
want.SetParam(FORM_RENDERER_PROCESS_ON_ADD_SURFACE, renderDelegate->AsObject());
|
||||
OHOS::AppExecFwk::FormJsInfo formJsInfo;
|
||||
formRendererGroup->AddForm(want, formJsInfo);
|
||||
auto formRenderer = formRendererGroup->formRenderer_;
|
||||
EXPECT_TRUE(formRenderer);
|
||||
formRenderer->SetVisibleChange(true);
|
||||
formRenderer->uiContent_ = UIContent::Create(nullptr, nullptr);
|
||||
EXPECT_TRUE(formRenderer->uiContent_);
|
||||
formRenderer->SetVisibleChange(true);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
Loading…
Reference in New Issue
Block a user