mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!33814 ArkTS卡片支持无障碍
Merge pull request !33814 from yangzk/form_accessibility_dev
This commit is contained in:
commit
61cc3f9e9e
@ -2372,6 +2372,47 @@ void UIContentImpl::SetFormLinkInfoUpdateHandler(std::function<void(const std::v
|
||||
pipelineContext->SetFormLinkInfoUpdateHandler(std::move(callback));
|
||||
}
|
||||
|
||||
void UIContentImpl::RegisterAccessibilityChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId)
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
CHECK_NULL_VOID(container);
|
||||
auto front = container->GetFrontend();
|
||||
CHECK_NULL_VOID(front);
|
||||
auto accessibilityManager = front->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityManager->RegisterInteractionOperationAsChildTree(parentWindowId, parentTreeId, parentElementId);
|
||||
}
|
||||
|
||||
void UIContentImpl::SetAccessibilityGetParentRectHandler(std::function<void(int32_t&, int32_t&)>&& callback)
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
CHECK_NULL_VOID(container);
|
||||
auto front = container->GetFrontend();
|
||||
CHECK_NULL_VOID(front);
|
||||
auto accessibilityManager = front->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityManager->SetAccessibilityGetParentRectHandler(std::move(callback));
|
||||
}
|
||||
|
||||
void UIContentImpl::DeregisterAccessibilityChildTree()
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
CHECK_NULL_VOID(container);
|
||||
auto front = container->GetFrontend();
|
||||
CHECK_NULL_VOID(front);
|
||||
auto accessibilityManager = front->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityManager->DeregisterInteractionOperationAsChildTree();
|
||||
}
|
||||
|
||||
void UIContentImpl::AccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
CHECK_NULL_VOID(container);
|
||||
container->Dump(params, info);
|
||||
}
|
||||
|
||||
void UIContentImpl::SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback)
|
||||
{
|
||||
CHECK_NULL_VOID(errorCallback);
|
||||
|
@ -156,6 +156,12 @@ public:
|
||||
|
||||
void SetFormBackgroundColor(const std::string& color) override;
|
||||
|
||||
void RegisterAccessibilityChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId) override;
|
||||
void SetAccessibilityGetParentRectHandler(std::function<void(int32_t&, int32_t&)>&& callback) override;
|
||||
void DeregisterAccessibilityChildTree() override;
|
||||
void AccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
|
||||
void SetFontScaleFollowSystem(const bool fontScaleFollowSystem) override;
|
||||
|
||||
SerializeableObjectArray DumpUITree() override
|
||||
|
@ -390,6 +390,7 @@ void UpdateAccessibilityNodeInfo(const RefPtr<AccessibilityNode>& node, Accessib
|
||||
void UpdateCacheInfo(std::list<AccessibilityElementInfo>& infos, uint32_t mode, const RefPtr<AccessibilityNode>& node,
|
||||
const RefPtr<JsAccessibilityManager>& jsAccessibilityManager, int windowId)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "elementId: %{public}d, mode: %{public}d", node->GetNodeId(), mode);
|
||||
// parent
|
||||
uint32_t umode = mode;
|
||||
if (umode & static_cast<uint32_t>(PREFETCH_PREDECESSORS)) {
|
||||
@ -1114,8 +1115,10 @@ void UpdateSupportAction(const RefPtr<NG::FrameNode>& node, AccessibilityElement
|
||||
nodeInfo.AddAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateAccessibilityElementInfo(const RefPtr<NG::FrameNode>& node, AccessibilityElementInfo& nodeInfo)
|
||||
void JsAccessibilityManager::UpdateAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, AccessibilityElementInfo& nodeInfo)
|
||||
{
|
||||
CHECK_NULL_VOID(node);
|
||||
auto accessibilityProperty = node->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||
@ -1179,6 +1182,14 @@ static void UpdateAccessibilityElementInfo(const RefPtr<NG::FrameNode>& node, Ac
|
||||
nodeInfo.SetSelectedEnd(accessibilityProperty->GetTextSelectionEnd());
|
||||
nodeInfo.SetInputType(static_cast<int>(accessibilityProperty->GetTextInputType()));
|
||||
nodeInfo.SetItemCounts(accessibilityProperty->GetCollectionItemCounts());
|
||||
nodeInfo.SetChildTreeIdAndWinId(
|
||||
accessibilityProperty->GetChildTreeId(), accessibilityProperty->GetChildWindowId());
|
||||
if (nodeInfo.GetComponentType() == "FormComponent") {
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "elementId: %{public}" PRId64 ", Set: %{public}d %{public}d",
|
||||
nodeInfo.GetAccessibilityId(), accessibilityProperty->GetChildTreeId(),
|
||||
accessibilityProperty->GetChildWindowId());
|
||||
}
|
||||
nodeInfo.SetBelongTreeId(treeId_);
|
||||
|
||||
GridInfo gridInfo(accessibilityProperty->GetCollectionInfo().rows,
|
||||
accessibilityProperty->GetCollectionInfo().columns, accessibilityProperty->GetCollectionInfo().selectMode);
|
||||
@ -1208,6 +1219,7 @@ static void UpdateAccessibilityElementInfo(const RefPtr<NG::FrameNode>& node, Ac
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
#ifdef WEB_SUPPORTED
|
||||
static void UpdateWebAccessibilityElementInfo(
|
||||
RefPtr<NG::WebAccessibilityNode> node, AccessibilityElementInfo& nodeInfo)
|
||||
@ -1320,8 +1332,9 @@ void UpdateChildrenOfAccessibilityElementInfo(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateVirtualNodeChildAccessibilityElementInfo(
|
||||
void JsAccessibilityManager::UpdateVirtualNodeChildAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, const CommonProperty& commonProperty,
|
||||
AccessibilityElementInfo& nodeParentInfo, AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline)
|
||||
@ -1368,7 +1381,7 @@ void UpdateVirtualNodeChildAccessibilityElementInfo(
|
||||
UpdateAccessibilityElementInfo(node, nodeInfo);
|
||||
}
|
||||
|
||||
void UpdateVirtualNodeAccessibilityElementInfo(
|
||||
void JsAccessibilityManager::UpdateVirtualNodeAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& parent, const RefPtr<NG::FrameNode>& node,
|
||||
const CommonProperty& commonProperty, AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline)
|
||||
@ -1423,7 +1436,7 @@ void UpdateVirtualNodeAccessibilityElementInfo(
|
||||
UpdateAccessibilityElementInfo(node, nodeInfo);
|
||||
}
|
||||
|
||||
void UpdateAccessibilityElementInfo(
|
||||
void JsAccessibilityManager::UpdateAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, const CommonProperty& commonProperty,
|
||||
AccessibilityElementInfo& nodeInfo, const RefPtr<NG::PipelineContext>& ngPipeline)
|
||||
{
|
||||
@ -1469,6 +1482,7 @@ void UpdateAccessibilityElementInfo(
|
||||
UpdateAccessibilityElementInfo(node, nodeInfo);
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::list<AccessibilityElementInfo> SearchExtensionElementInfoByAccessibilityIdNG(
|
||||
int64_t elementId, int32_t mode, const RefPtr<NG::FrameNode>& node, int64_t offset)
|
||||
{
|
||||
@ -1534,9 +1548,10 @@ void GetChildrenFromFrameNode(const RefPtr<NG::FrameNode>& node,
|
||||
frameNodeChildren.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateVirtualNodeInfo(std::list<AccessibilityElementInfo>& infos, AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::UINode>& uiVirtualNode, const CommonProperty& commonProperty,
|
||||
void JsAccessibilityManager::UpdateVirtualNodeInfo(std::list<AccessibilityElementInfo>& infos,
|
||||
AccessibilityElementInfo& nodeInfo, const RefPtr<NG::UINode>& uiVirtualNode, const CommonProperty& commonProperty,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline)
|
||||
{
|
||||
AccessibilityElementInfo virtualInfo;
|
||||
@ -1561,6 +1576,7 @@ void UpdateVirtualNodeInfo(std::list<AccessibilityElementInfo>& infos, Accessibi
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void SearchExtensionElementInfoNG(const SearchParameter& searchParam,
|
||||
const RefPtr<NG::FrameNode>& node, std::list<Accessibility::AccessibilityElementInfo>& infos,
|
||||
Accessibility::AccessibilityElementInfo& parentInfo)
|
||||
@ -1590,9 +1606,11 @@ bool IsNodeInRoot(const RefPtr<NG::FrameNode>& node, const RefPtr<NG::PipelineCo
|
||||
return LessNotEqual(rect.GetX(), rootRect.GetX() + rootRect.Width());
|
||||
}
|
||||
|
||||
void UpdateCacheInfoNG(std::list<AccessibilityElementInfo>& infos, const RefPtr<NG::FrameNode>& node,
|
||||
const CommonProperty& commonProperty, const RefPtr<NG::PipelineContext>& ngPipeline,
|
||||
const SearchParameter& searchParam)
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::UpdateCacheInfoNG(std::list<AccessibilityElementInfo>& infos,
|
||||
const RefPtr<NG::FrameNode>& node, const CommonProperty& commonProperty,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline, const SearchParameter& searchParam)
|
||||
{
|
||||
uint32_t umode = searchParam.mode;
|
||||
std::list<std::variant<RefPtr<NG::FrameNode>, int64_t>> children;
|
||||
@ -1663,6 +1681,7 @@ void UpdateCacheInfoNG(std::list<AccessibilityElementInfo>& infos, const RefPtr<
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool CanAccessibilityFocusedNG(const RefPtr<NG::FrameNode>& node)
|
||||
{
|
||||
CHECK_NULL_RETURN(node, false);
|
||||
@ -1927,14 +1946,16 @@ static void DumpAccessibilityPropertyNG(const AccessibilityElementInfo& nodeInfo
|
||||
DumpLog::GetInstance().AddDesc("latest content: ", nodeInfo.GetLatestContent());
|
||||
}
|
||||
|
||||
inline string ChildernToString(const vector<int64_t>& children)
|
||||
inline string ChildernToString(const vector<int64_t>& children, int32_t treeId)
|
||||
{
|
||||
std::string ids;
|
||||
for (auto child : children) {
|
||||
if (!ids.empty()) {
|
||||
ids.append(",");
|
||||
}
|
||||
ids.append(std::to_string(child));
|
||||
int64_t childId = child;
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId, childId);
|
||||
ids.append(std::to_string(childId));
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
@ -1951,11 +1972,15 @@ inline void DumpRectNG(const Accessibility::Rect& rect)
|
||||
DumpLog::GetInstance().AddDesc("bottom: ", std::to_string(rect.GetRightBottomYScreenPostion()));
|
||||
}
|
||||
|
||||
static void DumpCommonPropertyNG(const AccessibilityElementInfo& nodeInfo)
|
||||
static void DumpCommonPropertyNG(const AccessibilityElementInfo& nodeInfo, int32_t treeId)
|
||||
{
|
||||
DumpLog::GetInstance().AddDesc("ID: ", nodeInfo.GetAccessibilityId());
|
||||
DumpLog::GetInstance().AddDesc("parent ID: ", nodeInfo.GetParentNodeId());
|
||||
DumpLog::GetInstance().AddDesc("child IDs: ", ChildernToString(nodeInfo.GetChildIds()));
|
||||
int64_t elementId = nodeInfo.GetAccessibilityId();
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId, elementId);
|
||||
DumpLog::GetInstance().AddDesc("ID: ", elementId);
|
||||
int64_t parentId = nodeInfo.GetParentNodeId();
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId, parentId);
|
||||
DumpLog::GetInstance().AddDesc("parent ID: ", parentId);
|
||||
DumpLog::GetInstance().AddDesc("child IDs: ", ChildernToString(nodeInfo.GetChildIds(), treeId));
|
||||
DumpLog::GetInstance().AddDesc("component type: ", nodeInfo.GetComponentType());
|
||||
DumpLog::GetInstance().AddDesc("text: ", nodeInfo.GetContent());
|
||||
DumpLog::GetInstance().AddDesc("window id: " + std::to_string(nodeInfo.GetWindowId()));
|
||||
@ -2135,6 +2160,9 @@ bool JsAccessibilityManager::SendAccessibilitySyncEvent(
|
||||
if (!isEnabled) {
|
||||
return false;
|
||||
}
|
||||
int64_t elementId = eventInfo.GetAccessibilityId();
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, elementId);
|
||||
eventInfo.SetSource(elementId);
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "send accessibility event:%{public}d accessibilityId:%{public}" PRId64,
|
||||
eventInfo.GetEventType(), eventInfo.GetAccessibilityId());
|
||||
return client->SendEvent(eventInfo);
|
||||
@ -2439,6 +2467,12 @@ void JsAccessibilityManager::OnDumpInfoNG(const std::vector<std::string>& params
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<std::string> info;
|
||||
bool isChildElement = CheckIsChildElement(nodeId, params, info);
|
||||
if (isChildElement) {
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "dump child element: %{public}" PRId64, nodeId);
|
||||
return;
|
||||
}
|
||||
switch (mode) {
|
||||
case DumpMode::TREE:
|
||||
DumpTreeNG(useWindowId, windowId, rootId);
|
||||
@ -2469,6 +2503,12 @@ void JsAccessibilityManager::DumpHandleEvent(const std::vector<std::string>& par
|
||||
auto pipeline = context_.Upgrade();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
int64_t nodeId = StringUtils::StringToLongInt(params[EVENT_DUMP_ID_INDEX]);
|
||||
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(nodeId, splitElementId, splitTreeId);
|
||||
nodeId = splitElementId;
|
||||
|
||||
auto action = static_cast<AceAction>(StringUtils::StringToInt(params[EVENT_DUMP_ACTION_INDEX]));
|
||||
auto op = ConvertAceAction(action);
|
||||
if ((op != ActionType::ACCESSIBILITY_ACTION_SET_SELECTION) && (params.size() > EVENT_DUMP_PARAM_LENGTH_UPPER + 1)) {
|
||||
@ -2576,7 +2616,7 @@ void JsAccessibilityManager::DumpPropertyNG(int64_t nodeID)
|
||||
nodeID, PREFETCH_RECURSIVE_CHILDREN, extensionElementInfos, ngPipeline, NG::UI_EXTENSION_OFFSET_MAX);
|
||||
for (auto& extensionElementInfo : extensionElementInfos) {
|
||||
if (nodeID == extensionElementInfo.GetAccessibilityId()) {
|
||||
DumpCommonPropertyNG(extensionElementInfo);
|
||||
DumpCommonPropertyNG(extensionElementInfo, treeId_);
|
||||
DumpAccessibilityPropertyNG(extensionElementInfo);
|
||||
DumpLog::GetInstance().Print(
|
||||
0, extensionElementInfo.GetComponentType(), extensionElementInfo.GetChildCount());
|
||||
@ -2600,7 +2640,7 @@ void JsAccessibilityManager::DumpPropertyNG(int64_t nodeID)
|
||||
std::list<AccessibilityElementInfo> extensionElementInfos;
|
||||
SearchExtensionElementInfoNG(param, frameNode, extensionElementInfos, nodeInfo);
|
||||
}
|
||||
DumpCommonPropertyNG(nodeInfo);
|
||||
DumpCommonPropertyNG(nodeInfo, treeId_);
|
||||
DumpAccessibilityPropertyNG(nodeInfo);
|
||||
auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||
if (accessibilityProperty) {
|
||||
@ -2719,6 +2759,8 @@ static void DumpTreeNodeInfoNG(
|
||||
"checked: " + std::to_string(node->GetAccessibilityProperty<NG::AccessibilityProperty>()->IsChecked()));
|
||||
DumpLog::GetInstance().AddDesc(
|
||||
"hint: " + node->GetAccessibilityProperty<NG::AccessibilityProperty>()->GetHintText());
|
||||
DumpLog::GetInstance().AddDesc(
|
||||
"childTree: " + std::to_string(node->GetAccessibilityProperty<NG::AccessibilityProperty>()->GetChildTreeId()));
|
||||
DumpLog::GetInstance().Print(depth, node->GetTag(), childSize);
|
||||
}
|
||||
|
||||
@ -2882,17 +2924,22 @@ RefPtr<PipelineBase> JsAccessibilityManager::GetPipelineByWindowId(const int32_t
|
||||
void JsAccessibilityManager::JsInteractionOperation::SearchElementInfoByAccessibilityId(const int64_t elementId,
|
||||
const int32_t requestId, AccessibilityElementOperatorCallback& callback, const int32_t mode)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto windowId = windowId_;
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = GetHandler(), elementId, requestId, &callback, mode, windowId]() {
|
||||
[weak = GetHandler(), splitElementId, requestId, &callback, mode, windowId]() {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("SearchElementInfoByAccessibilityId");
|
||||
jsAccessibilityManager->SearchElementInfoByAccessibilityId(elementId, requestId, callback, mode, windowId);
|
||||
jsAccessibilityManager->SearchElementInfoByAccessibilityId(
|
||||
splitElementId, requestId, callback, mode, windowId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIAccessibilitySearchElementInfoById");
|
||||
}
|
||||
@ -2937,6 +2984,8 @@ void JsAccessibilityManager::SearchElementInfoByAccessibilityId(const int64_t el
|
||||
void JsAccessibilityManager::SearchElementInfoByAccessibilityIdNG(int64_t elementId, int32_t mode,
|
||||
std::list<AccessibilityElementInfo>& infos, const RefPtr<PipelineBase>& context, int64_t uiExtensionOffset)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "elementId: %{public}" PRId64 ", treeId: %{public}d, mode: %{public}d",
|
||||
elementId, treeId_, mode);
|
||||
auto mainContext = context_.Upgrade();
|
||||
CHECK_NULL_VOID(mainContext);
|
||||
|
||||
@ -3114,6 +3163,10 @@ void JsAccessibilityManager::SearchElementInfosByTextNG(int64_t elementId, const
|
||||
void JsAccessibilityManager::JsInteractionOperation::SearchElementInfosByText(const int64_t elementId,
|
||||
const std::string& text, const int32_t requestId, AccessibilityElementOperatorCallback& callback)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
if (text.empty()) {
|
||||
return;
|
||||
}
|
||||
@ -3124,11 +3177,12 @@ void JsAccessibilityManager::JsInteractionOperation::SearchElementInfosByText(co
|
||||
auto windowId = windowId_;
|
||||
if (context) {
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = GetHandler(), elementId, text, requestId, &callback, windowId]() {
|
||||
[weak = GetHandler(), splitElementId, text, requestId, &callback, windowId]() {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("SearchElementInfosByText");
|
||||
jsAccessibilityManager->SearchElementInfosByText(elementId, text, requestId, callback, windowId);
|
||||
jsAccessibilityManager->SearchElementInfosByText(
|
||||
splitElementId, text, requestId, callback, windowId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIAccessibilitySearchElementInfoByText");
|
||||
}
|
||||
@ -3178,17 +3232,21 @@ void JsAccessibilityManager::SearchElementInfosByText(const int64_t elementId, c
|
||||
void JsAccessibilityManager::JsInteractionOperation::FindFocusedElementInfo(const int64_t elementId,
|
||||
const int32_t focusType, const int32_t requestId, AccessibilityElementOperatorCallback& callback)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto windowId = windowId_;
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = GetHandler(), elementId, focusType, requestId, &callback, windowId]() {
|
||||
[weak = GetHandler(), splitElementId, focusType, requestId, &callback, windowId]() {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("FindFocusedElementInfo");
|
||||
jsAccessibilityManager->FindFocusedElementInfo(elementId, focusType, requestId, callback, windowId);
|
||||
jsAccessibilityManager->FindFocusedElementInfo(splitElementId, focusType, requestId, callback, windowId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIAccessibilityFindFocusedElementInfo");
|
||||
}
|
||||
@ -3355,6 +3413,10 @@ void JsAccessibilityManager::JsInteractionOperation::ExecuteAction(const int64_t
|
||||
const std::map<std::string, std::string>& actionArguments, const int32_t requestId,
|
||||
AccessibilityElementOperatorCallback& callback)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
@ -3363,11 +3425,11 @@ void JsAccessibilityManager::JsInteractionOperation::ExecuteAction(const int64_t
|
||||
ActionParam param { actionInfo, actionArguments };
|
||||
auto windowId = windowId_;
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = GetHandler(), elementId, param, requestId, &callback, windowId] {
|
||||
[weak = GetHandler(), splitElementId, param, requestId, &callback, windowId] {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("ExecuteAction");
|
||||
jsAccessibilityManager->ExecuteAction(elementId, param, requestId, callback, windowId);
|
||||
jsAccessibilityManager->ExecuteAction(splitElementId, param, requestId, callback, windowId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIAccessibilityExecuteAction");
|
||||
}
|
||||
@ -3703,13 +3765,17 @@ void JsAccessibilityManager::ExecuteAction(const int64_t elementId, const Action
|
||||
void JsAccessibilityManager::JsInteractionOperation::GetCursorPosition(const int64_t elementId,
|
||||
const int32_t requestId, AccessibilityElementOperatorCallback &callback)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto ngPipeline = AceType::DynamicCast<NG::PipelineContext>(context);
|
||||
CHECK_NULL_VOID(ngPipeline);
|
||||
auto frameNode = GetFramenodeByAccessibilityId(ngPipeline->GetRootElement(), elementId);
|
||||
auto frameNode = GetFramenodeByAccessibilityId(ngPipeline->GetRootElement(), splitElementId);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||
CHECK_NULL_VOID(accessibilityProperty);
|
||||
@ -3735,16 +3801,6 @@ void JsAccessibilityManager::JsInteractionOperation::ClearFocus()
|
||||
|
||||
void JsAccessibilityManager::JsInteractionOperation::OutsideTouch() {}
|
||||
|
||||
bool JsAccessibilityManager::IsRegister()
|
||||
{
|
||||
return isReg_;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::Register(bool state)
|
||||
{
|
||||
isReg_ = state;
|
||||
}
|
||||
|
||||
int JsAccessibilityManager::RegisterInteractionOperation(int windowId)
|
||||
{
|
||||
if (IsRegister()) {
|
||||
@ -3765,6 +3821,9 @@ int JsAccessibilityManager::RegisterInteractionOperation(int windowId)
|
||||
retReg = instance->RegisterElementOperator(context->GetWindowId(), interactionOperation);
|
||||
}
|
||||
Register(retReg == RET_OK);
|
||||
if (retReg == RET_OK) {
|
||||
NotifyChildTreeOnRegister(treeId_);
|
||||
}
|
||||
|
||||
return retReg;
|
||||
}
|
||||
@ -3808,6 +3867,211 @@ void JsAccessibilityManager::DeregisterInteractionOperation()
|
||||
CHECK_NULL_VOID(context);
|
||||
instance->DeregisterElementOperator(context->GetWindowId());
|
||||
}
|
||||
NotifyChildTreeOnDeregister();
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::RegisterAccessibilityChildTreeCallback(
|
||||
int64_t elementId, const std::shared_ptr<AccessibilityChildTreeCallback> &callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
childTreeCallbackMap_[elementId] = callback;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::DeregisterAccessibilityChildTreeCallback(int64_t elementId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
childTreeCallbackMap_.erase(elementId);
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::NotifyChildTreeOnRegister(int32_t treeId)
|
||||
{
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "NotifyChildTreeOnRegister size: %{public}zu", childTreeCallbackMap_.size());
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
for (auto &item : childTreeCallbackMap_) {
|
||||
if (item.second == nullptr) {
|
||||
continue;
|
||||
}
|
||||
item.second->OnRegister(GetWindowId(), treeId);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::NotifyChildTreeOnDeregister()
|
||||
{
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "NotifyChildTreeOnDeregister size: %{public}zu",
|
||||
childTreeCallbackMap_.size());
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
for (auto &item : childTreeCallbackMap_) {
|
||||
if (item.second == nullptr) {
|
||||
continue;
|
||||
}
|
||||
item.second->OnDeregister();
|
||||
}
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::NotifySetChildTreeIdAndWinId(
|
||||
int64_t elementId, const int32_t treeId, const int32_t childWindowId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
auto findResult = childTreeCallbackMap_.find(elementId);
|
||||
if (findResult == childTreeCallbackMap_.end()) {
|
||||
TAG_LOGW(AceLogTag::ACE_ACCESSIBILITY, "node: %{public}" PRId64 " not found, treeId: %{public}d", elementId,
|
||||
treeId);
|
||||
return;
|
||||
}
|
||||
auto callback = findResult->second;
|
||||
CHECK_NULL_VOID(callback);
|
||||
callback->SetChildTreeId(treeId);
|
||||
callback->OnSetChildTree(childWindowId, treeId);
|
||||
}
|
||||
|
||||
bool JsAccessibilityManager::CheckIsChildElement(
|
||||
int64_t &elementId, const std::vector<std::string> ¶ms, std::vector<std::string> &info)
|
||||
{
|
||||
if (elementId <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
if (splitTreeId <= 0 || splitTreeId == treeId_) {
|
||||
elementId = splitElementId;
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(childTreeCallbackMapMutex_);
|
||||
for (const auto &item : childTreeCallbackMap_) {
|
||||
if (item.second == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (item.second->GetChildTreeId() != splitTreeId) {
|
||||
continue;
|
||||
}
|
||||
item.second->OnDumpChildInfo(params, info);
|
||||
for (const auto &childInfo : info) {
|
||||
DumpLog::GetInstance().Print(childInfo.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::RegisterInteractionOperationAsChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId)
|
||||
{
|
||||
if (IsRegister()) {
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "parentTreeId: %{public}d, %{public}" PRId64, parentTreeId, parentElementId);
|
||||
|
||||
std::shared_ptr<AccessibilitySystemAbilityClient> instance = AccessibilitySystemAbilityClient::GetInstance();
|
||||
CHECK_NULL_VOID(instance);
|
||||
int32_t windowId = GetWindowId();
|
||||
auto interactionOperation = std::make_shared<JsInteractionOperation>(windowId);
|
||||
interactionOperation->SetHandler(WeakClaim(this));
|
||||
Accessibility::Registration registration {
|
||||
.windowId = windowId,
|
||||
.parentWindowId = parentWindowId,
|
||||
.parentTreeId = parentTreeId,
|
||||
.elementId = parentElementId,
|
||||
};
|
||||
Accessibility::RetError retReg = instance->RegisterElementOperator(registration, interactionOperation);
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "RegisterElementOperator result: %{public}d", retReg);
|
||||
Register(retReg == RET_OK);
|
||||
AceApplicationInfo::GetInstance().SetAccessibilityEnabled(retReg == RET_OK);
|
||||
parentElementId_ = parentElementId;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::SetAccessibilityGetParentRectHandler(std::function<void(int32_t &, int32_t &)> &&callback)
|
||||
{
|
||||
getParentRectHandler_ = std::move(callback);
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::DeregisterInteractionOperationAsChildTree()
|
||||
{
|
||||
if (!IsRegister()) {
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "deregister accessibility childTree");
|
||||
|
||||
std::shared_ptr<AccessibilitySystemAbilityClient> instance = AccessibilitySystemAbilityClient::GetInstance();
|
||||
CHECK_NULL_VOID(instance);
|
||||
int32_t windowId = GetWindowId();
|
||||
Register(false);
|
||||
currentFocusNodeId_ = -1;
|
||||
instance->DeregisterElementOperator(windowId);
|
||||
AceApplicationInfo::GetInstance().SetAccessibilityEnabled(false);
|
||||
parentElementId_ = INVALID_PARENT_ID;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::JsInteractionOperation::SetChildTreeIdAndWinId(
|
||||
const int64_t nodeId, const int32_t treeId, const int32_t childWindowId)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(nodeId, splitElementId, splitTreeId);
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "SetChildTreeId node: %{public}" PRId64 " treeId: %{public}d",
|
||||
splitElementId, treeId);
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
jsAccessibilityManager->NotifySetChildTreeIdAndWinId(splitElementId, treeId, childWindowId);
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::JsInteractionOperation::SetBelongTreeId(const int32_t treeId)
|
||||
{
|
||||
TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "SetBelongTreeId treeId: %{public}d", treeId);
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
jsAccessibilityManager->treeId_ = treeId;
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::UpdateElementInfoTreeId(Accessibility::AccessibilityElementInfo& info)
|
||||
{
|
||||
if (treeId_ == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t elementId = info.GetAccessibilityId();
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, elementId);
|
||||
info.SetAccessibilityId(elementId);
|
||||
|
||||
int64_t parentId = info.GetParentNodeId();
|
||||
if (parentId != INVALID_PARENT_ID) {
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, parentId);
|
||||
info.SetParent(parentId);
|
||||
}
|
||||
|
||||
std::vector<int64_t> childIds = info.GetChildIds();
|
||||
for (int64_t child : childIds) {
|
||||
info.RemoveChild(child);
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, child);
|
||||
info.AddChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::UpdateElementInfosTreeId(std::list<Accessibility::AccessibilityElementInfo>& infos)
|
||||
{
|
||||
if (treeId_ == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &item : infos) {
|
||||
int64_t elementId = item.GetAccessibilityId();
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, elementId);
|
||||
item.SetAccessibilityId(elementId);
|
||||
|
||||
int64_t parentId = item.GetParentNodeId();
|
||||
if (parentId != INVALID_PARENT_ID) {
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, parentId);
|
||||
item.SetParent(parentId);
|
||||
}
|
||||
|
||||
std::vector<int64_t> childIds = item.GetChildIds();
|
||||
for (int64_t child : childIds) {
|
||||
item.RemoveChild(child);
|
||||
AccessibilitySystemAbilityClient::SetSplicElementIdTreeId(treeId_, child);
|
||||
item.AddChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::SetPipelineContext(const RefPtr<PipelineBase>& context)
|
||||
@ -3862,17 +4126,21 @@ void JsAccessibilityManager::JsAccessibilityStateObserver::OnStateChanged(const
|
||||
void JsAccessibilityManager::JsInteractionOperation::FocusMoveSearch(
|
||||
int64_t elementId, const int32_t direction, const int32_t requestId, AccessibilityElementOperatorCallback& callback)
|
||||
{
|
||||
int64_t splitElementId = AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID;
|
||||
int32_t splitTreeId = AccessibilityElementInfo::UNDEFINED_TREE_ID;
|
||||
AccessibilitySystemAbilityClient::GetTreeIdAndElementIdBySplitElementId(elementId, splitElementId, splitTreeId);
|
||||
|
||||
auto jsAccessibilityManager = GetHandler().Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
auto context = jsAccessibilityManager->GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto windowId = windowId_;
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = GetHandler(), elementId, direction, requestId, &callback, windowId] {
|
||||
[weak = GetHandler(), splitElementId, direction, requestId, &callback, windowId] {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
ACE_SCOPED_TRACE("FocusMoveSearch");
|
||||
jsAccessibilityManager->FocusMoveSearch(elementId, direction, requestId, callback, windowId);
|
||||
jsAccessibilityManager->FocusMoveSearch(splitElementId, direction, requestId, callback, windowId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI, "ArkUIAccessibilityFocusMoveSearch");
|
||||
}
|
||||
@ -4322,12 +4590,15 @@ void JsAccessibilityManager::SetSearchElementInfoByAccessibilityIdResult(Accessi
|
||||
auto context = GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = WeakClaim(this), infos = std::move(infos), &callback, requestId] {
|
||||
[weak = WeakClaim(this), infos = std::move(infos), &callback, requestId] () mutable {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "winId: %{public}d, treeId: %{public}d, reqId: %{public}d",
|
||||
jsAccessibilityManager->windowId_, jsAccessibilityManager->treeId_, requestId);
|
||||
if (!jsAccessibilityManager->IsRegister()) {
|
||||
return;
|
||||
}
|
||||
jsAccessibilityManager->UpdateElementInfosTreeId(infos);
|
||||
callback.SetSearchElementInfoByAccessibilityIdResult(infos, requestId);
|
||||
}, TaskExecutor::TaskType::BACKGROUND, "ArkUIAccessibilitySetSearchElementInfoById");
|
||||
}
|
||||
@ -4341,28 +4612,31 @@ void JsAccessibilityManager::SetSearchElementInfoByTextResult(AccessibilityEleme
|
||||
auto context = GetPipelineContext().Upgrade();
|
||||
CHECK_NULL_VOID(context);
|
||||
context->GetTaskExecutor()->PostTask(
|
||||
[weak = WeakClaim(this), infos = std::move(infos), &callback, requestId] {
|
||||
[weak = WeakClaim(this), infos = std::move(infos), &callback, requestId] () mutable {
|
||||
auto jsAccessibilityManager = weak.Upgrade();
|
||||
CHECK_NULL_VOID(jsAccessibilityManager);
|
||||
if (!jsAccessibilityManager->IsRegister()) {
|
||||
return;
|
||||
}
|
||||
jsAccessibilityManager->UpdateElementInfosTreeId(infos);
|
||||
callback.SetSearchElementInfoByTextResult(infos, requestId);
|
||||
}, TaskExecutor::TaskType::BACKGROUND, "ArkUIAccessibilitySetSearchElementInfoByText");
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::SetFindFocusedElementInfoResult(
|
||||
AccessibilityElementOperatorCallback& callback, const AccessibilityElementInfo& info, const int32_t requestId)
|
||||
AccessibilityElementOperatorCallback& callback, AccessibilityElementInfo& info, const int32_t requestId)
|
||||
{
|
||||
if (IsRegister()) {
|
||||
UpdateElementInfoTreeId(info);
|
||||
callback.SetFindFocusedElementInfoResult(info, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAccessibilityManager::SetFocusMoveSearchResult(
|
||||
AccessibilityElementOperatorCallback& callback, const AccessibilityElementInfo& info, const int32_t requestId)
|
||||
AccessibilityElementOperatorCallback& callback, AccessibilityElementInfo& info, const int32_t requestId)
|
||||
{
|
||||
if (IsRegister()) {
|
||||
UpdateElementInfoTreeId(info);
|
||||
callback.SetFocusMoveSearchResult(info, requestId);
|
||||
}
|
||||
}
|
||||
@ -4395,8 +4669,12 @@ void JsAccessibilityManager::GenerateCommonProperty(const RefPtr<PipelineBase>&
|
||||
auto page = stageManager->GetLastPage();
|
||||
CHECK_NULL_VOID(page);
|
||||
output.windowId = static_cast<int32_t>(ngPipeline->GetFocusWindowId());
|
||||
output.windowLeft = GetWindowLeft(ngPipeline->GetWindowId());
|
||||
output.windowTop = GetWindowTop(ngPipeline->GetWindowId());
|
||||
if (getParentRectHandler_) {
|
||||
getParentRectHandler_(output.windowTop, output.windowLeft);
|
||||
} else {
|
||||
output.windowLeft = GetWindowLeft(ngPipeline->GetWindowId());
|
||||
output.windowTop = GetWindowTop(ngPipeline->GetWindowId());
|
||||
}
|
||||
output.pageId = page->GetPageId();
|
||||
output.pagePath = GetPagePath();
|
||||
if (context->GetWindowId() != mainContext->GetWindowId()) {
|
||||
|
@ -89,9 +89,6 @@ public:
|
||||
lastFrameNode_ = node;
|
||||
}
|
||||
|
||||
|
||||
bool IsRegister();
|
||||
void Register(bool state);
|
||||
bool SubscribeToastObserver();
|
||||
bool UnsubscribeToastObserver();
|
||||
bool SubscribeStateObserver(int eventType);
|
||||
@ -150,6 +147,16 @@ public:
|
||||
|
||||
std::string GetPagePath();
|
||||
|
||||
void RegisterAccessibilityChildTreeCallback(
|
||||
int64_t elementId, const std::shared_ptr<AccessibilityChildTreeCallback> &callback) override;
|
||||
|
||||
void DeregisterAccessibilityChildTreeCallback(int64_t elementId) override;
|
||||
|
||||
void RegisterInteractionOperationAsChildTree(uint32_t parentWindowId, int32_t parentTreeId,
|
||||
int64_t parentElementId) override;
|
||||
void SetAccessibilityGetParentRectHandler(std::function<void(int32_t &, int32_t &)> &&callback) override;
|
||||
void DeregisterInteractionOperationAsChildTree() override;
|
||||
|
||||
protected:
|
||||
void OnDumpInfoNG(const std::vector<std::string>& params, uint32_t windowId) override;
|
||||
void DumpHandleEvent(const std::vector<std::string>& params) override;
|
||||
@ -157,6 +164,8 @@ protected:
|
||||
void DumpTree(int32_t depth, int64_t nodeID) override;
|
||||
|
||||
private:
|
||||
static constexpr int32_t INVALID_PARENT_ID = -2100000;
|
||||
|
||||
class JsInteractionOperation : public Accessibility::AccessibilityElementOperator {
|
||||
public:
|
||||
explicit JsInteractionOperation(int32_t windowId) : windowId_(windowId) {}
|
||||
@ -177,6 +186,8 @@ private:
|
||||
void OutsideTouch() override;
|
||||
void GetCursorPosition(const int64_t elementId, const int32_t requestId,
|
||||
Accessibility::AccessibilityElementOperatorCallback &callback) override;
|
||||
void SetChildTreeIdAndWinId(const int64_t nodeId, const int32_t treeId, const int32_t childWindowId) override;
|
||||
void SetBelongTreeId(const int32_t treeId) override;
|
||||
|
||||
void SetHandler(const WeakPtr<JsAccessibilityManager>& js)
|
||||
{
|
||||
@ -247,10 +258,10 @@ private:
|
||||
std::list<Accessibility::AccessibilityElementInfo>&& infos, const int32_t requestId);
|
||||
|
||||
void SetFindFocusedElementInfoResult(Accessibility::AccessibilityElementOperatorCallback& callback,
|
||||
const Accessibility::AccessibilityElementInfo& info, const int32_t requestId);
|
||||
Accessibility::AccessibilityElementInfo& info, const int32_t requestId);
|
||||
|
||||
void SetFocusMoveSearchResult(Accessibility::AccessibilityElementOperatorCallback& callback,
|
||||
const Accessibility::AccessibilityElementInfo& info, const int32_t requestId);
|
||||
Accessibility::AccessibilityElementInfo& info, const int32_t requestId);
|
||||
|
||||
void SetExecuteActionResult(
|
||||
Accessibility::AccessibilityElementOperatorCallback& callback, const bool succeeded, const int32_t requestId);
|
||||
@ -299,9 +310,47 @@ private:
|
||||
const RefPtr<NG::PipelineContext>& context,
|
||||
const CommonProperty& commonProperty, const SearchParameter& searchParam);
|
||||
|
||||
void UpdateAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, Accessibility::AccessibilityElementInfo& nodeInfo);
|
||||
|
||||
void UpdateVirtualNodeInfo(std::list<Accessibility::AccessibilityElementInfo>& infos,
|
||||
Accessibility::AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::UINode>& uiVirtualNode, const CommonProperty& commonProperty,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline);
|
||||
|
||||
void UpdateVirtualNodeChildAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, const CommonProperty& commonProperty,
|
||||
Accessibility::AccessibilityElementInfo& nodeParentInfo, Accessibility::AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline);
|
||||
|
||||
void UpdateVirtualNodeAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& parent, const RefPtr<NG::FrameNode>& node,
|
||||
const CommonProperty& commonProperty, Accessibility::AccessibilityElementInfo& nodeInfo,
|
||||
const RefPtr<NG::PipelineContext>& ngPipeline);
|
||||
|
||||
void UpdateAccessibilityElementInfo(
|
||||
const RefPtr<NG::FrameNode>& node, const CommonProperty& commonProperty,
|
||||
Accessibility::AccessibilityElementInfo& nodeInfo, const RefPtr<NG::PipelineContext>& ngPipeline);
|
||||
|
||||
void UpdateCacheInfoNG(std::list<Accessibility::AccessibilityElementInfo>& infos, const RefPtr<NG::FrameNode>& node,
|
||||
const CommonProperty& commonProperty, const RefPtr<NG::PipelineContext>& ngPipeline,
|
||||
const SearchParameter& searchParam);
|
||||
|
||||
void NotifyChildTreeOnRegister(int32_t treeId);
|
||||
|
||||
void NotifyChildTreeOnDeregister();
|
||||
|
||||
void NotifySetChildTreeIdAndWinId(int64_t elementId, const int32_t treeId, const int32_t childWindowId);
|
||||
|
||||
bool CheckIsChildElement(
|
||||
int64_t &elementId, const std::vector<std::string>& params, std::vector<std::string>& info);
|
||||
|
||||
void UpdateElementInfoTreeId(Accessibility::AccessibilityElementInfo& info);
|
||||
|
||||
void UpdateElementInfosTreeId(std::list<Accessibility::AccessibilityElementInfo>& infos);
|
||||
|
||||
std::string callbackKey_;
|
||||
uint32_t windowId_ = 0;
|
||||
bool isReg_ = false;
|
||||
std::shared_ptr<JsAccessibilityStateObserver> stateObserver_ = nullptr;
|
||||
std::shared_ptr<ToastAccessibilityConfigObserver> toastObserver_ = nullptr;
|
||||
float scaleX_ = 1.0f;
|
||||
@ -310,6 +359,11 @@ private:
|
||||
|
||||
int64_t lastElementId_ = -1;
|
||||
WeakPtr<NG::FrameNode> lastFrameNode_;
|
||||
mutable std::mutex childTreeCallbackMapMutex_;
|
||||
std::unordered_map<int64_t, std::shared_ptr<AccessibilityChildTreeCallback>> childTreeCallbackMap_;
|
||||
int32_t treeId_ = 0;
|
||||
int64_t parentElementId_ = INVALID_PARENT_ID;
|
||||
std::function<void(int32_t&, int32_t&)> getParentRectHandler_;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -47,6 +47,27 @@ enum class AccessibilityVersion {
|
||||
JS_DECLARATIVE_VERSION,
|
||||
};
|
||||
|
||||
class AccessibilityChildTreeCallback {
|
||||
public:
|
||||
AccessibilityChildTreeCallback() = default;
|
||||
virtual ~AccessibilityChildTreeCallback() = default;
|
||||
virtual bool OnRegister(uint32_t windowId, int32_t treeId) = 0;
|
||||
virtual bool OnDeregister() = 0;
|
||||
virtual bool OnSetChildTree(int32_t childWindowId, int32_t childTreeId) = 0;
|
||||
virtual bool OnDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
|
||||
int32_t GetChildTreeId() const
|
||||
{
|
||||
return childTreeId_;
|
||||
}
|
||||
void SetChildTreeId(int32_t childTreeId)
|
||||
{
|
||||
childTreeId_ = childTreeId;
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t childTreeId_ = 0;
|
||||
};
|
||||
|
||||
using VisibleRatioCallback = std::function<void(bool, double)>;
|
||||
class AccessibilityManager : public AceType {
|
||||
DECLARE_ACE_TYPE(AccessibilityManager, AceType);
|
||||
@ -124,8 +145,28 @@ public:
|
||||
return version_;
|
||||
}
|
||||
|
||||
virtual void RegisterAccessibilityChildTreeCallback(
|
||||
int64_t elementId, const std::shared_ptr<AccessibilityChildTreeCallback> &callback) {};
|
||||
|
||||
virtual void DeregisterAccessibilityChildTreeCallback(int64_t elementId) {};
|
||||
|
||||
virtual void RegisterInteractionOperationAsChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId) {};
|
||||
virtual void SetAccessibilityGetParentRectHandler(std::function<void(int32_t &, int32_t &)> &&callback) {};
|
||||
virtual void DeregisterInteractionOperationAsChildTree() {};
|
||||
bool IsRegister()
|
||||
{
|
||||
return isReg_;
|
||||
}
|
||||
|
||||
void Register(bool state)
|
||||
{
|
||||
isReg_ = state;
|
||||
}
|
||||
|
||||
private:
|
||||
AccessibilityVersion version_ = AccessibilityVersion::JS_VERSION;
|
||||
bool isReg_ = false;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -408,6 +408,14 @@ void FormManagerDelegate::AddFormLinkInfoUpdateCallback(OnFormLinkInfoUpdateCall
|
||||
onFormLinkInfoUpdateCallback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FormManagerDelegate::AddGetRectRelativeToWindowCallback(OnGetRectRelativeToWindowCallback&& callback)
|
||||
{
|
||||
if (!callback || state_ == State::RELEASED) {
|
||||
return;
|
||||
}
|
||||
onGetRectRelativeToWindowCallback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FormManagerDelegate::AddActionEventHandle(const ActionEventHandle& callback)
|
||||
{
|
||||
if (!callback || state_ == State::RELEASED) {
|
||||
@ -543,6 +551,13 @@ void FormManagerDelegate::RegisterRenderDelegateEvent()
|
||||
formManagerDelegate->OnFormLinkInfoUpdate(formLinkInfos);
|
||||
};
|
||||
renderDelegate_->SetFormLinkInfoUpdateHandler(std::move(onFormLinkInfoUpdateHandler));
|
||||
|
||||
auto &&onGetRectRelativeToWindowHandler = [weak = WeakClaim(this)](int32_t &top, int32_t &left) {
|
||||
auto formManagerDelegate = weak.Upgrade();
|
||||
CHECK_NULL_VOID(formManagerDelegate);
|
||||
formManagerDelegate->OnGetRectRelativeToWindow(top, left);
|
||||
};
|
||||
renderDelegate_->SetGetRectRelativeToWindowHandler(onGetRectRelativeToWindowHandler);
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnActionEvent(const std::string& action)
|
||||
@ -683,6 +698,13 @@ void FormManagerDelegate::OnFormLinkInfoUpdate(const std::vector<std::string>& f
|
||||
}
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnGetRectRelativeToWindow(int32_t &top, int32_t &left)
|
||||
{
|
||||
if (onGetRectRelativeToWindowCallback_) {
|
||||
onGetRectRelativeToWindowCallback_(top, left);
|
||||
}
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnFormAcquired(const std::string& param)
|
||||
{
|
||||
auto result = ParseMapFromString(param);
|
||||
@ -771,6 +793,25 @@ void FormManagerDelegate::SetObscured(bool isObscured)
|
||||
formRendererDispatcher_->SetObscured(isObscured);
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId)
|
||||
{
|
||||
CHECK_NULL_VOID(formRendererDispatcher_);
|
||||
formRendererDispatcher_->OnAccessibilityChildTreeRegister(windowId, treeId, accessibilityId);
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnAccessibilityChildTreeDeregister()
|
||||
{
|
||||
CHECK_NULL_VOID(formRendererDispatcher_);
|
||||
formRendererDispatcher_->OnAccessibilityChildTreeDeregister();
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnAccessibilityDumpChildInfo(
|
||||
const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
CHECK_NULL_VOID(formRendererDispatcher_);
|
||||
formRendererDispatcher_->OnAccessibilityDumpChildInfo(params, info);
|
||||
}
|
||||
|
||||
#ifdef OHOS_STANDARD_SYSTEM
|
||||
void FormManagerDelegate::ResetForm()
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
using OnFormUpdateCallback =
|
||||
std::function<void(int64_t, const std::string&, const std::map<std::string, sptr<AppExecFwk::FormAshmem>>&)>;
|
||||
using OnFormLinkInfoUpdateCallback = std::function<void(const std::vector<std::string>&)>;
|
||||
using OnGetRectRelativeToWindowCallback = std::function<void(int32_t&, int32_t&)>;
|
||||
using OnFormErrorCallback = std::function<void(const std::string&, const std::string&)>;
|
||||
using OnFormUninstallCallback = std::function<void(int64_t)>;
|
||||
using OnFormSurfaceNodeCallback = std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&, bool, bool)>;
|
||||
@ -97,6 +98,7 @@ public:
|
||||
void AddFormSurfaceChangeCallback(OnFormSurfaceChangeCallback&& callback);
|
||||
void AddFormSurfaceDetachCallback(OnFormSurfaceDetachCallback&& callback);
|
||||
void AddFormLinkInfoUpdateCallback(OnFormLinkInfoUpdateCallback&& callback);
|
||||
void AddGetRectRelativeToWindowCallback(OnGetRectRelativeToWindowCallback && callback);
|
||||
void AddActionEventHandle(const ActionEventHandle& callback);
|
||||
void AddUnTrustFormCallback(const UnTrustFormCallback& callback);
|
||||
void AddSnapshotCallback(SnapshotCallback&& callback);
|
||||
@ -109,8 +111,12 @@ public:
|
||||
void RegisterRenderDelegateEvent();
|
||||
void OnFormError(const std::string& code, const std::string& msg);
|
||||
void OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos);
|
||||
void OnGetRectRelativeToWindow(int32_t &top, int32_t &left);
|
||||
void ReleaseRenderer();
|
||||
void SetObscured(bool isObscured);
|
||||
void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId);
|
||||
void OnAccessibilityChildTreeDeregister();
|
||||
void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info);
|
||||
#ifdef OHOS_STANDARD_SYSTEM
|
||||
void ProcessFormUpdate(const AppExecFwk::FormJsInfo& formJsInfo);
|
||||
void ProcessFormUninstall(const int64_t formId);
|
||||
@ -149,6 +155,7 @@ private:
|
||||
OnFormAcquiredCallback onFormAcquiredCallback_;
|
||||
OnFormUpdateCallback onFormUpdateCallback_;
|
||||
OnFormLinkInfoUpdateCallback onFormLinkInfoUpdateCallback_;
|
||||
OnGetRectRelativeToWindowCallback onGetRectRelativeToWindowCallback_;
|
||||
OnFormErrorCallback onFormErrorCallback_;
|
||||
OnFormUninstallCallback onFormUninstallCallback_;
|
||||
OnFormSurfaceNodeCallback onFormSurfaceNodeCallback_;
|
||||
|
@ -73,6 +73,76 @@ std::shared_ptr<MMI::PointerEvent> ConvertPointerEvent(const OffsetF offsetF, co
|
||||
pointerEvent->SetPointerId(point.id);
|
||||
return pointerEvent;
|
||||
}
|
||||
|
||||
class FormAccessibilityChildTreeCallback : public AccessibilityChildTreeCallback {
|
||||
public:
|
||||
explicit FormAccessibilityChildTreeCallback(const WeakPtr<FormNode> &weakFormNode)
|
||||
: AccessibilityChildTreeCallback(), weakFormNode_(weakFormNode)
|
||||
{}
|
||||
|
||||
~FormAccessibilityChildTreeCallback() override = default;
|
||||
|
||||
bool OnRegister(uint32_t windowId, int32_t treeId) override
|
||||
{
|
||||
auto formNode = weakFormNode_.Upgrade();
|
||||
if (formNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (isReg_) {
|
||||
return true;
|
||||
}
|
||||
formNode->OnAccessibilityChildTreeRegister(windowId, treeId);
|
||||
isReg_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnDeregister() override
|
||||
{
|
||||
auto formNode = weakFormNode_.Upgrade();
|
||||
if (formNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (!isReg_) {
|
||||
return true;
|
||||
}
|
||||
formNode->OnAccessibilityChildTreeDeregister();
|
||||
isReg_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnSetChildTree(int32_t childWindowId, int32_t childTreeId) override
|
||||
{
|
||||
auto formNode = weakFormNode_.Upgrade();
|
||||
if (formNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
formNode->OnSetAccessibilityChildTree(childWindowId, childTreeId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override
|
||||
{
|
||||
auto formNode = weakFormNode_.Upgrade();
|
||||
if (formNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
formNode->OnAccessibilityDumpChildInfo(params, info);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool isReg_ = false;
|
||||
WeakPtr<FormNode> weakFormNode_;
|
||||
};
|
||||
}
|
||||
|
||||
FormNode::~FormNode()
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto accessibilityManager = pipeline->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityManager->DeregisterAccessibilityChildTreeCallback(GetAccessibilityId());
|
||||
}
|
||||
|
||||
HitTestResult FormNode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
|
||||
@ -163,6 +233,7 @@ RefPtr<FormNode> FormNode::GetOrCreateFormNode(
|
||||
auto pattern = patternCreator ? patternCreator() : AceType::MakeRefPtr<Pattern>();
|
||||
formNode = AceType::MakeRefPtr<FormNode>(tag, nodeId, pattern, false);
|
||||
formNode->InitializePatternAndContext();
|
||||
formNode->InitializeFormAccessibility();
|
||||
ElementRegister::GetInstance()->AddUINode(formNode);
|
||||
return formNode;
|
||||
}
|
||||
@ -173,4 +244,63 @@ void FormNode::OnDetachFromMainTree(bool recursive)
|
||||
eventHub->FireOnCache();
|
||||
FrameNode::OnDetachFromMainTree(recursive);
|
||||
}
|
||||
|
||||
void FormNode::InitializeFormAccessibility()
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto accessibilityManager = pipeline->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
accessibilityChildTreeCallback_ = std::make_shared<FormAccessibilityChildTreeCallback>(WeakClaim(this));
|
||||
accessibilityManager->RegisterAccessibilityChildTreeCallback(GetAccessibilityId(), accessibilityChildTreeCallback_);
|
||||
|
||||
}
|
||||
|
||||
void FormNode::NotifyAccessibilityChildTreeRegister()
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto accessibilityManager = pipeline->GetAccessibilityManager();
|
||||
CHECK_NULL_VOID(accessibilityManager);
|
||||
if (accessibilityManager->IsRegister()) {
|
||||
accessibilityChildTreeCallback_->OnRegister(pipeline->GetWindowId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void FormNode::OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId)
|
||||
{
|
||||
auto accessibilityId = GetAccessibilityId();
|
||||
auto pattern = GetPattern<FormPattern>();
|
||||
if (pattern == nullptr) {
|
||||
TAG_LOGE(AceLogTag::ACE_FORM, "pattern is null");
|
||||
return;
|
||||
}
|
||||
pattern->OnAccessibilityChildTreeRegister(windowId, treeId, accessibilityId);
|
||||
}
|
||||
|
||||
void FormNode::OnAccessibilityChildTreeDeregister()
|
||||
{
|
||||
auto pattern = GetPattern<FormPattern>();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->OnAccessibilityChildTreeDeregister();
|
||||
}
|
||||
|
||||
void FormNode::OnSetAccessibilityChildTree(int32_t childWindowId, int32_t childTreeId)
|
||||
{
|
||||
auto accessibilityProperty = GetAccessibilityProperty<AccessibilityProperty>();
|
||||
if (accessibilityProperty != nullptr) {
|
||||
accessibilityProperty->SetChildWindowId(childWindowId);
|
||||
accessibilityProperty->SetChildTreeId(childTreeId);
|
||||
}
|
||||
}
|
||||
|
||||
void FormNode::OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
auto pattern = GetPattern<FormPattern>();
|
||||
if (pattern == nullptr) {
|
||||
TAG_LOGE(AceLogTag::ACE_FORM, "pattern is null");
|
||||
return;
|
||||
}
|
||||
pattern->OnAccessibilityDumpChildInfo(params, info);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
FormNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot = false)
|
||||
: FrameNode(tag, nodeId, pattern, isRoot)
|
||||
{}
|
||||
~FormNode() override = default;
|
||||
~FormNode() override;
|
||||
|
||||
HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
|
||||
TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, bool isDispatch = false) override;
|
||||
@ -44,6 +44,18 @@ public:
|
||||
|
||||
OffsetF GetFormOffset() const;
|
||||
|
||||
void InitializeFormAccessibility();
|
||||
|
||||
void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId);
|
||||
|
||||
void OnAccessibilityChildTreeDeregister();
|
||||
|
||||
void OnSetAccessibilityChildTree(int32_t childWindowId, int32_t childTreeId);
|
||||
|
||||
void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info);
|
||||
|
||||
void NotifyAccessibilityChildTreeRegister();
|
||||
|
||||
int32_t GetImageId()
|
||||
{
|
||||
if (!imageId_.has_value()) {
|
||||
@ -54,7 +66,8 @@ public:
|
||||
|
||||
private:
|
||||
std::optional<int32_t> imageId_;
|
||||
std::shared_ptr<AccessibilityChildTreeCallback> accessibilityChildTreeCallback_;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_NODE_H
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_NODE_H
|
||||
|
@ -319,6 +319,36 @@ void FormPattern::HandleOnSnapshot(std::shared_ptr<Media::PixelMap> pixelMap)
|
||||
needSnapshotAgain_ = false;
|
||||
}
|
||||
|
||||
void FormPattern::OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_FORM, "call, treeId: %{public}d, id: %{public}" PRId64, treeId, accessibilityId);
|
||||
if (formManagerBridge_ == nullptr) {
|
||||
TAG_LOGE(AceLogTag::ACE_FORM, "formManagerBridge_ is null");
|
||||
return;
|
||||
}
|
||||
formManagerBridge_->OnAccessibilityChildTreeRegister(windowId, treeId, accessibilityId);
|
||||
}
|
||||
|
||||
void FormPattern::OnAccessibilityChildTreeDeregister()
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_FORM, "call.");
|
||||
if (formManagerBridge_ == nullptr) {
|
||||
TAG_LOGE(AceLogTag::ACE_FORM, "formManagerBridge_ is null");
|
||||
return;
|
||||
}
|
||||
formManagerBridge_->OnAccessibilityChildTreeDeregister();
|
||||
}
|
||||
|
||||
void FormPattern::OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
TAG_LOGD(AceLogTag::ACE_FORM, "call.");
|
||||
if (formManagerBridge_ == nullptr) {
|
||||
TAG_LOGE(AceLogTag::ACE_FORM, "formManagerBridge_ is null");
|
||||
return;
|
||||
}
|
||||
formManagerBridge_->OnAccessibilityDumpChildInfo(params, info);
|
||||
}
|
||||
|
||||
void FormPattern::UpdateStaticCard()
|
||||
{
|
||||
// 1. Use imageNode to display pixelMap
|
||||
@ -1030,6 +1060,25 @@ void FormPattern::InitFormManagerDelegate()
|
||||
CHECK_NULL_VOID(formPattern);
|
||||
formPattern->SetFormLinkInfos(infos);
|
||||
});
|
||||
|
||||
formManagerBridge_->AddGetRectRelativeToWindowCallback(
|
||||
[weak = WeakClaim(this), instanceID](int32_t &top, int32_t &left) {
|
||||
ContainerScope scope(instanceID);
|
||||
auto formPattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(formPattern);
|
||||
formPattern->GetRectRelativeToWindow(top, left);
|
||||
});
|
||||
}
|
||||
|
||||
void FormPattern::GetRectRelativeToWindow(int32_t &top, int32_t &left)
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto rect = host->GetTransformRectRelativeToWindow();
|
||||
top = rect.Top();
|
||||
left = rect.Left();
|
||||
TAG_LOGD(AceLogTag::ACE_ACCESSIBILITY, "elementId: %{public}" PRId64 ", top: %{public}d, left: %{public}d",
|
||||
host->GetAccessibilityId(), top, left);
|
||||
}
|
||||
|
||||
void FormPattern::ProcDeleteImageNode(bool isRecover)
|
||||
@ -1098,6 +1147,10 @@ void FormPattern::FireFormSurfaceNodeCallback(
|
||||
parent->RebuildRenderContextTree();
|
||||
renderContext->RequestNextFrame();
|
||||
OnLoadEvent();
|
||||
|
||||
auto formNode = DynamicCast<FormNode>(host);
|
||||
CHECK_NULL_VOID(formNode);
|
||||
formNode->NotifyAccessibilityChildTreeRegister();
|
||||
}
|
||||
|
||||
void FormPattern::DelayDeleteImageNode()
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
formLinkInfos_ = infos;
|
||||
}
|
||||
|
||||
void GetRectRelativeToWindow(int32_t &top, int32_t &left);
|
||||
|
||||
bool IsJsCard() const
|
||||
{
|
||||
return isJsCard_;
|
||||
@ -97,6 +99,12 @@ public:
|
||||
isFormObscured_ = isObscured;
|
||||
}
|
||||
|
||||
void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId);
|
||||
|
||||
void OnAccessibilityChildTreeDeregister();
|
||||
|
||||
void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info);
|
||||
|
||||
private:
|
||||
void OnAttachToFrameNode() override;
|
||||
bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
|
||||
|
@ -379,6 +379,16 @@ public:
|
||||
accessibilityGroup_ = accessibilityGroup;
|
||||
}
|
||||
|
||||
void SetChildTreeId(int32_t childTreeId)
|
||||
{
|
||||
childTreeId_ = childTreeId;
|
||||
}
|
||||
|
||||
void SetChildWindowId(int32_t childWindowId)
|
||||
{
|
||||
childWindowId_ = childWindowId;
|
||||
}
|
||||
|
||||
void SetAccessibilityText(const std::string& text)
|
||||
{
|
||||
accessibilityText_ = text;
|
||||
@ -399,6 +409,16 @@ public:
|
||||
return accessibilityGroup_;
|
||||
}
|
||||
|
||||
int32_t GetChildTreeId() const
|
||||
{
|
||||
return childTreeId_;
|
||||
}
|
||||
|
||||
int32_t GetChildWindowId() const
|
||||
{
|
||||
return childWindowId_;
|
||||
}
|
||||
|
||||
void SaveAccessibilityVirtualNode(const RefPtr<UINode>& node)
|
||||
{
|
||||
accessibilityVirtualNode_ = node;
|
||||
@ -552,6 +572,8 @@ protected:
|
||||
ActionSetCursorIndexImpl actionSetCursorIndexImpl_;
|
||||
ActionGetCursorIndexImpl actionGetCursorIndexImpl_;
|
||||
bool accessibilityGroup_ = false;
|
||||
int32_t childTreeId_ = -1;
|
||||
int32_t childWindowId_ = 0;
|
||||
RefPtr<UINode> accessibilityVirtualNode_;
|
||||
std::optional<std::string> accessibilityText_;
|
||||
std::optional<std::string> accessibilityDescription_;
|
||||
|
@ -192,6 +192,11 @@ public:
|
||||
virtual void SetActionEventHandler(std::function<void(const std::string&)>&& actionCallback) {};
|
||||
virtual void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) {};
|
||||
virtual void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& callback) {};
|
||||
virtual void RegisterAccessibilityChildTree(
|
||||
uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId) {};
|
||||
virtual void SetAccessibilityGetParentRectHandler(std::function<void(int32_t&, int32_t&)>&& callback) {};
|
||||
virtual void DeregisterAccessibilityChildTree() {};
|
||||
virtual void AccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) {};
|
||||
|
||||
|
||||
// for distribute UI source
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
void AttachForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
|
||||
void RecycleForm(std::string& statusData);
|
||||
void RecoverForm(const std::string& statusData);
|
||||
void GetRectRelativeToWindow(int32_t &top, int32_t &left) const;
|
||||
|
||||
private:
|
||||
void InitUIContent(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
|
||||
int32_t OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) override;
|
||||
|
||||
int32_t OnGetRectRelativeToWindow(int32_t &top, int32_t &left) override;
|
||||
|
||||
void SetSurfaceCreateEventHandler(std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&,
|
||||
const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>&& listener);
|
||||
void SetActionEventHandler(std::function<void(const std::string&)>&& listener);
|
||||
@ -68,6 +70,7 @@ public:
|
||||
void SetSurfaceChangeEventHandler(std::function<void(float width, float height, float borderWidth)>&& listener);
|
||||
void SetSurfaceDetachEventHandler(std::function<void()>&& listener);
|
||||
void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& listener);
|
||||
void SetGetRectRelativeToWindowHandler(std::function<void(int32_t&, int32_t&)>&& listener);
|
||||
|
||||
private:
|
||||
std::function<void(
|
||||
@ -78,6 +81,7 @@ private:
|
||||
std::function<void(float width, float height, float borderWidth)> surfaceChangeEventHandler_;
|
||||
std::function<void()> surfaceDetachEventHandler_;
|
||||
std::function<void(const std::vector<std::string>&)> formLinkInfoUpdateHandler_;
|
||||
std::function<void(int32_t&, int32_t&)> getRectRelativeToWindowHandler_;
|
||||
};
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -92,6 +92,12 @@ public:
|
||||
*/
|
||||
virtual int32_t OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) = 0;
|
||||
|
||||
/**
|
||||
* @brief OnGetRectRelativeToWindow.
|
||||
* @param rectF
|
||||
*/
|
||||
virtual int32_t OnGetRectRelativeToWindow(int32_t &top, int32_t &left) = 0;
|
||||
|
||||
enum Message : uint32_t {
|
||||
ON_SURFACE_CREATE = 1,
|
||||
ON_SURFACE_REUSE,
|
||||
@ -101,6 +107,7 @@ public:
|
||||
ON_SURFACE_CHANGE,
|
||||
ON_FORM_LINK_INFO_UPDATE,
|
||||
ON_FORMSURFACE_DETACH,
|
||||
ON_GET_RECT_RELATIVE_TO_WINDOW
|
||||
};
|
||||
};
|
||||
} // namespace Ace
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
|
||||
int32_t OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) override;
|
||||
|
||||
int32_t OnGetRectRelativeToWindow(int32_t &top, int32_t &left) override;
|
||||
|
||||
private:
|
||||
static bool WriteInterfaceToken(MessageParcel& data);
|
||||
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
int32_t HandleOnSurfaceChange(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t HandleOnSurfaceDetach(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t HandleOnFormLinkInfoUpdate(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t HandleOnGetRectRelativeToWindow(MessageParcel& data, MessageParcel& reply);
|
||||
|
||||
using FormRendererDelegateFunc = int32_t (FormRendererDelegateStub::*)(MessageParcel& data, MessageParcel& reply);
|
||||
std::map<uint32_t, FormRendererDelegateFunc> memberFuncMap_;
|
||||
|
@ -54,6 +54,9 @@ public:
|
||||
|
||||
void DispatchSurfaceChangeEvent(float width, float height, float borderWidth = 0.0) override;
|
||||
void SetObscured(bool isObscured) override;
|
||||
void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) override;
|
||||
void OnAccessibilityChildTreeDeregister() override;
|
||||
void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
private:
|
||||
std::weak_ptr<UIContent> uiContent_;
|
||||
std::weak_ptr<FormRenderer> formRenderer_;
|
||||
|
@ -52,11 +52,19 @@ public:
|
||||
virtual void DispatchSurfaceChangeEvent(float width, float height, float borderWidth = 0.0) = 0;
|
||||
virtual void SetObscured(bool isObscured) = 0;
|
||||
|
||||
virtual void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) = 0;
|
||||
virtual void OnAccessibilityChildTreeDeregister() = 0;
|
||||
virtual void OnAccessibilityDumpChildInfo(
|
||||
const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
|
||||
|
||||
enum Message : uint32_t {
|
||||
DISPATCH_POINTER_EVENT = 1,
|
||||
SET_ALLOW_UPDATE,
|
||||
DISPATCH_SURFACE_CHANGE_EVENT,
|
||||
SET_OBSCURED,
|
||||
ACCESSIBILITY_CHILD_TREE_REGISTER,
|
||||
ACCESSIBILITY_CHILD_TREE_DEREGISTER,
|
||||
ACCESSIBILITY_DUMP_CHILD_INFO,
|
||||
};
|
||||
};
|
||||
} // namespace Ace
|
||||
|
@ -41,6 +41,10 @@ public:
|
||||
void DispatchSurfaceChangeEvent(float width, float height, float borderWidth = 0.0) override;
|
||||
|
||||
void SetObscured(bool isObscured) override;
|
||||
void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) override;
|
||||
void OnAccessibilityChildTreeDeregister() override;
|
||||
void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
int32_t GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
|
||||
|
@ -48,6 +48,9 @@ private:
|
||||
int32_t HandleSetAllowUpdate(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDispatchSurfaceChangeEvent(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleSetObscured(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnAccessibilityChildTreeRegister(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnAccessibilityChildTreeDeregister(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnAccessibilityDumpChildInfo(MessageParcel &data, MessageParcel &reply);
|
||||
using FormRendererDispatcherFunc =
|
||||
int32_t (FormRendererDispatcherStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, FormRendererDispatcherFunc> memberFuncMap_;
|
||||
|
@ -470,6 +470,15 @@ void FormRenderer::AttachUIContent(const OHOS::AAFwk::Want& want, const OHOS::Ap
|
||||
uiContent_->Foreground();
|
||||
}
|
||||
|
||||
void FormRenderer::GetRectRelativeToWindow(int32_t &top, int32_t &left) const
|
||||
{
|
||||
if (!formRendererDelegate_) {
|
||||
HILOG_ERROR("form renderer delegate is null!");
|
||||
return;
|
||||
}
|
||||
formRendererDelegate_->OnGetRectRelativeToWindow(top, left);
|
||||
}
|
||||
|
||||
void FormRenderer::RecycleForm(std::string& statusData)
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
|
@ -98,6 +98,17 @@ int32_t FormRendererDelegateImpl::OnFormLinkInfoUpdate(const std::vector<std::st
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t FormRendererDelegateImpl::OnGetRectRelativeToWindow(int32_t &top, int32_t &left)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
if (!getRectRelativeToWindowHandler_) {
|
||||
HILOG_ERROR("getRectRelativeToWindowHandler_ is null");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
getRectRelativeToWindowHandler_(top, left);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void FormRendererDelegateImpl::SetSurfaceCreateEventHandler(
|
||||
std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&, const OHOS::AppExecFwk::FormJsInfo&,
|
||||
const AAFwk::Want&)>&& listener)
|
||||
@ -132,5 +143,10 @@ void FormRendererDelegateImpl::SetFormLinkInfoUpdateHandler(
|
||||
{
|
||||
formLinkInfoUpdateHandler_ = std::move(listener);
|
||||
}
|
||||
|
||||
void FormRendererDelegateImpl::SetGetRectRelativeToWindowHandler(std::function<void(int32_t&, int32_t&)>&& listener)
|
||||
{
|
||||
getRectRelativeToWindowHandler_ = std::move(listener);
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -269,6 +269,33 @@ int32_t FormRendererDelegateProxy::OnFormLinkInfoUpdate(const std::vector<std::s
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t FormRendererDelegateProxy::OnGetRectRelativeToWindow(int32_t &top, int32_t &left)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("failed to write interface token");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IFormRendererDelegate::Message::ON_GET_RECT_RELATIVE_TO_WINDOW), data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("failed to SendRequest: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
int32_t errCode = reply.ReadInt32();
|
||||
if (errCode != ERR_OK) {
|
||||
HILOG_ERROR("return errCode: %{public}d", errCode);
|
||||
return errCode;
|
||||
}
|
||||
reply.ReadInt32(top);
|
||||
reply.ReadInt32(left);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
bool FormRendererDelegateProxy::WriteInterfaceToken(MessageParcel& data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(FormRendererDelegateProxy::GetDescriptor())) {
|
||||
|
@ -39,6 +39,8 @@ FormRendererDelegateStub::FormRendererDelegateStub()
|
||||
&FormRendererDelegateStub::HandleOnFormLinkInfoUpdate;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDelegate::Message::ON_FORMSURFACE_DETACH)] =
|
||||
&FormRendererDelegateStub::HandleOnSurfaceDetach;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDelegate::Message::ON_GET_RECT_RELATIVE_TO_WINDOW)] =
|
||||
&FormRendererDelegateStub::HandleOnGetRectRelativeToWindow;
|
||||
}
|
||||
|
||||
FormRendererDelegateStub::~FormRendererDelegateStub()
|
||||
@ -197,5 +199,16 @@ int32_t FormRendererDelegateStub::HandleOnFormLinkInfoUpdate(MessageParcel& data
|
||||
reply.WriteInt32(errCode);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t FormRendererDelegateStub::HandleOnGetRectRelativeToWindow(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
int32_t top = 0;
|
||||
int32_t left = 0;
|
||||
int32_t errCode = OnGetRectRelativeToWindow(top, left);
|
||||
reply.WriteInt32(errCode);
|
||||
reply.WriteInt32(top);
|
||||
reply.WriteInt32(left);
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -140,5 +140,70 @@ void FormRendererDispatcherImpl::SetObscured(bool isObscured)
|
||||
uiContent->ChangeSensitiveNodes(isObscured);
|
||||
});
|
||||
}
|
||||
|
||||
void FormRendererDispatcherImpl::OnAccessibilityChildTreeRegister(
|
||||
uint32_t windowId, int32_t treeId, int64_t accessibilityId)
|
||||
{
|
||||
auto handler = eventHandler_.lock();
|
||||
if (!handler) {
|
||||
HILOG_ERROR("eventHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
handler->PostTask([content = uiContent_, formRenderer = formRenderer_, windowId, treeId, accessibilityId]() {
|
||||
auto uiContent = content.lock();
|
||||
if (!uiContent) {
|
||||
HILOG_ERROR("uiContent is nullptr");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("OnAccessibilityChildTreeRegister: %{public}d %{public}" PRId64, treeId, accessibilityId);
|
||||
uiContent->RegisterAccessibilityChildTree(windowId, treeId, accessibilityId);
|
||||
uiContent->SetAccessibilityGetParentRectHandler([formRenderer](int32_t &top, int32_t &left) {
|
||||
auto formRendererPtr = formRenderer.lock();
|
||||
if (!formRendererPtr) {
|
||||
HILOG_ERROR("formRenderer is nullptr");
|
||||
return;
|
||||
}
|
||||
formRendererPtr->GetRectRelativeToWindow(top, left);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void FormRendererDispatcherImpl::OnAccessibilityChildTreeDeregister()
|
||||
{
|
||||
auto handler = eventHandler_.lock();
|
||||
if (!handler) {
|
||||
HILOG_ERROR("eventHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
handler->PostTask([content = uiContent_]() {
|
||||
auto uiContent = content.lock();
|
||||
if (!uiContent) {
|
||||
HILOG_ERROR("uiContent is nullptr");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("OnAccessibilityChildTreeDeregister");
|
||||
uiContent->DeregisterAccessibilityChildTree();
|
||||
});
|
||||
}
|
||||
|
||||
void FormRendererDispatcherImpl::OnAccessibilityDumpChildInfo(
|
||||
const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
auto handler = eventHandler_.lock();
|
||||
if (!handler) {
|
||||
HILOG_ERROR("eventHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
handler->PostSyncTask([content = uiContent_, params, &info]() {
|
||||
auto uiContent = content.lock();
|
||||
if (!uiContent) {
|
||||
HILOG_ERROR("uiContent is nullptr");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("OnAccessibilityDumpChildInfo");
|
||||
uiContent->AccessibilityDumpChildInfo(params, info);
|
||||
});
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -151,5 +151,81 @@ void FormRendererDispatcherProxy::SetObscured(bool isObscured)
|
||||
HILOG_ERROR("failed to SendRequest: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void FormRendererDispatcherProxy::OnAccessibilityChildTreeRegister(
|
||||
uint32_t windowId, int32_t treeId, int64_t accessibilityId)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("failed to write interface token");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint32(windowId)) {
|
||||
HILOG_ERROR("write windowId fail, action error");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(treeId)) {
|
||||
HILOG_ERROR("write treeId fail, action error");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt64(accessibilityId)) {
|
||||
HILOG_ERROR("write accessibilityId fail, action error");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_CHILD_TREE_REGISTER),
|
||||
data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("failed to SendRequest: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void FormRendererDispatcherProxy::OnAccessibilityChildTreeDeregister()
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("failed to write interface token");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_CHILD_TREE_DEREGISTER),
|
||||
data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("failed to SendRequest: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void FormRendererDispatcherProxy::OnAccessibilityDumpChildInfo(
|
||||
const std::vector<std::string>& params, std::vector<std::string>& info)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("failed to write interface token");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteStringVector(params)) {
|
||||
HILOG_ERROR("failed to write params");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = Remote()->SendRequest(
|
||||
static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_DUMP_CHILD_INFO),
|
||||
data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("failed to SendRequest: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
if (!reply.ReadStringVector(&info)) {
|
||||
HILOG_ERROR("%{public}s, Read reply info failed.", __func__);
|
||||
}
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
@ -31,6 +31,12 @@ FormRendererDispatcherStub::FormRendererDispatcherStub()
|
||||
&FormRendererDispatcherStub::HandleDispatchSurfaceChangeEvent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDispatcher::Message::SET_OBSCURED)] =
|
||||
&FormRendererDispatcherStub::HandleSetObscured;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_CHILD_TREE_REGISTER)] =
|
||||
&FormRendererDispatcherStub::HandleOnAccessibilityChildTreeRegister;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_CHILD_TREE_DEREGISTER)] =
|
||||
&FormRendererDispatcherStub::HandleOnAccessibilityChildTreeDeregister;
|
||||
memberFuncMap_[static_cast<uint32_t>(IFormRendererDispatcher::Message::ACCESSIBILITY_DUMP_CHILD_INFO)] =
|
||||
&FormRendererDispatcherStub::HandleOnAccessibilityDumpChildInfo;
|
||||
}
|
||||
|
||||
FormRendererDispatcherStub::~FormRendererDispatcherStub()
|
||||
@ -106,5 +112,35 @@ int32_t FormRendererDispatcherStub::HandleSetObscured(MessageParcel &data, Messa
|
||||
reply.WriteInt32(ERR_OK);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t FormRendererDispatcherStub::HandleOnAccessibilityChildTreeRegister(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint32_t windowId = data.ReadUint32();
|
||||
int32_t treeId = data.ReadInt32();
|
||||
int64_t accessibilityId = data.ReadInt64();
|
||||
OnAccessibilityChildTreeRegister(windowId, treeId, accessibilityId);
|
||||
reply.WriteInt32(ERR_OK);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t FormRendererDispatcherStub::HandleOnAccessibilityChildTreeDeregister(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
OnAccessibilityChildTreeDeregister();
|
||||
reply.WriteInt32(ERR_OK);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t FormRendererDispatcherStub::HandleOnAccessibilityDumpChildInfo(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
if (!data.ReadStringVector(¶ms)) {
|
||||
HILOG_ERROR("%{public}s, Read params failed.", __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::vector<std::string> info;
|
||||
OnAccessibilityDumpChildInfo(params, info);
|
||||
reply.WriteStringVector(info);
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
@ -80,6 +80,8 @@ void FormManagerDelegate::AddFormSurfaceDetachCallback(OnFormSurfaceDetachCallba
|
||||
|
||||
void FormManagerDelegate::AddFormLinkInfoUpdateCallback(OnFormLinkInfoUpdateCallback&& callback) {}
|
||||
|
||||
void FormManagerDelegate::AddGetRectRelativeToWindowCallback(OnGetRectRelativeToWindowCallback&& callback) {}
|
||||
|
||||
void FormManagerDelegate::AddSnapshotCallback(SnapshotCallback&& callback) {}
|
||||
|
||||
void FormManagerDelegate::ResetForm() {}
|
||||
@ -90,8 +92,16 @@ void FormManagerDelegate::ReleaseRenderer() {}
|
||||
|
||||
void FormManagerDelegate::OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) {}
|
||||
|
||||
void FormManagerDelegate::OnGetRectRelativeToWindow(int32_t &top, int32_t &left) {}
|
||||
|
||||
void FormManagerDelegate::SetObscured(bool isObscured) {}
|
||||
|
||||
void FormManagerDelegate::OnAccessibilityChildTreeRegister(
|
||||
uint32_t windowId, int32_t treeId, int64_t accessibilityId) {}
|
||||
void FormManagerDelegate::OnAccessibilityChildTreeDeregister() {}
|
||||
void FormManagerDelegate::OnAccessibilityDumpChildInfo(
|
||||
const std::vector<std::string>& params, std::vector<std::string>& info) {}
|
||||
|
||||
#if OHOS_STANDARD_SYSTEM
|
||||
bool FormManagerDelegate::GetFormInfo(const std::string& bundleName, const std::string& moduleName,
|
||||
const std::string& cardName, AppExecFwk::FormInfo& formInfo)
|
||||
|
Loading…
Reference in New Issue
Block a user