• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ACCESSIBILITY_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ACCESSIBILITY_PROPERTY_H
18 
19 #include <cstdint>
20 #include <string>
21 #include <unordered_set>
22 
23 #include "base/memory/ace_type.h"
24 #include "interfaces/native/native_type.h"
25 #include "core/accessibility/accessibility_utils.h"
26 #include "core/components_ng/base/inspector_filter.h"
27 #include "core/components_ng/base/ui_node.h"
28 
29 namespace OHOS::Accessibility {
30 class ExtraElementInfo;
31 }
32 
33 namespace OHOS::Ace::NG {
34 using ActionNoParam = std::function<void()>;
35 using ActionSetTextImpl = std::function<void(const std::string&)>;
36 using ActionScrollForwardImpl = ActionNoParam;
37 using ActionScrollForwardWithParamImpl = std::function<void(AccessibilityScrollType scrollType)>;;
38 using ActionScrollBackwardImpl = ActionNoParam;
39 using ActionScrollBackwardWithParamImpl = std::function<void(AccessibilityScrollType scrollType)>;;
40 using ActionSetSelectionImpl = std::function<void(int32_t start, int32_t end, bool isForward)>;
41 using ActionCopyImpl = ActionNoParam;
42 using ActionCutImpl = ActionNoParam;
43 using ActionPasteImpl = ActionNoParam;
44 using ActionSelectImpl = ActionNoParam;
45 using ActionClearSelectionImpl = ActionNoParam;
46 using ActionMoveTextImpl = std::function<void(int32_t moveUnit, bool forward)>;
47 using ActionSetCursorIndexImpl = std::function<void(int32_t index)>;
48 using ActionExecSubComponentImpl = std::function<bool(int32_t spanId)>;
49 using ActionGetCursorIndexImpl = std::function<int32_t(void)>;
50 using ActionClickImpl = ActionNoParam;
51 using ActionLongClickImpl = ActionNoParam;
52 using ActionsImpl = std::function<void((uint32_t actionType))>;
53 using GetRelatedElementInfoImpl = std::function<void(Accessibility::ExtraElementInfo& extraElementInfo)>;
54 using OnAccessibilityFocusCallbackImpl = std::function<void((bool isFocus))>;
55 
56 class FrameNode;
57 using AccessibilityHoverTestPath = std::vector<RefPtr<FrameNode>>;
58 
59 class ACE_FORCE_EXPORT AccessibilityProperty : public virtual AceType {
60     DECLARE_ACE_TYPE(AccessibilityProperty, AceType);
61 
62 public:
63     AccessibilityProperty() = default;
64 
65     ~AccessibilityProperty() override = default;
66 
67     virtual std::string GetText() const;
68 
69     virtual std::string GetGroupText(bool forceGetChildren = false) const;
70 
SetText(const std::string & text)71     virtual void SetText(const std::string& text)
72     {
73         propText_ = text;
74     }
75 
IsCheckable()76     virtual bool IsCheckable() const
77     {
78         return false;
79     }
80 
IsChecked()81     virtual bool IsChecked() const
82     {
83         return false;
84     }
85 
IsSelected()86     virtual bool IsSelected() const
87     {
88         return false;
89     }
90 
IsPassword()91     virtual bool IsPassword() const
92     {
93         return false;
94     }
95 
IsEditable()96     virtual bool IsEditable() const
97     {
98         return false;
99     }
100 
IsMultiLine()101     virtual bool IsMultiLine() const
102     {
103         return false;
104     }
105 
IsDeletable()106     virtual bool IsDeletable() const
107     {
108         return false;
109     }
110 
IsHint()111     virtual bool IsHint() const
112     {
113         return false;
114     }
115 
IsScrollable()116     virtual bool IsScrollable() const
117     {
118         return false;
119     }
120 
GetCurrentIndex()121     virtual int32_t GetCurrentIndex() const
122     {
123         return -1;
124     }
125 
GetBeginIndex()126     virtual int32_t GetBeginIndex() const
127     {
128         return -1;
129     }
130 
GetEndIndex()131     virtual int32_t GetEndIndex() const
132     {
133         return -1;
134     }
135 
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)136     virtual void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const
137     {
138         json->PutFixedAttr("scrollable", IsScrollable(), filter, FIXED_ATTR_SCROLLABLE);
139         json->PutExtAttr("accessibilityLevel", GetAccessibilityLevel().c_str(), filter);
140         json->PutExtAttr("accessibilityGroup", IsAccessibilityGroup(), filter);
141         json->PutExtAttr("accessibilityVirtualNode", HasAccessibilityVirtualNode(), filter);
142         json->PutExtAttr("accessibilityText", GetAccessibilityText().c_str(), filter);
143         json->PutExtAttr("accessibilityTextHint", GetTextType().c_str(), filter);
144         json->PutExtAttr("accessibilityDescription", GetAccessibilityDescription().c_str(), filter);
145     }
146 
FromJson(const std::unique_ptr<JsonValue> & json)147     virtual void FromJson(const std::unique_ptr<JsonValue>& json) {}
148 
HasRange()149     virtual bool HasRange() const
150     {
151         return false;
152     }
153 
HasSubComponent()154     virtual bool HasSubComponent() const
155     {
156         return false;
157     }
158 
GetSubComponentInfo(std::vector<SubComponentInfo> & subComponentInfos)159     virtual void GetSubComponentInfo(std::vector<SubComponentInfo>& subComponentInfos) const {}
160 
GetAccessibilityValue()161     virtual AccessibilityValue GetAccessibilityValue() const
162     {
163         return AccessibilityValue();
164     }
165 
SetHost(const WeakPtr<FrameNode> & host)166     void SetHost(const WeakPtr<FrameNode>& host)
167     {
168         host_ = host;
169     }
170 
GetHintText()171     virtual std::string GetHintText() const
172     {
173         return "";
174     }
175 
GetTextLengthLimit()176     virtual int32_t GetTextLengthLimit() const
177     {
178         return -1;
179     }
180 
GetCollectionInfo()181     virtual AceCollectionInfo GetCollectionInfo() const
182     {
183         return AceCollectionInfo();
184     }
185 
GetCollectionItemInfo()186     virtual AceCollectionItemInfo GetCollectionItemInfo() const
187     {
188         return AceCollectionItemInfo();
189     }
190 
GetErrorText()191     virtual std::string GetErrorText() const
192     {
193         return "";
194     }
195 
GetTextSelectionStart()196     virtual int32_t GetTextSelectionStart() const
197     {
198         return 0;
199     }
200 
GetTextSelectionEnd()201     virtual int32_t GetTextSelectionEnd() const
202     {
203         return 0;
204     }
205 
GetTextInputType()206     virtual AceTextCategory GetTextInputType() const
207     {
208         return AceTextCategory::INPUT_TYPE_DEFAULT;
209     }
210 
GetCollectionItemCounts()211     virtual int32_t GetCollectionItemCounts() const
212     {
213         return 0;
214     }
215 
GetContentInvalid()216     virtual bool GetContentInvalid() const
217     {
218         return true;
219     }
220 
221     virtual float GetScrollOffSet() const;
222 
AddSupportAction(AceAction action)223     void AddSupportAction(AceAction action)
224     {
225         supportActions_ |= (1UL << static_cast<uint32_t>(action));
226     }
227 
228     std::unordered_set<AceAction> GetSupportAction() const;
229 
ResetSupportAction()230     void ResetSupportAction()
231     {
232         supportActions_ = 0;
233         SetSpecificSupportAction();
234     };
235 
SetActionSetText(const ActionSetTextImpl & actionSetTextImpl)236     void SetActionSetText(const ActionSetTextImpl& actionSetTextImpl)
237     {
238         actionSetTextImpl_ = actionSetTextImpl;
239     }
240 
ActActionSetText(const std::string & text)241     bool ActActionSetText(const std::string& text)
242     {
243         if (actionSetTextImpl_) {
244             actionSetTextImpl_(text);
245             return true;
246         }
247         return false;
248     }
249 
SetActionSetSelection(const ActionSetSelectionImpl & actionSetSelection)250     void SetActionSetSelection(const ActionSetSelectionImpl& actionSetSelection)
251     {
252         actionSetSelectionImpl_ = actionSetSelection;
253     }
254 
255     bool ActActionSetSelection(int32_t start, int32_t end, bool isForward = false)
256     {
257         if (actionSetSelectionImpl_) {
258             actionSetSelectionImpl_(start, end, isForward);
259             return true;
260         }
261         return false;
262     }
263 
SetActionSetIndex(const ActionSetCursorIndexImpl & actionSetCursorIndexImpl)264     void SetActionSetIndex(const ActionSetCursorIndexImpl& actionSetCursorIndexImpl)
265     {
266         actionSetCursorIndexImpl_ = actionSetCursorIndexImpl;
267     }
268 
ActActionSetIndex(int32_t index)269     bool ActActionSetIndex(int32_t index)
270     {
271         if (actionSetCursorIndexImpl_) {
272             actionSetCursorIndexImpl_(index);
273             return true;
274         }
275         return false;
276     }
277 
SetActionExecSubComponent(const ActionExecSubComponentImpl & actionExecSubComponentImpl)278     void SetActionExecSubComponent(const ActionExecSubComponentImpl& actionExecSubComponentImpl)
279     {
280         actionExecSubComponentImpl_ = actionExecSubComponentImpl;
281     }
282 
ActActionExecSubComponent(int32_t spanId)283     bool ActActionExecSubComponent(int32_t spanId)
284     {
285         if (actionExecSubComponentImpl_) {
286             return actionExecSubComponentImpl_(spanId);
287         }
288         return false;
289     }
290 
SetActionGetIndex(const ActionGetCursorIndexImpl & actionGetCursorIndexImpl)291     void SetActionGetIndex(const ActionGetCursorIndexImpl& actionGetCursorIndexImpl)
292     {
293         actionGetCursorIndexImpl_ = actionGetCursorIndexImpl;
294     }
295 
ActActionGetIndex()296     int32_t ActActionGetIndex()
297     {
298         if (actionGetCursorIndexImpl_) {
299             return actionGetCursorIndexImpl_();
300         }
301         return -1;
302     }
303 
SetActionMoveText(const ActionMoveTextImpl & actionMoveText)304     void SetActionMoveText(const ActionMoveTextImpl& actionMoveText)
305     {
306         actionMoveTextImpl_ = actionMoveText;
307     }
308 
ActActionMoveText(int32_t moveUnit,bool forward)309     bool ActActionMoveText(int32_t moveUnit, bool forward)
310     {
311         if (actionMoveTextImpl_) {
312             actionMoveTextImpl_(moveUnit, forward);
313             return true;
314         }
315         return false;
316     }
317 
SetActionScrollForward(const ActionScrollForwardImpl & actionScrollForwardImpl)318     void SetActionScrollForward(const ActionScrollForwardImpl& actionScrollForwardImpl)
319     {
320         actionScrollForwardImpl_ = actionScrollForwardImpl;
321     }
322 
SetActionScrollForward(const ActionScrollForwardWithParamImpl & actionScrollForwardImpl)323     void SetActionScrollForward(const ActionScrollForwardWithParamImpl& actionScrollForwardImpl)
324     {
325         actionScrollForwardWithParamImpl_ = actionScrollForwardImpl;
326     }
327 
328     bool ActActionScrollForward(AccessibilityScrollType scrollType = AccessibilityScrollType::SCROLL_DEFAULT)
329     {
330         if (actionScrollForwardWithParamImpl_ == nullptr) {
331             scrollType = AccessibilityScrollType::SCROLL_DEFAULT;
332         }
333 
334         if ((scrollType == AccessibilityScrollType::SCROLL_DEFAULT) && (actionScrollForwardImpl_)) {
335             actionScrollForwardImpl_();
336             return true;
337         }
338 
339         if (actionScrollForwardWithParamImpl_) {
340             actionScrollForwardWithParamImpl_(scrollType);
341             return true;
342         }
343         return false;
344     }
345 
SetActionScrollBackward(const ActionScrollBackwardImpl & actionScrollBackwardImpl)346     void SetActionScrollBackward(const ActionScrollBackwardImpl& actionScrollBackwardImpl)
347     {
348         actionScrollBackwardImpl_ = actionScrollBackwardImpl;
349     }
350 
SetActionScrollBackward(const ActionScrollBackwardWithParamImpl & actionScrollBackwardImpl)351     void SetActionScrollBackward(const ActionScrollBackwardWithParamImpl& actionScrollBackwardImpl)
352     {
353         actionScrollBackwardWithParamImpl_ = actionScrollBackwardImpl;
354     }
355 
356     bool ActActionScrollBackward(AccessibilityScrollType scrollType = AccessibilityScrollType::SCROLL_DEFAULT)
357     {
358         if (actionScrollBackwardWithParamImpl_ == nullptr) {
359             scrollType = AccessibilityScrollType::SCROLL_DEFAULT;
360         }
361 
362         if ((scrollType == AccessibilityScrollType::SCROLL_DEFAULT) && (actionScrollBackwardImpl_)) {
363             actionScrollBackwardImpl_();
364             return true;
365         }
366 
367         if (actionScrollBackwardWithParamImpl_) {
368             actionScrollBackwardWithParamImpl_(scrollType);
369             return true;
370         }
371         return false;
372     }
373 
SetActionCopy(const ActionCopyImpl & actionCopyImpl)374     void SetActionCopy(const ActionCopyImpl& actionCopyImpl)
375     {
376         actionCopyImpl_ = actionCopyImpl;
377     }
378 
ActActionCopy()379     bool ActActionCopy()
380     {
381         if (ActionsDefined(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_COPY))) {
382             actionsImpl_(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_COPY));
383             return true;
384         }
385         if (actionCopyImpl_) {
386             actionCopyImpl_();
387             return true;
388         }
389         return false;
390     }
391 
SetActionCut(const ActionCutImpl & actionCutImpl)392     void SetActionCut(const ActionCutImpl& actionCutImpl)
393     {
394         actionCutImpl_ = actionCutImpl;
395     }
396 
ActActionCut()397     bool ActActionCut()
398     {
399         if (ActionsDefined(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_CUT))) {
400             actionsImpl_(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_CUT));
401             return true;
402         }
403         if (actionCutImpl_) {
404             actionCutImpl_();
405             return true;
406         }
407         return false;
408     }
409 
SetActionPaste(const ActionPasteImpl & actionPasteImpl)410     void SetActionPaste(const ActionPasteImpl& actionPasteImpl)
411     {
412         actionPasteImpl_ = actionPasteImpl;
413     }
414 
ActActionPaste()415     bool ActActionPaste()
416     {
417         if (ActionsDefined(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_PASTE))) {
418             actionsImpl_(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_PASTE));
419             return true;
420         }
421         if (actionPasteImpl_) {
422             actionPasteImpl_();
423             return true;
424         }
425         return false;
426     }
427 
SetActionLongClick(const ActionLongClickImpl & actionLongClickImpl)428     void SetActionLongClick(const ActionLongClickImpl& actionLongClickImpl)
429     {
430         actionLongClickImpl_ = actionLongClickImpl;
431     }
432 
ActActionLongClick()433     bool ActActionLongClick()
434     {
435         if (ActionsDefined(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_LONG_CLICK))) {
436             actionsImpl_(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_LONG_CLICK));
437             return true;
438         }
439         if (actionLongClickImpl_) {
440             actionLongClickImpl_();
441             return true;
442         }
443         return false;
444     }
445 
SetActionClick(const ActionClickImpl & actionClickImpl)446     void SetActionClick(const ActionClickImpl& actionClickImpl)
447     {
448         actionClickImpl_ = actionClickImpl;
449     }
450 
ActActionClick()451     bool ActActionClick()
452     {
453         if (ActionsDefined(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_CLICK))) {
454             actionsImpl_(static_cast<uint32_t>(ARKUI_ACCESSIBILITY_ACTION_CLICK));
455             return true;
456         }
457         if (actionClickImpl_) {
458             actionClickImpl_();
459             return true;
460         }
461         return false;
462     }
463 
SetActionSelect(const ActionSelectImpl & actionSelectImpl)464     void SetActionSelect(const ActionSelectImpl& actionSelectImpl)
465     {
466         actionSelectImpl_ = actionSelectImpl;
467     }
468 
ActActionSelect()469     bool ActActionSelect()
470     {
471         if (actionSelectImpl_) {
472             actionSelectImpl_();
473             return true;
474         }
475         return false;
476     }
477 
SetActionClearSelection(const ActionClearSelectionImpl & actionClearSelectionImpl)478     void SetActionClearSelection(const ActionClearSelectionImpl& actionClearSelectionImpl)
479     {
480         actionClearSelectionImpl_ = actionClearSelectionImpl;
481     }
482 
ActActionClearSelection()483     bool ActActionClearSelection()
484     {
485         if (actionClearSelectionImpl_) {
486             actionClearSelectionImpl_();
487             return true;
488         }
489         return false;
490     }
491 
SetOnAccessibilityFocusCallback(const OnAccessibilityFocusCallbackImpl & onAccessibilityFocusCallbackImpl)492     void SetOnAccessibilityFocusCallback(const OnAccessibilityFocusCallbackImpl& onAccessibilityFocusCallbackImpl)
493     {
494         onAccessibilityFocusCallbackImpl_ = onAccessibilityFocusCallbackImpl;
495     }
496 
OnAccessibilityFocusCallback(bool isFocus)497     void OnAccessibilityFocusCallback(bool isFocus)
498     {
499         if (onAccessibilityFocusCallbackImpl_) {
500             onAccessibilityFocusCallbackImpl_(isFocus);
501         }
502     }
503 
GetAccessibilityFocusState()504     bool GetAccessibilityFocusState() const
505     {
506         return isAccessibilityFocused_;
507     }
508 
SetAccessibilityFocusState(bool state)509     void SetAccessibilityFocusState(bool state)
510     {
511         isAccessibilityFocused_ = state;
512     }
513 
514     void SetAccessibilityGroup(bool accessibilityGroup);
515 
SetChildTreeId(int32_t childTreeId)516     void SetChildTreeId(int32_t childTreeId)
517     {
518         childTreeId_ = childTreeId;
519     }
520 
SetChildWindowId(int32_t childWindowId)521     void SetChildWindowId(int32_t childWindowId)
522     {
523         childWindowId_ = childWindowId;
524     }
525 
526     void SetAccessibilityText(const std::string& text);
527 
528     void SetAccessibilityTextWithEvent(const std::string& text);
529 
SetAccessibilityTextHint(const std::string & text)530     void SetAccessibilityTextHint(const std::string& text)
531     {
532         textTypeHint_ = text;
533     }
534 
535     void SetAccessibilityDescription(const std::string& accessibilityDescription);
536 
537     void SetAccessibilityDescriptionWithEvent(const std::string& accessibilityDescription);
538 
IsAccessibilityGroup()539     bool IsAccessibilityGroup() const
540     {
541         return accessibilityGroup_;
542     }
543 
GetChildTreeId()544     int32_t GetChildTreeId() const
545     {
546         return childTreeId_;
547     }
548 
GetChildWindowId()549     int32_t GetChildWindowId() const
550     {
551         return childWindowId_;
552     }
553 
554     void NotifyComponentChangeEvent(AccessibilityEventType eventType);
555 
SaveAccessibilityVirtualNode(const RefPtr<UINode> & node)556     void SaveAccessibilityVirtualNode(const RefPtr<UINode>& node)
557     {
558         accessibilityVirtualNode_ = node;
559     }
560 
GetAccessibilityVirtualNode()561     RefPtr<UINode> GetAccessibilityVirtualNode()
562     {
563         return accessibilityVirtualNode_;
564     }
565 
GetAccessibilityVirtualNodePtr()566     NG::UINode* GetAccessibilityVirtualNodePtr()
567     {
568         return Referenced::RawPtr(accessibilityVirtualNode_);
569     }
570 
HasAccessibilityVirtualNode()571     bool HasAccessibilityVirtualNode() const
572     {
573         return accessibilityVirtualNode_ != nullptr;
574     }
575 
GetAccessibilityText()576     virtual std::string GetAccessibilityText() const
577     {
578         return accessibilityText_.value_or("");
579     }
580 
GetAccessibilityDescription()581     std::string GetAccessibilityDescription() const
582     {
583         return accessibilityDescription_.value_or("");
584     }
585 
GetTextType()586     std::string GetTextType() const
587     {
588         return textTypeHint_.value_or("");
589     }
590 
591     class Level {
592     public:
593         inline static const std::string AUTO = "auto";
594         inline static const std::string YES_STR = "yes";
595         inline static const std::string NO_STR = "no";
596         inline static const std::string NO_HIDE_DESCENDANTS = "no-hide-descendants";
597     };
598 
GetAccessibilityLevel()599     virtual std::string GetAccessibilityLevel() const
600     {
601         if (!accessibilityLevel_.has_value()) {
602             return Level::AUTO;
603         }
604         return accessibilityLevel_.value();
605     }
606 
607     void SetAccessibilityLevel(const std::string& accessibilityLevel);
608 
609     struct HoverTestDebugTraceInfo {
610         std::vector<std::unique_ptr<JsonValue>> trace;
611     };
612 
613     /*
614     * Get path from root to node which hit the hoverPoint.
615     * return: path contains nodes whose border cover the hoverPoint.
616     */
617     static AccessibilityHoverTestPath HoverTest(
618         const PointF& point,
619         const RefPtr<FrameNode>& root,
620         std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo
621     );
622 
623     /*
624     * Judge whether a node can be accessibility focused.
625     * return: if node is accessibility focusable, return true.
626     * param: {node} should be not-null
627     */
628     static bool IsAccessibilityFocusable(const RefPtr<FrameNode>& node);
629 
630     /*
631     * param: {node}, {info} should be not-null
632     */
633     static bool IsAccessibilityFocusableDebug(const RefPtr<FrameNode>& node, std::unique_ptr<JsonValue>& info);
634 
635     /*
636     * Judge whether a node's tag is default accessibility focusable.
637     * return: if a node's tag is default accessibility focusable, return true.
638     * param: {tag} should be not-null
639     */
640     static bool IsAccessibilityFocusableTag(const std::string &tag);
641 
642     static bool IsTagInCrossProcessComponent(const std::string& tag);
643 
644     static bool IsTagInModalDialog(const RefPtr<FrameNode>& node);
645 
GetExtraElementInfo(Accessibility::ExtraElementInfo & extraElementInfo)646     virtual void GetExtraElementInfo(Accessibility::ExtraElementInfo& extraElementInfo) {}
647 
SetRelatedElementInfoCallback(const GetRelatedElementInfoImpl & getRelatedElementInfoImpl)648     void SetRelatedElementInfoCallback(const GetRelatedElementInfoImpl& getRelatedElementInfoImpl)
649     {
650         getRelatedElementInfoImpl_ = getRelatedElementInfoImpl;
651     }
652 
GetAllExtraElementInfo(Accessibility::ExtraElementInfo & extraElementInfo)653     void GetAllExtraElementInfo(Accessibility::ExtraElementInfo& extraElementInfo)
654     {
655         if (getRelatedElementInfoImpl_) {
656             getRelatedElementInfoImpl_(extraElementInfo);
657         }
658         GetExtraElementInfo(extraElementInfo);
659     }
660 
661     void SetAccessibilityActions(uint32_t actions);
662     void ResetAccessibilityActions();
663     bool HasAccessibilityActions();
664     uint32_t GetAccessibilityActions() const;
665 
666     void SetAccessibilityRole(const std::string& role);
667     void ResetAccessibilityRole();
668     bool HasAccessibilityRole();
669     std::string GetAccessibilityRole() const;
670 
671     void SetActions(const ActionsImpl& actionsImpl);
672     bool ActionsDefined(uint32_t action);
673 
674     void SetUserDisabled(const bool& isDisabled);
675     bool HasUserDisabled();
676     bool IsUserDisabled();
677 
678     void SetUserSelected(const bool& isSelected);
679     bool HasUserSelected();
680     bool IsUserSelected();
681     void ResetUserSelected();
682 
683     void SetUserCheckedType(const int32_t& checkedType);
684     bool HasUserCheckedType();
685     int32_t GetUserCheckedType();
686     void ResetUserCheckedType();
687 
688     void SetUserMinValue(const int32_t& minValue);
689     bool HasUserMinValue();
690     int32_t GetUserMinValue();
691 
692     void SetUserMaxValue(const int32_t& maxValue);
693     bool HasUserMaxValue();
694     int32_t GetUserMaxValue();
695 
696     void SetUserCurrentValue(const int32_t& currentValue);
697     bool HasUserCurrentValue();
698     int32_t GetUserCurrentValue();
699 
700     void SetUserTextValue(const std::string& textValue);
701     bool HasUserTextValue();
702     std::string GetUserTextValue();
703 
704     void SetUserCheckable(const bool& checkable);
705     bool HasUserCheckable();
706     bool IsUserCheckable();
707     void ResetUserCheckable();
708 
709 private:
710     // node should be not-null
711     static bool HoverTestRecursive(
712         const PointF& parentPoint,
713         const RefPtr<FrameNode>& node,
714         AccessibilityHoverTestPath& path,
715         std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
716         bool& ancestorGroupFlag
717     );
718 
719     struct RecursiveParam {
720         bool hitTarget;
721         bool ancestorGroupFlag;
722     };
723 
724     static bool ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node,
725         AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
726         RecursiveParam recursiveParam);
727 
728     static std::unique_ptr<JsonValue> CreateNodeSearchInfo(const RefPtr<FrameNode>& node, const PointF& parentPoint,
729         bool& ancestorGroupFlag);
730 
731     /*
732     * Get whether node and its children should be searched.
733     * return: first: node itself should be searched.
734     *         second: children of node should be searched.
735     * param: {node} should be not-null
736     */
737     static std::tuple<bool, bool, bool> GetSearchStrategy(const RefPtr<FrameNode>& node, bool& ancestorGroupFlag);
738 
739     void GetGroupTextRecursive(bool forceGetChildren, std::string& text) const;
740 
741     bool HasAccessibilityTextOrDescription() const;
742 
743     bool HasAction() const;
744 
745 protected:
SetSpecificSupportAction()746     virtual void SetSpecificSupportAction() {}
747     std::optional<std::string> propText_;
748     WeakPtr<FrameNode> host_;
749     uint64_t supportActions_ = 0;
750     ActionSetTextImpl actionSetTextImpl_;
751     ActionSetSelectionImpl actionSetSelectionImpl_;
752     ActionMoveTextImpl actionMoveTextImpl_;
753     ActionScrollForwardImpl actionScrollForwardImpl_;
754     ActionScrollForwardWithParamImpl actionScrollForwardWithParamImpl_;
755     ActionScrollBackwardImpl actionScrollBackwardImpl_;
756     ActionScrollBackwardWithParamImpl actionScrollBackwardWithParamImpl_;
757     ActionCopyImpl actionCopyImpl_;
758     ActionCutImpl actionCutImpl_;
759     ActionPasteImpl actionPasteImpl_;
760     ActionSelectImpl actionSelectImpl_;
761     ActionClearSelectionImpl actionClearSelectionImpl_;
762     ActionSetCursorIndexImpl actionSetCursorIndexImpl_;
763     ActionExecSubComponentImpl actionExecSubComponentImpl_;
764     ActionGetCursorIndexImpl actionGetCursorIndexImpl_;
765     ActionClickImpl actionClickImpl_;
766     ActionLongClickImpl actionLongClickImpl_;
767     ActionsImpl actionsImpl_;
768     GetRelatedElementInfoImpl getRelatedElementInfoImpl_;
769     OnAccessibilityFocusCallbackImpl onAccessibilityFocusCallbackImpl_;
770     bool isAccessibilityFocused_ = false;
771     bool accessibilityGroup_ = false;
772     int32_t childTreeId_ = -1;
773     int32_t childWindowId_ = 0;
774     RefPtr<UINode> accessibilityVirtualNode_;
775     std::optional<std::string> accessibilityText_;
776     std::optional<std::string> accessibilityDescription_;
777     std::optional<std::string> accessibilityLevel_;
778     std::optional<std::string> textTypeHint_;
779     std::optional<uint32_t> accessibilityActions_;
780     std::optional<std::string> accessibilityRole_;
781     ACE_DISALLOW_COPY_AND_MOVE(AccessibilityProperty);
782 
783     std::optional<bool> isDisabled_;
784     std::optional<bool> isSelected_;
785     std::optional<int32_t> checkedType_;
786     std::optional<bool> isUserCheckable_;
787 
788     std::optional<int32_t> minValue_;
789     std::optional<int32_t> maxValue_;
790     std::optional<int32_t> currentValue_;
791     std::optional<std::string> textValue_;
792 };
793 } // namespace OHOS::Ace::NG
794 
795 #endif
796