1 /*
2  * Copyright (c) 2021-2023 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 "core/components_v2/inspector/inspector_composed_component.h"
17 
18 #include <unordered_map>
19 
20 #include "base/utils/string_utils.h"
21 #include "core/common/container.h"
22 #include "core/components_v2/inspector/actionsheetdialog_composed_element.h"
23 #include "core/components_v2/inspector/alertdialog_composed_element.h"
24 #include "core/components_v2/inspector/badge_composed_element.h"
25 #include "core/components_v2/inspector/blank_composed_element.h"
26 #include "core/components_v2/inspector/button_composed_element.h"
27 #include "core/components_v2/inspector/calendar_composed_element.h"
28 #include "core/components_v2/inspector/checkboxGroup_composed_element.h"
29 #include "core/components_v2/inspector/checkbox_composed_element.h"
30 #include "core/components_v2/inspector/column_composed_element.h"
31 #include "core/components_v2/inspector/column_split_composed_element.h"
32 #include "core/components_v2/inspector/counter_composed_element.h"
33 #include "core/components_v2/inspector/customdialog_composed_element.h"
34 #include "core/components_v2/inspector/data_panel_composed_element.h"
35 #include "core/components_v2/inspector/date_picker_composed_element.h"
36 #include "core/components_v2/inspector/date_picker_dialog_composed_element.h"
37 #include "core/components_v2/inspector/divider_composed_element.h"
38 #include "core/components_v2/inspector/flex_composed_element.h"
39 #include "core/components_v2/inspector/gauge_composed_element.h"
40 #include "core/components_v2/inspector/grid_col_composed_element.h"
41 #include "core/components_v2/inspector/grid_composed_element.h"
42 #include "core/components_v2/inspector/grid_container_composed_element.h"
43 #include "core/components_v2/inspector/grid_item_composed_element.h"
44 #include "core/components_v2/inspector/grid_row_composed_element.h"
45 #include "core/components_v2/inspector/hyperlink_composed_element.h"
46 #include "core/components_v2/inspector/image_animator_composed_element.h"
47 #include "core/components_v2/inspector/image_composed_element.h"
48 #include "core/components_v2/inspector/indexer_composed_element.h"
49 #include "core/components_v2/inspector/inspector_constants.h"
50 #include "core/components_v2/inspector/list_composed_element.h"
51 #include "core/components_v2/inspector/list_item_composed_element.h"
52 #include "core/components_v2/inspector/list_item_group_composed_element.h"
53 #include "core/components_v2/inspector/loading_progress_composed_element.h"
54 #include "core/components_v2/inspector/marquee_composed_element.h"
55 #include "core/components_v2/inspector/menu_composed_element.h"
56 #include "core/components_v2/inspector/navigation_composed_element.h"
57 #include "core/components_v2/inspector/navigation_menus_composed_element.h"
58 #include "core/components_v2/inspector/navigation_title_composed_element.h"
59 #include "core/components_v2/inspector/navigator_composed_element.h"
60 #include "core/components_v2/inspector/panel_composed_element.h"
61 #include "core/components_v2/inspector/pattern_lock_composed_element.h"
62 #include "core/components_v2/inspector/picker_text_dialog_composed_element.h"
63 #include "core/components_v2/inspector/progress_composed_element.h"
64 #include "core/components_v2/inspector/qrcode_composed_element.h"
65 #include "core/components_v2/inspector/radio_composed_element.h"
66 #include "core/components_v2/inspector/rating_composed_element.h"
67 #include "core/components_v2/inspector/refresh_composed_element.h"
68 #include "core/components_v2/inspector/relative_container_composed_element.h"
69 #include "core/components_v2/inspector/row_composed_element.h"
70 #include "core/components_v2/inspector/row_split_composed_element.h"
71 #include "core/components_v2/inspector/scroll_bar_composed_element.h"
72 #include "core/components_v2/inspector/scroll_composed_element.h"
73 #include "core/components_v2/inspector/search_composed_element.h"
74 #include "core/components_v2/inspector/select_composed_element.h"
75 #include "core/components_v2/inspector/shape_composed_element.h"
76 #include "core/components_v2/inspector/shape_container_composed_element.h"
77 #include "core/components_v2/inspector/sheet_composed_element.h"
78 #include "core/components_v2/inspector/side_bar_composed_element.h"
79 #include "core/components_v2/inspector/slider_composed_element.h"
80 #include "core/components_v2/inspector/span_composed_element.h"
81 #include "core/components_v2/inspector/stack_composed_element.h"
82 #include "core/components_v2/inspector/stepper_composed_element.h"
83 #include "core/components_v2/inspector/stepper_item_composed_element.h"
84 #include "core/components_v2/inspector/swiper_composed_element.h"
85 #include "core/components_v2/inspector/switch_composed_element.h"
86 #include "core/components_v2/inspector/tab_content_composed_element.h"
87 #include "core/components_v2/inspector/tabs_composed_element.h"
88 #include "core/components_v2/inspector/text_clock_composed_element.h"
89 #include "core/components_v2/inspector/text_composed_element.h"
90 #include "core/components_v2/inspector/text_picker_composed_element.h"
91 #include "core/components_v2/inspector/textarea_composed_element.h"
92 #include "core/components_v2/inspector/textinput_composed_element.h"
93 #include "core/components_v2/inspector/texttimer_composed_element.h"
94 #include "core/components_v2/inspector/time_picker_composed_element.h"
95 #include "core/components_v2/inspector/time_picker_dialog_composed_element.h"
96 #include "core/components_v2/inspector/toggle_composed_element.h"
97 #include "core/components_v2/inspector/water_flow_composed_element.h"
98 #include "core/components_v2/inspector/water_flow_item_composed_element.h"
99 #include "core/components_v2/inspector/wrap_composed_element.h"
100 #include "core/pipeline/base/composed_element.h"
101 
102 namespace OHOS::Ace::V2 {
103 
104 namespace {
105 
106 using CreateElementFunc = std::function<RefPtr<InspectorComposedElement>(const std::string& id)>;
107 
108 const std::unordered_map<std::string, CreateElementFunc> CREATE_ELEMENT_MAP {
__anona4bda69c0202() 109     { COLUMN_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ColumnComposedElement>(id); } },
110     { COLUMN_SPLIT_COMPONENT_TAG,
__anona4bda69c0302() 111         [](const std::string& id) { return AceType::MakeRefPtr<V2::ColumnSplitComposedElement>(id); } },
112     { COUNTER_COMPONENT_TAG,
__anona4bda69c0402() 113         [](const std::string& id) { return AceType::MakeRefPtr<V2::CounterComposedElement>(id); } },
114     { NAVIGATION_VIEW_COMPONENT_TAG,
__anona4bda69c0502() 115         [](const std::string& id) { return AceType::MakeRefPtr<V2::NavigationComposedElement>(id); } },
116     { ROW_SPLIT_COMPONENT_TAG,
__anona4bda69c0602() 117         [](const std::string& id) { return AceType::MakeRefPtr<V2::RowSplitComposedElement>(id); } },
__anona4bda69c0702() 118     { STACK_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::StackComposedElement>(id); } },
__anona4bda69c0802() 119     { SWIPER_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SwiperComposedElement>(id); } },
120     { TAB_CONTENT_ITEM_COMPONENT_TAG,
__anona4bda69c0902() 121         [](const std::string& id) { return AceType::MakeRefPtr<V2::TabContentComposedElement>(id); } },
__anona4bda69c0a02() 122     { TABS_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::TabsComposedElement>(id); } },
__anona4bda69c0b02() 123     { TEXT_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::TextComposedElement>(id); } },
__anona4bda69c0c02() 124     { FLEX_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::FlexComposedElement>(id); } },
__anona4bda69c0d02() 125     { WRAP_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::WrapComposedElement>(id); } },
__anona4bda69c0e02() 126     { GRID_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::GridComposedElement>(id); } },
127     { GRID_ITEM_COMPONENT_TAG,
__anona4bda69c0f02() 128         [](const std::string& id) { return AceType::MakeRefPtr<V2::GridItemComposedElement>(id); } },
129     { WATERFLOW_COMPONENT_TAG,
__anona4bda69c1002() 130         [](const std::string& id) { return AceType::MakeRefPtr<V2::WaterFlowComposedElement>(id); } },
131     { FLOW_ITEM_COMPONENT_TAG,
__anona4bda69c1102() 132         [](const std::string& id) { return AceType::MakeRefPtr<V2::WaterFlowItemComposedElement>(id); } },
__anona4bda69c1202() 133     { LIST_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ListComposedElement>(id); } },
134     { LIST_ITEM_COMPONENT_TAG,
__anona4bda69c1302() 135         [](const std::string& id) { return AceType::MakeRefPtr<V2::ListItemComposedElement>(id); } },
136     { LIST_ITEM_GROUP_COMPONENT_TAG,
__anona4bda69c1402() 137         [](const std::string& id) { return AceType::MakeRefPtr<V2::ListItemGroupComposedElement>(id); } },
138     { NAVIGATOR_COMPONENT_TAG,
__anona4bda69c1502() 139         [](const std::string& id) { return AceType::MakeRefPtr<V2::NavigatorComposedElement>(id); } },
__anona4bda69c1602() 140     { PANEL_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::PanelComposedElement>(id); } },
141     { PATTERN_LOCK_COMPONENT_TAG,
__anona4bda69c1702() 142         [](const std::string& id) { return AceType::MakeRefPtr<V2::PatternLockComposedElement>(id); } },
__anona4bda69c1802() 143     { ROW_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::RowComposedElement>(id); } },
__anona4bda69c1902() 144     { SHAPE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ShapeComposedElement>(id); } },
145     { SHAPE_CONTAINER_COMPONENT_TAG,
__anona4bda69c1a02() 146         [](const std::string& id) { return AceType::MakeRefPtr<V2::ShapeContainerComposedElement>(id); } },
147     { IMAGE_ANIMATOR_COMPONENT_TAG,
__anona4bda69c1b02() 148         [](const std::string& id) { return AceType::MakeRefPtr<V2::ImageAnimatorComposedElement>(id); } },
__anona4bda69c1c02() 149     { IMAGE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ImageComposedElement>(id); } },
__anona4bda69c1d02() 150     { QRCODE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::QrcodeComposedElement>(id); } },
__anona4bda69c1e02() 151     { SPAN_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SpanComposedElement>(id); } },
__anona4bda69c1f02() 152     { BOX_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::BlankComposedElement>(id); } },
__anona4bda69c2002() 153     { BUTTON_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ButtonComposedElement>(id); } },
154     { DIVIDER_COMPONENT_TAG,
__anona4bda69c2102() 155         [](const std::string& id) { return AceType::MakeRefPtr<V2::DividerComposedElement>(id); } },
156     { CHECKBOX_COMPONENT_TAG,
__anona4bda69c2202() 157         [](const std::string& id) { return AceType::MakeRefPtr<V2::CheckboxComposedElement>(id); } },
158     { CHECK_BOX_COMPONENT_TAG,
__anona4bda69c2302() 159         [](const std::string& id) { return AceType::MakeRefPtr<V2::CheckboxComposedElement>(id); } },
__anona4bda69c2402() 160     { SWITCH_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SwitchComposedElement>(id); } },
__anona4bda69c2502() 161     { TOGGLE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ToggleComposedElement>(id); } },
__anona4bda69c2602() 162     { SCROLL_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::ScrollComposedElement>(id); } },
163     { CALENDAR_COMPONENT_TAG,
__anona4bda69c2702() 164         [](const std::string& id) { return AceType::MakeRefPtr<V2::CalendarComposedElement>(id); } },
__anona4bda69c2802() 165     { BADGE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::BadgeComposedElement>(id); } },
__anona4bda69c2902() 166     { SEARCH_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SearchComposedElement>(id); } },
__anona4bda69c2a02() 167     { FORM_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
168     { PLUGIN_COMPONENT_TAG,
__anona4bda69c2b02() 169         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
170     { VIDEO_COMPONENT_TAG,
__anona4bda69c2c02() 171         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
172     { INDEXER_COMPONENT_TAG,
__anona4bda69c2d02() 173         [](const std::string& id) { return AceType::MakeRefPtr<V2::IndexerComposedElement>(id); } },
__anona4bda69c2e02() 174     { SLIDER_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SliderComposedElement>(id); } },
__anona4bda69c2f02() 175     { RATING_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::RatingComposedElement>(id); } },
176     { PROGRESS_COMPONENT_TAG,
__anona4bda69c3002() 177         [](const std::string& id) { return AceType::MakeRefPtr<V2::ProgressComposedElement>(id); } },
178     { DATA_PANEL_COMPONENT_TAG,
__anona4bda69c3102() 179         [](const std::string& id) { return AceType::MakeRefPtr<V2::DataPanelComposedElement>(id); } },
__anona4bda69c3202() 180     { SHEET_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SheetComposedElement>(id); } },
181     { HYPERLINK_COMPONENT_TAG,
__anona4bda69c3302() 182         [](const std::string& id) { return AceType::MakeRefPtr<V2::HyperlinkComposedElement>(id); } },
183     { STEPPER_COMPONENT_TAG,
__anona4bda69c3402() 184         [](const std::string& id) { return AceType::MakeRefPtr<V2::StepperComposedElement>(id); } },
185     { STEPPER_ITEM_COMPONENT_TAG,
__anona4bda69c3502() 186         [](const std::string& id) { return AceType::MakeRefPtr<V2::StepperItemComposedElement>(id); } },
187     { SCROLL_BAR_COMPONENT_TAG,
__anona4bda69c3602() 188         [](const std::string& id) { return AceType::MakeRefPtr<V2::ScrollBarComposedElement>(id); } },
189     { REFRESH_COMPONENT_TAG,
__anona4bda69c3702() 190         [](const std::string& id) { return AceType::MakeRefPtr<V2::RefreshComposedElement>(id); } },
191     { DATE_PICKER_COMPONENT_TAG,
__anona4bda69c3802() 192         [](const std::string& id) { return AceType::MakeRefPtr<V2::DatePickerComposedElement>(id); } },
193     { TIME_PICKER_COMPONENT_TAG,
__anona4bda69c3902() 194         [](const std::string& id) { return AceType::MakeRefPtr<V2::TimePickerComposedElement>(id); } },
__anona4bda69c3a02() 195     { RADIO_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::RadioComposedElement>(id); } },
__anona4bda69c3b02() 196     { GAUGE_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::GaugeComposedElement>(id); } },
197     { GRIDCONTAINER_COMPONENT_TAG,
__anona4bda69c3c02() 198         [](const std::string& id) { return AceType::MakeRefPtr<V2::GridContainerComposedElement>(id); } },
199     { GRID_COL_COMPONENT_TAG,
__anona4bda69c3d02() 200         [](const std::string& id) { return AceType::MakeRefPtr<V2::GridColComposedElement>(id); } },
201     { GRID_ROW_COMPONENT_TAG,
__anona4bda69c3e02() 202         [](const std::string& id) { return AceType::MakeRefPtr<V2::GridRowComposedElement>(id); } },
__anona4bda69c3f02() 203     { MENU_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::MenuComposedElement>(id); } },
204     { TEXTAREA_COMPONENT_TAG,
__anona4bda69c4002() 205         [](const std::string& id) { return AceType::MakeRefPtr<V2::TextareaComposedElement>(id); } },
206     { TEXTINPUT_COMPONENT_TAG,
__anona4bda69c4102() 207         [](const std::string& id) { return AceType::MakeRefPtr<V2::TextInputComposedElement>(id); } },
208     { TEXTTIMER_COMPONENT_TAG,
__anona4bda69c4202() 209         [](const std::string& id) { return AceType::MakeRefPtr<V2::TextTimerComposedElement>(id); } },
__anona4bda69c4302() 210     { SELECT_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::SelectComposedElement>(id); } },
211     { MARQUEE_COMPONENT_TAG,
__anona4bda69c4402() 212         [](const std::string& id) { return AceType::MakeRefPtr<V2::MarqueeComposedElement>(id); } },
213     { TEXTCLOCK_COMPONENT_TAG,
__anona4bda69c4502() 214         [](const std::string& id) { return AceType::MakeRefPtr<V2::TextClockComposedElement>(id); } },
215     { TEXT_PICKER_COMPONENT_TAG,
__anona4bda69c4602() 216         [](const std::string& id) { return AceType::MakeRefPtr<V2::TextPickerComposedElement>(id); } },
217     { PICKER_TEXT_DIALOG_COMPONENT_TAG,
__anona4bda69c4702() 218         [](const std::string& id) { return AceType::MakeRefPtr<V2::PickerTextDialogComposedElement>(id); } },
219     { CANVAS_COMPONENT_TAG,
__anona4bda69c4802() 220         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
221     { DIALOG_COMPONENT_TAG,
__anona4bda69c4902() 222         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
223     { ACTION_SHEET_DIALOG_COMPONENT_TAG,
__anona4bda69c4a02() 224         [](const std::string& id) { return AceType::MakeRefPtr<V2::ActionSheetDialogComposedElement>(id); } },
225     { ALERT_DIALOG_COMPONENT_TAG,
__anona4bda69c4b02() 226         [](const std::string& id) { return AceType::MakeRefPtr<V2::AlertDialogComposedElement>(id); } },
227     { CUSTOM_DIALOG_COMPONENT_TAG,
__anona4bda69c4c02() 228         [](const std::string& id) { return AceType::MakeRefPtr<V2::CustomDialogComposedElement>(id); } },
229     { DATE_PICKER_DIALOG_COMPONENT_TAG,
__anona4bda69c4d02() 230         [](const std::string& id) { return AceType::MakeRefPtr<V2::DatePickerDialogComposedElement>(id); } },
231     { SIDE_BAR_COMPONENT_TAG,
__anona4bda69c4e02() 232         [](const std::string& id) { return AceType::MakeRefPtr<V2::SideBarComposedElement>(id); } },
233     { LOADING_PROGRESS_COMPONENT_TAG,
__anona4bda69c4f02() 234         [](const std::string& id) { return AceType::MakeRefPtr<V2::LoadingProgressComposedElement>(id); } },
235     { CHECKBOXGROUP_COMPONENT_TAG,
__anona4bda69c5002() 236         [](const std::string& id) { return AceType::MakeRefPtr<V2::CheckboxGroupComposedElement>(id); } },
237     { TIME_PICKER_DIALOG_COMPONENT_TAG,
__anona4bda69c5102() 238         [](const std::string& id) { return AceType::MakeRefPtr<V2::TimePickerDialogComposedElement>(id); } },
__anona4bda69c5202() 239     { WEB_COMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
240     { RICH_TEXT_COMPONENT_TAG,
__anona4bda69c5302() 241         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
__anona4bda69c5402() 242     { XCOMPONENT_TAG, [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
243     { NAVIGATION_TITLE_COMPONENT_TAG,
__anona4bda69c5502() 244         [](const std::string& id) { return AceType::MakeRefPtr<V2::NavigationTitleComposedElement>(id); } },
245     { NAVIGATION_MENUS_COMPONENT_TAG,
__anona4bda69c5602() 246         [](const std::string& id) { return AceType::MakeRefPtr<V2::NavigationMenusComposedElement>(id); } },
247     { JS_VIEW_COMPONENT_TAG,
__anona4bda69c5702() 248         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
249     { RELATIVE_CONTAINER_COMPONENT_TAG,
__anona4bda69c5802() 250         [](const std::string& id) { return AceType::MakeRefPtr<V2::RelativeContainerComposedElement>(id); } },
251     { MOVING_PHOTO_COMPONENT_TAG,
__anona4bda69c5902() 252         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
253     { ANALOGCLOCK_COMPONENT_TAG,
__anona4bda69c5a02() 254         [](const std::string& id) { return AceType::MakeRefPtr<V2::InspectorComposedElement>(id); } },
255 };
256 
257 } // namespace
258 
259 const std::unordered_map<std::string, std::string> COMPONENT_TAG_TO_ETS_TAG_MAP {
260     { COLUMN_COMPONENT_TAG, COLUMN_ETS_TAG },
261     { TEXT_COMPONENT_TAG, TEXT_ETS_TAG },
262     { COLUMN_SPLIT_COMPONENT_TAG, COLUMN_SPLIT_ETS_TAG },
263     { COUNTER_COMPONENT_TAG, COUNTER_ETS_TAG },
264     { NAVIGATION_VIEW_COMPONENT_TAG, NAVIGATION_VIEW_ETS_TAG },
265     { ROW_SPLIT_COMPONENT_TAG, ROW_SPLIT_ETS_TAG },
266     { STACK_COMPONENT_TAG, STACK_ETS_TAG },
267     { SWIPER_COMPONENT_TAG, SWIPER_ETS_TAG },
268     { TAB_CONTENT_ITEM_COMPONENT_TAG, TAB_CONTENT_ITEM_ETS_TAG },
269     { TABS_COMPONENT_TAG, TABS_ETS_TAG },
270     { FLEX_COMPONENT_TAG, FLEX_ETS_TAG },
271     { WRAP_COMPONENT_TAG, WRAP_ETS_TAG },
272     { GRID_COMPONENT_TAG, GRID_ETS_TAG },
273     { GRID_ITEM_COMPONENT_TAG, GRID_ITEM_ETS_TAG },
274     { WATERFLOW_COMPONENT_TAG, WATERFLOW_ETS_TAG },
275     { FLOW_ITEM_COMPONENT_TAG, FLOW_ITEM_ETS_TAG },
276     { LIST_COMPONENT_TAG, LIST_ETS_TAG },
277     { LIST_ITEM_COMPONENT_TAG, LIST_ITEM_ETS_TAG },
278     { LIST_ITEM_GROUP_COMPONENT_TAG, LIST_ITEM_GROUP_ETS_TAG },
279     { NAVIGATOR_COMPONENT_TAG, NAVIGATOR_ETS_TAG },
280     { PANEL_COMPONENT_TAG, PANEL_ETS_TAG },
281     { PATTERN_LOCK_COMPONENT_TAG, PATTERN_LOCK_ETS_TAG },
282     { ROW_COMPONENT_TAG, ROW_ETS_TAG },
283     { IMAGE_ANIMATOR_COMPONENT_TAG, IMAGE_ANIMATOR_ETS_TAG },
284     { SHAPE_CONTAINER_COMPONENT_TAG, SHAPE_CONTAINER_ETS_TAG },
285     { SHAPE_COMPONENT_TAG, SHAPE_ETS_TAG },
286     { IMAGE_COMPONENT_TAG, IMAGE_ETS_TAG },
287     { QRCODE_COMPONENT_TAG, QRCODE_ETS_TAG },
288     { SPAN_COMPONENT_TAG, SPAN_ETS_TAG },
289     { PLACEHOLDER_SPAN_COMPONENT_TAG, PLACEHOLDER_SPAN_ETS_TAG },
290     { BOX_COMPONENT_TAG, BLANK_ETS_TAG },
291     { BUTTON_COMPONENT_TAG, BUTTON_ETS_TAG },
292     { DIVIDER_COMPONENT_TAG, DIVIDER_ETS_TAG },
293     { CHECKBOX_COMPONENT_TAG, CHECKBOX_ETS_TAG },
294     { CHECK_BOX_COMPONENT_TAG, CHECK_BOX_ETS_TAG },
295     { SWITCH_COMPONENT_TAG, SWITCH_ETS_TAG },
296     { TOGGLE_COMPONENT_TAG, TOGGLE_ETS_TAG },
297     { SCROLL_COMPONENT_TAG, SCROLL_ETS_TAG },
298     { CALENDAR_COMPONENT_TAG, CALENDAR_ETS_TAG },
299     { CALENDAR_PICKER_COMPONENT_TAG, CALENDAR_PICKER_ETS_TAG },
300     { BADGE_COMPONENT_TAG, BADGE_ETS_TAG },
301     { SEARCH_COMPONENT_TAG, SEARCH_ETS_TAG },
302     { FORM_COMPONENT_TAG, FORM_ETS_TAG },
303     { PLUGIN_COMPONENT_TAG, PLUGIN_ETS_TAG },
304     { VIDEO_COMPONENT_TAG, VIDEO_ETS_TAG },
305     { INDEXER_COMPONENT_TAG, INDEXER_ETS_TAG },
306     { SLIDER_COMPONENT_TAG, SLIDER_ETS_TAG },
307     { RATING_COMPONENT_TAG, RATING_ETS_TAG },
308     { PROGRESS_COMPONENT_TAG, PROGRESS_ETS_TAG },
309     { DATA_PANEL_COMPONENT_TAG, DATA_PANEL_ETS_TAG },
310     { SHEET_COMPONENT_TAG, SHEET_ETS_TAG },
311     { HYPERLINK_COMPONENT_TAG, HYPERLINK_ETS_TAG },
312     { STEPPER_COMPONENT_TAG, STEPPER_ETS_TAG },
313     { STEPPER_ITEM_COMPONENT_TAG, STEPPER_ITEM_ETS_TAG },
314     { SCROLL_BAR_COMPONENT_TAG, SCROLL_BAR_ETS_TAG },
315     { REFRESH_COMPONENT_TAG, REFRESH_ETS_TAG },
316     { DATE_PICKER_COMPONENT_TAG, DATE_PICKER_ETS_TAG },
317     { TIME_PICKER_COMPONENT_TAG, TIME_PICKER_ETS_TAG },
318     { RADIO_COMPONENT_TAG, RADIO_ETS_TAG },
319     { GRIDCONTAINER_COMPONENT_TAG, GRIDCONTAINER_ETS_TAG },
320     { GRID_COL_COMPONENT_TAG, GRID_COL_ETS_TAG },
321     { GRID_ROW_COMPONENT_TAG, GRID_ROW_ETS_TAG },
322     { INDEXER_COMPONENT_TAG, INDEXER_ETS_TAG },
323     { MENU_COMPONENT_TAG, MENU_ETS_TAG },
324     { MENU_TAG, MENU_ETS_TAG },
325     { TEXTAREA_COMPONENT_TAG, TEXTAREA_ETS_TAG },
326     { TEXTINPUT_COMPONENT_TAG, TEXTINPUT_ETS_TAG },
327     { MARQUEE_COMPONENT_TAG, MARQUEE_ETS_TAG },
328     { SELECT_COMPONENT_TAG, SELECT_ETS_TAG },
329     { TEXTCLOCK_COMPONENT_TAG, TEXTCLOCK_ETS_TAG },
330     { TEXTTIMER_COMPONENT_TAG, TEXTTIMER_ETS_TAG },
331     { TEXT_PICKER_COMPONENT_TAG, TEXT_PICKER_ETS_TAG },
332     { PICKER_TEXT_DIALOG_COMPONENT_TAG, PICKER_TEXT_DIALOG_ETS_TAG },
333     { CANVAS_COMPONENT_TAG, CANVAS_ETS_TAG },
334     { ACTION_SHEET_DIALOG_COMPONENT_TAG, ACTION_SHEET_DIALOG_ETS_TAG },
335     { ALERT_DIALOG_COMPONENT_TAG, ALERT_DIALOG_ETS_TAG },
336     { CUSTOM_DIALOG_COMPONENT_TAG, CUSTOM_DIALOG_ETS_TAG },
337     { DATE_PICKER_DIALOG_COMPONENT_TAG, DATE_PICKER_DIALOG_ETS_TAG },
338     { SIDE_BAR_COMPONENT_TAG, SIDE_BAR_ETS_TAG },
339     { LOADING_PROGRESS_COMPONENT_TAG, LOADING_PROGRESS_ETS_TAG },
340     { CHECKBOXGROUP_COMPONENT_TAG, CHECKBOXGROUP_ETS_TAG },
341     { TIME_PICKER_DIALOG_COMPONENT_TAG, TIME_PICKER_DIALOG_ETS_TAG },
342     { WEB_COMPONENT_TAG, WEB_ETS_TAG },
343     { RICH_TEXT_COMPONENT_TAG, RICH_TEXT_ETS_TAG },
344     { XCOMPONENT_TAG, XCOMPONENT_ETS_TAG },
345     { JS_VIEW_COMPONENT_TAG, JS_VIEW_ETS_TAG },
346     { RELATIVE_CONTAINER_COMPONENT_TAG, RELATIVE_CONTAINER_ETS_TAG },
347     { UI_EXTENSION_COMPONENT_TAG, UI_EXTENSION_COMPONENT_ETS_TAG },
348     { LOCATION_BUTTON_COMPONENT_TAG, LOCATION_BUTTON_ETS_TAG },
349     { PASTE_BUTTON_COMPONENT_TAG, PASTE_BUTTON_ETS_TAG },
350     { SAVE_BUTTON_COMPONENT_TAG, SAVE_BUTTON_ETS_TAG },
351     { PARTICLE_COMPONENT_TAG, PARTICLE_ETS_TAG },
352     { CONTAINER_SPAN_COMPONENT_TAG, CONTAINER_SPAN_ETS_TAG },
353     { SYMBOL_COMPONENT_TAG, SYMBOL_ETS_TAG },
354     { SYMBOL_SPAN_COMPONENT_TAG, SYMBOL_SPAN_ETS_TAG },
355     { ISOLATED_COMPONENT_TAG, ISOLATED_COMPONENT_ETS_TAG },
356     { EMBEDDED_COMPONENT_TAG, EMBEDDED_COMPONENT_ETS_TAG },
357     { MOVING_PHOTO_COMPONENT_TAG, MOVING_PHOTO_ETS_TAG },
358     {ANALOGCLOCK_COMPONENT_TAG, ANALOGCLOCK_ETS_TAG},
359 };
360 
361 thread_local int32_t InspectorComposedComponent::composedElementId_ = 1;
362 
CreateElement()363 RefPtr<Element> InspectorComposedComponent::CreateElement()
364 {
365     auto generateFunc = CREATE_ELEMENT_MAP.find(GetName());
366     if (generateFunc != CREATE_ELEMENT_MAP.end()) {
367         auto composedElement = generateFunc->second(id_);
368         composedElement->SetInspectorTag(GetName());
369         composedElement->SetDebugLine(GetDebugLine());
370         composedElement->SetViewId(viewId_);
371         auto inspectorElement = AceType::DynamicCast<InspectorComposedElement>(composedElement);
372         inspectorElement->SetKey(GetInspectorKey());
373         return composedElement;
374     }
375     return nullptr;
376 }
377 
GetAccessibilityManager()378 RefPtr<AccessibilityManager> InspectorComposedComponent::GetAccessibilityManager()
379 {
380     auto container = OHOS::Ace::Container::Current();
381     if (!container) {
382         LOGE("container is nullptr");
383         return nullptr;
384     }
385     auto front = container->GetFrontend();
386     if (!front) {
387         LOGE("front is nullptr");
388         return nullptr;
389     }
390     auto accessibilityManager = front->GetAccessibilityManager();
391     return accessibilityManager;
392 }
393 
HasInspectorFinished(std::string tag)394 bool InspectorComposedComponent::HasInspectorFinished(std::string tag)
395 {
396     auto generateFunc = CREATE_ELEMENT_MAP.find(tag);
397     if (generateFunc != CREATE_ELEMENT_MAP.end()) {
398         return true;
399     }
400     return false;
401 }
402 
CreateAccessibilityNode(const std::string & tag,int32_t nodeId,int32_t parentNodeId,int32_t itemIndex)403 RefPtr<AccessibilityNode> InspectorComposedComponent::CreateAccessibilityNode(
404     const std::string& tag, int32_t nodeId, int32_t parentNodeId, int32_t itemIndex)
405 {
406     auto accessibilityManager = GetAccessibilityManager();
407     if (!accessibilityManager) {
408         LOGE("get AccessibilityManager failed");
409         return nullptr;
410     }
411 
412     auto node = accessibilityManager->CreateAccessibilityNode(
413         InspectorComposedComponent::GetEtsTag(tag), nodeId, parentNodeId, itemIndex);
414     return node;
415 }
416 
GetEtsTag(const std::string & tag)417 std::string InspectorComposedComponent::GetEtsTag(const std::string& tag)
418 {
419     auto iter = COMPONENT_TAG_TO_ETS_TAG_MAP.find(tag);
420     if (iter == COMPONENT_TAG_TO_ETS_TAG_MAP.end()) {
421         return tag;
422     }
423     return iter->second;
424 }
425 
GenerateId()426 std::string InspectorComposedComponent::GenerateId()
427 {
428     return std::to_string(composedElementId_++);
429 }
430 
431 } // namespace OHOS::Ace::V2
432