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 #include <cinttypes>
17 #include "accessibility_element_info.h"
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace Accessibility {
SetComponentId(const int64_t componentId)22 void AccessibilityElementInfo::SetComponentId(const int64_t componentId)
23 {
24     elementId_ = componentId;
25 }
26 
GetChildId(const int32_t index) const27 int64_t AccessibilityElementInfo::GetChildId(const int32_t index) const
28 {
29     if (index >= childCount_ || index < 0 || index >= static_cast<int32_t>(childNodeIds_.size())) {
30         HILOG_ERROR("index[%{public}d] is invalid", index);
31         return -1;
32     }
33     return childNodeIds_[index];
34 }
35 
GetChildCount() const36 int32_t AccessibilityElementInfo::GetChildCount() const
37 {
38     return childCount_;
39 }
40 
GetChildIds() const41 const std::vector<int64_t> &AccessibilityElementInfo::GetChildIds() const
42 {
43     return childNodeIds_;
44 }
45 
AddChild(const int64_t childId)46 void AccessibilityElementInfo::AddChild(const int64_t childId)
47 {
48     for (int32_t i = 0; i < childCount_; i++) {
49         if (childNodeIds_[i] == childId) {
50             HILOG_ERROR("childId[%{public}" PRId64 "] is exited", childId);
51             return;
52         }
53     }
54     childCount_++;
55     childNodeIds_.push_back(childId);
56 }
57 
RemoveChild(const int64_t childId)58 bool AccessibilityElementInfo::RemoveChild(const int64_t childId)
59 {
60     for (auto iter = childNodeIds_.begin(); iter != childNodeIds_.end(); iter++) {
61         if (*iter == childId) {
62             iter = childNodeIds_.erase(iter);
63             childCount_--;
64             return true;
65         }
66     }
67     HILOG_ERROR("Not find childId[%{public}" PRId64 "]", childId);
68     return false;
69 }
70 
GetActionList() const71 const std::vector<AccessibleAction> &AccessibilityElementInfo::GetActionList() const
72 {
73     return operations_;
74 }
75 
AddAction(AccessibleAction & action)76 void AccessibilityElementInfo::AddAction(AccessibleAction &action)
77 {
78     operations_.push_back(action);
79 }
80 
DeleteAction(AccessibleAction & action)81 void AccessibilityElementInfo::DeleteAction(AccessibleAction &action)
82 {
83     for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
84         if (iter->GetActionType() == action.GetActionType()) {
85             iter = operations_.erase(iter);
86             return;
87         }
88     }
89     HILOG_ERROR("Not find actionType[%{public}d]", action.GetActionType());
90 }
91 
DeleteAction(ActionType & actionType)92 bool AccessibilityElementInfo::DeleteAction(ActionType &actionType)
93 {
94     for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
95         if (iter->GetActionType() == actionType) {
96             iter = operations_.erase(iter);
97             return true;
98         }
99     }
100     HILOG_ERROR("Not find actionType[%{public}d]", actionType);
101     return false;
102 }
103 
DeleteAllActions()104 void AccessibilityElementInfo::DeleteAllActions()
105 {
106     operations_.clear();
107 }
108 
SetTextLengthLimit(const int32_t max)109 void AccessibilityElementInfo::SetTextLengthLimit(const int32_t max)
110 {
111     textLengthLimit_ = max;
112 }
113 
GetTextLengthLimit() const114 int32_t AccessibilityElementInfo::GetTextLengthLimit() const
115 {
116     return textLengthLimit_;
117 }
118 
GetWindowId() const119 int32_t AccessibilityElementInfo::GetWindowId() const
120 {
121     return windowId_;
122 }
123 
SetWindowId(const int32_t windowId)124 void AccessibilityElementInfo::SetWindowId(const int32_t windowId)
125 {
126     windowId_ = windowId;
127 }
128 
GetMainWindowId() const129 int32_t AccessibilityElementInfo::GetMainWindowId() const
130 {
131     return mainWindowId_;
132 }
133 
SetMainWindowId(const int32_t windowId)134 void AccessibilityElementInfo::SetMainWindowId(const int32_t windowId)
135 {
136     mainWindowId_ = windowId;
137 }
138 
GetParentNodeId() const139 int64_t AccessibilityElementInfo::GetParentNodeId() const
140 {
141     return parentId_;
142 }
143 
SetParent(const int64_t parentId)144 void AccessibilityElementInfo::SetParent(const int64_t parentId)
145 {
146     parentId_ = parentId;
147 }
148 
GetRectInScreen() const149 const Rect &AccessibilityElementInfo::GetRectInScreen() const
150 {
151     return bounds_;
152 }
153 
SetRectInScreen(Rect & bounds)154 void AccessibilityElementInfo::SetRectInScreen(Rect &bounds)
155 {
156     bounds_.SetLeftTopScreenPostion(bounds.GetLeftTopXScreenPostion(), bounds.GetLeftTopYScreenPostion());
157     bounds_.SetRightBottomScreenPostion(bounds.GetRightBottomXScreenPostion(), bounds.GetRightBottomYScreenPostion());
158 }
159 
IsCheckable() const160 bool AccessibilityElementInfo::IsCheckable() const
161 {
162     return checkable_;
163 }
164 
SetCheckable(const bool checkable)165 void AccessibilityElementInfo::SetCheckable(const bool checkable)
166 {
167     checkable_ = checkable;
168 }
169 
IsChecked() const170 bool AccessibilityElementInfo::IsChecked() const
171 {
172     return checked_;
173 }
174 
SetChecked(const bool checked)175 void AccessibilityElementInfo::SetChecked(const bool checked)
176 {
177     checked_ = checked;
178 }
179 
IsFocusable() const180 bool AccessibilityElementInfo::IsFocusable() const
181 {
182     return focusable_;
183 }
184 
SetFocusable(const bool focusable)185 void AccessibilityElementInfo::SetFocusable(const bool focusable)
186 {
187     focusable_ = focusable;
188 }
189 
IsFocused() const190 bool AccessibilityElementInfo::IsFocused() const
191 {
192     return focused_;
193 }
194 
SetFocused(const bool focused)195 void AccessibilityElementInfo::SetFocused(const bool focused)
196 {
197     focused_ = focused;
198 }
199 
IsVisible() const200 bool AccessibilityElementInfo::IsVisible() const
201 {
202     return visible_;
203 }
204 
SetVisible(const bool visible)205 void AccessibilityElementInfo::SetVisible(const bool visible)
206 {
207     visible_ = visible;
208 }
209 
HasAccessibilityFocus() const210 bool AccessibilityElementInfo::HasAccessibilityFocus() const
211 {
212     return accessibilityFocused_;
213 }
214 
SetAccessibilityFocus(const bool focused)215 void AccessibilityElementInfo::SetAccessibilityFocus(const bool focused)
216 {
217     accessibilityFocused_ = focused;
218 }
219 
IsSelected() const220 bool AccessibilityElementInfo::IsSelected() const
221 {
222     return selected_;
223 }
224 
SetSelected(const bool selected)225 void AccessibilityElementInfo::SetSelected(const bool selected)
226 {
227     selected_ = selected;
228 }
229 
IsClickable() const230 bool AccessibilityElementInfo::IsClickable() const
231 {
232     return clickable_;
233 }
234 
SetClickable(const bool clickable)235 void AccessibilityElementInfo::SetClickable(const bool clickable)
236 {
237     clickable_ = clickable;
238 }
239 
IsLongClickable() const240 bool AccessibilityElementInfo::IsLongClickable() const
241 {
242     return longClickable_;
243 }
244 
SetLongClickable(const bool longClickable)245 void AccessibilityElementInfo::SetLongClickable(const bool longClickable)
246 {
247     longClickable_ = longClickable;
248 }
249 
IsEnabled() const250 bool AccessibilityElementInfo::IsEnabled() const
251 {
252     return enable_;
253 }
254 
SetEnabled(const bool enabled)255 void AccessibilityElementInfo::SetEnabled(const bool enabled)
256 {
257     enable_ = enabled;
258 }
259 
IsPassword() const260 bool AccessibilityElementInfo::IsPassword() const
261 {
262     return isPassword_;
263 }
264 
SetPassword(const bool type)265 void AccessibilityElementInfo::SetPassword(const bool type)
266 {
267     isPassword_ = type;
268 }
269 
IsScrollable() const270 bool AccessibilityElementInfo::IsScrollable() const
271 {
272     return scrollable_;
273 }
274 
SetScrollable(const bool scrollable)275 void AccessibilityElementInfo::SetScrollable(const bool scrollable)
276 {
277     scrollable_ = scrollable;
278 }
279 
GetCurrentIndex() const280 int32_t AccessibilityElementInfo::GetCurrentIndex() const
281 {
282     return currentIndex_;
283 }
284 
SetCurrentIndex(const int32_t index)285 void AccessibilityElementInfo::SetCurrentIndex(const int32_t index)
286 {
287     currentIndex_ = index;
288 }
289 
GetBeginIndex() const290 int32_t AccessibilityElementInfo::GetBeginIndex() const
291 {
292     return beginIndex_;
293 }
294 
SetBeginIndex(const int32_t index)295 void AccessibilityElementInfo::SetBeginIndex(const int32_t index)
296 {
297     beginIndex_ = index;
298 }
299 
GetEndIndex() const300 int32_t AccessibilityElementInfo::GetEndIndex() const
301 {
302     return endIndex_;
303 }
304 
SetEndIndex(const int32_t index)305 void AccessibilityElementInfo::SetEndIndex(const int32_t index)
306 {
307     endIndex_ = index;
308 }
309 
GetInputType() const310 int32_t AccessibilityElementInfo::GetInputType() const
311 {
312     return inputType_;
313 }
314 
SetInputType(const int32_t inputType)315 void AccessibilityElementInfo::SetInputType(const int32_t inputType)
316 {
317     inputType_ = inputType;
318 }
319 
SetValidElement(const bool valid)320 void AccessibilityElementInfo::SetValidElement(const bool valid)
321 {
322     validElement_ = valid;
323 }
324 
SetInspectorKey(const std::string & key)325 void AccessibilityElementInfo::SetInspectorKey(const std::string &key)
326 {
327     inspectorKey_ = key;
328 }
329 
GetInspectorKey() const330 const std::string &AccessibilityElementInfo::GetInspectorKey() const
331 {
332     return inspectorKey_;
333 }
334 
SetPagePath(const std::string & path)335 void AccessibilityElementInfo::SetPagePath(const std::string &path)
336 {
337     pagePath_ = path;
338 }
339 
GetPagePath() const340 const std::string &AccessibilityElementInfo::GetPagePath() const
341 {
342     return pagePath_;
343 }
344 
IsValidElement() const345 bool AccessibilityElementInfo::IsValidElement() const
346 {
347     return validElement_;
348 }
349 
IsEditable() const350 bool AccessibilityElementInfo::IsEditable() const
351 {
352     return editable_;
353 }
354 
SetEditable(const bool editable)355 void AccessibilityElementInfo::SetEditable(const bool editable)
356 {
357     editable_ = editable;
358 }
359 
IsPluraLineSupported() const360 bool AccessibilityElementInfo::IsPluraLineSupported() const
361 {
362     return multiLine_;
363 }
364 
SetPluraLineSupported(const bool multiLine)365 void AccessibilityElementInfo::SetPluraLineSupported(const bool multiLine)
366 {
367     multiLine_ = multiLine;
368 }
369 
IsPopupSupported() const370 bool AccessibilityElementInfo::IsPopupSupported() const
371 {
372     return popupSupported_;
373 }
374 
SetPopupSupported(const bool supportPopup)375 void AccessibilityElementInfo::SetPopupSupported(const bool supportPopup)
376 {
377     popupSupported_ = supportPopup;
378 }
379 
IsDeletable() const380 bool AccessibilityElementInfo::IsDeletable() const
381 {
382     return deletable_;
383 }
384 
SetDeletable(const bool deletable)385 void AccessibilityElementInfo::SetDeletable(const bool deletable)
386 {
387     deletable_ = deletable;
388 }
389 
IsEssential() const390 bool AccessibilityElementInfo::IsEssential() const
391 {
392     return isEssential_;
393 }
394 
SetEssential(const bool essential)395 void AccessibilityElementInfo::SetEssential(const bool essential)
396 {
397     isEssential_ = essential;
398 }
399 
IsGivingHint() const400 bool AccessibilityElementInfo::IsGivingHint() const
401 {
402     return hint_;
403 }
SetHinting(const bool hinting)404 void AccessibilityElementInfo::SetHinting(const bool hinting)
405 {
406     hint_ = hinting;
407 }
408 
GetBundleName() const409 const std::string &AccessibilityElementInfo::GetBundleName() const
410 {
411     return bundleName_;
412 }
413 
SetBundleName(const std::string & bundleName)414 void AccessibilityElementInfo::SetBundleName(const std::string &bundleName)
415 {
416     bundleName_ = bundleName;
417 }
418 
GetComponentType() const419 const std::string &AccessibilityElementInfo::GetComponentType() const
420 {
421     return componentType_;
422 }
423 
SetComponentType(const std::string & className)424 void AccessibilityElementInfo::SetComponentType(const std::string &className)
425 {
426     componentType_ = className;
427 }
428 
GetContent() const429 const std::string &AccessibilityElementInfo::GetContent() const
430 {
431     return text_;
432 }
433 
SetContent(const std::string & text)434 void AccessibilityElementInfo::SetContent(const std::string &text)
435 {
436     text_ = text;
437 }
438 
SetSelectedBegin(const int32_t start)439 void AccessibilityElementInfo::SetSelectedBegin(const int32_t start)
440 {
441     beginSelected_ = start;
442 }
443 
GetSelectedBegin() const444 int32_t AccessibilityElementInfo::GetSelectedBegin() const
445 {
446     return beginSelected_;
447 }
448 
SetSelectedEnd(const int32_t end)449 void AccessibilityElementInfo::SetSelectedEnd(const int32_t end)
450 {
451     endSelected_ = end;
452 }
453 
GetSelectedEnd() const454 int32_t AccessibilityElementInfo::GetSelectedEnd() const
455 {
456     return endSelected_;
457 }
458 
GetHint() const459 const std::string &AccessibilityElementInfo::GetHint() const
460 {
461     return hintText_;
462 }
463 
SetHint(const std::string & hintText)464 void AccessibilityElementInfo::SetHint(const std::string &hintText)
465 {
466     hintText_ = hintText;
467 }
468 
GetDescriptionInfo() const469 const std::string &AccessibilityElementInfo::GetDescriptionInfo() const
470 {
471     return contentDescription_;
472 }
473 
SetDescriptionInfo(const std::string & contentDescription)474 void AccessibilityElementInfo::SetDescriptionInfo(const std::string &contentDescription)
475 {
476     contentDescription_ = contentDescription;
477 }
478 
SetComponentResourceId(const std::string & viewIdResName)479 void AccessibilityElementInfo::SetComponentResourceId(const std::string &viewIdResName)
480 {
481     resourceName_ = viewIdResName;
482 }
483 
GetComponentResourceId() const484 const std::string &AccessibilityElementInfo::GetComponentResourceId() const
485 {
486     return resourceName_;
487 }
488 
SetLiveRegion(const int32_t liveRegion)489 void AccessibilityElementInfo::SetLiveRegion(const int32_t liveRegion)
490 {
491     liveRegion_ = liveRegion;
492 }
493 
GetLiveRegion() const494 int32_t AccessibilityElementInfo::GetLiveRegion() const
495 {
496     return liveRegion_;
497 }
498 
SetContentInvalid(const bool contentInvalid)499 void AccessibilityElementInfo::SetContentInvalid(const bool contentInvalid)
500 {
501     contentInvalid_ = contentInvalid;
502 }
503 
GetContentInvalid() const504 bool AccessibilityElementInfo::GetContentInvalid() const
505 {
506     return contentInvalid_;
507 }
508 
SetError(const std::string & error)509 void AccessibilityElementInfo::SetError(const std::string &error)
510 {
511     error_ = error;
512 }
513 
GetError() const514 const std::string &AccessibilityElementInfo::GetError() const
515 {
516     return error_;
517 }
518 
SetLabeled(const int64_t componentId)519 void AccessibilityElementInfo::SetLabeled(const int64_t componentId)
520 {
521     labeled_ = componentId;
522 }
523 
GetLabeledAccessibilityId() const524 int64_t AccessibilityElementInfo::GetLabeledAccessibilityId() const
525 {
526     return labeled_;
527 }
528 
SetAccessibilityId(const int64_t componentId)529 void AccessibilityElementInfo::SetAccessibilityId(const int64_t componentId)
530 {
531     elementId_ = componentId;
532 }
533 
GetAccessibilityId() const534 int64_t AccessibilityElementInfo::GetAccessibilityId() const
535 {
536     return elementId_;
537 }
538 
GetRange() const539 const RangeInfo &AccessibilityElementInfo::GetRange() const
540 {
541     return rangeInfo_;
542 }
543 
SetRange(RangeInfo & rangeInfo)544 void AccessibilityElementInfo::SetRange(RangeInfo &rangeInfo)
545 {
546     rangeInfo_.SetMax(rangeInfo.GetMax());
547     rangeInfo_.SetMin(rangeInfo.GetMin());
548     rangeInfo_.SetCurrent(rangeInfo.GetCurrent());
549 }
550 
GetGrid() const551 const GridInfo &AccessibilityElementInfo::GetGrid() const
552 {
553     return grid_;
554 }
555 
SetGrid(const GridInfo & grid)556 void AccessibilityElementInfo::SetGrid(const GridInfo &grid)
557 {
558     grid_ = grid;
559 }
560 
GetGridItem() const561 const GridItemInfo &AccessibilityElementInfo::GetGridItem() const
562 {
563     return gridItem_;
564 }
565 
SetGridItem(const GridItemInfo & gridItem)566 void AccessibilityElementInfo::SetGridItem(const GridItemInfo &gridItem)
567 {
568     gridItem_ = gridItem;
569 }
570 
GetAccessibilityText() const571 const std::string &AccessibilityElementInfo::GetAccessibilityText() const
572 {
573     return accessibilityText_;
574 }
575 
SetAccessibilityText(const std::string & accessibilityText)576 void AccessibilityElementInfo::SetAccessibilityText(const std::string &accessibilityText)
577 {
578     accessibilityText_ = accessibilityText;
579 }
580 
SetTextType(const std::string & textType)581 void AccessibilityElementInfo::SetTextType(const std::string &textType)
582 {
583     textType_ = textType;
584 }
585 
GetTextType() const586 const std::string &AccessibilityElementInfo::GetTextType() const
587 {
588     return textType_;
589 }
590 
SetOffset(const float offset)591 void AccessibilityElementInfo::SetOffset(const float offset)
592 {
593     offset_ = offset;
594 }
595 
GetOffset() const596 float AccessibilityElementInfo::GetOffset() const
597 {
598     return offset_;
599 }
600 
AccessibilityElementInfo()601 AccessibilityElementInfo::AccessibilityElementInfo()
602 {
603 }
604 
AccessibleAction(ActionType actionType,const std::string & description)605 AccessibleAction::AccessibleAction(ActionType actionType, const std::string &description)
606 {
607     actionType_ = actionType;
608     description_ = description;
609 }
610 
GetActionType() const611 ActionType AccessibleAction::GetActionType() const
612 {
613     return actionType_;
614 }
615 
GetDescriptionInfo() const616 const std::string &AccessibleAction::GetDescriptionInfo() const
617 {
618     return description_;
619 }
620 
RangeInfo(double min,double max,double current)621 RangeInfo::RangeInfo(double min, double max, double current)
622 {
623     min_ = min;
624     max_ = max;
625     current_ = current;
626 }
627 
GetMin() const628 double RangeInfo::GetMin() const
629 {
630     return min_;
631 }
632 
GetMax() const633 double RangeInfo::GetMax() const
634 {
635     return max_;
636 }
637 
GetCurrent() const638 double RangeInfo::GetCurrent() const
639 {
640     return current_;
641 }
642 
SetMin(double min)643 void RangeInfo::SetMin(double min)
644 {
645     min_ = min;
646 }
647 
SetMax(double max)648 void RangeInfo::SetMax(double max)
649 {
650     max_ = max;
651 }
652 
SetCurrent(double current)653 void RangeInfo::SetCurrent(double current)
654 {
655     current_ = current;
656 }
657 
GridInfo(int32_t rowCount,int32_t columnCount,int32_t mode)658 GridInfo::GridInfo(int32_t rowCount, int32_t columnCount, int32_t mode)
659 {
660     rowCount_ = rowCount;
661     columnCount_ = columnCount;
662     selectionMode_ = mode;
663 }
664 
SetGrid(int32_t rowCount,int32_t columnCount,int32_t mode)665 void GridInfo::SetGrid(int32_t rowCount, int32_t columnCount, int32_t mode)
666 {
667     rowCount_ = rowCount;
668     columnCount_ = columnCount;
669     selectionMode_ = mode;
670 }
671 
SetGrid(GridInfo other)672 void GridInfo::SetGrid(GridInfo other)
673 {
674     rowCount_ = other.rowCount_;
675     columnCount_ = other.columnCount_;
676     selectionMode_ = other.selectionMode_;
677 }
678 
GetRowCount() const679 int32_t GridInfo::GetRowCount() const
680 {
681     return rowCount_;
682 }
683 
GetColumnCount() const684 int32_t GridInfo::GetColumnCount() const
685 {
686     return columnCount_;
687 }
688 
GetSelectionMode() const689 int32_t GridInfo::GetSelectionMode() const
690 {
691     return selectionMode_;
692 }
693 
GridItemInfo(int32_t rowIndex,int32_t rowSpan,int32_t columnIndex,int32_t columnSpan,bool heading,bool selected)694 GridItemInfo::GridItemInfo(int32_t rowIndex, int32_t rowSpan, int32_t columnIndex, int32_t columnSpan,
695     bool heading, bool selected)
696 {
697     rowIndex_ = rowIndex;
698     rowSpan_ = rowSpan;
699     columnIndex_ = columnIndex;
700     columnSpan_ = columnSpan;
701     heading_ = heading;
702     selected_ = selected;
703 }
704 
SetGridItemInfo(GridItemInfo other)705 void GridItemInfo::SetGridItemInfo(GridItemInfo other)
706 {
707     rowIndex_ = other.rowIndex_;
708     rowSpan_ = other.rowSpan_;
709     columnIndex_ = other.columnIndex_;
710     columnSpan_ = other.columnSpan_;
711     heading_ = other.heading_;
712     selected_ = other.selected_;
713 }
714 
SetGridItemInfo(int32_t rowIndex,int32_t rowSpan,int32_t columnIndex,int32_t columnSpan,bool heading,bool selected)715 void GridItemInfo::SetGridItemInfo(int32_t rowIndex, int32_t rowSpan, int32_t columnIndex,
716     int32_t columnSpan, bool heading, bool selected)
717 {
718     rowIndex_ = rowIndex;
719     rowSpan_ = rowSpan;
720     columnIndex_ = columnIndex;
721     columnSpan_ = columnSpan;
722     heading_ = heading;
723     selected_ = selected;
724 }
725 
GetColumnIndex() const726 int32_t GridItemInfo::GetColumnIndex() const
727 {
728     return columnIndex_;
729 }
730 
GetRowIndex() const731 int32_t GridItemInfo::GetRowIndex() const
732 {
733     return rowIndex_;
734 }
735 
GetColumnSpan() const736 int32_t GridItemInfo::GetColumnSpan() const
737 {
738     return columnSpan_;
739 }
740 
GetRowSpan() const741 int32_t GridItemInfo::GetRowSpan() const
742 {
743     return rowSpan_;
744 }
745 
IsHeading() const746 bool GridItemInfo::IsHeading() const
747 {
748     return heading_;
749 }
750 
IsSelected() const751 bool GridItemInfo::IsSelected() const
752 {
753     return selected_;
754 }
755 
GetPageId() const756 int32_t AccessibilityElementInfo::GetPageId() const
757 {
758     return pageId_;
759 }
760 
SetPageId(const int32_t pageId)761 void AccessibilityElementInfo::SetPageId(const int32_t pageId)
762 {
763     pageId_ = pageId;
764 }
765 
SetTextMovementStep(const TextMoveUnit granularity)766 void AccessibilityElementInfo::SetTextMovementStep(const TextMoveUnit granularity)
767 {
768     textMoveStep_ = granularity;
769 }
770 
GetTextMovementStep() const771 TextMoveUnit AccessibilityElementInfo::GetTextMovementStep() const
772 {
773     return textMoveStep_;
774 }
775 
SetItemCounts(const int32_t itemCounts)776 void AccessibilityElementInfo::SetItemCounts(const int32_t itemCounts)
777 {
778     itemCounts_ = itemCounts;
779 }
780 
GetItemCounts() const781 int32_t AccessibilityElementInfo::GetItemCounts() const
782 {
783     return itemCounts_;
784 }
785 
SetTriggerAction(const ActionType action)786 void AccessibilityElementInfo::SetTriggerAction(const ActionType action)
787 {
788     triggerAction_ = action;
789 }
790 
GetTriggerAction() const791 ActionType AccessibilityElementInfo::GetTriggerAction() const
792 {
793     return triggerAction_;
794 }
795 
SetContentList(const std::vector<std::string> & contentList)796 void AccessibilityElementInfo::SetContentList(const std::vector<std::string> &contentList)
797 {
798     contentList_.clear();
799     contentList_.resize(contentList.size());
800     std::copy(contentList.begin(), contentList.end(), contentList_.begin());
801 }
802 
GetContentList(std::vector<std::string> & contentList) const803 void AccessibilityElementInfo::GetContentList(std::vector<std::string> &contentList) const
804 {
805     contentList.clear();
806     contentList.resize(contentList_.size());
807     std::copy(contentList_.begin(), contentList_.end(), contentList.begin());
808 }
809 
SetLatestContent(const std::string & content)810 void AccessibilityElementInfo::SetLatestContent(const std::string &content)
811 {
812     latestContent_ = content;
813 }
814 
GetLatestContent() const815 const std::string &AccessibilityElementInfo::GetLatestContent() const
816 {
817     return latestContent_;
818 }
819 
SetChildTreeIdAndWinId(const int32_t iChildTreeId,const int32_t iChildWindowId)820 void AccessibilityElementInfo::SetChildTreeIdAndWinId(const int32_t iChildTreeId, const int32_t iChildWindowId)
821 {
822     childTreeId_ = iChildTreeId;
823     childWindowId_ = iChildWindowId;
824 }
825 
GetChildTreeId() const826 int32_t AccessibilityElementInfo::GetChildTreeId() const
827 {
828     return childTreeId_;
829 }
830 
GetChildWindowId() const831 int32_t AccessibilityElementInfo::GetChildWindowId() const
832 {
833     return childWindowId_;
834 }
835 
SetBelongTreeId(const int32_t iBelongTreeId)836 void AccessibilityElementInfo::SetBelongTreeId(const int32_t iBelongTreeId)
837 {
838     belongTreeId_ = iBelongTreeId;
839 }
840 
GetBelongTreeId() const841 int32_t AccessibilityElementInfo::GetBelongTreeId() const
842 {
843     return belongTreeId_;
844 }
845 
SetParentWindowId(const int32_t iParentWindowId)846 void AccessibilityElementInfo::SetParentWindowId(const int32_t iParentWindowId)
847 {
848     parentWindowId_ = iParentWindowId;
849 }
850 
GetParentWindowId() const851 int32_t AccessibilityElementInfo::GetParentWindowId() const
852 {
853     return parentWindowId_;
854 }
855 
ExtraElementInfo(const std::map<std::string,std::string> extraElementValueStr,const std::map<std::string,int32_t> extraElementValueInt)856 ExtraElementInfo::ExtraElementInfo(const std::map<std::string, std::string> extraElementValueStr,
857     const std::map<std::string, int32_t> extraElementValueInt)
858 {
859     extraElementValueStr_ = extraElementValueStr;
860     extraElementValueInt_ = extraElementValueInt;
861 }
862 
SetExtraElementInfo(const std::string keyStr,const std::string valueStr)863 RetError ExtraElementInfo::SetExtraElementInfo(const std::string keyStr, const std::string valueStr)
864 {
865     auto extraElementInfoIter = EXTRA_ELEMENTINFO_SET.find(keyStr);
866     if (extraElementInfoIter != EXTRA_ELEMENTINFO_SET.end()) {
867         extraElementValueStr_[keyStr] = valueStr;
868         HILOG_DEBUG("SetExtraElementInfo: size is extraElementValueStr : [%{public}zu]",
869             extraElementValueStr_.size());
870     } else {
871         return RET_ERR_FAILED;
872     }
873     return RET_OK;
874 }
875 
SetExtraElementInfo(const std::string keyStr,const int32_t valueInt)876 RetError ExtraElementInfo::SetExtraElementInfo(const std::string keyStr, const int32_t valueInt)
877 {
878     auto extraElementInfoIter = EXTRA_ELEMENTINFO_SET.find(keyStr);
879     if (extraElementInfoIter != EXTRA_ELEMENTINFO_SET.end()) {
880         extraElementValueInt_[keyStr] = valueInt;
881         HILOG_DEBUG("SetExtraElementInfo: size is extraElementValueInt : [%{public}zu]",
882             extraElementValueInt_.size());
883     } else {
884         return RET_ERR_FAILED;
885     }
886     return RET_OK;
887 }
888 
GetExtraElementInfoValueStr() const889 const std::map<std::string, std::string> &ExtraElementInfo::GetExtraElementInfoValueStr() const
890 {
891     return extraElementValueStr_;
892 }
893 
GetExtraElementInfoValueInt() const894 const std::map<std::string, int32_t> &ExtraElementInfo::GetExtraElementInfoValueInt() const
895 {
896     return extraElementValueInt_;
897 }
898 
SetExtraElement(const ExtraElementInfo & extraElementInfo)899 void AccessibilityElementInfo::SetExtraElement(const ExtraElementInfo &extraElementInfo)
900 {
901     extraElementInfo_ = extraElementInfo;
902 }
903 
GetExtraElement() const904 const ExtraElementInfo &AccessibilityElementInfo::GetExtraElement() const
905 {
906     return extraElementInfo_;
907 }
GetAccessibilityLevel() const908 const std::string &AccessibilityElementInfo::GetAccessibilityLevel() const
909 {
910     return accessibilityLevel_;
911 }
912 
GetAccessibilityGroup() const913 bool AccessibilityElementInfo::GetAccessibilityGroup() const
914 {
915     return accessibilityGroup_;
916 }
917 
SetAccessibilityGroup(const bool accessibilityGroup)918 void AccessibilityElementInfo::SetAccessibilityGroup(const bool accessibilityGroup)
919 {
920     accessibilityGroup_ = accessibilityGroup;
921 }
922 
SetAccessibilityLevel(const std::string accessibilityLevel)923 void AccessibilityElementInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
924 {
925     accessibilityLevel_ = accessibilityLevel;
926 }
927 
SetZIndex(const int32_t zIndex)928 void AccessibilityElementInfo::SetZIndex(const int32_t zIndex)
929 {
930     zIndex_ = zIndex;
931 }
932 
GetZIndex() const933 int32_t AccessibilityElementInfo::GetZIndex() const
934 {
935     return zIndex_;
936 }
937 
SetOpacity(const float opacity)938 void AccessibilityElementInfo::SetOpacity(const float opacity)
939 {
940     opacity_ = opacity;
941 }
942 
GetOpacity() const943 float AccessibilityElementInfo::GetOpacity() const
944 {
945     return opacity_;
946 }
947 
SetBackgroundColor(const std::string & backgroundColor)948 void AccessibilityElementInfo::SetBackgroundColor(const std::string &backgroundColor)
949 {
950     backgroundColor_ = backgroundColor;
951 }
952 
GetBackgroundColor() const953 const std::string &AccessibilityElementInfo::GetBackgroundColor() const
954 {
955     return backgroundColor_;
956 }
957 
SetBackgroundImage(const std::string & backgroundImage)958 void AccessibilityElementInfo::SetBackgroundImage(const std::string &backgroundImage)
959 {
960     backgroundImage_ = backgroundImage;
961 }
962 
GetBackgroundImage() const963 const std::string &AccessibilityElementInfo::GetBackgroundImage() const
964 {
965     return backgroundImage_;
966 }
967 
SetBlur(const std::string & blur)968 void AccessibilityElementInfo::SetBlur(const std::string &blur)
969 {
970     blur_ = blur;
971 }
972 
GetBlur() const973 const std::string &AccessibilityElementInfo::GetBlur() const
974 {
975     return blur_;
976 }
977 
SetHitTestBehavior(const std::string & hitTestBehavior)978 void AccessibilityElementInfo::SetHitTestBehavior(const std::string &hitTestBehavior)
979 {
980     hitTestBehavior_ = hitTestBehavior;
981 }
982 
GetHitTestBehavior() const983 const std::string &AccessibilityElementInfo::GetHitTestBehavior() const
984 {
985     return hitTestBehavior_;
986 }
987 
SetNavDestinationId(const int64_t navDestinationId)988 void AccessibilityElementInfo::SetNavDestinationId(const int64_t navDestinationId)
989 {
990     navDestinationId_ = navDestinationId;
991 }
992 
GetNavDestinationId() const993 int64_t AccessibilityElementInfo::GetNavDestinationId() const
994 {
995     return navDestinationId_;
996 }
997 
AddSpan(const SpanInfo & span)998 void AccessibilityElementInfo::AddSpan(const SpanInfo &span)
999 {
1000     spanList_.push_back(span);
1001     for (auto array: spanList_) {
1002         HILOG_INFO("AddSpanListsize:spanId: %{public}d, spanText: %{public}s, accessibilityText: %{public}s,"
1003             "accessibilityDescription: %{public}s, accessibilityLevel: %{public}s", span.GetSpanId(),
1004             span.GetSpanText().c_str(), span.GetAccessibilityText().c_str(), span.GetAccessibilityDescription().c_str(),
1005             span.GetAccessibilityLevel().c_str());
1006     }
1007 }
1008 
SetSpanList(const std::vector<SpanInfo> & spanList)1009 void AccessibilityElementInfo::SetSpanList(const std::vector<SpanInfo> &spanList)
1010 {
1011     spanList_.clear();
1012     spanList_.resize(spanList.size());
1013     std::copy(spanList.begin(), spanList.end(), spanList_.begin());
1014 }
1015 
GetSpanList() const1016 const std::vector<SpanInfo> &AccessibilityElementInfo::GetSpanList() const
1017 {
1018     return spanList_;
1019 }
1020 
SpanInfo(const int32_t & spanId,const std::string & spanText,const std::string & accessibilityText,const std::string & accessibilityDescription,const std::string & accessibilityLevel)1021 SpanInfo::SpanInfo(const int32_t &spanId, const std::string &spanText, const std::string &accessibilityText,
1022     const std::string &accessibilityDescription, const std::string &accessibilityLevel)
1023 {
1024     spanId_ = spanId;
1025     spanText_ = spanText;
1026     accessibilityText_ = accessibilityText;
1027     accessibilityDescription_ = accessibilityDescription;
1028     accessibilityLevel_ = accessibilityLevel;
1029 }
1030 
SetSpanId(const int32_t spanId)1031 void SpanInfo::SetSpanId(const int32_t spanId)
1032 {
1033     spanId_ = spanId;
1034 }
1035 
SetSpanText(const std::string spanText)1036 void SpanInfo::SetSpanText(const std::string spanText)
1037 {
1038     spanText_ = spanText;
1039 }
1040 
SetAccessibilityText(const std::string accessibilityText)1041 void SpanInfo::SetAccessibilityText(const std::string accessibilityText)
1042 {
1043     accessibilityText_ = accessibilityText;
1044 }
1045 
SetAccessibilityDescription(const std::string accessibilityDescription)1046 void SpanInfo::SetAccessibilityDescription(const std::string accessibilityDescription)
1047 {
1048     accessibilityDescription_ = accessibilityDescription;
1049 }
1050 
SetAccessibilityLevel(const std::string accessibilityLevel)1051 void SpanInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
1052 {
1053     accessibilityLevel_ = accessibilityLevel;
1054 }
1055 
GetSpanId() const1056 int32_t SpanInfo::GetSpanId() const
1057 {
1058     return spanId_;
1059 }
1060 
GetSpanText() const1061 const std::string &SpanInfo::GetSpanText() const
1062 {
1063     return spanText_;
1064 }
1065 
GetAccessibilityText() const1066 const std::string &SpanInfo::GetAccessibilityText() const
1067 {
1068     return accessibilityText_;
1069 }
1070 
GetAccessibilityDescription() const1071 const std::string &SpanInfo::GetAccessibilityDescription() const
1072 {
1073     return accessibilityDescription_;
1074 }
1075 
GetAccessibilityLevel() const1076 const std::string &SpanInfo::GetAccessibilityLevel() const
1077 {
1078     return accessibilityLevel_;
1079 }
1080 
GetIsActive() const1081 bool AccessibilityElementInfo::GetIsActive() const
1082 {
1083     return isActive_;
1084 }
1085 
SetIsActive(const bool isActive)1086 void AccessibilityElementInfo::SetIsActive(const bool isActive)
1087 {
1088     isActive_ = isActive;
1089 }
1090 
GetAccessibilityVisible() const1091 bool AccessibilityElementInfo::GetAccessibilityVisible() const
1092 {
1093     return accessibilityVisible_;
1094 }
1095 
SetAccessibilityVisible(const bool accessibilityVisible)1096 void AccessibilityElementInfo::SetAccessibilityVisible(const bool accessibilityVisible)
1097 {
1098     accessibilityVisible_ = accessibilityVisible;
1099 }
1100 } // namespace Accessibility
1101 } // namespace OHOS