• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_CORE_ACCESSIBILITY_ACCESSIBILITY_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_ACCESSIBILITY_ACCESSIBILITY_NODE_H
18 
19 #include <functional>
20 #include <list>
21 #include <string>
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <vector>
25 
26 #include "base/geometry/axis.h"
27 #include "base/geometry/matrix4.h"
28 #include "base/geometry/rect.h"
29 #include "base/memory/ace_type.h"
30 #include "base/utils/macros.h"
31 #include "core/accessibility/accessibility_utils.h"
32 #include "core/event/ace_event_handler.h"
33 
34 namespace OHOS::Ace {
35 
36 struct PositionInfo {
37     double width = 0.0;
38     double height = 0.0;
39     double left = 0.0;
40     double top = 0.0;
41 };
42 
43 using ActionClickImpl = std::function<void()>;
44 using ActionLongClickImpl = std::function<void()>;
45 using ActionScrollForwardImpl = std::function<bool()>;
46 using ActionScrollBackwardImpl = std::function<bool()>;
47 using ActionFocusImpl = std::function<void()>;
48 using ActionUpdateIdsImpl = std::function<void()>;
49 using FocusChangeCallback = std::function<void(const std::string&)>;
50 using ActionAccessibilityFocusImpl = std::function<void(bool)>;
51 
52 using NodeId = int32_t;
53 // If no insertion location is specified, new child will be added to the end of children list by default.
54 constexpr int32_t DEFAULT_INDEX = -1;
55 constexpr uint64_t DEFAULT_ACTIONS = std::numeric_limits<uint64_t>::max();
56 
57 class ACE_EXPORT AccessibilityNode : public AceType {
58     DECLARE_ACE_TYPE(AccessibilityNode, AceType);
59 
60 public:
61     using ChartValue = std::unordered_map<std::string, std::vector<std::pair<std::string, double>>>;
62 
63     AccessibilityNode(NodeId nodeId, const std::string& nodeName);
64     ~AccessibilityNode() override = default;
65 
66     // node event action
67     void SetActionClickImpl(const ActionClickImpl& actionClickImpl);
68     bool ActionClick();
69     void SetActionLongClickImpl(const ActionLongClickImpl& actionLongClickImpl);
70     bool ActionLongClick();
71     void SetActionScrollForward(const ActionScrollForwardImpl& actionScrollForwardImpl);
72     bool ActionScrollForward();
73     void SetActionScrollBackward(const ActionScrollBackwardImpl& actionScrollBackwardImpl);
74     bool ActionScrollBackward();
75     void SetActionFocusImpl(const ActionFocusImpl& actionFocusImpl);
76     bool ActionFocus();
77     void SetActionUpdateIdsImpl(const ActionUpdateIdsImpl& actionUpdateIdsImpl);
78     void ActionUpdateIds();
79     void SetActionAccessibilityFocusImpl(const ActionAccessibilityFocusImpl& actionAccessibilityFocusImpl);
80     bool ActionAccessibilityFocus(bool isFocus);
81 
82     // node base
83     void SetAttr(const std::vector<std::pair<std::string, std::string>>& attrs);
84     // used for inspector node in PC preview
85     void SetStyle(const std::vector<std::pair<std::string, std::string>>& styles);
86     void AddEvent(int32_t pageId, const std::vector<std::string>& events);
87     void AddNode(const RefPtr<AccessibilityNode>& node, int32_t slot = DEFAULT_INDEX);
88     void RemoveNode(const RefPtr<AccessibilityNode>& node);
89     void Mount(int32_t slot);
90 
SetIsRootNode(bool isRootNode)91     void SetIsRootNode(bool isRootNode)
92     {
93         isRootNode_ = isRootNode;
94     }
95 
IsRootNode()96     bool IsRootNode() const
97     {
98         return isRootNode_;
99     }
100 
ResetChildList(std::list<RefPtr<AccessibilityNode>> & children)101     void ResetChildList(std::list<RefPtr<AccessibilityNode>>& children)
102     {
103         children_.clear();
104         children_.swap(children);
105     }
106 
GetChildList()107     const std::list<RefPtr<AccessibilityNode>>& GetChildList() const
108     {
109         return children_;
110     }
111 
GetParentId()112     NodeId GetParentId() const
113     {
114         auto parentNode = parentNode_.Upgrade();
115         return parentNode ? parentNode->GetNodeId() : -1;
116     }
117 
GetParentNode()118     RefPtr<AccessibilityNode> GetParentNode() const
119     {
120         return parentNode_.Upgrade();
121     }
122 
123     void SetParentNode(const RefPtr<AccessibilityNode>& parentNode);
124 
GetTag()125     const std::string& GetTag() const
126     {
127         return tag_;
128     }
129 
SetTag(const std::string & tag)130     void SetTag(const std::string& tag)
131     {
132         tag_ = tag;
133     }
134 
GetPageId()135     int32_t GetPageId() const
136     {
137         return pageId_;
138     }
139 
SetPageId(int32_t pageId)140     void SetPageId(int32_t pageId)
141     {
142         pageId_ = pageId;
143     }
144 
145     void SetPositionInfo(const PositionInfo& positionInfo);
146 
GetAccessibilityEventMarker()147     const EventMarker& GetAccessibilityEventMarker() const
148     {
149         return onAccessibilityEventId_;
150     }
151 
GetClickEventMarker()152     const EventMarker& GetClickEventMarker() const
153     {
154         return onClickId_;
155     }
156 
GetLongPressEventMarker()157     const EventMarker& GetLongPressEventMarker() const
158     {
159         return onLongPressId_;
160     }
161 
GetFocusEventMarker()162     const EventMarker& GetFocusEventMarker() const
163     {
164         return onFocusId_;
165     }
166 
167     void SetFocusChangeEventMarker(const EventMarker& eventId);
168 
169     void OnFocusChange(bool isFocus);
170 
GetBlurEventMarker()171     const EventMarker& GetBlurEventMarker() const
172     {
173         return onBlurId_;
174     }
175 
176     // node attr need to barrierfree
GetNodeId()177     NodeId GetNodeId() const
178     {
179         return nodeId_;
180     }
181 
GetText()182     const std::string& GetText() const
183     {
184         return text_;
185     }
186 
SetText(const std::string & text)187     void SetText(const std::string& text)
188     {
189         text_ = text;
190     }
191 
GetHintText()192     const std::string& GetHintText() const
193     {
194         return hintText_;
195     }
196 
SetHintText(const std::string & hintText)197     void SetHintText(const std::string& hintText)
198     {
199         hintText_ = hintText;
200     }
201 
GetChildIds()202     const std::vector<int32_t>& GetChildIds() const
203     {
204         return childIds_;
205     }
206 
SetChildIds(const std::vector<int32_t> & ids)207     void SetChildIds(const std::vector<int32_t>& ids)
208     {
209         childIds_ = ids;
210     }
211 
GetWidth()212     double GetWidth() const
213     {
214         return rect_.Width();
215     }
216 
SetWidth(double width)217     void SetWidth(double width)
218     {
219         rect_.SetWidth(width);
220     }
221 
GetHeight()222     double GetHeight() const
223     {
224         return rect_.Height();
225     }
226 
SetHeight(double height)227     void SetHeight(double height)
228     {
229         rect_.SetHeight(height);
230     }
231 
GetLeft()232     double GetLeft() const
233     {
234         return rect_.Left();
235     }
236 
SetLeft(double left)237     void SetLeft(double left)
238     {
239         return rect_.SetLeft(left);
240     }
241 
GetTop()242     double GetTop() const
243     {
244         return rect_.Top();
245     }
246 
SetTop(double top)247     void SetTop(double top)
248     {
249         return rect_.SetTop(top);
250     }
251 
GetCheckedState()252     bool GetCheckedState() const
253     {
254         return isChecked_;
255     }
256 
SetCheckedState(bool state)257     void SetCheckedState(bool state)
258     {
259         isChecked_ = state;
260     }
261 
GetEnabledState()262     bool GetEnabledState() const
263     {
264         return isEnabled_;
265     }
266 
SetEnabledState(bool state)267     void SetEnabledState(bool state)
268     {
269         isEnabled_ = state;
270     }
271 
GetEditable()272     bool GetEditable() const
273     {
274         return isEditable_;
275     }
276 
SetEditable(bool editable)277     void SetEditable(bool editable)
278     {
279         isEditable_ = editable;
280     }
281 
GetFocusedState()282     bool GetFocusedState() const
283     {
284         return isFocused_;
285     }
286 
SetFocusedState(bool state)287     void SetFocusedState(bool state)
288     {
289         isFocused_ = state;
290         OnFocusChange(isFocused_);
291     }
292 
GetAccessibilityFocusedState()293     bool GetAccessibilityFocusedState() const
294     {
295         return isAccessibilityFocused_;
296     }
297 
SetAccessibilityFocusedState(bool state)298     void SetAccessibilityFocusedState(bool state)
299     {
300         isAccessibilityFocused_ = state;
301     }
302 
GetSelectedState()303     bool GetSelectedState() const
304     {
305         return isSelected_;
306     }
307 
SetSelectedState(bool state)308     void SetSelectedState(bool state)
309     {
310         isSelected_ = state;
311     }
312 
GetCheckableState()313     bool GetCheckableState() const
314     {
315         return isCheckable_;
316     }
317 
SetCheckableState(bool state)318     void SetCheckableState(bool state)
319     {
320         isCheckable_ = state;
321     }
322 
GetClickableState()323     bool GetClickableState() const
324     {
325         return isClickable_;
326     }
327 
SetClickableState(bool state)328     void SetClickableState(bool state)
329     {
330         isClickable_ = state;
331         SetSupportAction(AceAction::ACTION_CLICK, state);
332     }
333 
GetFocusableState()334     bool GetFocusableState() const
335     {
336         return isFocusable_;
337     }
338 
SetFocusableState(bool state)339     void SetFocusableState(bool state)
340     {
341         isFocusable_ = state;
342     }
343 
GetScrollableState()344     bool GetScrollableState() const
345     {
346         return isScrollable_;
347     }
348 
SetScrollableState(bool state)349     void SetScrollableState(bool state)
350     {
351         isScrollable_ = state;
352     }
353 
GetLongClickableState()354     bool GetLongClickableState() const
355     {
356         return isLongClickable_;
357     }
358 
SetLongClickableState(bool state)359     void SetLongClickableState(bool state)
360     {
361         isLongClickable_ = state;
362         SetSupportAction(AceAction::ACTION_LONG_CLICK, state);
363     }
364 
GetIsMultiLine()365     bool GetIsMultiLine() const
366     {
367         return isMultiLine_;
368     }
369 
SetIsMultiLine(bool multiLine)370     void SetIsMultiLine(bool multiLine)
371     {
372         isMultiLine_ = multiLine;
373     }
374 
GetIsPassword()375     bool GetIsPassword() const
376     {
377         return isPassword_;
378     }
379 
SetIsPassword(bool isPassword)380     void SetIsPassword(bool isPassword)
381     {
382         isPassword_ = isPassword;
383     }
384 
385     std::unordered_set<AceAction> GetSupportAction(uint64_t enableActions = DEFAULT_ACTIONS) const;
386 
AddSupportAction(AceAction action)387     void AddSupportAction(AceAction action)
388     {
389         supportActions_ |= (1UL << static_cast<uint32_t>(action));
390     }
391 
SetSupportAction(AceAction action,bool isEnable)392     void SetSupportAction(AceAction action, bool isEnable)
393     {
394         isEnable ? supportActions_ |= (1UL << static_cast<uint32_t>(action))
395                  : supportActions_ &= (~(0UL)) ^ (1UL << static_cast<uint32_t>(action));
396     }
397 
GetAccessibilityLabel()398     const std::string& GetAccessibilityLabel() const
399     {
400         return accessibilityLabel_;
401     }
402 
SetAccessibilityLabel(const std::string & label)403     void SetAccessibilityLabel(const std::string& label)
404     {
405         accessibilityLabel_ = label;
406     }
407 
GetAccessibilityHint()408     const std::string& GetAccessibilityHint() const
409     {
410         return accessibilityHint_;
411     }
412 
SetAccessibilityHint(const std::string & hint)413     void SetAccessibilityHint(const std::string& hint)
414     {
415         accessibilityHint_ = hint;
416     }
417 
GetImportantForAccessibility()418     const std::string& GetImportantForAccessibility() const
419     {
420         return importantForAccessibility_;
421     }
422 
SetImportantForAccessibility(const std::string & importance)423     void SetImportantForAccessibility(const std::string& importance)
424     {
425         importantForAccessibility_ = importance;
426     }
427 
GetMaxTextLength()428     size_t GetMaxTextLength() const
429     {
430         return maxTextLength_;
431     }
432 
SetMaxTextLength(size_t length)433     void SetMaxTextLength(size_t length)
434     {
435         maxTextLength_ = length;
436     }
437 
GetTextSelectionStart()438     int32_t GetTextSelectionStart() const
439     {
440         return textSelectionStart_;
441     }
442 
SetTextSelectionStart(int32_t start)443     void SetTextSelectionStart(int32_t start)
444     {
445         textSelectionStart_ = start;
446     }
447 
GetTextSelectionEnd()448     int32_t GetTextSelectionEnd() const
449     {
450         return textSelectionEnd_;
451     }
452 
SetTextSelectionEnd(int32_t end)453     void SetTextSelectionEnd(int32_t end)
454     {
455         textSelectionEnd_ = end;
456     }
457 
GetErrorText()458     const std::string& GetErrorText() const
459     {
460         return errorText_;
461     }
462 
SetErrorText(const std::string & errorText)463     void SetErrorText(const std::string& errorText)
464     {
465         errorText_ = errorText;
466     }
467 
GetJsComponentId()468     const std::string& GetJsComponentId() const
469     {
470         return jsComponentId_;
471     }
472 
SetJsComponentId(const std::string & jsComponentId)473     void SetJsComponentId(const std::string& jsComponentId)
474     {
475         jsComponentId_ = jsComponentId;
476     }
477 
GetAccessible()478     bool GetAccessible() const
479     {
480         return accessible_;
481     }
482 
SetAccessible(bool accessible)483     void SetAccessible(bool accessible)
484     {
485         accessible_ = accessible;
486     }
487 
GetAccessibilityValue()488     AccessibilityValue GetAccessibilityValue() const
489     {
490         return accessibilityValue_;
491     }
492 
493     void SetAccessibilityValue(double cur, double min = 0.0, double max = 0.0)
494     {
495         accessibilityValue_.current = cur;
496         accessibilityValue_.min = min;
497         accessibilityValue_.max = max;
498     }
499 
GetChartValue()500     const std::unique_ptr<ChartValue>& GetChartValue() const
501     {
502         return chartValue_;
503     }
504 
PutChartValue(const std::string & groupName,const std::vector<std::pair<std::string,double>> & values)505     void PutChartValue(const std::string& groupName, const std::vector<std::pair<std::string, double>>& values)
506     {
507         if (!chartValue_) {
508             chartValue_ = std::make_unique<ChartValue>();
509         }
510 
511         auto result = chartValue_->try_emplace(groupName, values);
512         if (!result.second) {
513             result.first->second = values;
514         }
515     }
516 
GetInputType()517     std::string GetInputType() const
518     {
519         return inputType_;
520     }
521 
GetTextInputType()522     AceTextCategory GetTextInputType() const
523     {
524         return textInputType_;
525     }
526 
SetTextInputType(AceTextCategory type)527     void SetTextInputType(AceTextCategory type)
528     {
529         textInputType_ = type;
530     }
531 
GetCollectionInfo()532     const AceCollectionInfo& GetCollectionInfo() const
533     {
534         return collectionInfo_;
535     }
536 
SetCollectionInfo(const AceCollectionInfo & collectionInfo)537     void SetCollectionInfo(const AceCollectionInfo& collectionInfo)
538     {
539         collectionInfo_ = collectionInfo;
540     }
541 
GetCollectionItemInfo()542     const AceCollectionItemInfo& GetCollectionItemInfo() const
543     {
544         return collectionItemInfo_;
545     }
546 
SetCollectionItemInfo(const AceCollectionItemInfo & collectionItemInfo)547     void SetCollectionItemInfo(const AceCollectionItemInfo& collectionItemInfo)
548     {
549         collectionItemInfo_ = collectionItemInfo;
550     }
551 
GetShown()552     bool GetShown() const
553     {
554         return shown_;
555     }
556 
GetVisible()557     bool GetVisible() const
558     {
559         return visible_;
560     }
561 
SetVisible(bool visible)562     void SetVisible(bool visible)
563     {
564         visible_ = visible;
565     }
566 
GetRect()567     const Rect& GetRect() const
568     {
569         return rect_;
570     }
571 
SetRect(const Rect & rect)572     void SetRect(const Rect& rect)
573     {
574         isValidRect_ = rect.IsValid();
575         if (isValidRect_) {
576             rect_ = rect;
577         }
578     }
579 
GetGlobalRect()580     const Rect& GetGlobalRect()
581     {
582         return globalRect_;
583     }
584 
SetGlobalRect(const Rect & rect)585     void SetGlobalRect(const Rect& rect)
586     {
587         globalRect_ = rect;
588     }
589 
ClearRect()590     void ClearRect()
591     {
592         rect_ = Rect(0, 0, 0, 0);
593     }
594 
IsValidRect()595     bool IsValidRect() const
596     {
597         return isValidRect_;
598     }
599 
GetClicked()600     bool GetClicked() const
601     {
602         return isClicked_;
603     }
604 
SetClicked(bool clicked)605     void SetClicked(bool clicked)
606     {
607         isClicked_ = clicked;
608     }
609 
SetMarginSize(const Size & marginSize)610     void SetMarginSize(const Size& marginSize)
611     {
612         marginSize_ = marginSize;
613     }
614 
GetMarginSize()615     Size GetMarginSize() const
616     {
617         return marginSize_;
618     }
619 
GetAttrs()620     const std::vector<std::pair<std::string, std::string>>& GetAttrs() const
621     {
622         return attrs_;
623     }
624 
GetStyles()625     const std::vector<std::pair<std::string, std::string>>& GetStyles() const
626     {
627         return styles_;
628     }
629 
SetClipFlagToChild(bool clipFlag)630     void SetClipFlagToChild(bool clipFlag)
631     {
632         for (auto& child : children_) {
633             child->SetClipFlagToChild(clipFlag);
634         }
635         clipFlag_ = clipFlag;
636     }
637 
GetClipFlag()638     bool GetClipFlag()
639     {
640         return clipFlag_;
641     }
642 
SetTransformToChild(Matrix4 matrix4)643     void SetTransformToChild(Matrix4 matrix4)
644     {
645         for (auto& child : children_) {
646             child->SetTransformToChild(matrix4);
647         }
648         matrix4_ = matrix4;
649     }
650 
GetMatrix4()651     Matrix4 GetMatrix4()
652     {
653         return matrix4_;
654     }
655 
GetRectWithTransform(const Rect & rect,Matrix4 & matrix4)656     Rect GetRectWithTransform(const Rect& rect, Matrix4& matrix4)
657     {
658         Point ltPoint = matrix4 * Point(rect.Left(), rect.Top());
659         Point rtPoint = matrix4 * Point(rect.Right(), rect.Top());
660         Point lbPoint = matrix4 * Point(rect.Left(), rect.Bottom());
661         Point rbPoint = matrix4 * Point(rect.Right(), rect.Bottom());
662         auto left = std::min(std::min(ltPoint.GetX(), rtPoint.GetX()), std::min(lbPoint.GetX(), rbPoint.GetX()));
663         auto right = std::max(std::max(ltPoint.GetX(), rtPoint.GetX()), std::max(lbPoint.GetX(), rbPoint.GetX()));
664         auto top = std::min(std::min(ltPoint.GetY(), rtPoint.GetY()), std::min(lbPoint.GetY(), rbPoint.GetY()));
665         auto bottom = std::max(std::max(ltPoint.GetY(), rtPoint.GetY()), std::max(lbPoint.GetY(), rbPoint.GetY()));
666         return Rect(left, top, right - left, bottom - top);
667     }
668 
GetMatrix4Flag()669     bool GetMatrix4Flag()
670     {
671         if (matrix4_ == Matrix4()) {
672             return false;
673         }
674         return true;
675     }
676 #if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
677     // used for inspector node in PC preview
GetClearRectInfoFlag()678     bool GetClearRectInfoFlag() const
679     {
680         return isClearRectInfo_;
681     }
682 
683     // used for inspector node in PC preview
SetClearRectInfoFlag(bool isClearRectInfo)684     void SetClearRectInfoFlag(bool isClearRectInfo)
685     {
686         isClearRectInfo_ = isClearRectInfo;
687     }
688 
689     // used for inspector node in PC preview
SetScaleToChild(double scale)690     void SetScaleToChild(double scale)
691     {
692         for (auto& child : children_) {
693             child->SetScaleToChild(scale);
694         }
695         SetScale(scale);
696     }
697 
698     // used for inspector node in PC preview
SetScaleCenterToChild(Offset center)699     void SetScaleCenterToChild(Offset center)
700     {
701         for (auto& child : children_) {
702             child->SetScaleCenterToChild(center);
703         }
704         SetScaleCenter(center);
705     }
706 
707     // used for inspector node in PC preview
GetScale()708     double GetScale()
709     {
710         return scale_;
711     }
712 
713     // used for inspector node in PC preview
SetScale(double scale)714     void SetScale(double scale)
715     {
716         scale_ = scale;
717         SetIsAnimationNode(true);
718     }
719 
720     // used for inspector node in PC preview
SetScaleCenter(Offset center)721     void SetScaleCenter(Offset center)
722     {
723         scaleCenter_ = center;
724     }
725 
726     // used for inspector node in PC preview
GetScaleCenter()727     Offset GetScaleCenter()
728     {
729         return scaleCenter_;
730     }
731 
732     // used for inspector node in PC preview
SetTranslateOffsetToChild(const Offset & offset)733     void SetTranslateOffsetToChild(const Offset& offset)
734     {
735         for (auto& child : children_) {
736             child->SetTranslateOffsetToChild(offset);
737         }
738         SetTranslateOffset(offset);
739     }
740 
SetTranslateOffset(const Offset & offset)741     void SetTranslateOffset(const Offset& offset)
742     {
743         translateOffset_ = offset;
744         SetIsAnimationNode(true);
745     }
746 
GetTranslateOffset()747     Offset GetTranslateOffset() const
748     {
749         return translateOffset_;
750     }
751 
752     // used for inspector node in PC preview
SetRotateToChild(const double & angle,const RotateAxis & Axis)753     void SetRotateToChild(const double& angle, const RotateAxis& Axis)
754     {
755         for (auto& child : children_) {
756             child->SetRotateToChild(angle, Axis);
757         }
758         SetRotateAngle(angle);
759         SetRotateAxis(Axis);
760     }
761 
SetRotateAngle(const double & angle)762     void SetRotateAngle(const double& angle)
763     {
764         rotateAngle_ = angle;
765         SetIsAnimationNode(true);
766     }
767 
GetRotateAngle()768     double GetRotateAngle() const
769     {
770         return rotateAngle_;
771     }
772 
SetRotateAxis(const RotateAxis & Axis)773     void SetRotateAxis(const RotateAxis& Axis)
774     {
775         rotateAxis_ = Axis;
776     }
777 
GetRotateAxis(RotateAxis Axis)778     RotateAxis GetRotateAxis(RotateAxis Axis) const
779     {
780         return rotateAxis_;
781     }
782 
IsAnimationNode()783     bool IsAnimationNode() const
784     {
785         return isAnimationNode_;
786     }
787 
SetIsAnimationNode(bool IsAnimationNode)788     void SetIsAnimationNode(bool IsAnimationNode)
789     {
790         isAnimationNode_ = IsAnimationNode;
791     }
792 
GetZIndex()793     int32_t GetZIndex()
794     {
795         return zIndex_;
796     }
797 
SetZIndex(int32_t index)798     void SetZIndex(int32_t index)
799     {
800         zIndex_ = index;
801     }
802 
803     // only panel has ZIndex,others components is default value 0
SetZIndexToChild(int32_t index)804     void SetZIndexToChild(int32_t index)
805     {
806         for (auto& child : children_) {
807             child->SetZIndexToChild(index);
808         }
809         SetZIndex(index);
810     }
811 
UpdateRectWithChildRect()812     void UpdateRectWithChildRect()
813     {
814         if (children_.empty()) {
815             return;
816         }
817         SetRect(children_.front()->GetRect());
818     }
819 #endif
820 
821 protected:
822     // inner use, don't need to barrierfree
823     NodeId nodeId_ = -1;
824     int32_t pageId_ = -1;
825     bool isRootNode_ = false;
826     std::string inputType_;
827     WeakPtr<AccessibilityNode> parentNode_;
828     std::list<RefPtr<AccessibilityNode>> children_;
829     ActionClickImpl actionClickImpl_;
830     ActionLongClickImpl actionLongClickImpl_;
831     ActionScrollForwardImpl actionScrollForwardImpl_;
832     ActionScrollBackwardImpl actionScrollBackwardImpl_;
833     ActionFocusImpl actionFocusImpl_;
834     ActionUpdateIdsImpl actionUpdateIdsImpl_;
835     ActionAccessibilityFocusImpl actionAccessibilityFocusIdsImpl_;
836     EventMarker onAccessibilityEventId_;
837     EventMarker onClickId_;
838     EventMarker onLongPressId_;
839     EventMarker onFocusId_;
840     EventMarker onBlurId_;
841     FocusChangeCallback focusChangeEventId_;
842 
843 private:
844     void SetOperableInfo();
845 
846     // node attr need to barrierfree
847     size_t maxTextLength_ = 0;
848     int32_t textSelectionStart_ = 0;
849     int32_t textSelectionEnd_ = 0;
850     std::string tag_;
851     std::string text_;
852     std::string hintText_;
853     std::string errorText_;
854     std::string jsComponentId_;
855     std::string accessibilityLabel_;
856     std::string accessibilityHint_;
857     std::string importantForAccessibility_;
858     AceTextCategory textInputType_ { AceTextCategory::INPUT_TYPE_DEFAULT };
859     std::vector<int32_t> childIds_;
860     uint64_t supportActions_ = 0;
861     std::unique_ptr<ChartValue> chartValue_;
862 
863     Rect globalRect_;
864     Rect rect_;
865     Size marginSize_;
866     union {
867         struct {
868             bool isValidRect_ : 1;
869             bool isChecked_ : 1;
870             bool isEditable_ : 1;
871             bool isEnabled_ : 1;
872             bool accessible_ : 1;
873             bool isFocused_ : 1;
874             bool isSelected_ : 1;
875             bool isCheckable_ : 1;
876             bool isClickable_ : 1;
877             bool isFocusable_ : 1;
878             bool isScrollable_ : 1;
879             bool isLongClickable_ : 1;
880             bool isMultiLine_ : 1;
881             bool isPassword_ : 1;
882             bool visible_ : 1;
883             bool shown_ : 1;
884             bool isClicked_ : 1;
885             bool isAccessibilityFocused_ : 1;
886         };
887         uint64_t bits_ = 0;
888     };
889     AccessibilityValue accessibilityValue_;
890     AceCollectionInfo collectionInfo_;
891     AceCollectionItemInfo collectionItemInfo_;
892 
893     std::vector<std::pair<std::string, std::string>> attrs_;
894     std::vector<std::pair<std::string, std::string>> styles_;
895     bool clipFlag_ = false;
896     Matrix4 matrix4_;
897 #if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
898     // used for inspector node in PC preview
899     bool isClearRectInfo_ = false;
900     // focus scale or translateScale for inspector node in PC preview
901     double scale_ = 1.0;
902     Offset scaleCenter_ { 0.0, 0.0 };
903     Offset translateOffset_ { 0.0, 0.0 };
904     double rotateAngle_ = 0.0;
905     RotateAxis rotateAxis_ = RotateAxis::AXIS_Z;
906     bool isAnimationNode_ = false;
907     int32_t zIndex_ = 0;
908 #endif
909 };
910 
911 } // namespace OHOS::Ace
912 
913 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_ACCESSIBILITY_ACCESSIBILITY_NODE_H
914