• 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 {
22 namespace {
23 static std::set<std::string> EXTRA_ELEMENTINFO_SET = {
24     "CheckboxGroupSelectedStatus",
25     "Row",
26     "Column",
27     "SideBarContainerStates",
28     "ListItemIndex",
29     "ToggleType",
30     "BindSheet",
31     "hasRegisteredHover",
32     "direction",
33     "expandedState",
34     "componentTypeDescription",
35     "isModal"
36 };
37 }
SetComponentId(const int64_t componentId)38 void AccessibilityElementInfo::SetComponentId(const int64_t componentId)
39 {
40     elementId_ = componentId;
41 }
42 
GetChildId(const int32_t index) const43 int64_t AccessibilityElementInfo::GetChildId(const int32_t index) const
44 {
45     if (index >= childCount_ || index < 0 || index >= static_cast<int32_t>(childNodeIds_.size())) {
46         HILOG_ERROR("index[%{public}d] is invalid", index);
47         return -1;
48     }
49     return childNodeIds_[index];
50 }
51 
GetChildCount() const52 int32_t AccessibilityElementInfo::GetChildCount() const
53 {
54     return childCount_;
55 }
56 
GetChildIds() const57 const std::vector<int64_t> &AccessibilityElementInfo::GetChildIds() const
58 {
59     return childNodeIds_;
60 }
61 
AddChild(const int64_t childId)62 void AccessibilityElementInfo::AddChild(const int64_t childId)
63 {
64     for (int32_t i = 0; i < childCount_; i++) {
65         if (childNodeIds_[i] == childId) {
66             HILOG_ERROR("childId[%{public}" PRId64 "] is exited", childId);
67             return;
68         }
69     }
70     childCount_++;
71     childNodeIds_.push_back(childId);
72 }
73 
RemoveChild(const int64_t childId)74 bool AccessibilityElementInfo::RemoveChild(const int64_t childId)
75 {
76     for (auto iter = childNodeIds_.begin(); iter != childNodeIds_.end(); iter++) {
77         if (*iter == childId) {
78             iter = childNodeIds_.erase(iter);
79             childCount_--;
80             return true;
81         }
82     }
83     HILOG_ERROR("Not find childId[%{public}" PRId64 "]", childId);
84     return false;
85 }
86 
GetActionList() const87 const std::vector<AccessibleAction> &AccessibilityElementInfo::GetActionList() const
88 {
89     return operations_;
90 }
91 
AddAction(AccessibleAction & action)92 void AccessibilityElementInfo::AddAction(AccessibleAction &action)
93 {
94     operations_.push_back(action);
95 }
96 
DeleteAction(AccessibleAction & action)97 void AccessibilityElementInfo::DeleteAction(AccessibleAction &action)
98 {
99     for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
100         if (iter->GetActionType() == action.GetActionType()) {
101             iter = operations_.erase(iter);
102             return;
103         }
104     }
105     HILOG_ERROR("Not find actionType[%{public}d]", action.GetActionType());
106 }
107 
DeleteAction(ActionType & actionType)108 bool AccessibilityElementInfo::DeleteAction(ActionType &actionType)
109 {
110     for (auto iter = operations_.begin(); iter != operations_.end(); iter++) {
111         if (iter->GetActionType() == actionType) {
112             iter = operations_.erase(iter);
113             return true;
114         }
115     }
116     HILOG_ERROR("Not find actionType[%{public}d]", actionType);
117     return false;
118 }
119 
DeleteAllActions()120 void AccessibilityElementInfo::DeleteAllActions()
121 {
122     operations_.clear();
123 }
124 
SetTextLengthLimit(const int32_t max)125 void AccessibilityElementInfo::SetTextLengthLimit(const int32_t max)
126 {
127     textLengthLimit_ = max;
128 }
129 
GetTextLengthLimit() const130 int32_t AccessibilityElementInfo::GetTextLengthLimit() const
131 {
132     return textLengthLimit_;
133 }
134 
GetWindowId() const135 int32_t AccessibilityElementInfo::GetWindowId() const
136 {
137     return windowId_;
138 }
139 
SetWindowId(const int32_t windowId)140 void AccessibilityElementInfo::SetWindowId(const int32_t windowId)
141 {
142     windowId_ = windowId;
143 }
144 
GetMainWindowId() const145 int32_t AccessibilityElementInfo::GetMainWindowId() const
146 {
147     return mainWindowId_;
148 }
149 
SetMainWindowId(const int32_t windowId)150 void AccessibilityElementInfo::SetMainWindowId(const int32_t windowId)
151 {
152     mainWindowId_ = windowId;
153 }
154 
GetInnerWindowId() const155 int32_t AccessibilityElementInfo::GetInnerWindowId() const
156 {
157     return innerWindowId_;
158 }
159 
SetInnerWindowId(const int32_t windowId)160 void AccessibilityElementInfo::SetInnerWindowId(const int32_t windowId)
161 {
162     innerWindowId_ = windowId;
163 }
164 
GetParentNodeId() const165 int64_t AccessibilityElementInfo::GetParentNodeId() const
166 {
167     return parentId_;
168 }
169 
SetParent(const int64_t parentId)170 void AccessibilityElementInfo::SetParent(const int64_t parentId)
171 {
172     parentId_ = parentId;
173 }
174 
GetRectInScreen() const175 const Rect &AccessibilityElementInfo::GetRectInScreen() const
176 {
177     return bounds_;
178 }
179 
SetRectInScreen(Rect & bounds)180 void AccessibilityElementInfo::SetRectInScreen(Rect &bounds)
181 {
182     bounds_.SetLeftTopScreenPostion(bounds.GetLeftTopXScreenPostion(), bounds.GetLeftTopYScreenPostion());
183     bounds_.SetRightBottomScreenPostion(bounds.GetRightBottomXScreenPostion(), bounds.GetRightBottomYScreenPostion());
184 }
185 
IsCheckable() const186 bool AccessibilityElementInfo::IsCheckable() const
187 {
188     return checkable_;
189 }
190 
SetCheckable(const bool checkable)191 void AccessibilityElementInfo::SetCheckable(const bool checkable)
192 {
193     checkable_ = checkable;
194 }
195 
IsChecked() const196 bool AccessibilityElementInfo::IsChecked() const
197 {
198     return checked_;
199 }
200 
SetChecked(const bool checked)201 void AccessibilityElementInfo::SetChecked(const bool checked)
202 {
203     checked_ = checked;
204 }
205 
IsFocusable() const206 bool AccessibilityElementInfo::IsFocusable() const
207 {
208     return focusable_;
209 }
210 
SetFocusable(const bool focusable)211 void AccessibilityElementInfo::SetFocusable(const bool focusable)
212 {
213     focusable_ = focusable;
214 }
215 
IsFocused() const216 bool AccessibilityElementInfo::IsFocused() const
217 {
218     return focused_;
219 }
220 
SetFocused(const bool focused)221 void AccessibilityElementInfo::SetFocused(const bool focused)
222 {
223     focused_ = focused;
224 }
225 
IsVisible() const226 bool AccessibilityElementInfo::IsVisible() const
227 {
228     return visible_;
229 }
230 
SetVisible(const bool visible)231 void AccessibilityElementInfo::SetVisible(const bool visible)
232 {
233     visible_ = visible;
234 }
235 
HasAccessibilityFocus() const236 bool AccessibilityElementInfo::HasAccessibilityFocus() const
237 {
238     return accessibilityFocused_;
239 }
240 
SetAccessibilityFocus(const bool focused)241 void AccessibilityElementInfo::SetAccessibilityFocus(const bool focused)
242 {
243     accessibilityFocused_ = focused;
244 }
245 
IsSelected() const246 bool AccessibilityElementInfo::IsSelected() const
247 {
248     return selected_;
249 }
250 
SetSelected(const bool selected)251 void AccessibilityElementInfo::SetSelected(const bool selected)
252 {
253     selected_ = selected;
254 }
255 
IsClickable() const256 bool AccessibilityElementInfo::IsClickable() const
257 {
258     return clickable_;
259 }
260 
SetClickable(const bool clickable)261 void AccessibilityElementInfo::SetClickable(const bool clickable)
262 {
263     clickable_ = clickable;
264 }
265 
IsLongClickable() const266 bool AccessibilityElementInfo::IsLongClickable() const
267 {
268     return longClickable_;
269 }
270 
SetLongClickable(const bool longClickable)271 void AccessibilityElementInfo::SetLongClickable(const bool longClickable)
272 {
273     longClickable_ = longClickable;
274 }
275 
IsEnabled() const276 bool AccessibilityElementInfo::IsEnabled() const
277 {
278     return enable_;
279 }
280 
SetEnabled(const bool enabled)281 void AccessibilityElementInfo::SetEnabled(const bool enabled)
282 {
283     enable_ = enabled;
284 }
285 
IsPassword() const286 bool AccessibilityElementInfo::IsPassword() const
287 {
288     return isPassword_;
289 }
290 
SetPassword(const bool type)291 void AccessibilityElementInfo::SetPassword(const bool type)
292 {
293     isPassword_ = type;
294 }
295 
IsScrollable() const296 bool AccessibilityElementInfo::IsScrollable() const
297 {
298     return scrollable_;
299 }
300 
SetScrollable(const bool scrollable)301 void AccessibilityElementInfo::SetScrollable(const bool scrollable)
302 {
303     scrollable_ = scrollable;
304 }
305 
GetCurrentIndex() const306 int32_t AccessibilityElementInfo::GetCurrentIndex() const
307 {
308     return currentIndex_;
309 }
310 
SetCurrentIndex(const int32_t index)311 void AccessibilityElementInfo::SetCurrentIndex(const int32_t index)
312 {
313     currentIndex_ = index;
314 }
315 
GetBeginIndex() const316 int32_t AccessibilityElementInfo::GetBeginIndex() const
317 {
318     return beginIndex_;
319 }
320 
SetBeginIndex(const int32_t index)321 void AccessibilityElementInfo::SetBeginIndex(const int32_t index)
322 {
323     beginIndex_ = index;
324 }
325 
GetEndIndex() const326 int32_t AccessibilityElementInfo::GetEndIndex() const
327 {
328     return endIndex_;
329 }
330 
SetEndIndex(const int32_t index)331 void AccessibilityElementInfo::SetEndIndex(const int32_t index)
332 {
333     endIndex_ = index;
334 }
335 
GetInputType() const336 int32_t AccessibilityElementInfo::GetInputType() const
337 {
338     return inputType_;
339 }
340 
SetInputType(const int32_t inputType)341 void AccessibilityElementInfo::SetInputType(const int32_t inputType)
342 {
343     inputType_ = inputType;
344 }
345 
SetValidElement(const bool valid)346 void AccessibilityElementInfo::SetValidElement(const bool valid)
347 {
348     validElement_ = valid;
349 }
350 
SetInspectorKey(const std::string & key)351 void AccessibilityElementInfo::SetInspectorKey(const std::string &key)
352 {
353     inspectorKey_ = key;
354 }
355 
GetInspectorKey() const356 const std::string &AccessibilityElementInfo::GetInspectorKey() const
357 {
358     return inspectorKey_;
359 }
360 
SetPagePath(const std::string & path)361 void AccessibilityElementInfo::SetPagePath(const std::string &path)
362 {
363     pagePath_ = path;
364 }
365 
GetPagePath() const366 const std::string &AccessibilityElementInfo::GetPagePath() const
367 {
368     return pagePath_;
369 }
370 
IsValidElement() const371 bool AccessibilityElementInfo::IsValidElement() const
372 {
373     return validElement_;
374 }
375 
IsEditable() const376 bool AccessibilityElementInfo::IsEditable() const
377 {
378     return editable_;
379 }
380 
SetEditable(const bool editable)381 void AccessibilityElementInfo::SetEditable(const bool editable)
382 {
383     editable_ = editable;
384 }
385 
IsPluraLineSupported() const386 bool AccessibilityElementInfo::IsPluraLineSupported() const
387 {
388     return multiLine_;
389 }
390 
SetPluraLineSupported(const bool multiLine)391 void AccessibilityElementInfo::SetPluraLineSupported(const bool multiLine)
392 {
393     multiLine_ = multiLine;
394 }
395 
IsPopupSupported() const396 bool AccessibilityElementInfo::IsPopupSupported() const
397 {
398     return popupSupported_;
399 }
400 
SetPopupSupported(const bool supportPopup)401 void AccessibilityElementInfo::SetPopupSupported(const bool supportPopup)
402 {
403     popupSupported_ = supportPopup;
404 }
405 
IsDeletable() const406 bool AccessibilityElementInfo::IsDeletable() const
407 {
408     return deletable_;
409 }
410 
SetDeletable(const bool deletable)411 void AccessibilityElementInfo::SetDeletable(const bool deletable)
412 {
413     deletable_ = deletable;
414 }
415 
IsEssential() const416 bool AccessibilityElementInfo::IsEssential() const
417 {
418     return isEssential_;
419 }
420 
SetEssential(const bool essential)421 void AccessibilityElementInfo::SetEssential(const bool essential)
422 {
423     isEssential_ = essential;
424 }
425 
IsGivingHint() const426 bool AccessibilityElementInfo::IsGivingHint() const
427 {
428     return hint_;
429 }
SetHinting(const bool hinting)430 void AccessibilityElementInfo::SetHinting(const bool hinting)
431 {
432     hint_ = hinting;
433 }
434 
GetBundleName() const435 const std::string &AccessibilityElementInfo::GetBundleName() const
436 {
437     return bundleName_;
438 }
439 
SetBundleName(const std::string & bundleName)440 void AccessibilityElementInfo::SetBundleName(const std::string &bundleName)
441 {
442     bundleName_ = bundleName;
443 }
444 
GetComponentType() const445 const std::string &AccessibilityElementInfo::GetComponentType() const
446 {
447     return componentType_;
448 }
449 
SetComponentType(const std::string & className)450 void AccessibilityElementInfo::SetComponentType(const std::string &className)
451 {
452     componentType_ = className;
453 }
454 
GetContent() const455 const std::string &AccessibilityElementInfo::GetContent() const
456 {
457     return text_;
458 }
459 
SetContent(const std::string & text)460 void AccessibilityElementInfo::SetContent(const std::string &text)
461 {
462     text_ = text;
463 }
464 
SetSelectedBegin(const int32_t start)465 void AccessibilityElementInfo::SetSelectedBegin(const int32_t start)
466 {
467     beginSelected_ = start;
468 }
469 
GetSelectedBegin() const470 int32_t AccessibilityElementInfo::GetSelectedBegin() const
471 {
472     return beginSelected_;
473 }
474 
SetSelectedEnd(const int32_t end)475 void AccessibilityElementInfo::SetSelectedEnd(const int32_t end)
476 {
477     endSelected_ = end;
478 }
479 
GetSelectedEnd() const480 int32_t AccessibilityElementInfo::GetSelectedEnd() const
481 {
482     return endSelected_;
483 }
484 
GetHint() const485 const std::string &AccessibilityElementInfo::GetHint() const
486 {
487     return hintText_;
488 }
489 
SetHint(const std::string & hintText)490 void AccessibilityElementInfo::SetHint(const std::string &hintText)
491 {
492     hintText_ = hintText;
493 }
494 
GetDescriptionInfo() const495 const std::string &AccessibilityElementInfo::GetDescriptionInfo() const
496 {
497     return contentDescription_;
498 }
499 
SetDescriptionInfo(const std::string & contentDescription)500 void AccessibilityElementInfo::SetDescriptionInfo(const std::string &contentDescription)
501 {
502     contentDescription_ = contentDescription;
503 }
504 
SetComponentResourceId(const std::string & viewIdResName)505 void AccessibilityElementInfo::SetComponentResourceId(const std::string &viewIdResName)
506 {
507     resourceName_ = viewIdResName;
508 }
509 
GetComponentResourceId() const510 const std::string &AccessibilityElementInfo::GetComponentResourceId() const
511 {
512     return resourceName_;
513 }
514 
SetLiveRegion(const int32_t liveRegion)515 void AccessibilityElementInfo::SetLiveRegion(const int32_t liveRegion)
516 {
517     liveRegion_ = liveRegion;
518 }
519 
GetLiveRegion() const520 int32_t AccessibilityElementInfo::GetLiveRegion() const
521 {
522     return liveRegion_;
523 }
524 
SetContentInvalid(const bool contentInvalid)525 void AccessibilityElementInfo::SetContentInvalid(const bool contentInvalid)
526 {
527     contentInvalid_ = contentInvalid;
528 }
529 
GetContentInvalid() const530 bool AccessibilityElementInfo::GetContentInvalid() const
531 {
532     return contentInvalid_;
533 }
534 
SetError(const std::string & error)535 void AccessibilityElementInfo::SetError(const std::string &error)
536 {
537     error_ = error;
538 }
539 
GetError() const540 const std::string &AccessibilityElementInfo::GetError() const
541 {
542     return error_;
543 }
544 
SetLabeled(const int64_t componentId)545 void AccessibilityElementInfo::SetLabeled(const int64_t componentId)
546 {
547     labeled_ = componentId;
548 }
549 
GetLabeledAccessibilityId() const550 int64_t AccessibilityElementInfo::GetLabeledAccessibilityId() const
551 {
552     return labeled_;
553 }
554 
SetAccessibilityId(const int64_t componentId)555 void AccessibilityElementInfo::SetAccessibilityId(const int64_t componentId)
556 {
557     elementId_ = componentId;
558 }
559 
GetAccessibilityId() const560 int64_t AccessibilityElementInfo::GetAccessibilityId() const
561 {
562     return elementId_;
563 }
564 
GetRange() const565 const RangeInfo &AccessibilityElementInfo::GetRange() const
566 {
567     return rangeInfo_;
568 }
569 
SetRange(RangeInfo & rangeInfo)570 void AccessibilityElementInfo::SetRange(RangeInfo &rangeInfo)
571 {
572     rangeInfo_.SetMax(rangeInfo.GetMax());
573     rangeInfo_.SetMin(rangeInfo.GetMin());
574     rangeInfo_.SetCurrent(rangeInfo.GetCurrent());
575 }
576 
GetGrid() const577 const GridInfo &AccessibilityElementInfo::GetGrid() const
578 {
579     return grid_;
580 }
581 
SetGrid(const GridInfo & grid)582 void AccessibilityElementInfo::SetGrid(const GridInfo &grid)
583 {
584     grid_ = grid;
585 }
586 
GetGridItem() const587 const GridItemInfo &AccessibilityElementInfo::GetGridItem() const
588 {
589     return gridItem_;
590 }
591 
SetGridItem(const GridItemInfo & gridItem)592 void AccessibilityElementInfo::SetGridItem(const GridItemInfo &gridItem)
593 {
594     gridItem_ = gridItem;
595 }
596 
GetAccessibilityText() const597 const std::string &AccessibilityElementInfo::GetAccessibilityText() const
598 {
599     return accessibilityText_;
600 }
601 
SetAccessibilityText(const std::string & accessibilityText)602 void AccessibilityElementInfo::SetAccessibilityText(const std::string &accessibilityText)
603 {
604     accessibilityText_ = accessibilityText;
605 }
606 
SetTextType(const std::string & textType)607 void AccessibilityElementInfo::SetTextType(const std::string &textType)
608 {
609     textType_ = textType;
610 }
611 
GetTextType() const612 const std::string &AccessibilityElementInfo::GetTextType() const
613 {
614     return textType_;
615 }
616 
SetOffset(const float offset)617 void AccessibilityElementInfo::SetOffset(const float offset)
618 {
619     offset_ = offset;
620 }
621 
GetOffset() const622 float AccessibilityElementInfo::GetOffset() const
623 {
624     return offset_;
625 }
626 
AccessibilityElementInfo()627 AccessibilityElementInfo::AccessibilityElementInfo()
628 {
629 }
630 
AccessibleAction(ActionType actionType,const std::string & description)631 AccessibleAction::AccessibleAction(ActionType actionType, const std::string &description)
632 {
633     actionType_ = actionType;
634     description_ = description;
635 }
636 
GetActionType() const637 ActionType AccessibleAction::GetActionType() const
638 {
639     return actionType_;
640 }
641 
GetDescriptionInfo() const642 const std::string &AccessibleAction::GetDescriptionInfo() const
643 {
644     return description_;
645 }
646 
RangeInfo(double min,double max,double current)647 RangeInfo::RangeInfo(double min, double max, double current)
648 {
649     min_ = min;
650     max_ = max;
651     current_ = current;
652 }
653 
GetMin() const654 double RangeInfo::GetMin() const
655 {
656     return min_;
657 }
658 
GetMax() const659 double RangeInfo::GetMax() const
660 {
661     return max_;
662 }
663 
GetCurrent() const664 double RangeInfo::GetCurrent() const
665 {
666     return current_;
667 }
668 
SetMin(double min)669 void RangeInfo::SetMin(double min)
670 {
671     min_ = min;
672 }
673 
SetMax(double max)674 void RangeInfo::SetMax(double max)
675 {
676     max_ = max;
677 }
678 
SetCurrent(double current)679 void RangeInfo::SetCurrent(double current)
680 {
681     current_ = current;
682 }
683 
GridInfo(int32_t rowCount,int32_t columnCount,int32_t mode)684 GridInfo::GridInfo(int32_t rowCount, int32_t columnCount, int32_t mode)
685 {
686     rowCount_ = rowCount;
687     columnCount_ = columnCount;
688     selectionMode_ = mode;
689 }
690 
SetGrid(int32_t rowCount,int32_t columnCount,int32_t mode)691 void GridInfo::SetGrid(int32_t rowCount, int32_t columnCount, int32_t mode)
692 {
693     rowCount_ = rowCount;
694     columnCount_ = columnCount;
695     selectionMode_ = mode;
696 }
697 
SetGrid(GridInfo other)698 void GridInfo::SetGrid(GridInfo other)
699 {
700     rowCount_ = other.rowCount_;
701     columnCount_ = other.columnCount_;
702     selectionMode_ = other.selectionMode_;
703 }
704 
GetRowCount() const705 int32_t GridInfo::GetRowCount() const
706 {
707     return rowCount_;
708 }
709 
GetColumnCount() const710 int32_t GridInfo::GetColumnCount() const
711 {
712     return columnCount_;
713 }
714 
GetSelectionMode() const715 int32_t GridInfo::GetSelectionMode() const
716 {
717     return selectionMode_;
718 }
719 
GridItemInfo(int32_t rowIndex,int32_t rowSpan,int32_t columnIndex,int32_t columnSpan,bool heading,bool selected)720 GridItemInfo::GridItemInfo(int32_t rowIndex, int32_t rowSpan, int32_t columnIndex, int32_t columnSpan,
721     bool heading, bool selected)
722 {
723     rowIndex_ = rowIndex;
724     rowSpan_ = rowSpan;
725     columnIndex_ = columnIndex;
726     columnSpan_ = columnSpan;
727     heading_ = heading;
728     selected_ = selected;
729 }
730 
SetGridItemInfo(GridItemInfo other)731 void GridItemInfo::SetGridItemInfo(GridItemInfo other)
732 {
733     rowIndex_ = other.rowIndex_;
734     rowSpan_ = other.rowSpan_;
735     columnIndex_ = other.columnIndex_;
736     columnSpan_ = other.columnSpan_;
737     heading_ = other.heading_;
738     selected_ = other.selected_;
739 }
740 
SetGridItemInfo(int32_t rowIndex,int32_t rowSpan,int32_t columnIndex,int32_t columnSpan,bool heading,bool selected)741 void GridItemInfo::SetGridItemInfo(int32_t rowIndex, int32_t rowSpan, int32_t columnIndex,
742     int32_t columnSpan, bool heading, bool selected)
743 {
744     rowIndex_ = rowIndex;
745     rowSpan_ = rowSpan;
746     columnIndex_ = columnIndex;
747     columnSpan_ = columnSpan;
748     heading_ = heading;
749     selected_ = selected;
750 }
751 
GetColumnIndex() const752 int32_t GridItemInfo::GetColumnIndex() const
753 {
754     return columnIndex_;
755 }
756 
GetRowIndex() const757 int32_t GridItemInfo::GetRowIndex() const
758 {
759     return rowIndex_;
760 }
761 
GetColumnSpan() const762 int32_t GridItemInfo::GetColumnSpan() const
763 {
764     return columnSpan_;
765 }
766 
GetRowSpan() const767 int32_t GridItemInfo::GetRowSpan() const
768 {
769     return rowSpan_;
770 }
771 
IsHeading() const772 bool GridItemInfo::IsHeading() const
773 {
774     return heading_;
775 }
776 
IsSelected() const777 bool GridItemInfo::IsSelected() const
778 {
779     return selected_;
780 }
781 
GetPageId() const782 int32_t AccessibilityElementInfo::GetPageId() const
783 {
784     return pageId_;
785 }
786 
SetPageId(const int32_t pageId)787 void AccessibilityElementInfo::SetPageId(const int32_t pageId)
788 {
789     pageId_ = pageId;
790 }
791 
SetTextMovementStep(const TextMoveUnit granularity)792 void AccessibilityElementInfo::SetTextMovementStep(const TextMoveUnit granularity)
793 {
794     textMoveStep_ = granularity;
795 }
796 
GetTextMovementStep() const797 TextMoveUnit AccessibilityElementInfo::GetTextMovementStep() const
798 {
799     return textMoveStep_;
800 }
801 
SetItemCounts(const int32_t itemCounts)802 void AccessibilityElementInfo::SetItemCounts(const int32_t itemCounts)
803 {
804     itemCounts_ = itemCounts;
805 }
806 
GetItemCounts() const807 int32_t AccessibilityElementInfo::GetItemCounts() const
808 {
809     return itemCounts_;
810 }
811 
SetTriggerAction(const ActionType action)812 void AccessibilityElementInfo::SetTriggerAction(const ActionType action)
813 {
814     triggerAction_ = action;
815 }
816 
GetTriggerAction() const817 ActionType AccessibilityElementInfo::GetTriggerAction() const
818 {
819     return triggerAction_;
820 }
821 
SetContentList(const std::vector<std::string> & contentList)822 void AccessibilityElementInfo::SetContentList(const std::vector<std::string> &contentList)
823 {
824     contentList_.clear();
825     contentList_.resize(contentList.size());
826     std::copy(contentList.begin(), contentList.end(), contentList_.begin());
827 }
828 
GetContentList(std::vector<std::string> & contentList) const829 void AccessibilityElementInfo::GetContentList(std::vector<std::string> &contentList) const
830 {
831     contentList.clear();
832     contentList.resize(contentList_.size());
833     std::copy(contentList_.begin(), contentList_.end(), contentList.begin());
834 }
835 
SetLatestContent(const std::string & content)836 void AccessibilityElementInfo::SetLatestContent(const std::string &content)
837 {
838     latestContent_ = content;
839 }
840 
GetLatestContent() const841 const std::string &AccessibilityElementInfo::GetLatestContent() const
842 {
843     return latestContent_;
844 }
845 
SetChildTreeIdAndWinId(const int32_t iChildTreeId,const int32_t iChildWindowId)846 void AccessibilityElementInfo::SetChildTreeIdAndWinId(const int32_t iChildTreeId, const int32_t iChildWindowId)
847 {
848     childTreeId_ = iChildTreeId;
849     childWindowId_ = iChildWindowId;
850 }
851 
GetChildTreeId() const852 int32_t AccessibilityElementInfo::GetChildTreeId() const
853 {
854     return childTreeId_;
855 }
856 
GetChildWindowId() const857 int32_t AccessibilityElementInfo::GetChildWindowId() const
858 {
859     return childWindowId_;
860 }
861 
SetBelongTreeId(const int32_t iBelongTreeId)862 void AccessibilityElementInfo::SetBelongTreeId(const int32_t iBelongTreeId)
863 {
864     belongTreeId_ = iBelongTreeId;
865 }
866 
GetBelongTreeId() const867 int32_t AccessibilityElementInfo::GetBelongTreeId() const
868 {
869     return belongTreeId_;
870 }
871 
SetParentWindowId(const int32_t iParentWindowId)872 void AccessibilityElementInfo::SetParentWindowId(const int32_t iParentWindowId)
873 {
874     parentWindowId_ = iParentWindowId;
875 }
876 
GetParentWindowId() const877 int32_t AccessibilityElementInfo::GetParentWindowId() const
878 {
879     return parentWindowId_;
880 }
881 
ExtraElementInfo(const std::map<std::string,std::string> extraElementValueStr,const std::map<std::string,int32_t> extraElementValueInt)882 ExtraElementInfo::ExtraElementInfo(const std::map<std::string, std::string> extraElementValueStr,
883     const std::map<std::string, int32_t> extraElementValueInt)
884 {
885     extraElementValueStr_ = extraElementValueStr;
886     extraElementValueInt_ = extraElementValueInt;
887 }
888 
SetExtraElementInfo(const std::string keyStr,const std::string valueStr)889 RetError ExtraElementInfo::SetExtraElementInfo(const std::string keyStr, const std::string valueStr)
890 {
891     auto extraElementInfoIter = EXTRA_ELEMENTINFO_SET.find(keyStr);
892     if (extraElementInfoIter != EXTRA_ELEMENTINFO_SET.end()) {
893         extraElementValueStr_[keyStr] = valueStr;
894         HILOG_DEBUG("SetExtraElementInfo: size is extraElementValueStr : [%{public}zu]",
895             extraElementValueStr_.size());
896     } else {
897         return RET_ERR_FAILED;
898     }
899     return RET_OK;
900 }
901 
SetExtraElementInfo(const std::string keyStr,const int32_t valueInt)902 RetError ExtraElementInfo::SetExtraElementInfo(const std::string keyStr, const int32_t valueInt)
903 {
904     auto extraElementInfoIter = EXTRA_ELEMENTINFO_SET.find(keyStr);
905     if (extraElementInfoIter != EXTRA_ELEMENTINFO_SET.end()) {
906         extraElementValueInt_[keyStr] = valueInt;
907         HILOG_DEBUG("SetExtraElementInfo: size is extraElementValueInt : [%{public}zu]",
908             extraElementValueInt_.size());
909     } else {
910         return RET_ERR_FAILED;
911     }
912     return RET_OK;
913 }
914 
GetExtraElementInfoValueStr() const915 const std::map<std::string, std::string> &ExtraElementInfo::GetExtraElementInfoValueStr() const
916 {
917     return extraElementValueStr_;
918 }
919 
GetExtraElementInfoValueInt() const920 const std::map<std::string, int32_t> &ExtraElementInfo::GetExtraElementInfoValueInt() const
921 {
922     return extraElementValueInt_;
923 }
924 
SetExtraElement(const ExtraElementInfo & extraElementInfo)925 void AccessibilityElementInfo::SetExtraElement(const ExtraElementInfo &extraElementInfo)
926 {
927     extraElementInfo_ = extraElementInfo;
928 }
929 
GetExtraElement() const930 const ExtraElementInfo &AccessibilityElementInfo::GetExtraElement() const
931 {
932     return extraElementInfo_;
933 }
GetAccessibilityLevel() const934 const std::string &AccessibilityElementInfo::GetAccessibilityLevel() const
935 {
936     return accessibilityLevel_;
937 }
938 
GetAccessibilityGroup() const939 bool AccessibilityElementInfo::GetAccessibilityGroup() const
940 {
941     return accessibilityGroup_;
942 }
943 
SetAccessibilityGroup(const bool accessibilityGroup)944 void AccessibilityElementInfo::SetAccessibilityGroup(const bool accessibilityGroup)
945 {
946     accessibilityGroup_ = accessibilityGroup;
947 }
948 
SetAccessibilityLevel(const std::string accessibilityLevel)949 void AccessibilityElementInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
950 {
951     accessibilityLevel_ = accessibilityLevel;
952 }
953 
SetZIndex(const int32_t zIndex)954 void AccessibilityElementInfo::SetZIndex(const int32_t zIndex)
955 {
956     zIndex_ = zIndex;
957 }
958 
GetZIndex() const959 int32_t AccessibilityElementInfo::GetZIndex() const
960 {
961     return zIndex_;
962 }
963 
SetOpacity(const float opacity)964 void AccessibilityElementInfo::SetOpacity(const float opacity)
965 {
966     opacity_ = opacity;
967 }
968 
GetOpacity() const969 float AccessibilityElementInfo::GetOpacity() const
970 {
971     return opacity_;
972 }
973 
SetBackgroundColor(const std::string & backgroundColor)974 void AccessibilityElementInfo::SetBackgroundColor(const std::string &backgroundColor)
975 {
976     backgroundColor_ = backgroundColor;
977 }
978 
GetBackgroundColor() const979 const std::string &AccessibilityElementInfo::GetBackgroundColor() const
980 {
981     return backgroundColor_;
982 }
983 
SetBackgroundImage(const std::string & backgroundImage)984 void AccessibilityElementInfo::SetBackgroundImage(const std::string &backgroundImage)
985 {
986     if (backgroundImage.length() > backgroundImageMaxLength) {
987         backgroundImage_ = "true";
988     } else {
989         backgroundImage_ = backgroundImage;
990     }
991 }
992 
GetBackgroundImage() const993 const std::string &AccessibilityElementInfo::GetBackgroundImage() const
994 {
995     return backgroundImage_;
996 }
997 
SetBlur(const std::string & blur)998 void AccessibilityElementInfo::SetBlur(const std::string &blur)
999 {
1000     blur_ = blur;
1001 }
1002 
GetBlur() const1003 const std::string &AccessibilityElementInfo::GetBlur() const
1004 {
1005     return blur_;
1006 }
1007 
SetHitTestBehavior(const std::string & hitTestBehavior)1008 void AccessibilityElementInfo::SetHitTestBehavior(const std::string &hitTestBehavior)
1009 {
1010     hitTestBehavior_ = hitTestBehavior;
1011 }
1012 
GetHitTestBehavior() const1013 const std::string &AccessibilityElementInfo::GetHitTestBehavior() const
1014 {
1015     return hitTestBehavior_;
1016 }
1017 
SetNavDestinationId(const int64_t navDestinationId)1018 void AccessibilityElementInfo::SetNavDestinationId(const int64_t navDestinationId)
1019 {
1020     navDestinationId_ = navDestinationId;
1021 }
1022 
GetNavDestinationId() const1023 int64_t AccessibilityElementInfo::GetNavDestinationId() const
1024 {
1025     return navDestinationId_;
1026 }
1027 
AddSpan(const SpanInfo & span)1028 void AccessibilityElementInfo::AddSpan(const SpanInfo &span)
1029 {
1030     spanList_.push_back(span);
1031     for (auto array: spanList_) {
1032         HILOG_INFO("AddSpanListsize:spanId: %{public}d, spanText: %{public}s, accessibilityText: %{public}s,"
1033             "accessibilityDescription: %{public}s, accessibilityLevel: %{public}s", span.GetSpanId(),
1034             span.GetSpanText().c_str(), span.GetAccessibilityText().c_str(), span.GetAccessibilityDescription().c_str(),
1035             span.GetAccessibilityLevel().c_str());
1036     }
1037 }
1038 
SetSpanList(const std::vector<SpanInfo> & spanList)1039 void AccessibilityElementInfo::SetSpanList(const std::vector<SpanInfo> &spanList)
1040 {
1041     spanList_.clear();
1042     spanList_.resize(spanList.size());
1043     std::copy(spanList.begin(), spanList.end(), spanList_.begin());
1044 }
1045 
GetSpanList() const1046 const std::vector<SpanInfo> &AccessibilityElementInfo::GetSpanList() const
1047 {
1048     return spanList_;
1049 }
1050 
SpanInfo(const int32_t & spanId,const std::string & spanText,const std::string & accessibilityText,const std::string & accessibilityDescription,const std::string & accessibilityLevel)1051 SpanInfo::SpanInfo(const int32_t &spanId, const std::string &spanText, const std::string &accessibilityText,
1052     const std::string &accessibilityDescription, const std::string &accessibilityLevel)
1053 {
1054     spanId_ = spanId;
1055     spanText_ = spanText;
1056     accessibilityText_ = accessibilityText;
1057     accessibilityDescription_ = accessibilityDescription;
1058     accessibilityLevel_ = accessibilityLevel;
1059 }
1060 
SetSpanId(const int32_t spanId)1061 void SpanInfo::SetSpanId(const int32_t spanId)
1062 {
1063     spanId_ = spanId;
1064 }
1065 
SetSpanText(const std::string spanText)1066 void SpanInfo::SetSpanText(const std::string spanText)
1067 {
1068     spanText_ = spanText;
1069 }
1070 
SetAccessibilityText(const std::string accessibilityText)1071 void SpanInfo::SetAccessibilityText(const std::string accessibilityText)
1072 {
1073     accessibilityText_ = accessibilityText;
1074 }
1075 
SetAccessibilityDescription(const std::string accessibilityDescription)1076 void SpanInfo::SetAccessibilityDescription(const std::string accessibilityDescription)
1077 {
1078     accessibilityDescription_ = accessibilityDescription;
1079 }
1080 
SetAccessibilityLevel(const std::string accessibilityLevel)1081 void SpanInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
1082 {
1083     accessibilityLevel_ = accessibilityLevel;
1084 }
1085 
GetSpanId() const1086 int32_t SpanInfo::GetSpanId() const
1087 {
1088     return spanId_;
1089 }
1090 
GetSpanText() const1091 const std::string &SpanInfo::GetSpanText() const
1092 {
1093     return spanText_;
1094 }
1095 
GetAccessibilityText() const1096 const std::string &SpanInfo::GetAccessibilityText() const
1097 {
1098     return accessibilityText_;
1099 }
1100 
GetAccessibilityDescription() const1101 const std::string &SpanInfo::GetAccessibilityDescription() const
1102 {
1103     return accessibilityDescription_;
1104 }
1105 
GetAccessibilityLevel() const1106 const std::string &SpanInfo::GetAccessibilityLevel() const
1107 {
1108     return accessibilityLevel_;
1109 }
1110 
GetIsActive() const1111 bool AccessibilityElementInfo::GetIsActive() const
1112 {
1113     return isActive_;
1114 }
1115 
SetIsActive(const bool isActive)1116 void AccessibilityElementInfo::SetIsActive(const bool isActive)
1117 {
1118     isActive_ = isActive;
1119 }
1120 
GetAccessibilityVisible() const1121 bool AccessibilityElementInfo::GetAccessibilityVisible() const
1122 {
1123     return accessibilityVisible_;
1124 }
1125 
SetAccessibilityVisible(const bool accessibilityVisible)1126 void AccessibilityElementInfo::SetAccessibilityVisible(const bool accessibilityVisible)
1127 {
1128     accessibilityVisible_ = accessibilityVisible;
1129 }
1130 
GetClip() const1131 bool AccessibilityElementInfo::GetClip() const
1132 {
1133     return clip_;
1134 }
1135 
SetClip(const bool clip)1136 void AccessibilityElementInfo::SetClip(const bool clip)
1137 {
1138     clip_ = clip;
1139 }
1140 
GetCustomComponentType() const1141 const std::string &AccessibilityElementInfo::GetCustomComponentType() const
1142 {
1143     return customComponentType_;
1144 }
1145 
SetCustomComponentType(const std::string & customComponentType)1146 void AccessibilityElementInfo::SetCustomComponentType(const std::string &customComponentType)
1147 {
1148     customComponentType_ = customComponentType;
1149 }
1150 
GetAccessibilityNextFocusId() const1151 int64_t AccessibilityElementInfo::GetAccessibilityNextFocusId() const
1152 {
1153     return accessibilityNextFocusId_;
1154 }
1155 
SetAccessibilityNextFocusId(const int64_t accessibilityNextFocusId)1156 void AccessibilityElementInfo::SetAccessibilityNextFocusId(const int64_t accessibilityNextFocusId)
1157 {
1158     accessibilityNextFocusId_ = accessibilityNextFocusId;
1159 }
1160 
GetAccessibilityPreviousFocusId() const1161 int64_t AccessibilityElementInfo::GetAccessibilityPreviousFocusId() const
1162 {
1163     return accessibilityPreviousFocusId_;
1164 }
1165 
SetAccessibilityPreviousFocusId(const int64_t accessibilityPreviousFocusId)1166 void AccessibilityElementInfo::SetAccessibilityPreviousFocusId(const int64_t accessibilityPreviousFocusId)
1167 {
1168     accessibilityPreviousFocusId_ = accessibilityPreviousFocusId;
1169 }
1170 
GetAccessibilityNextFocusInspectorKey() const1171 const std::string &AccessibilityElementInfo::GetAccessibilityNextFocusInspectorKey() const
1172 {
1173     return accessibilityNextFocusInspectorKey_;
1174 }
1175 
SetAccessibilityNextFocusInspectorKey(const std::string & accessibilityNextFocusInspectorKey)1176 void AccessibilityElementInfo::SetAccessibilityNextFocusInspectorKey(const
1177     std::string &accessibilityNextFocusInspectorKey)
1178 {
1179     accessibilityNextFocusInspectorKey_ = accessibilityNextFocusInspectorKey;
1180 }
1181 
GetAccessibilityScrollable() const1182 bool AccessibilityElementInfo::GetAccessibilityScrollable() const
1183 {
1184     return accessibilityScrollable_;
1185 }
1186 
SetAccessibilityScrollable(const bool accessibilityScrollable)1187 void AccessibilityElementInfo::SetAccessibilityScrollable(const bool accessibilityScrollable)
1188 {
1189     accessibilityScrollable_ = accessibilityScrollable;
1190 }
1191 
GetUniqueId() const1192 int64_t AccessibilityElementInfo::GetUniqueId() const
1193 {
1194     return uniqueId_;
1195 }
1196 
SetUniqueId(const int64_t uniqueId)1197 void AccessibilityElementInfo::SetUniqueId(const int64_t uniqueId)
1198 {
1199     uniqueId_ = uniqueId;
1200 }
1201 
GetOriginalText() const1202 const std::string &AccessibilityElementInfo::GetOriginalText() const
1203 {
1204     return originalText_;
1205 }
1206 
SetOriginalText(const std::string & originalText)1207 void AccessibilityElementInfo::SetOriginalText(const std::string &originalText)
1208 {
1209     originalText_ = originalText;
1210 }
1211 } // namespace Accessibility
1212 } // namespace OHOS