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
20namespace OHOS {
21namespace Accessibility {
22void AccessibilityElementInfo::SetComponentId(const int64_t componentId)
23{
24    elementId_ = componentId;
25}
26
27int64_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
36int32_t AccessibilityElementInfo::GetChildCount() const
37{
38    return childCount_;
39}
40
41const std::vector<int64_t> &AccessibilityElementInfo::GetChildIds() const
42{
43    return childNodeIds_;
44}
45
46void 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
58bool 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
71const std::vector<AccessibleAction> &AccessibilityElementInfo::GetActionList() const
72{
73    return operations_;
74}
75
76void AccessibilityElementInfo::AddAction(AccessibleAction &action)
77{
78    operations_.push_back(action);
79}
80
81void 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
92bool 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
104void AccessibilityElementInfo::DeleteAllActions()
105{
106    operations_.clear();
107}
108
109void AccessibilityElementInfo::SetTextLengthLimit(const int32_t max)
110{
111    textLengthLimit_ = max;
112}
113
114int32_t AccessibilityElementInfo::GetTextLengthLimit() const
115{
116    return textLengthLimit_;
117}
118
119int32_t AccessibilityElementInfo::GetWindowId() const
120{
121    return windowId_;
122}
123
124void AccessibilityElementInfo::SetWindowId(const int32_t windowId)
125{
126    windowId_ = windowId;
127}
128
129int64_t AccessibilityElementInfo::GetParentNodeId() const
130{
131    return parentId_;
132}
133
134void AccessibilityElementInfo::SetParent(const int64_t parentId)
135{
136    parentId_ = parentId;
137}
138
139const Rect &AccessibilityElementInfo::GetRectInScreen() const
140{
141    return bounds_;
142}
143
144void AccessibilityElementInfo::SetRectInScreen(Rect &bounds)
145{
146    bounds_.SetLeftTopScreenPostion(bounds.GetLeftTopXScreenPostion(), bounds.GetLeftTopYScreenPostion());
147    bounds_.SetRightBottomScreenPostion(bounds.GetRightBottomXScreenPostion(), bounds.GetRightBottomYScreenPostion());
148}
149
150bool AccessibilityElementInfo::IsCheckable() const
151{
152    return checkable_;
153}
154
155void AccessibilityElementInfo::SetCheckable(const bool checkable)
156{
157    checkable_ = checkable;
158}
159
160bool AccessibilityElementInfo::IsChecked() const
161{
162    return checked_;
163}
164
165void AccessibilityElementInfo::SetChecked(const bool checked)
166{
167    checked_ = checked;
168}
169
170bool AccessibilityElementInfo::IsFocusable() const
171{
172    return focusable_;
173}
174
175void AccessibilityElementInfo::SetFocusable(const bool focusable)
176{
177    focusable_ = focusable;
178}
179
180bool AccessibilityElementInfo::IsFocused() const
181{
182    return focused_;
183}
184
185void AccessibilityElementInfo::SetFocused(const bool focused)
186{
187    focused_ = focused;
188}
189
190bool AccessibilityElementInfo::IsVisible() const
191{
192    return visible_;
193}
194
195void AccessibilityElementInfo::SetVisible(const bool visible)
196{
197    visible_ = visible;
198}
199
200bool AccessibilityElementInfo::HasAccessibilityFocus() const
201{
202    return accessibilityFocused_;
203}
204
205void AccessibilityElementInfo::SetAccessibilityFocus(const bool focused)
206{
207    accessibilityFocused_ = focused;
208}
209
210bool AccessibilityElementInfo::IsSelected() const
211{
212    return selected_;
213}
214
215void AccessibilityElementInfo::SetSelected(const bool selected)
216{
217    selected_ = selected;
218}
219
220bool AccessibilityElementInfo::IsClickable() const
221{
222    return clickable_;
223}
224
225void AccessibilityElementInfo::SetClickable(const bool clickable)
226{
227    clickable_ = clickable;
228}
229
230bool AccessibilityElementInfo::IsLongClickable() const
231{
232    return longClickable_;
233}
234
235void AccessibilityElementInfo::SetLongClickable(const bool longClickable)
236{
237    longClickable_ = longClickable;
238}
239
240bool AccessibilityElementInfo::IsEnabled() const
241{
242    return enable_;
243}
244
245void AccessibilityElementInfo::SetEnabled(const bool enabled)
246{
247    enable_ = enabled;
248}
249
250bool AccessibilityElementInfo::IsPassword() const
251{
252    return isPassword_;
253}
254
255void AccessibilityElementInfo::SetPassword(const bool type)
256{
257    isPassword_ = type;
258}
259
260bool AccessibilityElementInfo::IsScrollable() const
261{
262    return scrollable_;
263}
264
265void AccessibilityElementInfo::SetScrollable(const bool scrollable)
266{
267    scrollable_ = scrollable;
268}
269
270int32_t AccessibilityElementInfo::GetCurrentIndex() const
271{
272    return currentIndex_;
273}
274
275void AccessibilityElementInfo::SetCurrentIndex(const int32_t index)
276{
277    currentIndex_ = index;
278}
279
280int32_t AccessibilityElementInfo::GetBeginIndex() const
281{
282    return beginIndex_;
283}
284
285void AccessibilityElementInfo::SetBeginIndex(const int32_t index)
286{
287    beginIndex_ = index;
288}
289
290int32_t AccessibilityElementInfo::GetEndIndex() const
291{
292    return endIndex_;
293}
294
295void AccessibilityElementInfo::SetEndIndex(const int32_t index)
296{
297    endIndex_ = index;
298}
299
300int32_t AccessibilityElementInfo::GetInputType() const
301{
302    return inputType_;
303}
304
305void AccessibilityElementInfo::SetInputType(const int32_t inputType)
306{
307    inputType_ = inputType;
308}
309
310void AccessibilityElementInfo::SetValidElement(const bool valid)
311{
312    validElement_ = valid;
313}
314
315void AccessibilityElementInfo::SetInspectorKey(const std::string &key)
316{
317    inspectorKey_ = key;
318}
319
320const std::string &AccessibilityElementInfo::GetInspectorKey() const
321{
322    return inspectorKey_;
323}
324
325void AccessibilityElementInfo::SetPagePath(const std::string &path)
326{
327    pagePath_ = path;
328}
329
330const std::string &AccessibilityElementInfo::GetPagePath() const
331{
332    return pagePath_;
333}
334
335bool AccessibilityElementInfo::IsValidElement() const
336{
337    return validElement_;
338}
339
340bool AccessibilityElementInfo::IsEditable() const
341{
342    return editable_;
343}
344
345void AccessibilityElementInfo::SetEditable(const bool editable)
346{
347    editable_ = editable;
348}
349
350bool AccessibilityElementInfo::IsPluraLineSupported() const
351{
352    return multiLine_;
353}
354
355void AccessibilityElementInfo::SetPluraLineSupported(const bool multiLine)
356{
357    multiLine_ = multiLine;
358}
359
360bool AccessibilityElementInfo::IsPopupSupported() const
361{
362    return popupSupported_;
363}
364
365void AccessibilityElementInfo::SetPopupSupported(const bool supportPopup)
366{
367    popupSupported_ = supportPopup;
368}
369
370bool AccessibilityElementInfo::IsDeletable() const
371{
372    return deletable_;
373}
374
375void AccessibilityElementInfo::SetDeletable(const bool deletable)
376{
377    deletable_ = deletable;
378}
379
380bool AccessibilityElementInfo::IsEssential() const
381{
382    return isEssential_;
383}
384
385void AccessibilityElementInfo::SetEssential(const bool essential)
386{
387    isEssential_ = essential;
388}
389
390bool AccessibilityElementInfo::IsGivingHint() const
391{
392    return hint_;
393}
394void AccessibilityElementInfo::SetHinting(const bool hinting)
395{
396    hint_ = hinting;
397}
398
399const std::string &AccessibilityElementInfo::GetBundleName() const
400{
401    return bundleName_;
402}
403
404void AccessibilityElementInfo::SetBundleName(const std::string &bundleName)
405{
406    bundleName_ = bundleName;
407}
408
409const std::string &AccessibilityElementInfo::GetComponentType() const
410{
411    return componentType_;
412}
413
414void AccessibilityElementInfo::SetComponentType(const std::string &className)
415{
416    componentType_ = className;
417}
418
419const std::string &AccessibilityElementInfo::GetContent() const
420{
421    return text_;
422}
423
424void AccessibilityElementInfo::SetContent(const std::string &text)
425{
426    text_ = text;
427}
428
429void AccessibilityElementInfo::SetSelectedBegin(const int32_t start)
430{
431    beginSelected_ = start;
432}
433
434int32_t AccessibilityElementInfo::GetSelectedBegin() const
435{
436    return beginSelected_;
437}
438
439void AccessibilityElementInfo::SetSelectedEnd(const int32_t end)
440{
441    endSelected_ = end;
442}
443
444int32_t AccessibilityElementInfo::GetSelectedEnd() const
445{
446    return endSelected_;
447}
448
449const std::string &AccessibilityElementInfo::GetHint() const
450{
451    return hintText_;
452}
453
454void AccessibilityElementInfo::SetHint(const std::string &hintText)
455{
456    hintText_ = hintText;
457}
458
459const std::string &AccessibilityElementInfo::GetDescriptionInfo() const
460{
461    return contentDescription_;
462}
463
464void AccessibilityElementInfo::SetDescriptionInfo(const std::string &contentDescription)
465{
466    contentDescription_ = contentDescription;
467}
468
469void AccessibilityElementInfo::SetComponentResourceId(const std::string &viewIdResName)
470{
471    resourceName_ = viewIdResName;
472}
473
474const std::string &AccessibilityElementInfo::GetComponentResourceId() const
475{
476    return resourceName_;
477}
478
479void AccessibilityElementInfo::SetLiveRegion(const int32_t liveRegion)
480{
481    liveRegion_ = liveRegion;
482}
483
484int32_t AccessibilityElementInfo::GetLiveRegion() const
485{
486    return liveRegion_;
487}
488
489void AccessibilityElementInfo::SetContentInvalid(const bool contentInvalid)
490{
491    contentInvalid_ = contentInvalid;
492}
493
494bool AccessibilityElementInfo::GetContentInvalid() const
495{
496    return contentInvalid_;
497}
498
499void AccessibilityElementInfo::SetError(const std::string &error)
500{
501    error_ = error;
502}
503
504const std::string &AccessibilityElementInfo::GetError() const
505{
506    return error_;
507}
508
509void AccessibilityElementInfo::SetLabeled(const int64_t componentId)
510{
511    labeled_ = componentId;
512}
513
514int64_t AccessibilityElementInfo::GetLabeledAccessibilityId() const
515{
516    return labeled_;
517}
518
519void AccessibilityElementInfo::SetAccessibilityId(const int64_t componentId)
520{
521    elementId_ = componentId;
522}
523
524int64_t AccessibilityElementInfo::GetAccessibilityId() const
525{
526    return elementId_;
527}
528
529const RangeInfo &AccessibilityElementInfo::GetRange() const
530{
531    return rangeInfo_;
532}
533
534void AccessibilityElementInfo::SetRange(RangeInfo &rangeInfo)
535{
536    rangeInfo_.SetMax(rangeInfo.GetMax());
537    rangeInfo_.SetMin(rangeInfo.GetMin());
538    rangeInfo_.SetCurrent(rangeInfo.GetCurrent());
539}
540
541const GridInfo &AccessibilityElementInfo::GetGrid() const
542{
543    return grid_;
544}
545
546void AccessibilityElementInfo::SetGrid(const GridInfo &grid)
547{
548    grid_ = grid;
549}
550
551const GridItemInfo &AccessibilityElementInfo::GetGridItem() const
552{
553    return gridItem_;
554}
555
556void AccessibilityElementInfo::SetGridItem(const GridItemInfo &gridItem)
557{
558    gridItem_ = gridItem;
559}
560
561const std::string &AccessibilityElementInfo::GetAccessibilityText() const
562{
563    return accessibilityText_;
564}
565
566void AccessibilityElementInfo::SetAccessibilityText(const std::string &accessibilityText)
567{
568    accessibilityText_ = accessibilityText;
569}
570
571void AccessibilityElementInfo::SetTextType(const std::string &textType)
572{
573    textType_ = textType;
574}
575
576const std::string &AccessibilityElementInfo::GetTextType() const
577{
578    return textType_;
579}
580
581void AccessibilityElementInfo::SetOffset(const float offset)
582{
583    offset_ = offset;
584}
585
586float AccessibilityElementInfo::GetOffset() const
587{
588    return offset_;
589}
590
591AccessibilityElementInfo::AccessibilityElementInfo()
592{
593}
594
595AccessibleAction::AccessibleAction(ActionType actionType, const std::string &description)
596{
597    actionType_ = actionType;
598    description_ = description;
599}
600
601ActionType AccessibleAction::GetActionType() const
602{
603    return actionType_;
604}
605
606const std::string &AccessibleAction::GetDescriptionInfo() const
607{
608    return description_;
609}
610
611RangeInfo::RangeInfo(double min, double max, double current)
612{
613    min_ = min;
614    max_ = max;
615    current_ = current;
616}
617
618double RangeInfo::GetMin() const
619{
620    return min_;
621}
622
623double RangeInfo::GetMax() const
624{
625    return max_;
626}
627
628double RangeInfo::GetCurrent() const
629{
630    return current_;
631}
632
633void RangeInfo::SetMin(double min)
634{
635    min_ = min;
636}
637
638void RangeInfo::SetMax(double max)
639{
640    max_ = max;
641}
642
643void RangeInfo::SetCurrent(double current)
644{
645    current_ = current;
646}
647
648GridInfo::GridInfo(int32_t rowCount, int32_t columnCount, int32_t mode)
649{
650    rowCount_ = rowCount;
651    columnCount_ = columnCount;
652    selectionMode_ = mode;
653}
654
655void GridInfo::SetGrid(int32_t rowCount, int32_t columnCount, int32_t mode)
656{
657    rowCount_ = rowCount;
658    columnCount_ = columnCount;
659    selectionMode_ = mode;
660}
661
662void GridInfo::SetGrid(GridInfo other)
663{
664    rowCount_ = other.rowCount_;
665    columnCount_ = other.columnCount_;
666    selectionMode_ = other.selectionMode_;
667}
668
669int32_t GridInfo::GetRowCount() const
670{
671    return rowCount_;
672}
673
674int32_t GridInfo::GetColumnCount() const
675{
676    return columnCount_;
677}
678
679int32_t GridInfo::GetSelectionMode() const
680{
681    return selectionMode_;
682}
683
684GridItemInfo::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
695void 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
705void 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
716int32_t GridItemInfo::GetColumnIndex() const
717{
718    return columnIndex_;
719}
720
721int32_t GridItemInfo::GetRowIndex() const
722{
723    return rowIndex_;
724}
725
726int32_t GridItemInfo::GetColumnSpan() const
727{
728    return columnSpan_;
729}
730
731int32_t GridItemInfo::GetRowSpan() const
732{
733    return rowSpan_;
734}
735
736bool GridItemInfo::IsHeading() const
737{
738    return heading_;
739}
740
741bool GridItemInfo::IsSelected() const
742{
743    return selected_;
744}
745
746int32_t AccessibilityElementInfo::GetPageId() const
747{
748    return pageId_;
749}
750
751void AccessibilityElementInfo::SetPageId(const int32_t pageId)
752{
753    pageId_ = pageId;
754}
755
756void AccessibilityElementInfo::SetTextMovementStep(const TextMoveUnit granularity)
757{
758    textMoveStep_ = granularity;
759}
760
761TextMoveUnit AccessibilityElementInfo::GetTextMovementStep() const
762{
763    return textMoveStep_;
764}
765
766void AccessibilityElementInfo::SetItemCounts(const int32_t itemCounts)
767{
768    itemCounts_ = itemCounts;
769}
770
771int32_t AccessibilityElementInfo::GetItemCounts() const
772{
773    return itemCounts_;
774}
775
776void AccessibilityElementInfo::SetTriggerAction(const ActionType action)
777{
778    triggerAction_ = action;
779}
780
781ActionType AccessibilityElementInfo::GetTriggerAction() const
782{
783    return triggerAction_;
784}
785
786void 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
793void 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
800void AccessibilityElementInfo::SetLatestContent(const std::string &content)
801{
802    latestContent_ = content;
803}
804
805const std::string &AccessibilityElementInfo::GetLatestContent() const
806{
807    return latestContent_;
808}
809
810void AccessibilityElementInfo::SetChildTreeIdAndWinId(const int32_t iChildTreeId, const int32_t iChildWindowId)
811{
812    childTreeId_ = iChildTreeId;
813    childWindowId_ = iChildWindowId;
814}
815
816int32_t AccessibilityElementInfo::GetChildTreeId() const
817{
818    return childTreeId_;
819}
820
821int32_t AccessibilityElementInfo::GetChildWindowId() const
822{
823    return childWindowId_;
824}
825
826void AccessibilityElementInfo::SetBelongTreeId(const int32_t iBelongTreeId)
827{
828    belongTreeId_ = iBelongTreeId;
829}
830
831int32_t AccessibilityElementInfo::GetBelongTreeId() const
832{
833    return belongTreeId_;
834}
835
836void AccessibilityElementInfo::SetParentWindowId(const int32_t iParentWindowId)
837{
838    parentWindowId_ = iParentWindowId;
839}
840
841int32_t AccessibilityElementInfo::GetParentWindowId() const
842{
843    return parentWindowId_;
844}
845
846ExtraElementInfo::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
853RetError 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
866RetError 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
879const std::map<std::string, std::string> &ExtraElementInfo::GetExtraElementInfoValueStr() const
880{
881    return extraElementValueStr_;
882}
883
884const std::map<std::string, int32_t> &ExtraElementInfo::GetExtraElementInfoValueInt() const
885{
886    return extraElementValueInt_;
887}
888
889void AccessibilityElementInfo::SetExtraElement(const ExtraElementInfo &extraElementInfo)
890{
891    extraElementInfo_ = extraElementInfo;
892}
893
894const ExtraElementInfo &AccessibilityElementInfo::GetExtraElement() const
895{
896    return extraElementInfo_;
897}
898const std::string &AccessibilityElementInfo::GetAccessibilityLevel() const
899{
900    return accessibilityLevel_;
901}
902
903bool AccessibilityElementInfo::GetAccessibilityGroup() const
904{
905    return accessibilityGroup_;
906}
907
908void AccessibilityElementInfo::SetAccessibilityGroup(const bool accessibilityGroup)
909{
910    accessibilityGroup_ = accessibilityGroup;
911}
912
913void AccessibilityElementInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
914{
915    accessibilityLevel_ = accessibilityLevel;
916}
917
918void AccessibilityElementInfo::SetZIndex(const int32_t zIndex)
919{
920    zIndex_ = zIndex;
921}
922
923int32_t AccessibilityElementInfo::GetZIndex() const
924{
925    return zIndex_;
926}
927
928void AccessibilityElementInfo::SetOpacity(const float opacity)
929{
930    opacity_ = opacity;
931}
932
933float AccessibilityElementInfo::GetOpacity() const
934{
935    return opacity_;
936}
937
938void AccessibilityElementInfo::SetBackgroundColor(const std::string &backgroundColor)
939{
940    backgroundColor_ = backgroundColor;
941}
942
943const std::string &AccessibilityElementInfo::GetBackgroundColor() const
944{
945    return backgroundColor_;
946}
947
948void AccessibilityElementInfo::SetBackgroundImage(const std::string &backgroundImage)
949{
950    if (backgroundImage.length() > backgroundImageMaxLength) {
951        backgroundImage_ = "true";
952    } else {
953        backgroundImage_ = backgroundImage;
954    }
955}
956
957const std::string &AccessibilityElementInfo::GetBackgroundImage() const
958{
959    return backgroundImage_;
960}
961
962void AccessibilityElementInfo::SetBlur(const std::string &blur)
963{
964    blur_ = blur;
965}
966
967const std::string &AccessibilityElementInfo::GetBlur() const
968{
969    return blur_;
970}
971
972void AccessibilityElementInfo::SetHitTestBehavior(const std::string &hitTestBehavior)
973{
974    hitTestBehavior_ = hitTestBehavior;
975}
976
977const std::string &AccessibilityElementInfo::GetHitTestBehavior() const
978{
979    return hitTestBehavior_;
980}
981
982void AccessibilityElementInfo::SetNavDestinationId(const int64_t navDestinationId)
983{
984    navDestinationId_ = navDestinationId;
985}
986
987int64_t AccessibilityElementInfo::GetNavDestinationId() const
988{
989    return navDestinationId_;
990}
991
992void 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
1003void 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
1010const std::vector<SpanInfo> &AccessibilityElementInfo::GetSpanList() const
1011{
1012    return spanList_;
1013}
1014
1015SpanInfo::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
1025void SpanInfo::SetSpanId(const int32_t spanId)
1026{
1027    spanId_ = spanId;
1028}
1029
1030void SpanInfo::SetSpanText(const std::string spanText)
1031{
1032    spanText_ = spanText;
1033}
1034
1035void SpanInfo::SetAccessibilityText(const std::string accessibilityText)
1036{
1037    accessibilityText_ = accessibilityText;
1038}
1039
1040void SpanInfo::SetAccessibilityDescription(const std::string accessibilityDescription)
1041{
1042    accessibilityDescription_ = accessibilityDescription;
1043}
1044
1045void SpanInfo::SetAccessibilityLevel(const std::string accessibilityLevel)
1046{
1047    accessibilityLevel_ = accessibilityLevel;
1048}
1049
1050int32_t SpanInfo::GetSpanId() const
1051{
1052    return spanId_;
1053}
1054
1055const std::string &SpanInfo::GetSpanText() const
1056{
1057    return spanText_;
1058}
1059
1060const std::string &SpanInfo::GetAccessibilityText() const
1061{
1062    return accessibilityText_;
1063}
1064
1065const std::string &SpanInfo::GetAccessibilityDescription() const
1066{
1067    return accessibilityDescription_;
1068}
1069
1070const std::string &SpanInfo::GetAccessibilityLevel() const
1071{
1072    return accessibilityLevel_;
1073}
1074
1075bool AccessibilityElementInfo::GetIsActive() const
1076{
1077    return isActive_;
1078}
1079
1080void AccessibilityElementInfo::SetIsActive(const bool isActive)
1081{
1082    isActive_ = isActive;
1083}
1084
1085bool AccessibilityElementInfo::GetAccessibilityVisible() const
1086{
1087    return accessibilityVisible_;
1088}
1089
1090void AccessibilityElementInfo::SetAccessibilityVisible(const bool accessibilityVisible)
1091{
1092    accessibilityVisible_ = accessibilityVisible;
1093}
1094
1095bool AccessibilityElementInfo::GetClip() const
1096{
1097    return clip_;
1098}
1099
1100void AccessibilityElementInfo::SetClip(const bool clip)
1101{
1102    clip_ = clip;
1103}
1104} // namespace Accessibility
1105} // namespace OHOS