diff --git a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp index 1336ec0c08a3c04ca0b8670da51a8b471f6fee55..1e91044ada980b310e34e78c4c06ec251c20fbca 100644 --- a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp +++ b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp @@ -52,8 +52,6 @@ #include "core/common/text_field_manager.h" #include "core/components/bubble/bubble_component.h" #include "core/components/popup/popup_component.h" -#include "core/components_ng/pattern/dialog/dialog_mask_pattern.h" -#include "core/components_ng/pattern/dialog/dialog_pattern.h" #include "core/components_ng/pattern/menu/menu_view.h" #include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h" #include "core/components_ng/pattern/overlay/overlay_manager.h" @@ -2344,74 +2342,6 @@ bool SubwindowOhos::ShowSelectOverlay(const RefPtr& overlayNode) return true; } -void SubwindowOhos::ShowDialogMaskNG(const RefPtr& dialog) -{ - TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "subwindow show dialog mask ng"); - CHECK_NULL_VOID(dialog); - ContainerScope scope(childContainerId_); - CHECK_NULL_VOID(window_); - ShowWindow(false); - window_->SetFollowParentWindowLayoutEnabled(true); - window_->SetTouchable(true); - window_->SetFocusable(false); - - // clear hostAreas, use the full window size of default hotArea - std::vector hotAreas; - window_->SetTouchHotAreas(hotAreas); - window_->SetRaiseByClickEnabled(false); - - auto dialogPattern = dialog->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - auto dialogProps = dialogPattern->GetDialogProperties(); - - DialogProperties maskarg; - maskarg.isMask = true; - maskarg.autoCancel = dialogProps.autoCancel; - maskarg.onWillDismiss = dialogProps.onWillDismiss; - maskarg.maskColor = dialogProps.maskColor; - - auto maskNode = NG::FrameNode::CreateFrameNode(DIALOG_MASK_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), - AceType::MakeRefPtr(maskarg, dialog)); - CHECK_NULL_VOID(maskNode); - - auto aceContainer = Platform::AceContainer::GetContainer(childContainerId_); - CHECK_NULL_VOID(aceContainer); - auto pipeline = DynamicCast(aceContainer->GetPipelineContext()); - CHECK_NULL_VOID(pipeline); - auto rootNode = pipeline->GetRootElement(); - CHECK_NULL_VOID(rootNode); - maskNode->MountToParent(rootNode); - rootNode->MarkDirtyNode(NG::PROPERTY_UPDATE_MEASURE_SELF_AND_CHILD); - - auto maskPattern = maskNode->GetPattern(); - CHECK_NULL_VOID(maskPattern); - maskPattern->ShowMask(); - dialogPattern->SetUECMaskNode(maskNode); - - // raise dialog window to top - auto dialogPipeline = dialog->GetContextRefPtr(); - CHECK_NULL_VOID(dialogPipeline); - auto dialogWindow = aceContainer->GetUIWindow(dialogPipeline->GetInstanceId()); - CHECK_NULL_VOID(dialogWindow); - if (dialogWindow->RaiseToAppTop() != OHOS::Rosen::WMError::WM_OK) { - TAG_LOGW(AceLogTag::ACE_SUB_WINDOW, "failed to raise window to top, windowId: %{public}d", - dialogWindow->GetWindowId()); - } -} - -void SubwindowOhos::CloseDialogMaskNG(const RefPtr& dialog) -{ - TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "subwindow close dialog mask ng"); - CHECK_NULL_VOID(dialog); - auto dialogPattern = dialog->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - auto maskNode = dialogPattern->GetUECMaskNode(); - CHECK_NULL_VOID(maskNode); - auto maskPattern = maskNode->GetPattern(); - CHECK_NULL_VOID(maskPattern); - maskPattern->CloseMask(); -} - void SubwindowOhos::SwitchFollowParentWindowLayout(bool freeMultiWindowEnable) { TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, diff --git a/adapter/ohos/entrance/subwindow/subwindow_ohos.h b/adapter/ohos/entrance/subwindow/subwindow_ohos.h index 18e3e406044cccacc5d6fa482e56717a068f16fc..a485eda4ad34b8027686d2e95c0f52121936290e 100644 --- a/adapter/ohos/entrance/subwindow/subwindow_ohos.h +++ b/adapter/ohos/entrance/subwindow/subwindow_ohos.h @@ -217,8 +217,6 @@ public: detachState_ = t; } - void ShowDialogMaskNG(const RefPtr& dialog) override; - void CloseDialogMaskNG(const RefPtr& dialog) override; void SwitchFollowParentWindowLayout(bool freeMultiWindowEnable) override; bool NeedFollowParentWindowLayout() override { diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 51528d61b8549ae3f216a16b8e08f82acfdbeee0..5dfca0b2067be86879f7350c4f7a4faa92b90dcb 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -113,7 +113,6 @@ #include "core/components_ng/base/view_abstract.h" #include "core/components_ng/pattern/container_modal/container_modal_view.h" #include "core/components_ng/pattern/container_modal/enhance/container_modal_view_enhance.h" -#include "core/components_ng/pattern/overlay/overlay_mask_manager.h" #include "core/components_ng/pattern/text_field/text_field_manager.h" #include "core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.h" #include "core/components_ng/pattern/ui_extension/ui_extension_config.h" @@ -2513,7 +2512,6 @@ UIContentErrorCode UIContentImpl::CommonInitialize( InitializeSafeArea(container); InitializeDisplayAvailableRect(container); - NG::OverlayMaskManager::GetInstance().RegisterOverlayHostMaskEventCallback(); // set container temp dir if (abilityContext) { diff --git a/adapter/ohos/osal/modal_ui_extension_impl.cpp b/adapter/ohos/osal/modal_ui_extension_impl.cpp index acf4b7da351efb6b2f3efac87aaa5532163a4bfa..982fce67c07fb2891eaab348de81ed266254d1f8 100644 --- a/adapter/ohos/osal/modal_ui_extension_impl.cpp +++ b/adapter/ohos/osal/modal_ui_extension_impl.cpp @@ -13,9 +13,7 @@ * limitations under the License. */ -#include "want.h" #include "core/common/modal_ui_extension.h" -#include "core/components_ng/pattern/ui_extension/ui_extension_manager.h" #include "core/components_ng/pattern/ui_extension/ui_extension_model_ng.h" #include "core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.h" @@ -41,71 +39,4 @@ void ModalUIExtension::SetBindModalCallback(const RefPtr& uiExtNo CHECK_NULL_VOID(pattern); pattern->SetBindModalCallback(std::move(bindModalCallback)); } - -OHOS::AAFwk::Want GetWantFromUECHostMaskInfo(const UECHostMaskInfo& maskInfo) -{ - OHOS::AAFwk::Want want; - want.SetParam("uuid", maskInfo.uuid); - want.SetParam("instanceId", maskInfo.instanceId); - want.SetParam("overlayTag", maskInfo.overlayTag); - want.SetParam("overlayId", maskInfo.overlayId); - want.SetParam("maskAction", static_cast(maskInfo.maskAction)); - want.SetParam("maskType", static_cast(maskInfo.maskType)); - if (maskInfo.maskColor.has_value()) { - want.SetParam("maskColor", maskInfo.maskColor.value().ToString()); - } - return want; -} - -UECHostMaskInfo ModalUIExtension::GetUECHostMaskInfoFromWant(const OHOS::AAFwk::Want& want) -{ - UECHostMaskInfo maskInfo; - maskInfo.uuid = want.GetStringParam("uuid"); - maskInfo.instanceId = want.GetIntParam("instanceId", -1); - maskInfo.overlayTag = want.GetStringParam("overlayTag"); - maskInfo.overlayId = want.GetIntParam("overlayId", -1); - maskInfo.maskAction = static_cast(want.GetIntParam("maskAction", 0)); - maskInfo.maskType = static_cast(want.GetIntParam("maskType", 0)); - - if (want.HasParameter("maskColor")) { - maskInfo.maskColor = Color::FromString(want.GetStringParam("maskColor")); - } - return maskInfo; -} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnUEA(const RefPtr& uiExtMgr, - NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{ - CHECK_NULL_VOID(uiExtMgr); - uiExtMgr->RegisterBusinessDataConsumeCallback(code, std::move(callback)); -} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnHost( - const RefPtr& uiExtNode, NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{ - CHECK_NULL_VOID(uiExtNode); - auto pattern = uiExtNode->GetPattern(); - CHECK_NULL_VOID(pattern); - pattern->RegisterUIExtBusinessConsumeCallback(code, std::move(callback)); -} - -bool ModalUIExtension::SendOverlayMaskInfoToUEA(const RefPtr& uiExtNode, const UECHostMaskInfo& info, - NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - CHECK_NULL_RETURN(uiExtNode, false); - auto pattern = uiExtNode->GetPattern(); - CHECK_NULL_RETURN(pattern, false); - - OHOS::AAFwk::Want data = GetWantFromUECHostMaskInfo(info); - return pattern->SendBusinessData(code, std::move(data), type); -} - -bool ModalUIExtension::SendOverlayMaskInfoToHost(const RefPtr& uiExtMgr, - const UECHostMaskInfo& info, NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - CHECK_NULL_RETURN(uiExtMgr, false); - - OHOS::AAFwk::Want data = GetWantFromUECHostMaskInfo(info); - return uiExtMgr->SendBusinessToHost(code, std::move(data), type); -} } // namespace OHOS::Ace diff --git a/adapter/preview/osal/modal_ui_extension_impl.cpp b/adapter/preview/osal/modal_ui_extension_impl.cpp index 868aaee6e93e76be3b59b9b5690de7a135aaa109..9e5ab7015a58252ea807a1888fbc9ade5193c3e5 100644 --- a/adapter/preview/osal/modal_ui_extension_impl.cpp +++ b/adapter/preview/osal/modal_ui_extension_impl.cpp @@ -32,29 +32,4 @@ void ModalUIExtension::SetBindModalCallback(const RefPtr& uiExtNo std::function&& bindModalCallback) { } - -UECHostMaskInfo ModalUIExtension::GetUECHostMaskInfoFromWant(const AAFwk::Want& data) -{ - return {}; -} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnUEA(const RefPtr& uiExtMgr, - NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnHost( - const RefPtr& uiExtNode, NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{} - -bool ModalUIExtension::SendOverlayMaskInfoToUEA(const RefPtr& uiExtNode, const UECHostMaskInfo& info, - NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - return false; -} - -bool ModalUIExtension::SendOverlayMaskInfoToHost(const RefPtr& uiExtMgr, - const UECHostMaskInfo& info, NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - return false; -} } // namespace OHOS::Ace diff --git a/frameworks/base/subwindow/subwindow.h b/frameworks/base/subwindow/subwindow.h index e2be62a7e19feae3d3bcfd009b48d940038b68ab..6fddbe1c543b2dc3e0cd3f89c45db95596a4febe 100644 --- a/frameworks/base/subwindow/subwindow.h +++ b/frameworks/base/subwindow/subwindow.h @@ -255,8 +255,6 @@ public: std::function&& onWidthDidChange, std::function&& onTypeDidChange, std::function&& sheetSpringBack, const RefPtr& targetNode) = 0; - virtual void ShowDialogMaskNG(const RefPtr& dialog) = 0; - virtual void CloseDialogMaskNG(const RefPtr& dialog) = 0; virtual void SwitchFollowParentWindowLayout(bool freeMultiWindowEnable) = 0; virtual bool NeedFollowParentWindowLayout() = 0; virtual void AddFollowParentWindowLayoutNode(int32_t nodeId) = 0; diff --git a/frameworks/base/subwindow/subwindow_manager.cpp b/frameworks/base/subwindow/subwindow_manager.cpp index 0e978839475b36b4e7b6046a0f895d1ba0f14d7f..411534fcf9a94ca898219194a6837ff728b7d4ca 100644 --- a/frameworks/base/subwindow/subwindow_manager.cpp +++ b/frameworks/base/subwindow/subwindow_manager.cpp @@ -1798,70 +1798,4 @@ void SubwindowManager::AddSubwindowBySearchKey(const SubwindowKey& searchKey, co } AddInstanceSubwindowMap(subwindow->GetChildContainerId(), subwindow); } - -void SubwindowManager::AddMaskSubwindowMap(int32_t dialogId, const RefPtr& subwindow) -{ - std::lock_guard lock(maskSubwindowMutex_); - maskSubWindowMap_.try_emplace(dialogId, subwindow); -} - -void SubwindowManager::RemoveMaskSubwindowMap(int32_t dialogId) -{ - std::lock_guard lock(maskSubwindowMutex_); - maskSubWindowMap_.erase(dialogId); -} - -const RefPtr SubwindowManager::GetMaskSubwindow(int32_t dialogId) -{ - std::lock_guard lock(maskSubwindowMutex_); - auto result = maskSubWindowMap_.find(dialogId); - if (result != maskSubWindowMap_.end()) { - return result->second; - } else { - return nullptr; - } -} - -void SubwindowManager::ShowDialogMaskNG(const RefPtr& dialog) -{ - TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "show dialog mask ng enter"); - CHECK_NULL_VOID(dialog); - auto dialogId = dialog->GetId(); - auto maskSubwindow = GetMaskSubwindow(dialogId); - if (maskSubwindow) { - TAG_LOGW(AceLogTag::ACE_SUB_WINDOW, "maskSubwindow is exist, dialogId: %{public}d, subContainerId: %{public}d", - dialogId, maskSubwindow->GetChildContainerId()); - return; - } - - auto pipeline = NG::PipelineContext::GetMainPipelineContext(); - CHECK_NULL_VOID(pipeline); - auto subwindow = Subwindow::CreateSubwindow(pipeline->GetInstanceId()); - CHECK_NULL_VOID(subwindow); - subwindow->InitContainer(); - CHECK_NULL_VOID(subwindow->GetIsRosenWindowCreate()); - AddMaskSubwindowMap(dialogId, subwindow); - AddInstanceSubwindowMap(subwindow->GetChildContainerId(), subwindow); - subwindow->ShowDialogMaskNG(dialog); -} - -void SubwindowManager::CloseDialogMaskNG(const RefPtr& dialog) -{ - TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "close dialog mask ng enter"); - CHECK_NULL_VOID(dialog); - auto maskSubwindow = GetMaskSubwindow(dialog->GetId()); - CHECK_NULL_VOID(maskSubwindow); - maskSubwindow->CloseDialogMaskNG(dialog); -} - -void SubwindowManager::CloseMaskSubwindow(int32_t dialogId) -{ - TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "close mask subwindow enter, dialogId: %{public}d", dialogId); - auto maskSubwindow = GetMaskSubwindow(dialogId); - CHECK_NULL_VOID(maskSubwindow); - - if (maskSubwindow->Close()) { - RemoveMaskSubwindowMap(dialogId); - } -} } // namespace OHOS::Ace diff --git a/frameworks/base/subwindow/subwindow_manager.h b/frameworks/base/subwindow/subwindow_manager.h index ba0f6d62b7d7c24a1aaae2e2562973e50bdbd258..f6c11b7a1e56a80bb9670a731a5ae7553168af89 100644 --- a/frameworks/base/subwindow/subwindow_manager.h +++ b/frameworks/base/subwindow/subwindow_manager.h @@ -218,12 +218,6 @@ public: const RefPtr GetSubwindowByType(int32_t instanceId, SubwindowType windowType); void AddSubwindow(int32_t instanceId, SubwindowType windowType, RefPtr subwindow); const std::vector> GetSortSubwindow(int32_t instanceId); - void AddMaskSubwindowMap(int32_t dialogId, const RefPtr& subwindow); - void RemoveMaskSubwindowMap(int32_t dialogId); - const RefPtr GetMaskSubwindow(int32_t dialogId); - void ShowDialogMaskNG(const RefPtr& dialog); - void CloseDialogMaskNG(const RefPtr& dialog); - void CloseMaskSubwindow(int32_t dialogId); private: RefPtr GetOrCreateSubWindow(bool isDialog = false); @@ -264,10 +258,6 @@ private: Rect uiExtensionWindowRect_; bool isSuperFoldDisplayDevice_ = false; bool expandDisplay_ = false; - - std::mutex maskSubwindowMutex_; - std::unordered_map> maskSubWindowMap_; - }; } // namespace OHOS::Ace diff --git a/frameworks/core/common/modal_ui_extension.h b/frameworks/core/common/modal_ui_extension.h index 6c81e28c70eca090a3486a6c37bf5b9ae5fb79c1..203507f2674dbdc01d0dce75ce79b7a36d92b35a 100644 --- a/frameworks/core/common/modal_ui_extension.h +++ b/frameworks/core/common/modal_ui_extension.h @@ -18,9 +18,7 @@ #include -#include "core/components/dialog/dialog_properties.h" #include "core/components_ng/base/frame_node.h" -#include "core/components_ng/pattern/ui_extension/ui_extension_config.h" #include "core/components_ng/pattern/ui_extension/ui_extension_model.h" namespace OHOS::AAFwk { @@ -29,13 +27,8 @@ class Want; namespace OHOS::Ace { struct ModalUIExtensionCallbacks; -using BusinessDataUECConsumeCallback = std::function; } // namespace OHOS::Ace -namespace OHOS::Ace::NG { -class UIExtensionManager; -} // namespace OHOS::Ace::NG - namespace OHOS::Ace { class ModalUIExtension final { public: @@ -46,20 +39,6 @@ public: static void SetBindModalCallback(const RefPtr& uiExtNode, std::function&& bindModalCallback); - - static UECHostMaskInfo GetUECHostMaskInfoFromWant(const AAFwk::Want& data); - - static void RegisterBusinessConsumeCallbackOnUEA(const RefPtr& uiExtMgr, - NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback); - - static void RegisterBusinessConsumeCallbackOnHost(const RefPtr& uiExtNode, - NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback); - - static bool SendOverlayMaskInfoToUEA(const RefPtr& uiExtNode, const UECHostMaskInfo& info, - NG::UIContentBusinessCode code, NG::BusinessDataSendType type = NG::BusinessDataSendType::ASYNC); - - static bool SendOverlayMaskInfoToHost(const RefPtr& uiExtMgr, const UECHostMaskInfo& info, - NG::UIContentBusinessCode code, NG::BusinessDataSendType type = NG::BusinessDataSendType::ASYNC); }; } // namespace OHOS::Ace diff --git a/frameworks/core/components/dialog/dialog_properties.h b/frameworks/core/components/dialog/dialog_properties.h index 01bad1946dab2458da480fa5955f1443c3fe6895..254f7e80938543b59f5e0ef267da714ad8b9a7ed 100644 --- a/frameworks/core/components/dialog/dialog_properties.h +++ b/frameworks/core/components/dialog/dialog_properties.h @@ -281,7 +281,6 @@ struct DialogProperties { bool isShowInSubWindow = false; DialogButtonDirection buttonDirection = DialogButtonDirection::AUTO; bool isMask = false; - bool isUECHostMask = false; bool isModal = true; std::optional enableHoverMode; bool isSceneBoardDialog = false; @@ -399,21 +398,6 @@ struct PromptDialogAttr { WeakPtr customCNode; }; -enum class UECHostMaskAction { - NONE = 0, - MOUNT, - UNMOUNT, - UPDATE, - CLICK, - PRESS_BACK, -}; - -enum class UECHostMaskType { - NONE = 0, - DIALOG, - BIND_SHEET, -}; - enum class PromptActionCommonState { UNINITIALIZED = 0, INITIALIZED = 1, @@ -423,35 +407,6 @@ enum class PromptActionCommonState { DISAPPEARED = 5, }; -struct UECHostMaskInfo { - std::string uuid; - int32_t instanceId = -1; - - std::string overlayTag; // the tag of overlay node on UEA - int32_t overlayId = -1; // the id of overlay node on UEA - - std::optional maskColor; - UECHostMaskAction maskAction = UECHostMaskAction::NONE; - UECHostMaskType maskType = UECHostMaskType::NONE; - - std::string ToString() const - { - std::stringstream ss; - ss << "uuid: " << uuid << ", "; - ss << "instanceId: " << instanceId << ", "; - ss << "overlayTag: " << overlayTag << ", "; - ss << "overlayId: " << overlayId << ", "; - if (maskColor.has_value()) { - ss << "maskColor: " << maskColor.value().ToString() << ", "; - } - ss << "maskAction: " << static_cast(maskAction) << ", "; - ss << "maskType: " << static_cast(maskType); - - std::string output = ss.str(); - return output; - }; -}; - } // namespace OHOS::Ace #endif // FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_CORE_COMPONENTS_COMMON_PROPERTIES_DIALOG_PROPERTIES_H diff --git a/frameworks/core/components_ng/pattern/BUILD.gn b/frameworks/core/components_ng/pattern/BUILD.gn index 822a19b5d16b944380fd41c3532a14d6a9dd391e..35eb4978211c78ac29cd11c1f3d5ed1c63284a06 100644 --- a/frameworks/core/components_ng/pattern/BUILD.gn +++ b/frameworks/core/components_ng/pattern/BUILD.gn @@ -114,7 +114,6 @@ build_component_ng("pattern_ng") { "dialog/dialog_accessibility_property.cpp", "dialog/dialog_event_hub.cpp", "dialog/dialog_layout_algorithm.cpp", - "dialog/dialog_mask_pattern.cpp", "dialog/dialog_pattern.cpp", "dialog/dialog_view.cpp", "divider/divider_layout_algorithm.cpp", @@ -314,7 +313,6 @@ build_component_ng("pattern_ng") { "overlay/modal_presentation_pattern.cpp", "overlay/overlay_container_pattern.cpp", "overlay/overlay_manager.cpp", - "overlay/overlay_mask_manager.cpp", "overlay/popup_base_pattern.cpp", "overlay/sheet_drag_bar_paint_method.cpp", "overlay/sheet_drag_bar_pattern.cpp", diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp index 1cb5f7b54e3837ffda3160ca870b487277d8aa20..cfbd14674ab1bdcb588cd27d4549a70fd0835ab1 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp @@ -43,6 +43,7 @@ constexpr double HALF = 2.0; constexpr double LANDSCAPE_DIALOG_WIDTH_RATIO = 0.75; constexpr Dimension SCROLL_MIN_HEIGHT_SUITOLD = 100.0_vp; constexpr int32_t TEXT_ALIGN_CONTENT_CENTER = 1; +constexpr int32_t EXTRA_MASK_NODE_INDEX = 1; } // namespace void DialogLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) @@ -579,6 +580,9 @@ void DialogLayoutAlgorithm::ProcessMaskRect( dialogContext->UpdateClipEdge(true); } } + if (isUIExtensionSubWindow_ && isModal_) { + ClipUIExtensionSubWindowContent(dialog); + } auto gestureHub = hub->GetOrCreateGestureEventHub(); std::vector mouseResponseRegion; mouseResponseRegion.emplace_back(width, height, offset); @@ -586,6 +590,26 @@ void DialogLayoutAlgorithm::ProcessMaskRect( gestureHub->SetResponseRegion(mouseResponseRegion); } +std::optional DialogLayoutAlgorithm::GetMaskRect(const RefPtr& dialog) +{ + std::optional maskRect; + auto dialogPattern = dialog->GetPattern(); + CHECK_NULL_RETURN(dialogPattern, maskRect); + maskRect = dialogPattern->GetDialogProperties().maskRect; + if (!isUIExtensionSubWindow_) { + return maskRect; + } + + if (expandDisplay_ && hostWindowRect_.GetSize().IsPositive()) { + auto offset = DimensionOffset(Dimension(hostWindowRect_.GetX()), Dimension(hostWindowRect_.GetY())); + maskRect = DimensionRect(Dimension(hostWindowRect_.Width()), Dimension(hostWindowRect_.Height()), offset); + } else { + maskRect = DimensionRect(CalcDimension(1, DimensionUnit::PERCENT), CalcDimension(1, DimensionUnit::PERCENT), + DimensionOffset(CalcDimension(0, DimensionUnit::VP), CalcDimension(0, DimensionUnit::VP))); + } + return maskRect; +} + void DialogLayoutAlgorithm::UpdateCustomMaskNodeLayout(const RefPtr& dialog) { auto maskNodePtr = dialog->GetChildByIndex(1); @@ -623,7 +647,8 @@ void DialogLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) auto dialogPattern = frameNode->GetPattern(); CHECK_NULL_VOID(dialogPattern); if (isModal_ && dialogPattern->GetDialogProperties().maskRect.has_value()) { - ProcessMaskRect(dialogPattern->GetDialogProperties().maskRect, frameNode, true); + std::optional maskRect = GetMaskRect(frameNode); + ProcessMaskRect(maskRect, frameNode, true); } if (hasAddMaskNode_) { UpdateCustomMaskNodeLayout(frameNode); @@ -645,7 +670,8 @@ void DialogLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) dialogOffset_ = dialogProp->GetDialogOffset().value_or(DimensionOffset()); alignment_ = dialogProp->GetDialogAlignment().value_or(DialogAlignment::DEFAULT); topLeftPoint_ = ComputeChildPosition(childSize, dialogProp, selfSize); - if ((!isModal_ || isShowInSubWindow_) && !dialogProp->GetIsSceneBoardDialog().value_or(false)) { + auto isNonUIExtensionSubwindow = isShowInSubWindow_ && !isUIExtensionSubWindow_; + if ((!isModal_ || isNonUIExtensionSubwindow) && !dialogProp->GetIsSceneBoardDialog().value_or(false)) { ProcessMaskRect( DimensionRect(Dimension(childSize.Width()), Dimension(childSize.Height()), DimensionOffset(topLeftPoint_)), frameNode); @@ -753,6 +779,18 @@ void DialogLayoutAlgorithm::SetSubWindowHotarea( } else { rect = Rect(0.0f, 0.0f, selfSize.Width(), selfSize.Height()); } + if (isUIExtensionSubWindow_ && isModal_) { + if (expandDisplay_) { + auto isValid = hostWindowRect_.GetSize().IsPositive(); + auto hostOffset = Offset(hostWindowRect_.GetX(), hostWindowRect_.GetY()); + auto hostSize = Size(hostWindowRect_.Width(), hostWindowRect_.Height()); + rect = isValid ? Rect(hostOffset, hostSize) : Rect(0.0f, 0.0f, selfSize.Width(), selfSize.Height()); + auto contentRect = Rect(topLeftPoint_.GetX(), topLeftPoint_.GetY(), childSize.Width(), childSize.Height()); + rects.emplace_back(contentRect); + } else { + rect = Rect(0.0f, 0.0f, selfSize.Width(), selfSize.Height()); + } + } rects.emplace_back(rect); SubwindowManager::GetInstance()->SetHotAreas(rects, SubwindowType::TYPE_DIALOG, frameNodeId, subWindowId_); } @@ -1040,6 +1078,45 @@ void DialogLayoutAlgorithm::UpdateSafeArea(const RefPtr& frameNode) TAG_LOGI(AceLogTag::ACE_DIALOG, "safeAreaInsets: %{public}s", safeAreaInsets_.ToString().c_str()); } +void DialogLayoutAlgorithm::ClipUIExtensionSubWindowContent(const RefPtr& dialog) +{ + CHECK_NULL_VOID(dialog); + auto dialogLayoutProp = AceType::DynamicCast(dialog->GetLayoutProperty()); + CHECK_NULL_VOID(dialogLayoutProp); + auto isFullScreen = + IsGetExpandDisplayValidHeight(dialogLayoutProp) && NearEqual(expandDisplayValidHeight_, hostWindowRect_.Height()); + auto maskNodePtr = dialog->GetChildByIndex(EXTRA_MASK_NODE_INDEX); + CHECK_NULL_VOID(maskNodePtr); + auto maskNode = AceType::DynamicCast(maskNodePtr); + CHECK_NULL_VOID(maskNode); + auto maskNodeLayoutProp = maskNode->GetLayoutProperty(); + CHECK_NULL_VOID(maskNodeLayoutProp); + auto maskGeometryNode = maskNode->GetGeometryNode(); + CHECK_NULL_VOID(maskGeometryNode); + if (expandDisplay_) { + maskNodeLayoutProp->ClearUserDefinedIdealSize(true, true); + SizeF realSize; + realSize.SetWidth(hostWindowRect_.Width()); + realSize.SetHeight(hostWindowRect_.Height()); + maskGeometryNode->SetFrameSize(realSize); + OffsetF offset; + offset.SetX(hostWindowRect_.GetX()); + offset.SetY(hostWindowRect_.GetY()); + maskGeometryNode->SetFrameOffset(offset); + if (!isFullScreen) { + auto maskNodeContext = maskNode->GetRenderContext(); + CHECK_NULL_VOID(maskNodeContext); + maskNodeContext->UpdateBorderRadius(NG::BorderRadiusPropertyT(CONTAINER_OUTER_RADIUS)); + } + } else { + maskNodeLayoutProp->UpdateUserDefinedIdealSize( + CalcSize(CalcLength(1.0, DimensionUnit::PERCENT), CalcLength(1.0, DimensionUnit::PERCENT))); + maskGeometryNode->SetFrameOffset(OffsetF(0, 0)); + maskNode->Measure(dialog->GetLayoutConstraint()); + } + maskNode->Layout(); +} + void DialogLayoutAlgorithm::UpdateIsScrollHeightNegative(LayoutWrapper* layoutWrapper, float height) { if (height < SCROLL_MIN_HEIGHT_SUITOLD.ConvertToPx()) { diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.h b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.h index 2f6b613a9da49a0fcb8b7ad9e2ed3610acedf380..42ef0f0f2005444ae045b93d5986d2e0fe746f55 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.h +++ b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.h @@ -81,6 +81,7 @@ private: void ProcessMaskRect(std::optional maskRect, const RefPtr& dialog, bool isMask = false); void SetSubWindowHotarea( const RefPtr& dialogProp, SizeF childSize, SizeF selfSize, int32_t frameNodeId); + std::optional GetMaskRect(const RefPtr& dialog); void UpdateTouchRegion(); @@ -94,6 +95,7 @@ private: void UpdateSafeArea(const RefPtr& frameNode); void UpdateChildLayoutConstraint(const RefPtr& dialogProp, LayoutConstraintF& childLayoutConstraint, RefPtr& childLayoutWrapper); + void ClipUIExtensionSubWindowContent(const RefPtr& dialog); void AdjustHeightForKeyboard(LayoutWrapper* layoutWrapper, const RefPtr& child); void UpdateIsScrollHeightNegative(LayoutWrapper* layoutWrapper, float height); void UpdateChildMaxSizeHeight(SizeT& maxSize); diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.cpp deleted file mode 100644 index fb20ad5bd20201820d9a4692a51dc9ef320cb887..0000000000000000000000000000000000000000 --- a/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/components_ng/pattern/dialog/dialog_mask_pattern.h" - -#include "base/subwindow/subwindow_manager.h" -#include "core/pipeline_ng/pipeline_context.h" - -namespace OHOS::Ace::NG { -void DialogMaskPattern::OnAttachToFrameNode() -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - - auto maskLayoutProps = host->GetLayoutProperty(); - CHECK_NULL_VOID(maskLayoutProps); - maskLayoutProps->UpdateMeasureType(MeasureType::MATCH_PARENT); - maskLayoutProps->UpdateAlignment(Alignment::TOP_LEFT); - - auto pipeline = host->GetContextRefPtr(); - CHECK_NULL_VOID(pipeline); - auto dialogTheme = pipeline->GetTheme(); - CHECK_NULL_VOID(dialogTheme); - - auto maskRenderContext = host->GetRenderContext(); - CHECK_NULL_VOID(maskRenderContext); - auto dialogProps = GetDialogProperties(); - maskRenderContext->UpdateBackgroundColor(dialogProps.maskColor.value_or(dialogTheme->GetMaskColorEnd())); - - InitClickEvent(); -} - -void DialogMaskPattern::InitClickEvent() -{ - if (onClick_) { - return; - } - - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto gestureHub = host->GetOrCreateGestureEventHub(); - CHECK_NULL_VOID(gestureHub); - - GestureEventFunc task = [weak = WeakClaim(this)](const GestureEvent& info) { - auto pattern = weak.Upgrade(); - CHECK_NULL_VOID(pattern); - auto dialog = pattern->GetDialogNode(); - if (!dialog) { - TAG_LOGW(AceLogTag::ACE_DIALOG, "dialog node is null, close mask by click"); - pattern->CloseMask(); - return; - } - - auto dialogProps = pattern->GetDialogProperties(); - if (dialogProps.autoCancel) { - CHECK_NULL_VOID(dialog); - auto dialogPattern = dialog->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - dialogPattern->CloseDialogByEvent(DialogDismissReason::DIALOG_TOUCH_OUTSIDE); - } - }; - onClick_ = MakeRefPtr(std::move(task)); - gestureHub->AddClickEvent(onClick_); -} - -void DialogMaskPattern::ShowMask() -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto renderContext = host->GetRenderContext(); - CHECK_NULL_VOID(renderContext); - - auto pipeline = host->GetContextRefPtr(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - - AnimationOption option; - option.SetCurve(Curves::SHARP); - option.SetDuration(theme->GetOpacityAnimationDurIn()); - - renderContext->OpacityAnimation(option, theme->GetOpacityStart(), theme->GetOpacityEnd()); -} - -void DialogMaskPattern::CloseMask() -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto renderContext = host->GetRenderContext(); - CHECK_NULL_VOID(renderContext); - - auto pipeline = host->GetContextRefPtr(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - ContainerScope scope(pipeline->GetInstanceId()); - - auto dialog = GetDialogNode(); - auto dialogId = dialog ? dialog->GetId() : dialogId_; - - AnimationOption option; - option.SetCurve(Curves::SHARP); - option.SetDuration(theme->GetAnimationDurationOut()); - option.SetOnFinishEvent([weakHost = WeakClaim(RawPtr(host)), dialogId]() { - auto host = weakHost.Upgrade(); - CHECK_NULL_VOID(host); - auto parent = host->GetParent(); - CHECK_NULL_VOID(parent); - parent->RemoveChild(host); - parent->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); - - SubwindowManager::GetInstance()->CloseMaskSubwindow(dialogId); - }); - - renderContext->OpacityAnimation(option, theme->GetOpacityEnd(), theme->GetOpacityStart()); -} -} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.h b/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.h deleted file mode 100644 index a426f3244b9f59413f77fd5a9cdd1bfb2d4c5a8f..0000000000000000000000000000000000000000 --- a/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIALOG_DIALOG_MASK_PATTERN_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIALOG_DIALOG_MASK_PATTERN_H - -#include "core/common/ace_engine.h" -#include "core/components_ng/pattern/dialog/dialog_pattern.h" -#include "core/components_ng/pattern/overlay/popup_base_pattern.h" - -const char DIALOG_MASK_ETS_TAG[] = "DialogMask"; - -namespace OHOS::Ace::NG { -class DialogMaskPattern : virtual public PopupBasePattern { - DECLARE_ACE_TYPE(DialogMaskPattern, PopupBasePattern); - -public: - DialogMaskPattern() = default; - DialogMaskPattern(const DialogProperties& param, const RefPtr& dialog) - : dialogProperties_(param), dialogNode_(dialog) - { - dialogId_ = dialog ? dialog->GetId() : -1; - } - ~DialogMaskPattern() override = default; - - FocusPattern GetFocusPattern() const override - { - return { FocusType::SCOPE, false }; - } - - const DialogProperties& GetDialogProperties() const - { - return dialogProperties_; - } - - const RefPtr GetDialogNode() - { - return dialogNode_.Upgrade(); - } - - void OnAttachToFrameNode() override; - void InitClickEvent(); - void ShowMask(); - void CloseMask(); - -protected: - bool AvoidKeyboard() const override - { - return false; - } - - bool AvoidBottom() const override - { - return false; - } - -private: - DialogProperties dialogProperties_; - WeakPtr dialogNode_; - RefPtr onClick_; - int32_t dialogId_ = -1; - - ACE_DISALLOW_COPY_AND_MOVE(DialogMaskPattern); -}; -} // namespace OHOS::Ace::NG - -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIALOG_DIALOG_MASK_PATTERN_H diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp index 7731c4bc1836941b3ebde0d5eaa5df58ac137f6c..42151d573da5c29cb213981dbd276aa9894d1770 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp @@ -52,7 +52,6 @@ #include "core/components_ng/pattern/navrouter/navdestination_pattern.h" #include "core/components_ng/pattern/overlay/dialog_manager.h" #include "core/components_ng/pattern/overlay/overlay_manager.h" -#include "core/components_ng/pattern/overlay/overlay_mask_manager.h" #include "core/components_ng/pattern/relative_container/relative_container_model_ng.h" #include "core/components_ng/pattern/relative_container/relative_container_pattern.h" #include "core/components_ng/pattern/scroll/scroll_pattern.h" @@ -250,52 +249,27 @@ void DialogPattern::HandleClick(const GestureEvent& info) auto&& clickPosition = info.GetGlobalLocation(); if (!contentRect.IsInRegion( PointF(clickPosition.GetX() - globalOffset.GetX(), clickPosition.GetY() - globalOffset.GetY()))) { - if (dialogProperties_.isUECHostMask) { - NG::OverlayMaskManager::GetInstance().SendDialogMaskEventToUEA(host, UECHostMaskAction::CLICK); + auto overlayManager = GetOverlayManager(nullptr); + CHECK_NULL_VOID(overlayManager); + if (this->CallDismissInNDK(static_cast(DialogDismissReason::DIALOG_TOUCH_OUTSIDE))) { + return; + } else if (this->ShouldDismiss()) { + overlayManager->SetDismissDialogId(host->GetId()); + DialogManager::GetInstance().SetDismissDialogInfo(host->GetId(), host->GetTag()); + auto currentId = Container::CurrentId(); + this->CallOnWillDismiss(static_cast(DialogDismissReason::DIALOG_TOUCH_OUTSIDE), currentId); + TAG_LOGI(AceLogTag::ACE_DIALOG, "Dialog Should Dismiss, currentId: %{public}d", currentId); return; } - CloseDialogByEvent(DialogDismissReason::DIALOG_TOUCH_OUTSIDE); + PopDialog(-1); + if (overlayManager->isMaskNode(GetHost()->GetId())) { + overlayManager->PopModalDialog(GetHost()->GetId()); + } } } } -void DialogPattern::CloseDialogByEvent(DialogDismissReason reason) -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto overlayManager = GetOverlayManager(nullptr); - CHECK_NULL_VOID(overlayManager); - - if (CallDismissInNDK(static_cast(reason))) { - return; - } - - if (ShouldDismiss()) { - overlayManager->SetDismissDialogId(host->GetId()); - DialogManager::GetInstance().SetDismissDialogInfo(host->GetId(), host->GetTag()); - auto currentId = Container::CurrentId(); - CallOnWillDismiss(static_cast(reason), currentId); - TAG_LOGI(AceLogTag::ACE_DIALOG, "Dialog Should Dismiss, currentId: %{public}d", currentId); - return; - } - - CloseDialog(); -} - -void DialogPattern::CloseDialog() -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto overlayManager = GetOverlayManager(nullptr); - CHECK_NULL_VOID(overlayManager); - - PopDialog(-1); - if (overlayManager->isMaskNode(host->GetId()) && !dialogProperties_.isUECHostMask) { - overlayManager->PopModalDialog(host->GetId()); - } -} - void DialogPattern::PopDialog(int32_t buttonIdx = -1) { auto host = GetHost(); @@ -590,7 +564,8 @@ void DialogPattern::AddExtraMaskNode(const DialogProperties& props) auto dialogTheme = pipeline->GetTheme(); CHECK_NULL_VOID(dialogTheme); auto needAddMaskNode = props.maskTransitionEffect != nullptr || props.dialogTransitionEffect != nullptr; - if (needAddMaskNode && props.isModal && !props.isShowInSubWindow) { + if ((IsUIExtensionSubWindow() && props.isModal) || + (needAddMaskNode && props.isModal && !props.isShowInSubWindow)) { auto extraMaskNode = FrameNode::CreateFrameNode(V2::COLUMN_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr(true)); CHECK_NULL_VOID(extraMaskNode); @@ -1945,7 +1920,15 @@ void DialogPattern::UpdateHostWindowRect() return; } - if (!SystemProperties::IsSuperFoldDisplayDevice()) { + auto needUpdate = true; + if (SystemProperties::IsSuperFoldDisplayDevice()) { + auto container = AceEngine::Get().GetContainer(currentId); + auto isHalfFold = container && container->GetCurrentFoldStatus() == FoldStatus::HALF_FOLD; + auto subwindow = SubwindowManager::GetInstance()->GetSubwindowById(currentId); + needUpdate = isHalfFold && subwindow && subwindow->IsSameDisplayWithParentWindow() && dialogProperties_.isModal; + } + + if (needUpdate) { InitHostWindowRect(); host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); } @@ -2268,7 +2251,6 @@ void DialogPattern::OnAttachToMainTree() AddFollowParentWindowLayoutNode(); auto host = GetHost(); CHECK_NULL_VOID(host); - MountUECMask(); auto parentNode = AceType::DynamicCast(host->GetParent()); CHECK_NULL_VOID(parentNode); if (parentNode->GetTag() != V2::NAVDESTINATION_VIEW_ETS_TAG) { @@ -2294,16 +2276,6 @@ void DialogPattern::OnDetachFromMainTree() overlay->RemoveDialogFromMapForcefully(host); } -void DialogPattern::MountUECMask() -{ - auto host = GetHost(); - CHECK_NULL_VOID(host); - - if (isUIExtensionSubWindow_ && dialogProperties_.isModal) { - SubwindowManager::GetInstance()->ShowDialogMaskNG(host); - } -} - RefPtr DialogPattern::GetOverlayManager(const RefPtr& host) { RefPtr pipeline; diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.h b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.h index 64b8b9efce96610f4a47f505443c45fd01c3e30d..0c127c8fce9d37a652e28466dff9b1186e015407 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.h +++ b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.h @@ -352,28 +352,6 @@ public: void OverlayDismissDialog(const RefPtr& dialogNode); RefPtr GetEmbeddedOverlay(const RefPtr& context); - void MountUECMask(); - void CloseDialog(); - void CloseDialogByEvent(DialogDismissReason reason = DialogDismissReason::DIALOG_TOUCH_OUTSIDE); - void SetUECHostMaskInfo(UECHostMaskInfo maskInfo) - { - hostMaskInfo_ = maskInfo; - } - - UECHostMaskInfo GetUECHostMaskInfo() - { - return hostMaskInfo_; - } - - void SetUECMaskNode(const RefPtr& dialogNode) - { - uecMaskNode_ = dialogNode; - } - - const RefPtr GetUECMaskNode() - { - return uecMaskNode_.Upgrade(); - } void UpdateDialogColor(const Color& color, const DialogResourceType type); void UpdateContentValue(std::string& text, const DialogResourceType type); void UpdateLayoutContent(const CalcDimension& value, const DialogResourceType type); @@ -519,8 +497,6 @@ private: bool isUIExtensionSubWindow_ = false; bool isDialogDisposed_ = false; RectF hostWindowRect_; - UECHostMaskInfo hostMaskInfo_; - WeakPtr uecMaskNode_; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp index 520a39c698b3ca34808f9b653182104fed79d247..7ac77421c22be2379763a555414e42fbda1abaa9 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp @@ -74,7 +74,6 @@ #include "core/components_ng/pattern/overlay/keyboard_view.h" #include "core/components_ng/pattern/overlay/level_order.h" #include "core/components_ng/pattern/overlay/overlay_container_pattern.h" -#include "core/components_ng/pattern/overlay/overlay_mask_manager.h" #include "core/components_ng/pattern/overlay/sheet_manager.h" #include "core/components_ng/pattern/overlay/sheet_view.h" #include "core/components_ng/pattern/overlay/sheet_wrapper_pattern.h" @@ -3069,7 +3068,6 @@ RefPtr OverlayManager::SetDialogMask(const DialogProperties& dialogPr { DialogProperties Maskarg; Maskarg.isMask = true; - Maskarg.isUECHostMask = dialogProps.isUECHostMask; Maskarg.autoCancel = dialogProps.autoCancel; Maskarg.onWillDismiss = dialogProps.onWillDismiss; Maskarg.maskColor = dialogProps.maskColor; @@ -3081,7 +3079,7 @@ RefPtr OverlayManager::SetDialogMask(const DialogProperties& dialogPr RefPtr OverlayManager::ShowDialog( const DialogProperties& dialogProps, std::function&& buildFunc, bool isRightToLeft) { - TAG_LOGI(AceLogTag::ACE_OVERLAY, "show dialog enter"); + TAG_LOGD(AceLogTag::ACE_OVERLAY, "show dialog enter"); RefPtr customNode; // create custom builder content if (buildFunc) { @@ -3834,7 +3832,7 @@ RefPtr OverlayManager::GetDialog(int32_t dialogId) void OverlayManager::CloseDialog(const RefPtr& dialogNode) { - TAG_LOGI(AceLogTag::ACE_OVERLAY, "close dialog enter"); + TAG_LOGD(AceLogTag::ACE_OVERLAY, "close dialog enter"); DeleteDialogHotAreas(dialogNode); auto dialogLayoutProp = AceType::DynamicCast(dialogNode->GetLayoutProperty()); CHECK_NULL_VOID(dialogLayoutProp); @@ -3888,7 +3886,6 @@ void OverlayManager::DeleteDialogHotAreas(const RefPtr& dialogNode) void OverlayManager::CloseDialogInner(const RefPtr& dialogNode) { - CHECK_NULL_VOID(dialogNode); RemoveDialogFromMap(dialogNode); auto topOrderNode = GetTopOrderNode(); auto topFocusableNode = GetTopFocusableNode(); @@ -3899,20 +3896,27 @@ void OverlayManager::CloseDialogInner(const RefPtr& dialogNode) return; } - auto pipeline = GetMainPipelineContext(dialogNode); - CHECK_NULL_VOID(pipeline); - ContainerScope scope(pipeline->GetInstanceId()); - auto mainPipeline = AceType::DynamicCast(pipeline); - CHECK_NULL_VOID(mainPipeline); - auto overlayManager = mainPipeline->GetOverlayManager(); + auto container = Container::Current(); + auto currentId = Container::CurrentId(); + CHECK_NULL_VOID(container); + if (container->IsSubContainer()) { + currentId = SubwindowManager::GetInstance()->GetParentContainerId(Container::CurrentId()); + container = AceEngine::Get().GetContainer(currentId); + CHECK_NULL_VOID(container); + } + ContainerScope scope(currentId); + auto pipelineContext = container->GetPipelineContext(); + CHECK_NULL_VOID(pipelineContext); + auto context = AceType::DynamicCast(pipelineContext); + CHECK_NULL_VOID(context); + auto overlayManager = context->GetOverlayManager(); CHECK_NULL_VOID(overlayManager); overlayManager->ResetLowerNodeFocusable(dialogNode); auto dialogPattern = dialogNode->GetPattern(); CHECK_NULL_VOID(dialogPattern); - auto dialogProperties = dialogPattern->GetDialogProperties(); - auto transitionEffect = dialogProperties.transitionEffect; - auto dialogTransitionEffect = dialogProperties.dialogTransitionEffect; - auto maskTransitionEffect = dialogProperties.maskTransitionEffect; + auto transitionEffect = dialogPattern->GetDialogProperties().transitionEffect; + auto dialogTransitionEffect = dialogPattern->GetDialogProperties().dialogTransitionEffect; + auto maskTransitionEffect = dialogPattern->GetDialogProperties().maskTransitionEffect; dialogNode->MarkRemoving(); if (dialogTransitionEffect != nullptr || maskTransitionEffect != nullptr) { CloseMaskAndContentMatchTransition(dialogNode); @@ -3922,16 +3926,11 @@ void OverlayManager::CloseDialogInner(const RefPtr& dialogNode) CloseDialogAnimation(dialogNode); } dialogCount_--; - if (dialogPattern->IsUIExtensionSubWindow() && !dialogPattern->GetUECHostMaskInfo().uuid.empty()) { - OverlayMaskManager::GetInstance().SendDialogMaskInfoToHost(dialogNode, UECHostMaskAction::UNMOUNT); - } else { - overlayManager->RemoveMaskFromMap(dialogNode); - } + overlayManager->RemoveMaskFromMap(dialogNode); // set close button enable if (dialogCount_ == 0) { SetContainerButtonEnable(true); } - SubwindowManager::GetInstance()->CloseDialogMaskNG(dialogNode); FireNavigationLifecycle(dialogNode, static_cast(NavDestinationLifecycle::ON_ACTIVE), true, static_cast(NavDestinationActiveReason::DIALOG)); CallOnHideDialogCallback(); @@ -4150,11 +4149,6 @@ int32_t OverlayManager::RemoveOverlayCommon(const RefPtr& rootNode, } auto dialogPattern = DynamicCast(pattern); CHECK_NULL_RETURN(dialogPattern, OVERLAY_EXISTS); - if (dialogPattern->GetDialogProperties().isUECHostMask) { - OverlayMaskManager::GetInstance().SendDialogMaskEventToUEA(overlay, UECHostMaskAction::PRESS_BACK); - return OVERLAY_REMOVE; - } - if (dialogPattern->CallDismissInNDK(static_cast(DialogDismissReason::DIALOG_PRESS_BACK))) { return OVERLAY_REMOVE; } else if (dialogPattern->ShouldDismiss()) { @@ -7051,7 +7045,7 @@ void OverlayManager::ShowFilterDisappearAnimation( void OverlayManager::RemoveFilterAnimation() { if (!hasFilter_) { - TAG_LOGD(AceLogTag::ACE_OVERLAY, "filter node is not exist"); + TAG_LOGI(AceLogTag::ACE_OVERLAY, "filter node is not exist"); return; } auto filterNode = filterColumnNodeWeak_.Upgrade(); diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.cpp deleted file mode 100644 index 90e0141e27958fa2f942188ffcb398f00e70fc20..0000000000000000000000000000000000000000 --- a/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/components_ng/pattern/overlay/overlay_mask_manager.h" - -#include "core/components_ng/pattern/dialog/dialog_pattern.h" -#include "core/pipeline_ng/pipeline_context.h" - -namespace OHOS::Ace::NG { -OverlayMaskManager::OverlayMaskManager() = default; - -OverlayMaskManager::~OverlayMaskManager() = default; - -void OverlayMaskManager::AddUECHostNodeMap(const std::string& uuid, const RefPtr& node) -{ - std::lock_guard lock(uecHostNodeMutex_); - uecHostNodeMap_.try_emplace(uuid, AceType::WeakClaim(AceType::RawPtr(node))); -} - -void OverlayMaskManager::RemoveUECHostNodeMap(const std::string& uuid) -{ - std::lock_guard lock(uecHostNodeMutex_); - uecHostNodeMap_.erase(uuid); -} - -RefPtr OverlayMaskManager::GetUECHostNode(const std::string& uuid) -{ - std::lock_guard lock(uecHostNodeMutex_); - auto result = uecHostNodeMap_.find(uuid); - if (result != uecHostNodeMap_.end()) { - return result->second.Upgrade(); - } - - return nullptr; -} - -void OverlayMaskManager::AddUECHostMaskMap(const std::string& uuid, HostMaskTuple maskTuple) -{ - std::lock_guard lock(uecHostMaskMutex_); - uecHostMaskMap_.try_emplace(uuid, maskTuple); -} - -void OverlayMaskManager::RemoveUECHostMaskMap(const std::string& uuid) -{ - std::lock_guard lock(uecHostMaskMutex_); - uecHostMaskMap_.erase(uuid); -} - -HostMaskTuple OverlayMaskManager::GetUECHostMask(const std::string& uuid) -{ - std::lock_guard lock(uecHostMaskMutex_); - auto result = uecHostMaskMap_.find(uuid); - if (result != uecHostMaskMap_.end()) { - return result->second; - } - - return {}; -} - -void OverlayMaskManager::RegisterOverlayHostMaskEventCallback() -{ - auto pipeline = PipelineContext::GetMainPipelineContext(); - CHECK_NULL_VOID(pipeline); - auto container = Container::GetContainer(pipeline->GetInstanceId()); - CHECK_NULL_VOID(container); - if (!container->IsUIExtensionWindow()) { - return; - } - -#ifdef WINDOW_SCENE_SUPPORTED - auto uiExtMgr = pipeline->GetUIExtensionManager(); - CHECK_NULL_VOID(uiExtMgr); - - ModalUIExtension::RegisterBusinessConsumeCallbackOnUEA( - uiExtMgr, UIContentBusinessCode::OVERLAY_MASK_EVENT, [](const AAFwk::Want& data) -> int32_t { - UECHostMaskInfo maskInfo = ModalUIExtension::GetUECHostMaskInfoFromWant(data); - TAG_LOGI(AceLogTag::ACE_OVERLAY, "UEA recv mask event from host, %{public}s", maskInfo.ToString().c_str()); - OverlayMaskManager::GetInstance().OnOverlayHostMaskEventCallback(maskInfo); - return 0; - }); -#endif -} - -void OverlayMaskManager::OnOverlayHostMaskEventCallback(const UECHostMaskInfo& maskInfo) -{ - auto uecNode = GetUECHostNode(maskInfo.uuid); - if (uecNode) { - TAG_LOGI(AceLogTag::ACE_OVERLAY, "current window is UEC, send host mask event to next UEC"); - auto ret = ModalUIExtension::SendOverlayMaskInfoToUEA( - uecNode, maskInfo, UIContentBusinessCode::OVERLAY_MASK_EVENT, BusinessDataSendType::ASYNC); - if (!ret) { - TAG_LOGW(AceLogTag::ACE_OVERLAY, "failed to send host mask event to UEA"); - } - - return; - } - - if (maskInfo.maskType == UECHostMaskType::DIALOG) { - HandleDialogHostMaskEvent(maskInfo); - } -} - -void OverlayMaskManager::HandleDialogHostMaskEvent(const UECHostMaskInfo& maskInfo) -{ - TAG_LOGI(AceLogTag::ACE_OVERLAY, "UEA handle dialog host mask event enter"); - - auto dialog = FrameNode::GetFrameNodeOnly(maskInfo.overlayTag, maskInfo.overlayId); - CHECK_NULL_VOID(dialog); - auto dialogPattern = dialog->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - - if (maskInfo.maskAction == UECHostMaskAction::CLICK) { - auto dialogProperties = dialogPattern->GetDialogProperties(); - if (dialogProperties.autoCancel) { - dialogPattern->CloseDialogByEvent(DialogDismissReason::DIALOG_TOUCH_OUTSIDE); - } - } else if (maskInfo.maskAction == UECHostMaskAction::PRESS_BACK) { - dialogPattern->CloseDialogByEvent(DialogDismissReason::DIALOG_PRESS_BACK); - } -} - -void OverlayMaskManager::RegisterOverlayHostMaskMountCallback(int32_t uiExtensionId, const RefPtr& uiextNode) -{ - CHECK_NULL_VOID(uiextNode); - ModalUIExtension::RegisterBusinessConsumeCallbackOnHost(uiextNode, UIContentBusinessCode::OVERLAY_MASK_MOUNT, - [uiExtensionId, uiextWeak = AceType::WeakClaim(AceType::RawPtr(uiextNode))]( - const AAFwk::Want& data) -> int32_t { - UECHostMaskInfo maskInfo = ModalUIExtension::GetUECHostMaskInfoFromWant(data); - TAG_LOGI(AceLogTag::ACE_OVERLAY, "host recv maskInfo from UEC, %{public}s", maskInfo.ToString().c_str()); - - auto uiextNode = uiextWeak.Upgrade(); - CHECK_NULL_RETURN(uiextNode, -1); - OverlayMaskManager::GetInstance().OnOverlayHostMaskMountCallback(uiExtensionId, uiextNode, maskInfo); - return 0; - }); -} - -void OverlayMaskManager::OnOverlayHostMaskMountCallback( - int32_t uiExtensionId, const RefPtr& uiextNode, const UECHostMaskInfo& maskInfo) -{ - CHECK_NULL_VOID(uiextNode); - auto pipeline = uiextNode->GetContextRefPtr(); - CHECK_NULL_VOID(pipeline); - auto container = Container::GetContainer(pipeline->GetInstanceId()); - CHECK_NULL_VOID(container); - - if (maskInfo.maskAction == UECHostMaskAction::UNMOUNT) { - RemoveUECHostNodeMap(maskInfo.uuid); - } else { - AddUECHostNodeMap(maskInfo.uuid, uiextNode); - } - - if (container->IsUIExtensionWindow()) { - TAG_LOGI(AceLogTag::ACE_OVERLAY, "current window is UEC, send to parnet host again"); -#ifdef WINDOW_SCENE_SUPPORTED - auto uiExtMgr = pipeline->GetUIExtensionManager(); - CHECK_NULL_VOID(uiExtMgr); - auto ret = ModalUIExtension::SendOverlayMaskInfoToHost( - uiExtMgr, maskInfo, UIContentBusinessCode::OVERLAY_MASK_MOUNT, BusinessDataSendType::ASYNC); - if (!ret) { - TAG_LOGW(AceLogTag::ACE_OVERLAY, "failed to send overlay mask info to host"); - } -#endif - return; - } - - if (maskInfo.maskType == UECHostMaskType::DIALOG) { - HostMountDialogMask(uiExtensionId, maskInfo); - } -} - -void OverlayMaskManager::HostMountDialogMask(int32_t uiExtensionId, const UECHostMaskInfo& maskInfo) -{ - TAG_LOGI(AceLogTag::ACE_OVERLAY, "host process dialog mask info enter"); - - if (maskInfo.maskAction == UECHostMaskAction::MOUNT) { - auto pipeline = PipelineContext::GetMainPipelineContext(); - CHECK_NULL_VOID(pipeline); - auto overlayManager = pipeline->GetOverlayManager(); - CHECK_NULL_VOID(overlayManager); - - DialogProperties maskarg; - maskarg.isUECHostMask = true; - maskarg.maskColor = maskInfo.maskColor; - auto mask = overlayManager->SetDialogMask(maskarg); - CHECK_NULL_VOID(mask); - auto dialogPattern = mask->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - dialogPattern->SetUECHostMaskInfo(maskInfo); - - HostMaskTuple maskTuple = { - .uiExtensionId = uiExtensionId, .maskInfo = maskInfo, .maskNode = AceType::WeakClaim(AceType::RawPtr(mask)) - }; - AddUECHostMaskMap(maskInfo.uuid, maskTuple); - } else if (maskInfo.maskAction == UECHostMaskAction::UNMOUNT) { - CloseHostMask(maskInfo.uuid); - } -} - -void OverlayMaskManager::SendMaskInfoToHost(const UECHostMaskInfo& maskInfo) -{ - if (maskInfo.uuid.empty()) { - TAG_LOGW(AceLogTag::ACE_OVERLAY, "uuid of maskInfo is invalid"); - return; - } - -#ifdef WINDOW_SCENE_SUPPORTED - auto pipeline = PipelineContext::GetMainPipelineContext(); - CHECK_NULL_VOID(pipeline); - auto uiExtMgr = pipeline->GetUIExtensionManager(); - CHECK_NULL_VOID(uiExtMgr); - - TAG_LOGI(AceLogTag::ACE_OVERLAY, "send mask info to host, %{public}s", maskInfo.ToString().c_str()); - - auto ret = ModalUIExtension::SendOverlayMaskInfoToHost( - uiExtMgr, maskInfo, UIContentBusinessCode::OVERLAY_MASK_MOUNT, BusinessDataSendType::ASYNC); - if (!ret) { - TAG_LOGW(AceLogTag::ACE_OVERLAY, "failed to send overlay mask info to host"); - } -#endif -} - -void OverlayMaskManager::SendMaskEventToUEA(const UECHostMaskInfo& maskInfo) -{ - auto hostUECNode = GetUECHostNode(maskInfo.uuid); - CHECK_NULL_VOID(hostUECNode); - - TAG_LOGI(AceLogTag::ACE_OVERLAY, "host send mask event to UEA, %{public}s", maskInfo.ToString().c_str()); - - auto ret = ModalUIExtension::SendOverlayMaskInfoToUEA( - hostUECNode, maskInfo, UIContentBusinessCode::OVERLAY_MASK_EVENT, BusinessDataSendType::ASYNC); - if (!ret) { - TAG_LOGW(AceLogTag::ACE_OVERLAY, "failed to send host mask event to UEA"); - } -} - -const std::vector OverlayMaskManager::GetAllHostMaskUid(int32_t uiExtensionId) -{ - std::lock_guard lock(uecHostMaskMutex_); - - std::vector maskUids; - for (auto it = uecHostMaskMap_.begin(); it != uecHostMaskMap_.end(); it++) { - if (it->second.uiExtensionId == uiExtensionId) { - maskUids.push_back(it->second.maskInfo.uuid); - } - } - return maskUids; -} - -void OverlayMaskManager::OnUIExtDestroy(int32_t uiExtensionId) -{ - TAG_LOGI(AceLogTag::ACE_OVERLAY, "host is destroyed, close all mask by uiExtensionId: %{public}d", uiExtensionId); - for (auto uuid : GetAllHostMaskUid(uiExtensionId)) { - CloseHostMask(uuid); - } -} - -void OverlayMaskManager::CloseHostMask(const std::string& uuid) -{ - auto maskTuple = GetUECHostMask(uuid); - auto maskNode = maskTuple.maskNode.Upgrade(); - CHECK_NULL_VOID(maskNode); - - if (maskTuple.maskInfo.maskType == UECHostMaskType::DIALOG) { - auto dialogPattern = maskNode->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - dialogPattern->CloseDialog(); - RemoveUECHostMaskMap(uuid); - } else { - auto parent = maskNode->GetParent(); - CHECK_NULL_VOID(parent); - parent->RemoveChild(maskNode); - parent->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); - RemoveUECHostMaskMap(uuid); - } -} - -void OverlayMaskManager::SendDialogMaskInfoToHost( - const RefPtr& dialogNode, UECHostMaskAction maskAction, int32_t instanceId) -{ - TAG_LOGI(AceLogTag::ACE_OVERLAY, "UEA send dialog mask info to host"); - - CHECK_NULL_VOID(dialogNode); - auto pipeline = dialogNode->GetContextRefPtr(); - auto currentId = pipeline ? pipeline->GetInstanceId() : instanceId; - if (currentId < MIN_SUBCONTAINER_ID) { - return; - } - - CHECK_NULL_VOID(dialogNode); - auto dialogPattern = dialogNode->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - auto dialogprop = dialogPattern->GetDialogProperties(); - - UECHostMaskInfo maskInfo; - if (maskAction == UECHostMaskAction::MOUNT) { - auto nowTime = std::chrono::system_clock::now().time_since_epoch(); - uint64_t stamp = static_cast(std::chrono::duration_cast(nowTime).count()); - maskInfo = { - .uuid = std::to_string(stamp), - .instanceId = currentId, - .overlayTag = dialogNode->GetTag(), - .overlayId = dialogNode->GetId(), - .maskColor = dialogprop.maskColor, - .maskAction = UECHostMaskAction::MOUNT, - .maskType = UECHostMaskType::DIALOG, - }; - dialogPattern->SetUECHostMaskInfo(maskInfo); - } else if (maskAction == UECHostMaskAction::UNMOUNT) { - maskInfo = dialogPattern->GetUECHostMaskInfo(); - maskInfo.maskAction = UECHostMaskAction::UNMOUNT; - } - - SendMaskInfoToHost(maskInfo); -} - -void OverlayMaskManager::SendDialogMaskEventToUEA(const RefPtr& maskNode, UECHostMaskAction maskAction) -{ - TAG_LOGI(AceLogTag::ACE_OVERLAY, "host send dialog mask event to UEA enter"); - - CHECK_NULL_VOID(maskNode); - auto dialogPattern = maskNode->GetPattern(); - CHECK_NULL_VOID(dialogPattern); - - UECHostMaskInfo maskInfo = dialogPattern->GetUECHostMaskInfo(); - maskInfo.maskAction = maskAction; - SendMaskEventToUEA(maskInfo); -} -} // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.h b/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.h deleted file mode 100644 index 89e7e3c876378c290cee3621bf6f7d55cedaa16c..0000000000000000000000000000000000000000 --- a/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MASK_MANAGER_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MASK_MANAGER_H - -#include "base/utils/singleton.h" -#include "core/common/modal_ui_extension.h" -#include "core/components_ng/pattern/overlay/overlay_manager.h" - -namespace OHOS::Ace::NG { -namespace { -struct HostMaskTuple { - int32_t uiExtensionId = -1; - UECHostMaskInfo maskInfo = {}; - WeakPtr maskNode; -}; -} // namespace - -class ACE_FORCE_EXPORT OverlayMaskManager : public Singleton { - DECLARE_SINGLETON(OverlayMaskManager); - -public: - void RegisterOverlayHostMaskEventCallback(); - void RegisterOverlayHostMaskMountCallback(int32_t uiExtensionId, const RefPtr& uiextNode); - - void AddUECHostNodeMap(const std::string& uuid, const RefPtr& node); - void AddUECHostMaskMap(const std::string& uuid, HostMaskTuple maskTuple); - void RemoveUECHostNodeMap(const std::string& uuid); - void RemoveUECHostMaskMap(const std::string& uuid); - RefPtr GetUECHostNode(const std::string& uuid); - HostMaskTuple GetUECHostMask(const std::string& uuid); - - void SendDialogMaskInfoToHost( - const RefPtr& dialogNode, UECHostMaskAction maskAction, int32_t instanceId = -1); - void SendDialogMaskEventToUEA(const RefPtr& maskNode, UECHostMaskAction maskAction); - - void OnUIExtDestroy(int32_t uiExtensionId); - -private: - void OnOverlayHostMaskMountCallback( - int32_t uiExtensionId, const RefPtr& uiextNode, const UECHostMaskInfo& maskInfo); - void OnOverlayHostMaskEventCallback(const UECHostMaskInfo& maskInfo); - - void SendMaskInfoToHost(const UECHostMaskInfo& maskInfo); - void SendMaskEventToUEA(const UECHostMaskInfo& maskInfo); - - void HostMountDialogMask(int32_t uiExtensionId, const UECHostMaskInfo& maskInfo); - void HandleDialogHostMaskEvent(const UECHostMaskInfo& maskInfo); - - void CloseHostMask(const std::string& uuid); - const std::vector GetAllHostMaskUid(int32_t uiExtensionId); - - std::mutex uecHostNodeMutex_; - std::unordered_map> uecHostNodeMap_; - - std::mutex uecHostMaskMutex_; - std::unordered_map uecHostMaskMap_; -}; -} // namespace OHOS::Ace::NG -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MASK_MANAGER_H diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.cpp b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.cpp index f87720a3bf4f1428a8248af67194e334d19eeeb3..ab48948bf41687cf29ea2a029d536e085de011d7 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.cpp +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_component/ui_extension_pattern.cpp @@ -27,7 +27,6 @@ #include "base/utils/utils.h" #include "core/common/container.h" #include "core/components_ng/event/event_hub.h" -#include "core/components_ng/pattern/overlay/overlay_mask_manager.h" #include "core/components_ng/pattern/pattern.h" #include "core/components_ng/pattern/text_field/text_field_manager.h" #include "core/components_ng/pattern/ui_extension/session_wrapper.h" @@ -102,7 +101,6 @@ UIExtensionPattern::~UIExtensionPattern() } NotifyDestroy(); FireModalOnDestroy(); - OverlayMaskManager::GetInstance().OnUIExtDestroy(uiExtensionId_); UIExtensionIdUtility::GetInstance().RecycleExtensionId(uiExtensionId_); auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); @@ -554,7 +552,6 @@ void UIExtensionPattern::InitBusinessDataHandleCallback() RegisterEventProxyFlagCallback(); RegisterGetAvoidInfoCallback(); RegisterReplyPageModeCallback(); - OverlayMaskManager::GetInstance().RegisterOverlayHostMaskMountCallback(uiExtensionId_, GetHost()); } void UIExtensionPattern::ReplacePlaceholderByContent() diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_config.h b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_config.h index a2e6d8c4d378cea57f41b5f4e38f46a1f57f7dce..96295cd0c13bd87aff9c0c9b18397a301ed020db 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_config.h +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_config.h @@ -61,8 +61,6 @@ enum class UIContentBusinessCode : uint32_t { // avoid info business begin NOTIFY_AVOID_INFO_CHANGE = 3001, GET_AVOID_INFO = 3002, - OVERLAY_MASK_MOUNT = 4001, - OVERLAY_MASK_EVENT = 4002, // extension window code from 10000 to 20000 WINDOW_CODE_BEGIN = 10000, WINDOW_CODE_END = 20000, diff --git a/test/mock/adapter/mock_modal_ui_extension.cpp b/test/mock/adapter/mock_modal_ui_extension.cpp index 60ea43b2d91d593e5c5c751ba68391b6a0695d76..73cf7d65990f0fb26e40638ca8fab21c0dfd0344 100644 --- a/test/mock/adapter/mock_modal_ui_extension.cpp +++ b/test/mock/adapter/mock_modal_ui_extension.cpp @@ -31,29 +31,4 @@ int32_t ModalUIExtension::GetSessionId(const RefPtr& /* uiExtNode void ModalUIExtension::SetBindModalCallback( const RefPtr& uiExtNode, std::function&& bindModalCallback) {} - -UECHostMaskInfo ModalUIExtension::GetUECHostMaskInfoFromWant(const AAFwk::Want& data) -{ - return {}; -} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnUEA(const RefPtr& uiExtMgr, - NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{} - -void ModalUIExtension::RegisterBusinessConsumeCallbackOnHost( - const RefPtr& uiExtNode, NG::UIContentBusinessCode code, BusinessDataUECConsumeCallback callback) -{} - -bool ModalUIExtension::SendOverlayMaskInfoToUEA(const RefPtr& uiExtNode, const UECHostMaskInfo& info, - NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - return false; -} - -bool ModalUIExtension::SendOverlayMaskInfoToHost(const RefPtr& uiExtMgr, - const UECHostMaskInfo& info, NG::UIContentBusinessCode code, NG::BusinessDataSendType type) -{ - return false; -} } // namespace OHOS::Ace diff --git a/test/mock/base/mock_subwindow.h b/test/mock/base/mock_subwindow.h index a822bc5edbb36dd5c9c34a459456fc6e703c28eb..eee588f86f54c34551aecf5dbb5f0c3105f57df4 100644 --- a/test/mock/base/mock_subwindow.h +++ b/test/mock/base/mock_subwindow.h @@ -127,8 +127,6 @@ public: MOCK_METHOD0(GetAttachState, MenuWindowState()); MOCK_METHOD0(GetDetachState, MenuWindowState()); MOCK_CONST_METHOD0(GetWindowRect, NG::RectF()); - MOCK_METHOD1(ShowDialogMaskNG, void(const RefPtr& dialog)); - MOCK_METHOD1(CloseDialogMaskNG, void(const RefPtr& dialog)); MOCK_METHOD1(SwitchFollowParentWindowLayout, void(bool freeMultiWindowEnable)); MOCK_METHOD0(NeedFollowParentWindowLayout, bool()); MOCK_METHOD1(AddFollowParentWindowLayoutNode, void(int32_t nodeId)); diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 2a991ae8642e92b80f0d2716f83f4fc2f806d5b0..497a5041d4890cff5c852456e7e02e4e071c4673 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -900,7 +900,6 @@ ohos_source_set("ace_components_pattern") { "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_accessibility_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_event_hub.cpp", "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_mask_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/dialog/dialog_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/divider/divider_layout_algorithm.cpp", @@ -1104,7 +1103,6 @@ ohos_source_set("ace_components_pattern") { "$ace_root/frameworks/core/components_ng/pattern/overlay/modal_presentation_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_container_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp", - "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/popup_base_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_pattern.cpp", diff --git a/test/unittest/core/pattern/dialog/dialog_model_test_ng.cpp b/test/unittest/core/pattern/dialog/dialog_model_test_ng.cpp index 26e617e6d46f6fb4cd9a563c578644a06f90efb7..dc1ca208511d27a33f09c16a0e7f231f7438d210 100644 --- a/test/unittest/core/pattern/dialog/dialog_model_test_ng.cpp +++ b/test/unittest/core/pattern/dialog/dialog_model_test_ng.cpp @@ -1218,6 +1218,42 @@ HWTEST_F(DialogModelTestNg, DialogModelTestNg029, TestSize.Level1) AceApplicationInfo::GetInstance().isRightToLeft_ = false; } +/** + * @tc.name: DialogModelTestNg030 + * @tc.desc: Test DialogLayoutAlgorithm.ClipUIExtensionSubWindowContent function + * @tc.type: FUNC + */ +HWTEST_F(DialogModelTestNg, DialogModelTestNg030, TestSize.Level1) +{ + DialogProperties props; + auto dialog = DialogView::CreateDialogNode(props, nullptr); + ASSERT_NE(dialog, nullptr); + auto extraMaskNode = FrameNode::CreateFrameNode(V2::BLANK_ETS_TAG, 100, AceType::MakeRefPtr()); + extraMaskNode->MountToParent(dialog); + auto dialogPattern = dialog->GetPattern(); + ASSERT_NE(dialogPattern, nullptr); + auto dialogContext = dialog->GetRenderContext(); + ASSERT_NE(dialogContext, nullptr); + + auto dialogLayoutAlgorithm = dialogPattern->CreateLayoutAlgorithm(); + ASSERT_NE(dialogLayoutAlgorithm, nullptr); + RefPtr layoutAlgorithm = AceType::MakeRefPtr(); + ASSERT_NE(layoutAlgorithm, nullptr); + layoutAlgorithm->hostWindowRect_ = RectF(OffsetF(), SizeF(FULL_SCREEN_WIDTH / 2, FULL_SCREEN_HEIGHT / 2)); + layoutAlgorithm->expandDisplay_ = true; + layoutAlgorithm->ClipUIExtensionSubWindowContent(dialog); + NG::BorderRadiusPropertyT borderRadius; + borderRadius.SetRadius(Dimension(16.0, OHOS::Ace::DimensionUnit::VP)); + auto maskNode = AceType::DynamicCast(dialog->GetChildAtIndex(1)); + EXPECT_EQ(maskNode->GetRenderContext()->GetBorderRadius().value(), borderRadius); + + layoutAlgorithm->expandDisplay_ = false; + layoutAlgorithm->ClipUIExtensionSubWindowContent(dialog); + auto maskNodeProp = maskNode->GetLayoutProperty(); + EXPECT_EQ(maskNodeProp->GetCalcLayoutConstraint()->selfIdealSize.value(), + CalcSize(CalcLength(1.0, DimensionUnit::PERCENT), CalcLength(1.0, DimensionUnit::PERCENT))); +} + /** * @tc.name: DialogModelTestNg031 * @tc.desc: Test DialogLayoutAlgorithm.AdjustChildPosition function @@ -1259,6 +1295,49 @@ HWTEST_F(DialogModelTestNg, DialogModelTestNg031, TestSize.Level1) MockContainer::Current()->SetApiTargetVersion(backupApiVersion); } +/** + * @tc.name: DialogModelTestNg032 + * @tc.desc: Test DialogLayoutAlgorithm.SetSubWindowHotarea/GetMaskRect function + * @tc.type: FUNC + */ +HWTEST_F(DialogModelTestNg, DialogModelTestNg032, TestSize.Level1) +{ + auto layoutAlgorithm = AceType::MakeRefPtr(); + ASSERT_NE(layoutAlgorithm, nullptr); + DialogProperties props; + props.isShowInSubWindow = true; + auto dialog = DialogView::CreateDialogNode(props, nullptr); + ASSERT_NE(dialog, nullptr); + auto layoutWrapper = + AceType::MakeRefPtr(dialog, dialog->GetGeometryNode(), dialog->GetLayoutProperty()); + auto dialogProp = AceType::DynamicCast(layoutWrapper->GetLayoutProperty()); + CHECK_NULL_VOID(dialogProp); + + auto childSize = SizeF(CHILD_SIZE, CHILD_SIZE); + auto selfSize = SizeF(CHILD_SIZE_2, CHILD_SIZE_2); + + layoutAlgorithm->SetSubWindowHotarea(dialogProp, childSize, selfSize, dialog->GetId()); + auto maskRect = layoutAlgorithm->GetMaskRect(dialog); + EXPECT_FALSE(maskRect.has_value()); + + auto offset = DimensionOffset(CalcDimension(0, DimensionUnit::VP), CalcDimension(0, DimensionUnit::VP)); + layoutAlgorithm->isUIExtensionSubWindow_ = true; + layoutAlgorithm->SetSubWindowHotarea(dialogProp, childSize, selfSize, dialog->GetId()); + maskRect = layoutAlgorithm->GetMaskRect(dialog); + EXPECT_EQ(maskRect.value().GetOffset(), offset); + EXPECT_EQ(maskRect.value().GetWidth(), CalcDimension(1, DimensionUnit::PERCENT)); + EXPECT_EQ(maskRect.value().GetHeight(), CalcDimension(1, DimensionUnit::PERCENT)); + + layoutAlgorithm->expandDisplay_ = true; + layoutAlgorithm->hostWindowRect_ = RectF(OffsetF(), SizeF(CHILD_SIZE, CHILD_SIZE)); + layoutAlgorithm->SetSubWindowHotarea(dialogProp, childSize, selfSize, dialog->GetId()); + maskRect = layoutAlgorithm->GetMaskRect(dialog); + offset = DimensionOffset(CalcDimension(0, DimensionUnit::PX), CalcDimension(0, DimensionUnit::PX)); + EXPECT_EQ(maskRect.value().GetOffset(), offset); + EXPECT_EQ(maskRect.value().GetWidth(), Dimension(CHILD_SIZE, DimensionUnit::PX)); + EXPECT_EQ(maskRect.value().GetHeight(), Dimension(CHILD_SIZE, DimensionUnit::PX)); +} + /** * @tc.name: DialogModelTestNg033 * @tc.desc: Test DialogLayoutAlgorithm::UpdateChildMaxSizeHeight function diff --git a/test/unittest/core/pattern/dialog/dialog_pattern_test_ng.cpp b/test/unittest/core/pattern/dialog/dialog_pattern_test_ng.cpp index 96975095fbed152a0d04a48a5ce41f28f58a8dc2..f8cf9e6a1a3a7559524e3956186bef9b12fd4f46 100644 --- a/test/unittest/core/pattern/dialog/dialog_pattern_test_ng.cpp +++ b/test/unittest/core/pattern/dialog/dialog_pattern_test_ng.cpp @@ -905,6 +905,11 @@ HWTEST_F(DialogPatternAdditionalTestNg, DialogPatternAdditionalTestNgAddExtraMas props.isModal = false; pattern->AddExtraMaskNode(props); EXPECT_EQ(totalChildCount, frameNode->GetTotalChildCount()); + + pattern->isUIExtensionSubWindow_ = true; + props.isModal = true; + pattern->AddExtraMaskNode(props); + EXPECT_EQ(totalChildCount + 1, frameNode->GetTotalChildCount()); } /** diff --git a/test/unittest/core/pattern/web/BUILD.gn b/test/unittest/core/pattern/web/BUILD.gn index 89a177050df6ede9e57ad2080f6ec8e2e96b9be1..58dff9ad4c217439b39c08caa6240913cc2021f8 100755 --- a/test/unittest/core/pattern/web/BUILD.gn +++ b/test/unittest/core/pattern/web/BUILD.gn @@ -304,7 +304,6 @@ ohos_unittest("web_pattern_unit_test_ohos") { "$ace_root/frameworks/core/components_ng/pattern/overlay/modal_presentation_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_container_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp", - "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_mask_manager.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/popup_base_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_pattern.cpp",