diff --git a/adapter/ohos/osal/js_accessibility_manager.cpp b/adapter/ohos/osal/js_accessibility_manager.cpp index 1261aaf52339fdf1078fc77d4b3f4476125d04b4..5aea2e4e9984344ce54d0c78cb16132c350c12a4 100644 --- a/adapter/ohos/osal/js_accessibility_manager.cpp +++ b/adapter/ohos/osal/js_accessibility_manager.cpp @@ -1901,17 +1901,8 @@ static void DumpCommonPropertyNG(const AccessibilityElementInfo& nodeInfo) bool IsExtensionSendAccessibilitySyncEvent() { - bool isEnabled = false; -#ifdef WINDOW_SCENE_SUPPORTED - auto ngPipeline = NG::PipelineContext::GetCurrentContext(); - CHECK_NULL_RETURN(ngPipeline, isEnabled); - auto uiExtensionManager = ngPipeline->GetUIExtensionManager(); - CHECK_NULL_RETURN(uiExtensionManager, isEnabled); - if (uiExtensionManager->IsWindowTypeUIExtension(ngPipeline)) { - isEnabled = true; - } -#endif - return isEnabled; + auto container = Container::Current(); + return container && container->IsUIExtensionWindow(); } void GenerateAccessibilityEventInfo(const AccessibilityEvent& accessibilityEvent, AccessibilityEventInfo& eventInfo) @@ -2055,7 +2046,7 @@ bool JsAccessibilityManager::SendExtensionAccessibilitySyncEvent( auto ngPipeline = NG::PipelineContext::GetCurrentContext(); auto uiExtensionManager = ngPipeline->GetUIExtensionManager(); CHECK_NULL_RETURN(uiExtensionManager, false); - if (uiExtensionManager->IsWindowTypeUIExtension(ngPipeline)) { + if (IsExtensionSendAccessibilitySyncEvent()) { return uiExtensionManager->SendAccessibilityEventInfo(eventInfo, NG::UI_EXTENSION_UNKNOW_ID, ngPipeline); } #endif @@ -2103,12 +2094,12 @@ bool JsAccessibilityManager::TransferAccessibilityAsyncEvent( auto pipeline = context_.Upgrade(); CHECK_NULL_RETURN(pipeline, false); - RefPtr ngPipeline; - ngPipeline = AceType::DynamicCast(pipeline); + RefPtr ngPipeline = AceType::DynamicCast(pipeline); CHECK_NULL_RETURN(ngPipeline, false); auto uiExtensionManager = ngPipeline->GetUIExtensionManager(); CHECK_NULL_RETURN(uiExtensionManager, false); - if (uiExtensionManager->IsWindowTypeUIExtension(pipeline)) { + auto container = Container::GetContainer(ngPipeline->GetInstanceId()); + if (container && container->IsUIExtensionWindow()) { return uiExtensionManager->SendAccessibilityEventInfo(eventInfo, uiExtensionOffset / NG::UI_EXTENSION_ID_FACTOR, pipeline); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js index cba4e5bae906664723de9864f3321f9140706a78..cb202a5777db08f1a6b2e39a5277da93161fa41a 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js +++ b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js @@ -2447,7 +2447,7 @@ var FoldStatus; var EmbeddedType; (function (EmbeddedType) { - EmbeddedType[EmbeddedType["UIEXTENSION"] = 0] = "UIEXTENSION"; + EmbeddedType[EmbeddedType["EMBEDDED_UI_EXTENSION"] = 0] = "EMBEDDED_UI_EXTENSION"; })(EmbeddedType || (EmbeddedType = {})); var OutlineStyle; diff --git a/frameworks/core/components_ng/pattern/text/text_base.h b/frameworks/core/components_ng/pattern/text/text_base.h index 2acd4648b4ab781a62ea25e52521ff4c0b6f4e81..71cc841858a4bfd424681270150ce5d37fc9255d 100644 --- a/frameworks/core/components_ng/pattern/text/text_base.h +++ b/frameworks/core/components_ng/pattern/text/text_base.h @@ -17,6 +17,7 @@ #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_TEXT_BASE_H #include "base/memory/ace_type.h" +#include "base/utils/utils.h" #include "core/common/container.h" #include "core/components_ng/manager/select_overlay/select_overlay_client.h" #include "core/components_ng/pattern/scrollable/scrollable_pattern.h" @@ -163,14 +164,11 @@ public: { auto container = Container::Current(); CHECK_NULL_VOID(container); - auto context = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(context); -#ifdef WINDOW_SCENE_SUPPORTED - auto uiExtMgr = context->GetUIExtensionManager(); - if (uiExtMgr && uiExtMgr->IsWindowTypeUIExtension(context)) { + if (container->IsUIExtensionWindow()) { return; } -#endif + auto context = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(context); auto keyboardArea = container->GetKeyboardSafeArea(); auto keyboardLength = keyboardArea.bottom_.Length(); Rect keyboardRect; diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.cpp b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.cpp index bce033cbad65937ab520c4c7e850be9a59fc9328..696580778ad60aca5f9b371636c65a00a09245ba 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.cpp +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.cpp @@ -59,14 +59,6 @@ bool UIExtensionManager::IsWrapExtensionAbilityId(int64_t elementId) return elementId > UI_EXTENSION_OFFSET_MIN; } -bool UIExtensionManager::IsWindowTypeUIExtension(const RefPtr& pipeline) -{ - auto instanceId = pipeline->GetInstanceId(); - auto window = Platform::AceContainer::GetUIWindow(instanceId); - CHECK_NULL_RETURN(window, false); - return window->GetType() == OHOS::Rosen::WindowType::WINDOW_TYPE_UI_EXTENSION; -} - bool UIExtensionManager::SendAccessibilityEventInfo(const Accessibility::AccessibilityEventInfo& eventInfo, int64_t uiExtensionOffset, const RefPtr& pipeline) { diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.h b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.h index 6e409f9ed71023c99f1ecf2de0998e1dfaacf770..9030d23960b3c4d65884dc7c1751a322a5d3a708 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.h +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_manager.h @@ -61,7 +61,6 @@ public: bool OnBackPressed(); const RefPtr GetFocusUiExtensionNode(); bool IsWrapExtensionAbilityId(int64_t elementId); - bool IsWindowTypeUIExtension(const RefPtr& pipeline); bool SendAccessibilityEventInfo(const Accessibility::AccessibilityEventInfo& eventInfo, int64_t uiExtensionOffset, const RefPtr& pipeline); std::pair UnWrapExtensionAbilityId(int64_t extensionOffset, int64_t elementId); diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.cpp b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.cpp index f2cf57f4c66802763db803eb5e8209e6b161d1c0..160360051a00c6d27956cf0c781e732ce728a9de 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.cpp +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.cpp @@ -28,6 +28,7 @@ #include "base/error/error_code.h" #include "base/geometry/offset.h" #include "base/utils/utils.h" +#include "core/common/container.h" #include "core/components_ng/event/event_hub.h" #include "core/components_ng/pattern/pattern.h" #include "core/components_ng/pattern/text_field/text_field_manager.h" @@ -103,22 +104,11 @@ void UIExtensionPattern::UpdateWant(const RefPtr& wantWrap) UpdateWant(want); } -bool UIExtensionPattern::CheckCascadeStatus() -{ - auto pipeline = PipelineContext::GetCurrentContext(); - CHECK_NULL_RETURN(pipeline, false); - auto uiExtensionManager = pipeline->GetUIExtensionManager(); - CHECK_NULL_RETURN(uiExtensionManager, false); - bool isUIExtProcess = uiExtensionManager->IsWindowTypeUIExtension(pipeline); - TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "Current process type is uiextension: %{private}d.", - isUIExtProcess); - return isUIExtProcess && IsEmbeddedComponentType(); -} - void UIExtensionPattern::UpdateWant(const AAFwk::Want& want) { CHECK_NULL_VOID(sessionWrapper_); - if (CheckCascadeStatus()) { + auto container = Container::GetContainer(instanceId_); + if (container && container->IsUIExtensionWindow() && embeddedType_ == EmbeddedType::UI_EXTENSION) { TAG_LOGE(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "This is embedded component, not allowed to pull up another."); std::string name = "extension_pulling_up_fail"; std::string message = "pulling another embedded component failed, not allowed to cascade."; @@ -168,12 +158,11 @@ void UIExtensionPattern::OnConnect() surfaceNode->CreateNodeInRenderThread(); surfaceNode->SetForeground(isModal_); FireOnRemoteReadyCallback(); - if (isModal_) { - auto focusHub = host->GetFocusHub(); - CHECK_NULL_VOID(focusHub); + auto focusHub = host->GetFocusHub(); + if (isModal_ && focusHub) { focusHub->RequestFocusImmediately(); } - bool isFocused = IsCurrentFocus(); + bool isFocused = focusHub && focusHub->IsCurrentFocus(); RegisterVisibleAreaChange(); DispatchFocusState(isFocused); auto pipeline = PipelineContext::GetCurrentContext(); @@ -835,15 +824,6 @@ void UIExtensionPattern::RegisterVisibleAreaChange() pipeline->AddVisibleAreaChangeNode(host, ratioList, callback, false); } -bool UIExtensionPattern::IsCurrentFocus() const -{ - auto host = GetHost(); - CHECK_NULL_RETURN(host, false); - auto focusHub = host->GetFocusHub(); - CHECK_NULL_RETURN(focusHub, false); - return focusHub->IsCurrentFocus(); -} - void UIExtensionPattern::OnLanguageConfigurationUpdate() { CHECK_NULL_VOID(sessionWrapper_); @@ -883,11 +863,6 @@ void UIExtensionPattern::DispatchOriginAvoidArea(const Rosen::AvoidArea& avoidAr sessionWrapper_->NotifyOriginAvoidArea(avoidArea, type); } -bool UIExtensionPattern::IsEmbeddedComponentType() -{ - return embeddedType_ == EmbeddedType::UI_EXTENSION; -} - void UIExtensionPattern::SetWantWrap(const RefPtr& wantWrap) { curWant_ = wantWrap; diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.h b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.h index 4632bd107ba4eaa3102a510de7001414b9d2808e..0dc1bc0d57e6c6088e276476448d18a7ad775322 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.h +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.h @@ -131,7 +131,6 @@ public: int32_t GetUiExtensionId() override; int64_t WrapExtensionAbilityId(int64_t extensionOffset, int64_t abilityId) override; void DispatchOriginAvoidArea(const Rosen::AvoidArea& avoidArea, uint32_t type); - bool IsEmbeddedComponentType(); void SetWantWrap(const RefPtr& wantWrap); RefPtr GetWantWrap(); @@ -192,9 +191,6 @@ private: void DispatchDisplayArea(bool isForce = false); void RegisterVisibleAreaChange(); - void UpdateTextFieldManager(const Offset& offset, float height); - bool IsCurrentFocus() const; - bool CheckCascadeStatus(); RefPtr touchEvent_; RefPtr mouseEvent_;