• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h"
17 #if !defined(PREVIEW) && defined(OHOS_PLATFORM)
18 #include "interfaces/inner_api/ui_session/ui_session_manager.h"
19 #endif
20 
21 #include "base/log/ace_scoring_log.h"
22 #include "base/log/log_wrapper.h"
23 #include "bridge/declarative_frontend/engine/functions/js_click_function.h"
24 #include "bridge/declarative_frontend/engine/functions/js_hover_function.h"
25 #include "bridge/declarative_frontend/engine/functions/js_key_function.h"
26 #include "bridge/declarative_frontend/engine/js_execution_scope_defines.h"
27 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h"
28 #include "bridge/declarative_frontend/jsview/js_pan_handler.h"
29 #include "bridge/declarative_frontend/jsview/js_touch_handler.h"
30 #include "bridge/declarative_frontend/jsview/js_utils.h"
31 #include "bridge/declarative_frontend/view_stack_processor.h"
32 #include "core/common/container.h"
33 #include "core/components/gesture_listener/gesture_listener_component.h"
34 #include "core/components_ng/base/view_abstract_model.h"
35 #include "core/components_ng/base/view_stack_processor.h"
36 #include "core/gestures/click_recognizer.h"
37 #include "core/pipeline/base/single_child.h"
38 #include "core/pipeline/pipeline_context.h"
39 
40 #ifdef PLUGIN_COMPONENT_SUPPORTED
41 #include "core/common/plugin_manager.h"
42 #endif
43 
44 namespace OHOS::Ace::Framework {
45 
JsOnTouch(const JSCallbackInfo & args)46 void JSInteractableView::JsOnTouch(const JSCallbackInfo& args)
47 {
48     if (args[0]->IsUndefined() && IsDisableEventVersion()) {
49         ViewAbstractModel::GetInstance()->DisableOnTouch();
50         return;
51     }
52     if (!args[0]->IsFunction()) {
53         return;
54     }
55     EcmaVM* vm = args.GetVm();
56     CHECK_NULL_VOID(vm);
57     auto jsOnTouchFunc = JSRef<JSFunc>::Cast(args[0]);
58     if (jsOnTouchFunc->IsEmpty()) {
59         return;
60     }
61     auto jsOnTouchFuncLocalHandle = jsOnTouchFunc->GetLocalHandle();
62     auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
63     auto onTouch = [vm, execCtx = args.GetExecutionContext(),
64                        func = panda::CopyableGlobal(vm, jsOnTouchFuncLocalHandle),
65                        node = frameNode](TouchEventInfo& info) {
66         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
67         ACE_SCORING_EVENT("onTouch");
68         PipelineContext::SetCallBackNode(node);
69         auto eventObj = NG::FrameNodeBridge::CreateTouchEventInfo(vm, info);
70         panda::Local<panda::JSValueRef> params[1] = { eventObj };
71         func->Call(vm, func.ToLocal(), params, 1);
72     };
73     ViewAbstractModel::GetInstance()->SetOnTouch(std::move(onTouch));
74 }
75 
JsOnKey(const JSCallbackInfo & args)76 void JSInteractableView::JsOnKey(const JSCallbackInfo& args)
77 {
78     if (args[0]->IsUndefined() && IsDisableEventVersion()) {
79         ViewAbstractModel::GetInstance()->DisableOnKeyEvent();
80         return;
81     }
82     if (!args[0]->IsFunction()) {
83         return;
84     }
85     RefPtr<JsKeyFunction> JsOnKeyEvent = AceType::MakeRefPtr<JsKeyFunction>(JSRef<JSFunc>::Cast(args[0]));
86     WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
87     auto onKeyEvent = [execCtx = args.GetExecutionContext(), func = std::move(JsOnKeyEvent), node = frameNode](
88                           KeyEventInfo& info) -> bool {
89         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, false);
90         ACE_SCORING_EVENT("onKey");
91         PipelineContext::SetCallBackNode(node);
92         auto ret = func->ExecuteWithValue(info);
93         return ret->IsBoolean() ? ret->ToBoolean() : false;
94     };
95     ViewAbstractModel::GetInstance()->SetOnKeyEvent(std::move(onKeyEvent));
96 }
97 
JsOnKeyPreIme(const JSCallbackInfo & args)98 void JSInteractableView::JsOnKeyPreIme(const JSCallbackInfo& args)
99 {
100     if (args[0]->IsUndefined()) {
101         ViewAbstractModel::GetInstance()->DisableOnKeyPreIme();
102         return;
103     }
104     if (!args[0]->IsFunction()) {
105         return;
106     }
107     RefPtr<JsKeyFunction> JsOnPreImeEvent = AceType::MakeRefPtr<JsKeyFunction>(JSRef<JSFunc>::Cast(args[0]));
108     auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
109     auto onPreImeEvent = [execCtx = args.GetExecutionContext(), func = std::move(JsOnPreImeEvent), node = frameNode](
110                           KeyEventInfo& info) -> bool {
111         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, false);
112         ACE_SCORING_EVENT("onKeyPreIme");
113         PipelineContext::SetCallBackNode(node);
114         auto ret = func->ExecuteWithValue(info);
115         return ret->IsBoolean() ? ret->ToBoolean() : false;
116     };
117     ViewAbstractModel::GetInstance()->SetOnKeyPreIme(std::move(onPreImeEvent));
118 }
119 
JsOnKeyEventDispatch(const JSCallbackInfo & args)120 void JSInteractableView::JsOnKeyEventDispatch(const JSCallbackInfo& args)
121 {
122     if (args[0]->IsUndefined() || !args[0]->IsFunction()) {
123         ViewAbstractModel::GetInstance()->DisableOnKeyEventDispatch();
124         return;
125     }
126     RefPtr<JsKeyFunction> JsOnKeyEventDispatch = AceType::MakeRefPtr<JsKeyFunction>(JSRef<JSFunc>::Cast(args[0]));
127     WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
128     auto onKeyEventDispatch = [execCtx = args.GetExecutionContext(), func = std::move(JsOnKeyEventDispatch),
129                              node = frameNode](KeyEventInfo& keyEvent) -> bool {
130         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, false);
131         ACE_SCORING_EVENT("onKeyEventDispatch");
132         PipelineContext::SetCallBackNode(node);
133         auto ret = func->ExecuteWithValue(keyEvent);
134         return ret->IsBoolean() ? ret->ToBoolean() : false;
135     };
136     ViewAbstractModel::GetInstance()->SetOnKeyEventDispatch(std::move(onKeyEventDispatch));
137 }
138 
JsOnHover(const JSCallbackInfo & info)139 void JSInteractableView::JsOnHover(const JSCallbackInfo& info)
140 {
141     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
142         ViewAbstractModel::GetInstance()->DisableOnHover();
143         return;
144     }
145     if (!info[0]->IsFunction()) {
146         return;
147     }
148     RefPtr<JsHoverFunction> jsOnHoverFunc = AceType::MakeRefPtr<JsHoverFunction>(JSRef<JSFunc>::Cast(info[0]));
149     WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
150     auto onHover = [execCtx = info.GetExecutionContext(), func = std::move(jsOnHoverFunc), node = frameNode](
151                        bool isHover, HoverInfo& hoverInfo) {
152         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
153         ACE_SCORING_EVENT("onHover");
154         PipelineContext::SetCallBackNode(node);
155         func->HoverExecute(isHover, hoverInfo);
156     };
157     ViewAbstractModel::GetInstance()->SetOnHover(std::move(onHover));
158 }
159 
JsOnHoverMove(const JSCallbackInfo & info)160 void JSInteractableView::JsOnHoverMove(const JSCallbackInfo& info)
161 {
162     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
163         ViewAbstractModel::GetInstance()->DisableOnHoverMove();
164         return;
165     }
166     if (!info[0]->IsFunction()) {
167         return;
168     }
169     RefPtr<JsHoverFunction> jsOnHoverMoveFunc = AceType::MakeRefPtr<JsHoverFunction>(JSRef<JSFunc>::Cast(info[0]));
170     WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
171     auto onHover = [execCtx = info.GetExecutionContext(), func = std::move(jsOnHoverMoveFunc), node = frameNode](
172                        HoverInfo& hoverInfo) {
173         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
174         ACE_SCORING_EVENT("onHoverMove");
175         PipelineContext::SetCallBackNode(node);
176         func->HoverMoveExecute(hoverInfo);
177     };
178     ViewAbstractModel::GetInstance()->SetOnHoverMove(std::move(onHover));
179 }
180 
JsOnPan(const JSCallbackInfo & args)181 void JSInteractableView::JsOnPan(const JSCallbackInfo& args)
182 {
183     if (args[0]->IsObject()) {
184 #ifndef NG_BUILD
185         JSRef<JSObject> obj = JSRef<JSObject>::Cast(args[0]);
186         JSPanHandler* handler = obj->Unwrap<JSPanHandler>();
187         if (handler) {
188             handler->CreateComponent(args);
189         }
190 #endif
191     }
192 }
193 
JsOnDelete(const JSCallbackInfo & info)194 void JSInteractableView::JsOnDelete(const JSCallbackInfo& info)
195 {
196     if (info[0]->IsFunction()) {
197         RefPtr<JsFunction> jsOnDeleteFunc =
198             AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
199         auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
200         auto onDelete = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDeleteFunc), node = frameNode]() {
201             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
202             ACE_SCORING_EVENT("onDelete");
203             PipelineContext::SetCallBackNode(node);
204             func->Execute();
205         };
206         ViewAbstractModel::GetInstance()->SetOnDelete(std::move(onDelete));
207     }
208 }
209 
JsTouchable(const JSCallbackInfo & info)210 void JSInteractableView::JsTouchable(const JSCallbackInfo& info)
211 {
212     if (info[0]->IsBoolean()) {
213         ViewAbstractModel::GetInstance()->SetTouchable(info[0]->ToBoolean());
214     }
215 }
216 
JsMonopolizeEvents(const JSCallbackInfo & info)217 void JSInteractableView::JsMonopolizeEvents(const JSCallbackInfo& info)
218 {
219     if (info[0]->IsBoolean()) {
220         ViewAbstractModel::GetInstance()->SetMonopolizeEvents(info[0]->ToBoolean());
221     } else {
222         ViewAbstractModel::GetInstance()->SetMonopolizeEvents(false);
223     }
224 }
225 
JsOnClick(const JSCallbackInfo & info)226 void JSInteractableView::JsOnClick(const JSCallbackInfo& info)
227 {
228     JSRef<JSVal> jsOnClickVal = info[0];
229     if (jsOnClickVal->IsUndefined() && IsDisableEventVersion()) {
230         ViewAbstractModel::GetInstance()->DisableOnClick();
231         return;
232     }
233     if (!jsOnClickVal->IsFunction()) {
234         return;
235     }
236     auto frameNode = NG::ViewStackProcessor::GetInstance()->GetMainFrameNode();
237     WeakPtr<NG::FrameNode> weak = AceType::WeakClaim(frameNode);
238     auto jsOnClickFunc = AceType::MakeRefPtr<JsClickFunction>(JSRef<JSFunc>::Cast(jsOnClickVal));
239     auto onTap = [execCtx = info.GetExecutionContext(), func = jsOnClickFunc, node = weak](GestureEvent& info) {
240         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
241         ACE_SCORING_EVENT("onClick");
242         PipelineContext::SetCallBackNode(node);
243         func->Execute(info);
244 #if !defined(PREVIEW) && defined(OHOS_PLATFORM)
245         ReportClickEvent(node);
246 #endif
247     };
248     auto onClick = [execCtx = info.GetExecutionContext(), func = jsOnClickFunc, node = weak](
249                        const ClickInfo* info) {
250         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
251         ACE_SCORING_EVENT("onClick");
252         PipelineContext::SetCallBackNode(node);
253         func->Execute(*info);
254 #if !defined(PREVIEW) && defined(OHOS_PLATFORM)
255         ReportClickEvent(node);
256 #endif
257     };
258 
259     double distanceThreshold = std::numeric_limits<double>::infinity();
260     if (info.Length() > 1 && info[1]->IsNumber()) {
261         distanceThreshold = info[1]->ToNumber<double>();
262     }
263     distanceThreshold = Dimension(distanceThreshold, DimensionUnit::VP).ConvertToPx();
264 
265     ViewAbstractModel::GetInstance()->SetOnClick(std::move(onTap), std::move(onClick), distanceThreshold);
266     CHECK_NULL_VOID(frameNode);
267     auto focusHub = frameNode->GetOrCreateFocusHub();
268     CHECK_NULL_VOID(focusHub);
269     focusHub->SetFocusable(true, false);
270 }
271 
SetFocusable(bool focusable)272 void JSInteractableView::SetFocusable(bool focusable)
273 {
274     ViewAbstractModel::GetInstance()->SetFocusable(focusable);
275 }
276 
SetFocusNode(bool isFocusNode)277 void JSInteractableView::SetFocusNode(bool isFocusNode)
278 {
279     ViewAbstractModel::GetInstance()->SetFocusNode(isFocusNode);
280 }
281 
JsOnAppear(const JSCallbackInfo & info)282 void JSInteractableView::JsOnAppear(const JSCallbackInfo& info)
283 {
284     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
285         ViewAbstractModel::GetInstance()->DisableOnAppear();
286         return;
287     }
288     if (info[0]->IsFunction()) {
289         RefPtr<JsFunction> jsOnAppearFunc =
290             AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
291         auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
292         auto onAppear = [execCtx = info.GetExecutionContext(), func = std::move(jsOnAppearFunc), node = frameNode]() {
293             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
294             ACE_SCORING_EVENT("onAppear");
295             PipelineContext::SetCallBackNode(node);
296             func->Execute();
297         };
298         ViewAbstractModel::GetInstance()->SetOnAppear(std::move(onAppear));
299     }
300 }
301 
JsOnDisAppear(const JSCallbackInfo & info)302 void JSInteractableView::JsOnDisAppear(const JSCallbackInfo& info)
303 {
304     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
305         ViewAbstractModel::GetInstance()->DisableOnDisAppear();
306         return;
307     }
308     if (info[0]->IsFunction()) {
309         RefPtr<JsFunction> jsOnDisAppearFunc =
310             AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
311         auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
312         auto onDisappear = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDisAppearFunc),
313                                node = frameNode]() {
314             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
315             ACE_SCORING_EVENT("onDisAppear");
316             PipelineContext::SetCallBackNode(node);
317             func->Execute();
318         };
319         ViewAbstractModel::GetInstance()->SetOnDisAppear(std::move(onDisappear));
320     }
321 }
322 
JsOnAttach(const JSCallbackInfo & info)323 void JSInteractableView::JsOnAttach(const JSCallbackInfo& info)
324 {
325     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
326         ViewAbstractModel::GetInstance()->DisableOnAttach();
327         return;
328     }
329     if (info[0]->IsFunction()) {
330         RefPtr<JsFunction> jsOnAttachFunc =
331             AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
332         auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
333         auto onAttach = [execCtx = info.GetExecutionContext(), func = std::move(jsOnAttachFunc), node = frameNode]() {
334             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
335             ACE_SCORING_EVENT("onAttach");
336             PipelineContext::SetCallBackNode(node);
337             func->Execute();
338         };
339         ViewAbstractModel::GetInstance()->SetOnAttach(std::move(onAttach));
340     }
341 }
342 
JsOnDetach(const JSCallbackInfo & info)343 void JSInteractableView::JsOnDetach(const JSCallbackInfo& info)
344 {
345     if (info[0]->IsUndefined() && IsDisableEventVersion()) {
346         ViewAbstractModel::GetInstance()->DisableOnDetach();
347         return;
348     }
349     if (info[0]->IsFunction()) {
350         RefPtr<JsFunction> jsOnDetachFunc =
351             AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
352         auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
353         auto onDetach = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDetachFunc), node = frameNode]() {
354             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
355             ACE_SCORING_EVENT("onDetach");
356             PipelineContext::SetCallBackNode(node);
357             func->Execute();
358         };
359         ViewAbstractModel::GetInstance()->SetOnDetach(std::move(onDetach));
360     }
361 }
362 
JsOnAccessibility(const JSCallbackInfo & info)363 void JSInteractableView::JsOnAccessibility(const JSCallbackInfo& info)
364 {
365     if (!info[0]->IsFunction()) {
366         return;
367     }
368     RefPtr<JsFunction> jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
369     WeakPtr<NG::FrameNode> frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
370     auto onAccessibility = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = frameNode](
371                                const std::string& param) {
372         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
373         ACE_SCORING_EVENT("onAccessibility");
374         PipelineContext::SetCallBackNode(node);
375 
376         func->Execute({ "eventType" }, param);
377     };
378     ViewAbstractModel::GetInstance()->SetOnAccessibility(std::move(onAccessibility));
379 }
380 
JsCommonRemoteMessage(const JSCallbackInfo & info)381 void JSInteractableView::JsCommonRemoteMessage(const JSCallbackInfo& info)
382 {
383     if (info.Length() != 0 && info[0]->IsObject()) {
384         RemoteCallback remoteCallback;
385         JsRemoteMessage(info, remoteCallback);
386         ViewAbstractModel::GetInstance()->SetOnRemoteMessage(std::move(remoteCallback));
387     }
388 }
389 
JsRemoteMessage(const JSCallbackInfo & info,RemoteCallback & remoteCallback)390 void JSInteractableView::JsRemoteMessage(const JSCallbackInfo& info, RemoteCallback& remoteCallback)
391 {
392     if (!info[0]->IsObject()) {
393         return;
394     }
395 
396     auto eventCallback = GetRemoteMessageEventCallback(info);
397     remoteCallback = [func = std::move(eventCallback)](const BaseEventInfo* info) {
398         auto touchInfo = TypeInfoHelper::DynamicCast<ClickInfo>(info);
399         if (touchInfo && touchInfo->GetType().compare("onClick") == 0) {
400             func();
401         }
402     };
403 }
404 
GetRemoteMessageEventCallback(const JSCallbackInfo & info)405 std::function<void()> JSInteractableView::GetRemoteMessageEventCallback(const JSCallbackInfo& info)
406 {
407     JSRef<JSVal> arg = info[0];
408     if (!arg->IsObject()) {
409         return []() {};
410     }
411     auto obj = JSRef<JSObject>::Cast(arg);
412     auto actionValue = obj->GetProperty("action");
413     std::string action;
414     if (actionValue->IsString()) {
415         action = actionValue->ToString();
416     }
417     auto abilityValue = obj->GetProperty("ability");
418     std::string ability;
419     if (abilityValue->IsString()) {
420         ability = abilityValue->ToString();
421     }
422     auto paramsObj = obj->GetProperty("params");
423     std::string params;
424     if (paramsObj->IsObject()) {
425         params = paramsObj->ToString();
426     }
427     auto eventCallback = [action, ability, params]() {
428         if (action.compare("message") == 0) {
429             // onCall
430         } else if (action.compare("route") == 0) {
431             // startAbility
432 #ifdef PLUGIN_COMPONENT_SUPPORTED
433             std::vector<std::string> strList;
434             SplitString(ability, '/', strList);
435             if (strList.size() <= 1) {
436                 return;
437             }
438             int32_t result = PluginManager::GetInstance().StartAbility(strList[0], strList[1], params);
439             if (result != 0) {
440                 LOGW("Failed to start the APP %{public}s.", ability.c_str());
441             }
442 #else
443             LOGW("Unsupported Windows and Mac platforms to start APP.");
444 #endif
445         }
446     };
447 
448     return eventCallback;
449 }
450 
451 #if !defined(PREVIEW) && defined(OHOS_PLATFORM)
ReportClickEvent(const WeakPtr<NG::FrameNode> & weakNode,const std::string text)452 void JSInteractableView::ReportClickEvent(const WeakPtr<NG::FrameNode>& weakNode, const std::string text)
453 {
454     if (UiSessionManager::GetInstance().GetClickEventRegistered()) {
455         auto data = JsonUtil::Create();
456         data->Put("event", "onClick");
457         std::string content = text;
458         auto node = weakNode.Upgrade();
459         if (node) {
460             data->Put("id", node->GetId());
461             auto children = node->GetChildren();
462             if (!children.empty()) {
463                 node->GetContainerComponentText(content);
464             }
465             data->Put("text", content.data());
466             data->Put("position", node->GetGeometryNode()->GetFrameRect().ToString().data());
467         }
468         UiSessionManager::GetInstance().ReportClickEvent(data->ToString());
469     }
470 }
471 #endif
472 
SplitString(const std::string & str,char tag,std::vector<std::string> & strList)473 void JSInteractableView::SplitString(const std::string& str, char tag, std::vector<std::string>& strList)
474 {
475     std::string subStr;
476     for (size_t i = 0; i < str.length(); i++) {
477         if (tag == str[i]) {
478             if (!subStr.empty()) {
479                 strList.push_back(subStr);
480                 subStr.clear();
481             }
482         } else {
483             subStr.push_back(str[i]);
484         }
485     }
486     if (!subStr.empty()) {
487         strList.push_back(subStr);
488     }
489 }
490 } // namespace OHOS::Ace::Framework
491