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