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