• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "core/components_ng/pattern/web/web_accessibility_child_tree_callback.h"
17 
18 #include "base/log/log_wrapper.h"
19 #include "base/utils/utils.h"
20 #include "core/components/common/layout/constants.h"
21 #include "core/components_ng/pattern/web/web_pattern.h"
22 
23 namespace OHOS::Ace::NG {
OnRegister(uint32_t windowId,int32_t treeId)24 bool WebAccessibilityChildTreeCallback::OnRegister(uint32_t windowId, int32_t treeId)
25 {
26     auto pattern = weakPattern_.Upgrade();
27     if (pattern == nullptr) {
28         return false;
29     }
30     if (isReg_) {
31         return true;
32     }
33     if (!pattern->OnAccessibilityChildTreeRegister()) {
34         return false;
35     }
36     pattern->SetAccessibilityState(true, isDelayed_);
37     isDelayed_ = false;
38     isReg_ = true;
39     return true;
40 }
41 
OnDeregister()42 bool WebAccessibilityChildTreeCallback::OnDeregister()
43 {
44     auto pattern = weakPattern_.Upgrade();
45     if (pattern == nullptr) {
46         return false;
47     }
48     if (!isReg_) {
49         return true;
50     }
51     if (!pattern->OnAccessibilityChildTreeDeregister()) {
52         return false;
53     }
54     pattern->SetAccessibilityState(false);
55     isReg_ = false;
56     return true;
57 }
58 
OnSetChildTree(int32_t childWindowId,int32_t childTreeId)59 bool WebAccessibilityChildTreeCallback::OnSetChildTree(int32_t childWindowId, int32_t childTreeId)
60 {
61     auto pattern = weakPattern_.Upgrade();
62     if (pattern == nullptr) {
63         return false;
64     }
65     pattern->OnSetAccessibilityChildTree(childWindowId, childTreeId);
66     return true;
67 }
68 
OnDumpChildInfo(const std::vector<std::string> & params,std::vector<std::string> & info)69 bool WebAccessibilityChildTreeCallback::OnDumpChildInfo(
70     const std::vector<std::string>& params, std::vector<std::string>& info)
71 {
72     return false;
73 }
74 
OnClearRegisterFlag()75 void WebAccessibilityChildTreeCallback::OnClearRegisterFlag()
76 {
77     auto pattern = weakPattern_.Upgrade();
78     if (pattern == nullptr) {
79         return;
80     }
81     isReg_ = false;
82 }
83 
SetIsDelayed(bool isDelayed)84 void WebAccessibilityChildTreeCallback::SetIsDelayed(bool isDelayed)
85 {
86     isDelayed_ = isDelayed;
87 }
88 } // namespace OHOS::Ace::NG
89