From 0f749e76aa328ef25e14e298c69b269b8edf39f9 Mon Sep 17 00:00:00 2001 From: ZhangYu Date: Sat, 30 Mar 2024 12:36:35 +0000 Subject: [PATCH] Add the tag of the EmbeddedComponent Signed-off-by: ZhangYu Change-Id: I45486eb51f17df21c3d13603721ddbb9a6af3958 --- .../ohos/osal/js_accessibility_manager.cpp | 32 +++++++++++-------- .../core/components_ng/event/focus_hub.cpp | 5 +-- .../manager/drag_drop/drag_drop_manager.cpp | 11 ++++--- .../ui_extension/ui_extension_model_ng.cpp | 2 +- .../helper/window_scene_helper.cpp | 4 +-- .../property/accessibility_property.cpp | 1 + .../inspector_composed_component.cpp | 3 +- .../inspector/inspector_constants.cpp | 4 +++ .../inspector/inspector_constants.h | 4 +++ 9 files changed, 42 insertions(+), 24 deletions(-) diff --git a/adapter/ohos/osal/js_accessibility_manager.cpp b/adapter/ohos/osal/js_accessibility_manager.cpp index ac93bdba5ef..f804bb38648 100644 --- a/adapter/ohos/osal/js_accessibility_manager.cpp +++ b/adapter/ohos/osal/js_accessibility_manager.cpp @@ -110,6 +110,12 @@ const std::map& node) +{ + return node && + (node->GetTag() == V2::UI_EXTENSION_COMPONENT_ETS_TAG || node->GetTag() == V2::EMBEDDED_COMPONENT_ETS_TAG); +} + Accessibility::EventType ConvertStrToEventType(const std::string& type) { // static linear map must be sorted by key. @@ -608,7 +614,7 @@ RefPtr FindAccessibilityFocus(const RefPtr& node, } for (const auto& child : node->GetChildren()) { auto extensionNode = AceType::DynamicCast(child); - if ((child->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG) && extensionNode && + if (IsUIExtensionOrEmbeddedComponent(child) && extensionNode && (extensionNode->GetUiExtensionId() > NG::UI_EXTENSION_UNKNOW_ID) && (((extensionNode->GetUiExtensionId() <= NG::UI_EXTENSION_ID_FIRST_MAX) && (NG::UI_EXTENSION_OFFSET_MAX == uiExtensionOffset)) || @@ -704,7 +710,7 @@ RefPtr FindInputFocus(const RefPtr& node, int32_t foc auto focusChildren = focusHub->GetChildren(); for (const auto& focusChild : focusChildren) { auto extensionNode = focusChild->GetFrameNode(); - if (((extensionNode) && (extensionNode->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG)) && + if ((extensionNode && IsUIExtensionOrEmbeddedComponent(extensionNode)) && (extensionNode->GetUiExtensionId() > NG::UI_EXTENSION_UNKNOW_ID) && (((extensionNode->GetUiExtensionId() <= NG::UI_EXTENSION_ID_FIRST_MAX) && (NG::UI_EXTENSION_OFFSET_MAX == uiExtensionOffset)) || @@ -1238,7 +1244,7 @@ void UpdateWebAccessibilityElementInfo(RefPtr node, void UpdateChildrenOfAccessibilityElementInfo( const RefPtr& node, const CommonProperty& commonProperty, AccessibilityElementInfo& nodeInfo) { - if (V2::UI_EXTENSION_COMPONENT_TAG != node->GetTag()) { + if (!IsUIExtensionOrEmbeddedComponent(node)) { std::vector children; for (const auto& item : node->GetChildren()) { GetFrameNodeChildren(item, children, commonProperty.pageId); @@ -1576,7 +1582,7 @@ void UpdateCacheInfoNG(std::list& infos, const RefPtr< infos.push_back(nodeInfo); continue; } - if (frameNodeParent->GetTag() != V2::UI_EXTENSION_COMPONENT_TAG) { + if (!IsUIExtensionOrEmbeddedComponent(frameNodeParent)) { infos.push_back(nodeInfo); GetChildrenFromFrameNode(frameNodeParent, children, commonProperty.pageId); GetChildrenFromWebNode(frameNodeParent, children, ngPipeline); @@ -2520,7 +2526,7 @@ void JsAccessibilityManager::DumpPropertyNG(int64_t nodeID) GenerateCommonProperty(ngPipeline, commonProperty, pipeline); AccessibilityElementInfo nodeInfo; UpdateAccessibilityElementInfo(frameNode, commonProperty, nodeInfo, ngPipeline); - if (frameNode->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG) { + if (IsUIExtensionOrEmbeddedComponent(frameNode)) { SearchParameter param {-1, "", PREFETCH_RECURSIVE_CHILDREN, NG::UI_EXTENSION_OFFSET_MAX}; std::list extensionElementInfos; SearchExtensionElementInfoNG(param, frameNode, extensionElementInfos, nodeInfo); @@ -2671,7 +2677,7 @@ void JsAccessibilityManager::DumpTreeNG(const RefPtr& parent, int DumpTreeNodeInfoNG(frameChild, depth + 1, commonProperty, children.size()); } } - if (node->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG) { + if (IsUIExtensionOrEmbeddedComponent(node)) { std::list extensionElementInfos; auto pipeline = context_.Upgrade(); CHECK_NULL_VOID(pipeline); @@ -2885,7 +2891,7 @@ void JsAccessibilityManager::SearchElementInfoByAccessibilityIdNG(int64_t elemen auto node = GetFramenodeByAccessibilityId(rootNode, nodeId); CHECK_NULL_VOID(node); UpdateAccessibilityElementInfo(node, commonProperty, nodeInfo, ngPipeline); - if (node->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG) { + if (IsUIExtensionOrEmbeddedComponent(node)) { SearchParameter param {-1, "", mode, uiExtensionOffset}; SearchExtensionElementInfoNG(param, node, infos, nodeInfo); } @@ -2977,10 +2983,8 @@ RefPtr JsAccessibilityManager::FindNodeFromRootByExtensionId( auto current = nodes.front(); nodes.pop(); frameNode = AceType::DynamicCast(current); - if ((frameNode != nullptr) && (V2::UI_EXTENSION_COMPONENT_ETS_TAG == frameNode->GetTag())) { - if (uiExtensionId == frameNode->GetUiExtensionId()) { - return frameNode; - } + if (IsUIExtensionOrEmbeddedComponent(frameNode) && (uiExtensionId == frameNode->GetUiExtensionId())) { + return frameNode; } const auto& children = current->GetChildren(); for (const auto& child : children) { @@ -3178,7 +3182,7 @@ void JsAccessibilityManager::FindFocusedElementInfoNG(int64_t elementId, int32_t if (!node) { return info.SetValidElement(false); } - if (V2::UI_EXTENSION_COMPONENT_TAG == node->GetTag()) { + if (IsUIExtensionOrEmbeddedComponent(node)) { SearchParameter transferSearchParam {NG::UI_EXTENSION_ROOT_ID, "", focusType, uiExtensionOffset}; OHOS::Ace::Framework::FindFocusedExtensionElementInfoNG(transferSearchParam, node, info); return SetUiExtensionAbilityParentIdForFocus(node, uiExtensionOffset, info); @@ -3190,7 +3194,7 @@ void JsAccessibilityManager::FindFocusedElementInfoNG(int64_t elementId, int32_t if (focusType == FOCUS_TYPE_INPUT) { resultNode = FindInputFocus(node, focusType, info, uiExtensionOffset, context); } - if ((!resultNode) || (V2::UI_EXTENSION_COMPONENT_TAG == resultNode->GetTag())) { + if ((!resultNode) || IsUIExtensionOrEmbeddedComponent(resultNode)) { return; } CommonProperty commonProperty; @@ -4250,7 +4254,7 @@ void JsAccessibilityManager::FindText(const RefPtr& node, infos.emplace_back(nodeInfo); } } - if (frameNode && (frameNode->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG)) { + if (IsUIExtensionOrEmbeddedComponent(frameNode)) { auto infosByIPC = SearchElementInfosByTextNG(NG::UI_EXTENSION_ROOT_ID, searchParam.text, frameNode, searchParam.uiExtensionOffset / NG::UI_EXTENSION_ID_FACTOR); if (!infosByIPC.empty()) { diff --git a/frameworks/core/components_ng/event/focus_hub.cpp b/frameworks/core/components_ng/event/focus_hub.cpp index 9a845d9055b..6b739e81cdd 100644 --- a/frameworks/core/components_ng/event/focus_hub.cpp +++ b/frameworks/core/components_ng/event/focus_hub.cpp @@ -534,7 +534,8 @@ bool FocusHub::OnKeyPreIme(KeyEventInfo& info, const KeyEvent& keyEvent) eventManager->SetIsKeyConsumed(retPreIme); } return info.IsStopPropagation(); - } else if (GetFrameName() == V2::UI_EXTENSION_COMPONENT_ETS_TAG) { + } else if (GetFrameName() == V2::UI_EXTENSION_COMPONENT_ETS_TAG || + GetFrameName() == V2::EMBEDDED_COMPONENT_ETS_TAG) { return ProcessOnKeyEventInternal(keyEvent); } else { return false; @@ -560,7 +561,7 @@ bool FocusHub::OnKeyEventNode(const KeyEvent& keyEvent) bool isBypassInner = keyEvent.IsKey({ KeyCode::KEY_TAB }) && pipeline && pipeline->IsTabJustTriggerOnKeyEvent(); auto retInternal = false; - if (GetFrameNode() && GetFrameNode()->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG) { + if (GetFrameName() == V2::UI_EXTENSION_COMPONENT_ETS_TAG || GetFrameName() == V2::EMBEDDED_COMPONENT_ETS_TAG) { isBypassInner = false; } if (!isBypassInner && !onKeyEventsInternal_.empty()) { diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index 0bd97a30226..80afc00c3d5 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp @@ -218,8 +218,9 @@ RefPtr DragDropManager::FindTargetInChildNodes( if (!eventHub) { continue; } - if (eventHub->HasOnDrop() || eventHub->HasOnItemDrop() || eventHub->HasCustomerOnDrop() - || V2::UI_EXTENSION_COMPONENT_ETS_TAG == parentFrameNode->GetTag()) { + if (eventHub->HasOnDrop() || eventHub->HasOnItemDrop() || eventHub->HasCustomerOnDrop() || + V2::UI_EXTENSION_COMPONENT_ETS_TAG == parentFrameNode->GetTag() || + V2::EMBEDDED_COMPONENT_ETS_TAG == parentFrameNode->GetTag()) { return parentFrameNode; } } @@ -554,7 +555,8 @@ void DragDropManager::OnDragMove(const PointerEvent& pointerEvent, const std::st return; } - if (V2::UI_EXTENSION_COMPONENT_ETS_TAG == dragFrameNode->GetTag()) { + if (V2::UI_EXTENSION_COMPONENT_ETS_TAG == dragFrameNode->GetTag() || + V2::EMBEDDED_COMPONENT_ETS_TAG == dragFrameNode->GetTag()) { auto pattern = dragFrameNode->GetPattern(); pattern->HandleDragEvent(pointerEvent); return; @@ -630,7 +632,8 @@ void DragDropManager::OnDragEnd(const PointerEvent& pointerEvent, const std::str "TargetNode is %{public}s, id is %{public}s", container->GetWindowId(), static_cast(point.GetX()), static_cast(point.GetY()), dragFrameNode->GetTag().c_str(), dragFrameNode->GetInspectorId()->c_str()); - if (V2::UI_EXTENSION_COMPONENT_ETS_TAG == dragFrameNode->GetTag()) { + if (V2::UI_EXTENSION_COMPONENT_ETS_TAG == dragFrameNode->GetTag() || + V2::EMBEDDED_COMPONENT_ETS_TAG == dragFrameNode->GetTag()) { auto pattern = dragFrameNode->GetPattern(); pattern->HandleDragEvent(pointerEvent); return; diff --git a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_model_ng.cpp b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_model_ng.cpp index d027a283746..1f135dd7b6a 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/ui_extension_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/ui_extension/ui_extension_model_ng.cpp @@ -91,7 +91,7 @@ void UIExtensionModelNG::Create(const RefPtr& wantWrap, Ses { auto* stack = ViewStackProcessor::GetInstance(); auto nodeId = stack->ClaimNodeId(); - auto frameNode = FrameNode::GetOrCreateFrameNode(V2::UI_EXTENSION_COMPONENT_ETS_TAG, nodeId, + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::EMBEDDED_COMPONENT_ETS_TAG, nodeId, [sessionType]() { return AceType::MakeRefPtr(false, false, false, sessionType); }); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); diff --git a/frameworks/core/components_ng/pattern/window_scene/helper/window_scene_helper.cpp b/frameworks/core/components_ng/pattern/window_scene/helper/window_scene_helper.cpp index 5f0e099ff46..16f6664ea8d 100644 --- a/frameworks/core/components_ng/pattern/window_scene/helper/window_scene_helper.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/helper/window_scene_helper.cpp @@ -149,8 +149,8 @@ bool WindowSceneHelper::GetNeedKeyboardOnFocusFlag(const RefPtr frame void WindowSceneHelper::IsWindowSceneCloseKeyboard(RefPtr frameNode) { #if defined (ENABLE_STANDARD_INPUT) - if (frameNode->GetTag() == V2::UI_EXTENSION_COMPONENT_TAG || frameNode->GetTag() == - V2::UI_EXTENSION_COMPONENT_ETS_TAG) { + if (frameNode->GetTag() == V2::UI_EXTENSION_COMPONENT_ETS_TAG || + frameNode->GetTag() == V2::EMBEDDED_COMPONENT_ETS_TAG) { TAG_LOGD(AceLogTag::ACE_KEYBOARD, "UIExtension(%{public}s/%{public}d) notNeedSoftKeyboard.", frameNode->GetTag().c_str(), frameNode->GetId()); return; diff --git a/frameworks/core/components_ng/property/accessibility_property.cpp b/frameworks/core/components_ng/property/accessibility_property.cpp index f14701f72f8..1516e39ee6c 100755 --- a/frameworks/core/components_ng/property/accessibility_property.cpp +++ b/frameworks/core/components_ng/property/accessibility_property.cpp @@ -319,6 +319,7 @@ static const std::set TAGS_FOCUSABLE = { V2::WEB_ETS_TAG, V2::XCOMPONENT_ETS_TAG, V2::UI_EXTENSION_COMPONENT_ETS_TAG, + V2::EMBEDDED_COMPONENT_ETS_TAG, V2::FORM_ETS_TAG }; diff --git a/frameworks/core/components_v2/inspector/inspector_composed_component.cpp b/frameworks/core/components_v2/inspector/inspector_composed_component.cpp index 08aed149c7b..2db0f8846f5 100644 --- a/frameworks/core/components_v2/inspector/inspector_composed_component.cpp +++ b/frameworks/core/components_v2/inspector/inspector_composed_component.cpp @@ -346,9 +346,10 @@ const std::unordered_map COMPONENT_TAG_TO_ETS_TAG_MAP { SAVE_BUTTON_COMPONENT_TAG, SAVE_BUTTON_ETS_TAG }, { PARTICLE_COMPONENT_TAG, PARTICLE_ETS_TAG }, { SYMBOL_COMPONENT_TAG, SYMBOL_ETS_TAG }, - { SYMBOL_SPAN_COMPONENT_TAG, SYMBOL_SPAN_ETS_TAG}, + { SYMBOL_SPAN_COMPONENT_TAG, SYMBOL_SPAN_ETS_TAG }, { DYNAMIC_COMPONENT_TAG, DYNAMIC_COMPONENT_ETS_TAG }, { CONTAINER_SPAN_COMPONENT_TAG, CONTAINER_SPAN_ETS_TAG }, + { EMBEDDED_COMPONENT_TAG, EMBEDDED_COMPONENT_ETS_TAG }, }; thread_local int32_t InspectorComposedComponent::composedElementId_ = 1; diff --git a/frameworks/core/components_v2/inspector/inspector_constants.cpp b/frameworks/core/components_v2/inspector/inspector_constants.cpp index 6517dc9ced7..048aefd6d1e 100644 --- a/frameworks/core/components_v2/inspector/inspector_constants.cpp +++ b/frameworks/core/components_v2/inspector/inspector_constants.cpp @@ -548,6 +548,10 @@ const char UI_EXTENSION_COMPONENT_TAG[] = "UIExtensionComponent"; const char UI_EXTENSION_SURFACE_TAG[] = "UIExtensionSurface"; const char UI_EXTENSION_COMPONENT_ETS_TAG[] = "UIExtensionComponent"; +// embedded_component +const char EMBEDDED_COMPONENT_TAG[] = "EmbeddedComponent"; +const char EMBEDDED_COMPONENT_ETS_TAG[] = "EmbeddedComponent"; + // LocationButton const char LOCATION_BUTTON_COMPONENT_TAG[] = "LocationButtonComponent"; const char LOCATION_BUTTON_ETS_TAG[] = "LocationButton"; diff --git a/frameworks/core/components_v2/inspector/inspector_constants.h b/frameworks/core/components_v2/inspector/inspector_constants.h index 5bd2c35f522..d7ee6563e01 100644 --- a/frameworks/core/components_v2/inspector/inspector_constants.h +++ b/frameworks/core/components_v2/inspector/inspector_constants.h @@ -558,6 +558,10 @@ ACE_EXPORT extern const char UI_EXTENSION_COMPONENT_TAG[]; ACE_EXPORT extern const char UI_EXTENSION_SURFACE_TAG[]; ACE_EXPORT extern const char UI_EXTENSION_COMPONENT_ETS_TAG[]; +// embedded_component +ACE_EXPORT extern const char EMBEDDED_COMPONENT_TAG[]; +ACE_EXPORT extern const char EMBEDDED_COMPONENT_ETS_TAG[]; + // LocationButton ACE_EXPORT extern const char LOCATION_BUTTON_COMPONENT_TAG[]; ACE_EXPORT extern const char LOCATION_BUTTON_ETS_TAG[]; -- Gitee