123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ci
1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_UI_CONTENT_IMPL_H
1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_UI_CONTENT_IMPL_H
1823b3eb3cSopenharmony_ci
1923b3eb3cSopenharmony_ci#include <list>
2023b3eb3cSopenharmony_ci
2123b3eb3cSopenharmony_ci#include "ability_info.h"
2223b3eb3cSopenharmony_ci#include "display_manager.h"
2323b3eb3cSopenharmony_ci#include "dm/display_manager.h"
2423b3eb3cSopenharmony_ci#include "interfaces/inner_api/ace/arkui_rect.h"
2523b3eb3cSopenharmony_ci#include "interfaces/inner_api/ace/ui_content.h"
2623b3eb3cSopenharmony_ci#include "interfaces/inner_api/ace/viewport_config.h"
2723b3eb3cSopenharmony_ci#include "interfaces/inner_api/ui_session/ui_content_stub_impl.h"
2823b3eb3cSopenharmony_ci#include "key_event.h"
2923b3eb3cSopenharmony_ci#include "native_engine/native_engine.h"
3023b3eb3cSopenharmony_ci#include "native_engine/native_value.h"
3123b3eb3cSopenharmony_ci#include "wm/window.h"
3223b3eb3cSopenharmony_ci
3323b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/distributed_ui_manager.h"
3423b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_viewport_config.h"
3523b3eb3cSopenharmony_ci#include "base/thread/task_executor.h"
3623b3eb3cSopenharmony_ci#include "base/view_data/view_data_wrap.h"
3723b3eb3cSopenharmony_ci#include "core/common/asset_manager_impl.h"
3823b3eb3cSopenharmony_ci#include "core/common/update_config_manager.h"
3923b3eb3cSopenharmony_ci#include "core/components/common/properties/animation_option.h"
4023b3eb3cSopenharmony_ci#include "core/components/common/properties/popup_param.h"
4123b3eb3cSopenharmony_ci
4223b3eb3cSopenharmony_cinamespace OHOS::Accessibility {
4323b3eb3cSopenharmony_ciclass AccessibilityElementInfo;
4423b3eb3cSopenharmony_ci}
4523b3eb3cSopenharmony_ci
4623b3eb3cSopenharmony_cinamespace OHOS::Ace {
4723b3eb3cSopenharmony_ciclass ACE_FORCE_EXPORT UIContentImpl : public UIContent {
4823b3eb3cSopenharmony_cipublic:
4923b3eb3cSopenharmony_ci    UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime);
5023b3eb3cSopenharmony_ci    UIContentImpl(OHOS::AppExecFwk::Ability* ability);
5123b3eb3cSopenharmony_ci    UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime, bool isCard);
5223b3eb3cSopenharmony_ci    ~UIContentImpl()
5323b3eb3cSopenharmony_ci    {
5423b3eb3cSopenharmony_ci        ProcessDestructCallbacks();
5523b3eb3cSopenharmony_ci        DestroyUIDirector();
5623b3eb3cSopenharmony_ci        DestroyCallback();
5723b3eb3cSopenharmony_ci    }
5823b3eb3cSopenharmony_ci
5923b3eb3cSopenharmony_ci    // UI content lifeCycles
6023b3eb3cSopenharmony_ci    UIContentErrorCode Initialize(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) override;
6123b3eb3cSopenharmony_ci    UIContentErrorCode Initialize(
6223b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::shared_ptr<std::vector<uint8_t>>& content, napi_value storage) override;
6323b3eb3cSopenharmony_ci    UIContentErrorCode InitializeByName(
6423b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::string& name, napi_value storage) override;
6523b3eb3cSopenharmony_ci    void InitializeDynamic(int32_t hostInstanceId, const std::string& hapPath, const std::string& abcPath,
6623b3eb3cSopenharmony_ci        const std::string& entryPoint, const std::vector<std::string>& registerComponents) override;
6723b3eb3cSopenharmony_ci    void Initialize(
6823b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::string& url, napi_value storage, uint32_t focusWindowId) override;
6923b3eb3cSopenharmony_ci    void Foreground() override;
7023b3eb3cSopenharmony_ci    void Background() override;
7123b3eb3cSopenharmony_ci    void Focus() override;
7223b3eb3cSopenharmony_ci    void UnFocus() override;
7323b3eb3cSopenharmony_ci    void Destroy() override;
7423b3eb3cSopenharmony_ci    void OnNewWant(const OHOS::AAFwk::Want& want) override;
7523b3eb3cSopenharmony_ci
7623b3eb3cSopenharmony_ci    // restore
7723b3eb3cSopenharmony_ci    UIContentErrorCode Restore(OHOS::Rosen::Window* window, const std::string& contentInfo,
7823b3eb3cSopenharmony_ci        napi_value storage, ContentInfoType type) override;
7923b3eb3cSopenharmony_ci    std::string GetContentInfo(ContentInfoType type) const override;
8023b3eb3cSopenharmony_ci    void DestroyUIDirector() override;
8123b3eb3cSopenharmony_ci    void SetUIContentType(UIContentType uIContentType) override;
8223b3eb3cSopenharmony_ci    void UpdateFontScale(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
8323b3eb3cSopenharmony_ci
8423b3eb3cSopenharmony_ci    // UI content event process
8523b3eb3cSopenharmony_ci    bool ProcessBackPressed() override;
8623b3eb3cSopenharmony_ci    void UpdateDialogResourceConfiguration(RefPtr<Container>& container,
8723b3eb3cSopenharmony_ci        const std::shared_ptr<OHOS::AbilityRuntime::Context>& context);
8823b3eb3cSopenharmony_ci    bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) override;
8923b3eb3cSopenharmony_ci    bool ProcessPointerEventWithCallback(
9023b3eb3cSopenharmony_ci        const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, const std::function<void()>& callback) override;
9123b3eb3cSopenharmony_ci    bool ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme) override;
9223b3eb3cSopenharmony_ci    bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) override;
9323b3eb3cSopenharmony_ci    bool ProcessVsyncEvent(uint64_t timeStampNanos) override;
9423b3eb3cSopenharmony_ci    void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) override;
9523b3eb3cSopenharmony_ci    void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason,
9623b3eb3cSopenharmony_ci        const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction = nullptr,
9723b3eb3cSopenharmony_ci        const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas = {}) override;
9823b3eb3cSopenharmony_ci    void UpdateViewportConfigWithAnimation(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason,
9923b3eb3cSopenharmony_ci        AnimationOption animationOpt, const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction = nullptr,
10023b3eb3cSopenharmony_ci        const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas = {});
10123b3eb3cSopenharmony_ci    void UIExtensionUpdateViewportConfig(const ViewportConfig& config);
10223b3eb3cSopenharmony_ci    void UpdateWindowMode(OHOS::Rosen::WindowMode mode, bool hasDeco = true) override;
10323b3eb3cSopenharmony_ci    void UpdateDecorVisible(bool visible, bool hasDeco) override;
10423b3eb3cSopenharmony_ci    void HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose) override;
10523b3eb3cSopenharmony_ci    void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) override;
10623b3eb3cSopenharmony_ci    void UpdateMaximizeMode(OHOS::Rosen::MaximizeMode mode) override;
10723b3eb3cSopenharmony_ci    void UpdateTitleInTargetPos(bool isShow, int32_t height) override;
10823b3eb3cSopenharmony_ci    void NotifyRotationAnimationEnd() override;
10923b3eb3cSopenharmony_ci
11023b3eb3cSopenharmony_ci    void ChangeSensitiveNodes(bool isSensitive) override;
11123b3eb3cSopenharmony_ci
11223b3eb3cSopenharmony_ci    // Window color
11323b3eb3cSopenharmony_ci    uint32_t GetBackgroundColor() override;
11423b3eb3cSopenharmony_ci    void SetBackgroundColor(uint32_t color) override;
11523b3eb3cSopenharmony_ci    void SetWindowContainerColor(uint32_t activeColor, uint32_t inactiveColor) override;
11623b3eb3cSopenharmony_ci
11723b3eb3cSopenharmony_ci    bool NeedSoftKeyboard() override;
11823b3eb3cSopenharmony_ci
11923b3eb3cSopenharmony_ci    void SetOnWindowFocused(const std::function<void()>& callback) override;
12023b3eb3cSopenharmony_ci
12123b3eb3cSopenharmony_ci    // Current paintSize of window
12223b3eb3cSopenharmony_ci    void GetAppPaintSize(OHOS::Rosen::Rect& paintrect) override;
12323b3eb3cSopenharmony_ci
12423b3eb3cSopenharmony_ci    // Get paintSize of window by calculating
12523b3eb3cSopenharmony_ci    void GetWindowPaintSize(OHOS::Rosen::Rect& paintrect) override;
12623b3eb3cSopenharmony_ci
12723b3eb3cSopenharmony_ci    void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
12823b3eb3cSopenharmony_ci
12923b3eb3cSopenharmony_ci    // Set UIContent callback for custom window animation
13023b3eb3cSopenharmony_ci    void SetNextFrameLayoutCallback(std::function<void()>&& callback) override;
13123b3eb3cSopenharmony_ci
13223b3eb3cSopenharmony_ci    // Set UIContent callback after layout finish
13323b3eb3cSopenharmony_ci    void SetFrameLayoutFinishCallback(std::function<void()>&& callback) override;
13423b3eb3cSopenharmony_ci
13523b3eb3cSopenharmony_ci    // Set UIContent callback after lastest layout finish
13623b3eb3cSopenharmony_ci    void SetLastestFrameLayoutFinishCallback(std::function<void()>&& callback) override;
13723b3eb3cSopenharmony_ci
13823b3eb3cSopenharmony_ci    // Receive memory level notification
13923b3eb3cSopenharmony_ci    void NotifyMemoryLevel(int32_t level) override;
14023b3eb3cSopenharmony_ci
14123b3eb3cSopenharmony_ci    void SetAppWindowTitle(const std::string& title) override;
14223b3eb3cSopenharmony_ci    void SetAppWindowIcon(const std::shared_ptr<Media::PixelMap>& pixelMap) override;
14323b3eb3cSopenharmony_ci
14423b3eb3cSopenharmony_ci    // ArkTS Form
14523b3eb3cSopenharmony_ci    void PreInitializeForm(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) override;
14623b3eb3cSopenharmony_ci    void RunFormPage() override;
14723b3eb3cSopenharmony_ci    std::shared_ptr<Rosen::RSSurfaceNode> GetFormRootNode() override;
14823b3eb3cSopenharmony_ci    void UpdateFormData(const std::string& data) override;
14923b3eb3cSopenharmony_ci    void UpdateFormSharedImage(const std::map<std::string, sptr<OHOS::AppExecFwk::FormAshmem>>& imageDataMap) override;
15023b3eb3cSopenharmony_ci    void ReloadForm(const std::string& url) override;
15123b3eb3cSopenharmony_ci
15223b3eb3cSopenharmony_ci    void SetFormWidth(float width) override
15323b3eb3cSopenharmony_ci    {
15423b3eb3cSopenharmony_ci        formWidth_ = width;
15523b3eb3cSopenharmony_ci    }
15623b3eb3cSopenharmony_ci    void SetFormHeight(float height) override
15723b3eb3cSopenharmony_ci    {
15823b3eb3cSopenharmony_ci        formHeight_ = height;
15923b3eb3cSopenharmony_ci    }
16023b3eb3cSopenharmony_ci    float GetFormWidth() override
16123b3eb3cSopenharmony_ci    {
16223b3eb3cSopenharmony_ci        return formWidth_;
16323b3eb3cSopenharmony_ci    }
16423b3eb3cSopenharmony_ci    float GetFormHeight() override
16523b3eb3cSopenharmony_ci    {
16623b3eb3cSopenharmony_ci        return formHeight_;
16723b3eb3cSopenharmony_ci    }
16823b3eb3cSopenharmony_ci
16923b3eb3cSopenharmony_ci    void SetActionEventHandler(std::function<void(const std::string& action)>&& actionCallback) override;
17023b3eb3cSopenharmony_ci    void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) override;
17123b3eb3cSopenharmony_ci    void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& callback) override;
17223b3eb3cSopenharmony_ci
17323b3eb3cSopenharmony_ci    void OnFormSurfaceChange(float width, float height,
17423b3eb3cSopenharmony_ci        OHOS::Rosen::WindowSizeChangeReason type = static_cast<OHOS::Rosen::WindowSizeChangeReason>(0),
17523b3eb3cSopenharmony_ci        const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) override;
17623b3eb3cSopenharmony_ci
17723b3eb3cSopenharmony_ci    void SetFormBackgroundColor(const std::string& color) override;
17823b3eb3cSopenharmony_ci
17923b3eb3cSopenharmony_ci    void RegisterAccessibilityChildTree(
18023b3eb3cSopenharmony_ci        uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId) override;
18123b3eb3cSopenharmony_ci    void SetAccessibilityGetParentRectHandler(std::function<void(int32_t&, int32_t&)>&& callback) override;
18223b3eb3cSopenharmony_ci    void SetAccessibilityGetParentRectHandler(
18323b3eb3cSopenharmony_ci        std::function<void(AccessibilityParentRectInfo&)>&& callback) override;
18423b3eb3cSopenharmony_ci    void DeregisterAccessibilityChildTree() override;
18523b3eb3cSopenharmony_ci    void AccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
18623b3eb3cSopenharmony_ci
18723b3eb3cSopenharmony_ci    void SetFontScaleFollowSystem(const bool fontScaleFollowSystem) override;
18823b3eb3cSopenharmony_ci
18923b3eb3cSopenharmony_ci    SerializeableObjectArray DumpUITree() override
19023b3eb3cSopenharmony_ci    {
19123b3eb3cSopenharmony_ci        CHECK_NULL_RETURN(uiManager_, SerializeableObjectArray());
19223b3eb3cSopenharmony_ci        return uiManager_->DumpUITree();
19323b3eb3cSopenharmony_ci    }
19423b3eb3cSopenharmony_ci    void SubscribeUpdate(const std::function<void(int32_t, SerializeableObjectArray&)>& onUpdate) override
19523b3eb3cSopenharmony_ci    {
19623b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
19723b3eb3cSopenharmony_ci        return uiManager_->SubscribeUpdate(onUpdate);
19823b3eb3cSopenharmony_ci    }
19923b3eb3cSopenharmony_ci    void UnSubscribeUpdate() override
20023b3eb3cSopenharmony_ci    {
20123b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
20223b3eb3cSopenharmony_ci        uiManager_->UnSubscribeUpdate();
20323b3eb3cSopenharmony_ci    }
20423b3eb3cSopenharmony_ci    void ProcessSerializeableInputEvent(const SerializeableObjectArray& array) override
20523b3eb3cSopenharmony_ci    {
20623b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
20723b3eb3cSopenharmony_ci        uiManager_->ProcessSerializeableInputEvent(array);
20823b3eb3cSopenharmony_ci    }
20923b3eb3cSopenharmony_ci    void RestoreUITree(const SerializeableObjectArray& array) override
21023b3eb3cSopenharmony_ci    {
21123b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
21223b3eb3cSopenharmony_ci        uiManager_->RestoreUITree(array);
21323b3eb3cSopenharmony_ci    }
21423b3eb3cSopenharmony_ci    void UpdateUITree(const SerializeableObjectArray& array) override
21523b3eb3cSopenharmony_ci    {
21623b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
21723b3eb3cSopenharmony_ci        uiManager_->UpdateUITree(array);
21823b3eb3cSopenharmony_ci    }
21923b3eb3cSopenharmony_ci    void SubscribeInputEventProcess(const std::function<void(SerializeableObjectArray&)>& onEvent) override
22023b3eb3cSopenharmony_ci    {
22123b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
22223b3eb3cSopenharmony_ci        uiManager_->SubscribeInputEventProcess(onEvent);
22323b3eb3cSopenharmony_ci    }
22423b3eb3cSopenharmony_ci    void UnSubscribeInputEventProcess() override
22523b3eb3cSopenharmony_ci    {
22623b3eb3cSopenharmony_ci        CHECK_NULL_VOID(uiManager_);
22723b3eb3cSopenharmony_ci        uiManager_->UnSubscribeInputEventProcess();
22823b3eb3cSopenharmony_ci    }
22923b3eb3cSopenharmony_ci    void GetResourcePaths(std::vector<std::string>& resourcesPaths, std::string& assetRootPath,
23023b3eb3cSopenharmony_ci        std::vector<std::string>& assetBasePaths, std::string& resFolderName) override;
23123b3eb3cSopenharmony_ci    void SetResourcePaths(const std::vector<std::string>& resourcesPaths, const std::string& assetRootPath,
23223b3eb3cSopenharmony_ci        const std::vector<std::string>& assetBasePaths) override;
23323b3eb3cSopenharmony_ci
23423b3eb3cSopenharmony_ci    napi_value GetUINapiContext() override;
23523b3eb3cSopenharmony_ci    void SetIsFocusActive(bool isFocusActive) override;
23623b3eb3cSopenharmony_ci
23723b3eb3cSopenharmony_ci    void UpdateResource() override;
23823b3eb3cSopenharmony_ci
23923b3eb3cSopenharmony_ci    int32_t CreateModalUIExtension(const AAFwk::Want& want,
24023b3eb3cSopenharmony_ci        const ModalUIExtensionCallbacks& callbacks, const ModalUIExtensionConfig& config) override;
24123b3eb3cSopenharmony_ci    void CloseModalUIExtension(int32_t sessionId) override;
24223b3eb3cSopenharmony_ci
24323b3eb3cSopenharmony_ci    void SetParentToken(sptr<IRemoteObject> token) override;
24423b3eb3cSopenharmony_ci    sptr<IRemoteObject> GetParentToken() override;
24523b3eb3cSopenharmony_ci    AbilityBase::AutoFillType ViewDataToType(const AbilityBase::ViewData& viewData);
24623b3eb3cSopenharmony_ci    bool DumpViewData(AbilityBase::ViewData& viewData, AbilityBase::AutoFillType& type) override;
24723b3eb3cSopenharmony_ci    bool CheckNeedAutoSave() override;
24823b3eb3cSopenharmony_ci    bool DumpViewData(const RefPtr<NG::FrameNode>& node, RefPtr<ViewDataWrap> viewDataWrap,
24923b3eb3cSopenharmony_ci        bool skipSubAutoFillContainer = false, bool needsRecordData = false);
25023b3eb3cSopenharmony_ci
25123b3eb3cSopenharmony_ci    void SearchElementInfoByAccessibilityId(
25223b3eb3cSopenharmony_ci        int64_t elementId, int32_t mode,
25323b3eb3cSopenharmony_ci        int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& output) override;
25423b3eb3cSopenharmony_ci
25523b3eb3cSopenharmony_ci    void SearchElementInfosByText(
25623b3eb3cSopenharmony_ci        int64_t elementId, const std::string& text, int64_t baseParent,
25723b3eb3cSopenharmony_ci        std::list<Accessibility::AccessibilityElementInfo>& output) override;
25823b3eb3cSopenharmony_ci
25923b3eb3cSopenharmony_ci    void FindFocusedElementInfo(
26023b3eb3cSopenharmony_ci        int64_t elementId, int32_t focusType,
26123b3eb3cSopenharmony_ci        int64_t baseParent, Accessibility::AccessibilityElementInfo& output) override;
26223b3eb3cSopenharmony_ci
26323b3eb3cSopenharmony_ci    void FocusMoveSearch(
26423b3eb3cSopenharmony_ci        int64_t elementId, int32_t direction,
26523b3eb3cSopenharmony_ci        int64_t baseParent, Accessibility::AccessibilityElementInfo& output) override;
26623b3eb3cSopenharmony_ci
26723b3eb3cSopenharmony_ci    bool NotifyExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
26823b3eb3cSopenharmony_ci        int32_t action, int64_t offset) override;
26923b3eb3cSopenharmony_ci
27023b3eb3cSopenharmony_ci    void HandleAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
27123b3eb3cSopenharmony_ci        int32_t eventType, int64_t timeMs) override;
27223b3eb3cSopenharmony_ci
27323b3eb3cSopenharmony_ci    int32_t GetInstanceId() override
27423b3eb3cSopenharmony_ci    {
27523b3eb3cSopenharmony_ci        return instanceId_;
27623b3eb3cSopenharmony_ci    }
27723b3eb3cSopenharmony_ci
27823b3eb3cSopenharmony_ci    std::string RecycleForm() override;
27923b3eb3cSopenharmony_ci
28023b3eb3cSopenharmony_ci    void RecoverForm(const std::string& statusData) override;
28123b3eb3cSopenharmony_ci    Shadow GetPopupShadow();
28223b3eb3cSopenharmony_ci
28323b3eb3cSopenharmony_ci    int32_t CreateCustomPopupUIExtension(const AAFwk::Want& want,
28423b3eb3cSopenharmony_ci        const ModalUIExtensionCallbacks& callbacks, const CustomPopupUIExtensionConfig& config) override;
28523b3eb3cSopenharmony_ci    bool GetTargetNode(
28623b3eb3cSopenharmony_ci        int32_t& nodeIdLabel, RefPtr<NG::FrameNode>& targetNode, const CustomPopupUIExtensionConfig& config);
28723b3eb3cSopenharmony_ci    void DestroyCustomPopupUIExtension(int32_t nodeId) override;
28823b3eb3cSopenharmony_ci    void UpdateCustomPopupUIExtension(const CustomPopupUIExtensionConfig& config) override;
28923b3eb3cSopenharmony_ci
29023b3eb3cSopenharmony_ci    void SetContainerModalTitleVisible(bool customTitleSettedShow, bool floatingTitleSettedShow) override;
29123b3eb3cSopenharmony_ci    void SetContainerModalTitleHeight(int32_t height) override;
29223b3eb3cSopenharmony_ci    int32_t GetContainerModalTitleHeight() override;
29323b3eb3cSopenharmony_ci    bool GetContainerModalButtonsRect(Rosen::Rect& containerModal, Rosen::Rect& buttons) override;
29423b3eb3cSopenharmony_ci    void SubscribeContainerModalButtonsRectChange(
29523b3eb3cSopenharmony_ci        std::function<void(Rosen::Rect& containerModal, Rosen::Rect& buttons)>&& callback) override;
29623b3eb3cSopenharmony_ci    void UpdateTransform(const OHOS::Rosen::Transform& transform) override;
29723b3eb3cSopenharmony_ci
29823b3eb3cSopenharmony_ci    SerializedGesture GetFormSerializedGesture() override;
29923b3eb3cSopenharmony_ci
30023b3eb3cSopenharmony_ci    void SetUIExtensionSubWindow(bool isUIExtensionSubWindow) override
30123b3eb3cSopenharmony_ci    {
30223b3eb3cSopenharmony_ci        isUIExtensionSubWindow_ = isUIExtensionSubWindow;
30323b3eb3cSopenharmony_ci    }
30423b3eb3cSopenharmony_ci
30523b3eb3cSopenharmony_ci    bool IsUIExtensionSubWindow() override
30623b3eb3cSopenharmony_ci    {
30723b3eb3cSopenharmony_ci        return isUIExtensionSubWindow_;
30823b3eb3cSopenharmony_ci    }
30923b3eb3cSopenharmony_ci
31023b3eb3cSopenharmony_ci    void SetUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess) override
31123b3eb3cSopenharmony_ci    {
31223b3eb3cSopenharmony_ci        isUIExtensionAbilityProcess_ = isUIExtensionAbilityProcess;
31323b3eb3cSopenharmony_ci    }
31423b3eb3cSopenharmony_ci
31523b3eb3cSopenharmony_ci    bool IsUIExtensionAbilityProcess() override
31623b3eb3cSopenharmony_ci    {
31723b3eb3cSopenharmony_ci        return isUIExtensionAbilityProcess_;
31823b3eb3cSopenharmony_ci    }
31923b3eb3cSopenharmony_ci
32023b3eb3cSopenharmony_ci    void SetUIExtensionAbilityHost(bool isUIExtensionAbilityHost) override
32123b3eb3cSopenharmony_ci    {
32223b3eb3cSopenharmony_ci        isUIExtensionAbilityHost_ = isUIExtensionAbilityHost;
32323b3eb3cSopenharmony_ci    }
32423b3eb3cSopenharmony_ci
32523b3eb3cSopenharmony_ci    bool IsUIExtensionAbilityHost() override
32623b3eb3cSopenharmony_ci    {
32723b3eb3cSopenharmony_ci        return isUIExtensionAbilityHost_;
32823b3eb3cSopenharmony_ci    }
32923b3eb3cSopenharmony_ci
33023b3eb3cSopenharmony_ci    std::vector<Ace::RectF> GetOverlayNodePositions() const override;
33123b3eb3cSopenharmony_ci
33223b3eb3cSopenharmony_ci    void RegisterOverlayNodePositionsUpdateCallback(
33323b3eb3cSopenharmony_ci        const std::function<void(std::vector<Ace::RectF>)>& callback) const override;
33423b3eb3cSopenharmony_ci
33523b3eb3cSopenharmony_ci    void SetFormRenderingMode(int8_t renderMode) override;
33623b3eb3cSopenharmony_ci
33723b3eb3cSopenharmony_ci    void SetContentNodeGrayScale(float grayscale) override;
33823b3eb3cSopenharmony_ci
33923b3eb3cSopenharmony_ci    void PreLayout() override;
34023b3eb3cSopenharmony_ci
34123b3eb3cSopenharmony_ci    sptr<IRemoteObject> GetRemoteObj() override
34223b3eb3cSopenharmony_ci    {
34323b3eb3cSopenharmony_ci        return instance_;
34423b3eb3cSopenharmony_ci    }
34523b3eb3cSopenharmony_ci
34623b3eb3cSopenharmony_ci    void SetStatusBarItemColor(uint32_t color) override;
34723b3eb3cSopenharmony_ci
34823b3eb3cSopenharmony_ci    void SetFontScaleAndWeightScale(const RefPtr<Platform::AceContainer>& container, int32_t instanceId);
34923b3eb3cSopenharmony_ci
35023b3eb3cSopenharmony_ci    void SetForceSplitEnable(bool isForceSplit, const std::string& homePage) override;
35123b3eb3cSopenharmony_ci
35223b3eb3cSopenharmony_ci    void UpdateDialogContainerConfig(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
35323b3eb3cSopenharmony_ci
35423b3eb3cSopenharmony_ci    void AddDestructCallback(void* key, const std::function<void()>& callback)
35523b3eb3cSopenharmony_ci    {
35623b3eb3cSopenharmony_ci        destructCallbacks_.emplace(key, callback);
35723b3eb3cSopenharmony_ci    }
35823b3eb3cSopenharmony_ci
35923b3eb3cSopenharmony_ci    void RemoveDestructCallback(void* key)
36023b3eb3cSopenharmony_ci    {
36123b3eb3cSopenharmony_ci        destructCallbacks_.erase(key);
36223b3eb3cSopenharmony_ci    }
36323b3eb3cSopenharmony_ci
36423b3eb3cSopenharmony_ciprivate:
36523b3eb3cSopenharmony_ci    UIContentErrorCode InitializeInner(
36623b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, bool isNamedRouter);
36723b3eb3cSopenharmony_ci    UIContentErrorCode CommonInitialize(
36823b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, uint32_t focusWindowId = 0);
36923b3eb3cSopenharmony_ci    UIContentErrorCode CommonInitializeForm(
37023b3eb3cSopenharmony_ci        OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage);
37123b3eb3cSopenharmony_ci    void InitializeSubWindow(OHOS::Rosen::Window* window, bool isDialog = false);
37223b3eb3cSopenharmony_ci    void DestroyCallback() const;
37323b3eb3cSopenharmony_ci    void ProcessDestructCallbacks();
37423b3eb3cSopenharmony_ci    void SetConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
37523b3eb3cSopenharmony_ci
37623b3eb3cSopenharmony_ci    void InitializeSafeArea(const RefPtr<Platform::AceContainer>& container);
37723b3eb3cSopenharmony_ci    void InitializeDisplayAvailableRect(const RefPtr<Platform::AceContainer>& container);
37823b3eb3cSopenharmony_ci
37923b3eb3cSopenharmony_ci    void InitDragSummaryMap(const RefPtr<Platform::AceContainer>& container);
38023b3eb3cSopenharmony_ci
38123b3eb3cSopenharmony_ci    RefPtr<PopupParam> CreateCustomPopupParam(bool isShow, const CustomPopupUIExtensionConfig& config);
38223b3eb3cSopenharmony_ci    void OnPopupStateChange(const std::string& event, const CustomPopupUIExtensionConfig& config, int32_t nodeId);
38323b3eb3cSopenharmony_ci    void SetCustomPopupConfig(int32_t nodeId, const CustomPopupUIExtensionConfig& config, int32_t popupId);
38423b3eb3cSopenharmony_ci
38523b3eb3cSopenharmony_ci    void AddWatchSystemParameter();
38623b3eb3cSopenharmony_ci    void StoreConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
38723b3eb3cSopenharmony_ci
38823b3eb3cSopenharmony_ci    std::weak_ptr<OHOS::AbilityRuntime::Context> context_;
38923b3eb3cSopenharmony_ci    void* runtime_ = nullptr;
39023b3eb3cSopenharmony_ci    OHOS::Rosen::Window* window_ = nullptr;
39123b3eb3cSopenharmony_ci    std::string startUrl_;
39223b3eb3cSopenharmony_ci    int32_t instanceId_ = -1;
39323b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::IWindowDragListener> dragWindowListener_ = nullptr;
39423b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::IOccupiedAreaChangeListener> occupiedAreaChangeListener_ = nullptr;
39523b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::IAvoidAreaChangedListener> avoidAreaChangedListener_ = nullptr;
39623b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::DisplayManager::IFoldStatusListener> foldStatusListener_ = nullptr;
39723b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::DisplayManager::IDisplayModeListener> foldDisplayModeListener_ = nullptr;
39823b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::DisplayManager::IAvailableAreaListener> availableAreaChangedListener_ = nullptr;
39923b3eb3cSopenharmony_ci
40023b3eb3cSopenharmony_ci    // ITouchOutsideListener is used for touching out of hot areas of window.
40123b3eb3cSopenharmony_ci    OHOS::sptr<OHOS::Rosen::ITouchOutsideListener> touchOutsideListener_ = nullptr;
40223b3eb3cSopenharmony_ci
40323b3eb3cSopenharmony_ci    // ArkTS Form
40423b3eb3cSopenharmony_ci    bool isFormRender_ = false;
40523b3eb3cSopenharmony_ci    bool isFormRenderInit_ = false;
40623b3eb3cSopenharmony_ci    std::string bundleName_;
40723b3eb3cSopenharmony_ci    std::string moduleName_;
40823b3eb3cSopenharmony_ci    std::string hapPath_;
40923b3eb3cSopenharmony_ci    bool isBundle_ = false;
41023b3eb3cSopenharmony_ci    float formWidth_ = 0.0;
41123b3eb3cSopenharmony_ci    float formHeight_ = 0.0;
41223b3eb3cSopenharmony_ci    std::string formData_;
41323b3eb3cSopenharmony_ci    bool fontScaleFollowSystem_ = true;
41423b3eb3cSopenharmony_ci    std::map<std::string, sptr<OHOS::AppExecFwk::FormAshmem>> formImageDataMap_;
41523b3eb3cSopenharmony_ci    std::unordered_map<int32_t, CustomPopupUIExtensionConfig> customPopupConfigMap_;
41623b3eb3cSopenharmony_ci    std::unordered_map<int32_t, int32_t> popupUIExtensionRecords_;
41723b3eb3cSopenharmony_ci    std::unique_ptr<DistributedUIManager> uiManager_;
41823b3eb3cSopenharmony_ci
41923b3eb3cSopenharmony_ci    bool isDynamicRender_ = false;
42023b3eb3cSopenharmony_ci    int32_t hostInstanceId_ = -1;
42123b3eb3cSopenharmony_ci    UIContentType uIContentType_ = UIContentType::UNDEFINED;
42223b3eb3cSopenharmony_ci    std::shared_ptr<TaskWrapper> taskWrapper_;
42323b3eb3cSopenharmony_ci    std::vector<std::string> registerComponents_;
42423b3eb3cSopenharmony_ci
42523b3eb3cSopenharmony_ci    sptr<IRemoteObject> parentToken_ = nullptr;
42623b3eb3cSopenharmony_ci    sptr<IRemoteObject> instance_ = new (std::nothrow) UIContentServiceStubImpl();
42723b3eb3cSopenharmony_ci    bool isUIExtensionSubWindow_ = false;
42823b3eb3cSopenharmony_ci    bool isUIExtensionAbilityProcess_ = false;
42923b3eb3cSopenharmony_ci    bool isUIExtensionAbilityHost_ = false;
43023b3eb3cSopenharmony_ci    RefPtr<UpdateConfigManager<AceViewportConfig>> viewportConfigMgr_ =
43123b3eb3cSopenharmony_ci        Referenced::MakeRefPtr<UpdateConfigManager<AceViewportConfig>>();
43223b3eb3cSopenharmony_ci    std::unordered_map<void*, std::function<void()>> destructCallbacks_;
43323b3eb3cSopenharmony_ci
43423b3eb3cSopenharmony_ci    SingleTaskExecutor::CancelableTask updateDecorVisibleTask_;
43523b3eb3cSopenharmony_ci};
43623b3eb3cSopenharmony_ci
43723b3eb3cSopenharmony_ci} // namespace OHOS::Ace
43823b3eb3cSopenharmony_ci
43923b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_UI_CONTENT_IMPL_H
440