• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_marquee_bridge.h"
16 
17 #include "base/geometry/dimension.h"
18 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
19 #include "core/components/common/properties/text_style.h"
20 
21 static const std::string DEFAULT_FONT_WEIGHT = "400";
22 static const std::vector<OHOS::Ace::MarqueeUpdateStrategy> MARQUEE_UPDATE_STRATEGYS = {
23     OHOS::Ace::MarqueeUpdateStrategy::DEFAULT, OHOS::Ace::MarqueeUpdateStrategy::PRESERVE_POSITION
24 };
25 
26 namespace OHOS::Ace::NG {
27 namespace {
28 constexpr int32_t DEFAULT_MARQUEE_LOOP = -1;
SetMarqueeScrollAmount(const EcmaVM * vm,const Local<JSValueRef> & jsVal,ArkUINodeHandle nativeNode)29 void SetMarqueeScrollAmount(const EcmaVM* vm, const Local<JSValueRef>& jsVal, ArkUINodeHandle nativeNode)
30 {
31     if (jsVal->IsNumber()) {
32         bool isNumber = false;
33         auto step = jsVal->GetValueDouble(isNumber);
34         if (GreatNotEqual(step, 0.0)) {
35             double stepOpt = Dimension(step, DimensionUnit::VP).ConvertToPx();
36             GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeScrollAmount(nativeNode, stepOpt);
37             return;
38         }
39     }
40     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeScrollAmount(nativeNode);
41 }
42 
SetMarqueeLoop(const EcmaVM * vm,const Local<JSValueRef> & jsVal,ArkUINodeHandle nativeNode)43 void SetMarqueeLoop(const EcmaVM* vm, const Local<JSValueRef>& jsVal, ArkUINodeHandle nativeNode)
44 {
45     if (jsVal->IsNumber()) {
46         int32_t loopOpt = 0;
47         bool isNumber = false;
48         auto loopDouble = jsVal->GetValueDouble(isNumber);
49         int32_t loop = DEFAULT_MARQUEE_LOOP;
50         if (GreatNotEqual(loopDouble, 0.0)) {
51             loop = static_cast<int32_t>(loopDouble);
52             if (loop == std::numeric_limits<int32_t>::max() || loop < 0) {
53                 loop = DEFAULT_MARQUEE_LOOP;
54             }
55         }
56         loopOpt = loop;
57         GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeLoop(nativeNode, loopOpt);
58         return;
59     }
60     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeLoop(nativeNode);
61 }
62 } // namespace
63 
SetAllowScale(ArkUIRuntimeCallInfo * runtimeCallInfo)64 ArkUINativeModuleValue MarqueeBridge::SetAllowScale(ArkUIRuntimeCallInfo* runtimeCallInfo)
65 {
66     EcmaVM* vm = runtimeCallInfo->GetVM();
67     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
68     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
69     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
70     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
71     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
72     bool allowScale = secondArg->ToBoolean(vm)->Value();
73     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeAllowScale(nativeNode, allowScale);
74     return panda::JSValueRef::Undefined(vm);
75 }
76 
ResetAllowScale(ArkUIRuntimeCallInfo * runtimeCallInfo)77 ArkUINativeModuleValue MarqueeBridge::ResetAllowScale(ArkUIRuntimeCallInfo* runtimeCallInfo)
78 {
79     EcmaVM* vm = runtimeCallInfo->GetVM();
80     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
81     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
82     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
83     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
84     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeAllowScale(nativeNode);
85     return panda::JSValueRef::Undefined(vm);
86 }
87 
SetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)88 ArkUINativeModuleValue MarqueeBridge::SetFontWeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
89 {
90     EcmaVM* vm = runtimeCallInfo->GetVM();
91     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
92     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
93     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(1);
94     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
95     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
96     std::string weight = DEFAULT_FONT_WEIGHT;
97     if (!weightArg->IsNull()) {
98         if (weightArg->IsNumber()) {
99             weight = std::to_string(weightArg->Int32Value(vm));
100         } else if (weightArg->IsString(vm)) {
101             weight = weightArg->ToString(vm)->ToString(vm);
102         }
103     }
104     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeFontWeight(nativeNode, weight.c_str());
105     return panda::JSValueRef::Undefined(vm);
106 }
107 
ResetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)108 ArkUINativeModuleValue MarqueeBridge::ResetFontWeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
109 {
110     EcmaVM* vm = runtimeCallInfo->GetVM();
111     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
112     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
113     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
114     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
115     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontWeight(nativeNode);
116     return panda::JSValueRef::Undefined(vm);
117 }
118 
SetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)119 ArkUINativeModuleValue MarqueeBridge::SetFontFamily(ArkUIRuntimeCallInfo* runtimeCallInfo)
120 {
121     EcmaVM* vm = runtimeCallInfo->GetVM();
122     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
123     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
124     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
125     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
126     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
127     if (!secondArg->IsString(vm)) {
128         return panda::JSValueRef::Undefined(vm);
129     }
130     std::string families = secondArg->ToString(vm)->ToString(vm);
131     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeFontFamily(nativeNode, families.c_str());
132     return panda::JSValueRef::Undefined(vm);
133 }
134 
ResetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)135 ArkUINativeModuleValue MarqueeBridge::ResetFontFamily(ArkUIRuntimeCallInfo* runtimeCallInfo)
136 {
137     EcmaVM* vm = runtimeCallInfo->GetVM();
138     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
139     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
140     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
141     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
142     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontFamily(nativeNode);
143     return panda::JSValueRef::Undefined(vm);
144 }
145 
SetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)146 ArkUINativeModuleValue MarqueeBridge::SetFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
147 {
148     EcmaVM* vm = runtimeCallInfo->GetVM();
149     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
150     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
151     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
152     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
153     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
154     CalcDimension fontSize;
155     RefPtr<ResourceObject> fontSizeResObj;
156     if (!ArkTSUtils::ParseJsDimensionFp(vm, secondArg, fontSize, fontSizeResObj) || fontSize.IsNegative() ||
157         fontSize.Unit() == DimensionUnit::PERCENT) {
158         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontSize(nativeNode);
159     } else {
160         GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeFontSize(
161             nativeNode, fontSize.Value(), static_cast<int>(fontSize.Unit()), AceType::RawPtr(fontSizeResObj));
162     }
163     return panda::JSValueRef::Undefined(vm);
164 }
165 
ResetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)166 ArkUINativeModuleValue MarqueeBridge::ResetFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
167 {
168     EcmaVM* vm = runtimeCallInfo->GetVM();
169     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
170     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
171     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
172     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
173     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontSize(nativeNode);
174     return panda::JSValueRef::Undefined(vm);
175 }
176 
SetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)177 ArkUINativeModuleValue MarqueeBridge::SetFontColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
178 {
179     EcmaVM* vm = runtimeCallInfo->GetVM();
180     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
181     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
182     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
183     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
184     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
185     Color color;
186     RefPtr<ResourceObject> colorResObj;
187     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
188     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, colorResObj, nodeInfo)) {
189         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontColor(nativeNode);
190     } else {
191         GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeFontColor(
192             nativeNode, color.GetValue(), AceType::RawPtr(colorResObj));
193     }
194     return panda::JSValueRef::Undefined(vm);
195 }
196 
ResetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)197 ArkUINativeModuleValue MarqueeBridge::ResetFontColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
198 {
199     EcmaVM* vm = runtimeCallInfo->GetVM();
200     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
201     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
202     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
203     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
204     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeFontColor(nativeNode);
205     return panda::JSValueRef::Undefined(vm);
206 }
207 
SetMarqueeUpdateStrategy(ArkUIRuntimeCallInfo * runtimeCallInfo)208 ArkUINativeModuleValue MarqueeBridge::SetMarqueeUpdateStrategy(ArkUIRuntimeCallInfo* runtimeCallInfo)
209 {
210     EcmaVM* vm = runtimeCallInfo->GetVM();
211     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
212     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
213     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
214     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
215     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
216     auto value = secondArg->ToString(vm)->ToString(vm);
217     static const LinearMapNode<MarqueeUpdateStrategy> marqueeUpdateStrategyTable[] = {
218         { "default", MarqueeUpdateStrategy::DEFAULT },
219         { "preserve_position", MarqueeUpdateStrategy::PRESERVE_POSITION },
220     };
221     auto marqueeUpdateStrategyIter =
222         BinarySearchFindIndex(marqueeUpdateStrategyTable, ArraySize(marqueeUpdateStrategyTable), value.c_str());
223     if (marqueeUpdateStrategyIter != -1) {
224         GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeUpdateStrategy(nativeNode, marqueeUpdateStrategyIter);
225     } else {
226         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeUpdateStrategy(nativeNode);
227     }
228     return panda::JSValueRef::Undefined(vm);
229 }
230 
ResetMarqueeUpdateStrategy(ArkUIRuntimeCallInfo * runtimeCallInfo)231 ArkUINativeModuleValue MarqueeBridge::ResetMarqueeUpdateStrategy(ArkUIRuntimeCallInfo* runtimeCallInfo)
232 {
233     EcmaVM* vm = runtimeCallInfo->GetVM();
234     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
235     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
236     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
237     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
238     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeUpdateStrategy(nativeNode);
239     return panda::JSValueRef::Undefined(vm);
240 }
241 
SetMarqueeOnStart(ArkUIRuntimeCallInfo * runtimeCallInfo)242 ArkUINativeModuleValue MarqueeBridge::SetMarqueeOnStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
243 {
244     EcmaVM *vm = runtimeCallInfo->GetVM();
245     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
246     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
247     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
248     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
249     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
250     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
251         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnStart(nativeNode);
252         return panda::JSValueRef::Undefined(vm);
253     }
254     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
255     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
256     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
257     std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)]() {
258         panda::LocalScope pandaScope(vm);
259         panda::TryCatch trycatch(vm);
260         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
261         func->Call(vm, func.ToLocal(), nullptr, 0);
262     };
263     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeOnStart(nativeNode, reinterpret_cast<void*>(&callback));
264     return panda::JSValueRef::Undefined(vm);
265 }
266 
ResetMarqueeOnStart(ArkUIRuntimeCallInfo * runtimeCallInfo)267 ArkUINativeModuleValue MarqueeBridge::ResetMarqueeOnStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
268 {
269     EcmaVM* vm = runtimeCallInfo->GetVM();
270     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
271     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
272     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
273     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
274     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnStart(nativeNode);
275     return panda::JSValueRef::Undefined(vm);
276 }
277 
SetMarqueeOnBounce(ArkUIRuntimeCallInfo * runtimeCallInfo)278 ArkUINativeModuleValue MarqueeBridge::SetMarqueeOnBounce(ArkUIRuntimeCallInfo* runtimeCallInfo)
279 {
280     EcmaVM *vm = runtimeCallInfo->GetVM();
281     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
282     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
283     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
284     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
285     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
286     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
287         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnBounce(nativeNode);
288         return panda::JSValueRef::Undefined(vm);
289     }
290     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
291     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
292     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
293     std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)]() {
294         panda::LocalScope pandaScope(vm);
295         panda::TryCatch trycatch(vm);
296         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
297         func->Call(vm, func.ToLocal(), nullptr, 0);
298     };
299     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeOnBounce(nativeNode, reinterpret_cast<void*>(&callback));
300     return panda::JSValueRef::Undefined(vm);
301 }
302 
ResetMarqueeOnBounce(ArkUIRuntimeCallInfo * runtimeCallInfo)303 ArkUINativeModuleValue MarqueeBridge::ResetMarqueeOnBounce(ArkUIRuntimeCallInfo* runtimeCallInfo)
304 {
305     EcmaVM* vm = runtimeCallInfo->GetVM();
306     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
307     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
308     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
309     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
310     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnBounce(nativeNode);
311     return panda::JSValueRef::Undefined(vm);
312 }
313 
SetMarqueeOnFinish(ArkUIRuntimeCallInfo * runtimeCallInfo)314 ArkUINativeModuleValue MarqueeBridge::SetMarqueeOnFinish(ArkUIRuntimeCallInfo* runtimeCallInfo)
315 {
316     EcmaVM *vm = runtimeCallInfo->GetVM();
317     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
318     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
319     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
320     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
321     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
322     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
323         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnFinish(nativeNode);
324         return panda::JSValueRef::Undefined(vm);
325     }
326     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
327     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
328     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
329     std::function<void(void)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)]() {
330         panda::LocalScope pandaScope(vm);
331         panda::TryCatch trycatch(vm);
332         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
333         func->Call(vm, func.ToLocal(), nullptr, 0);
334     };
335     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeOnFinish(nativeNode, reinterpret_cast<void*>(&callback));
336     return panda::JSValueRef::Undefined(vm);
337 }
338 
ResetMarqueeOnFinish(ArkUIRuntimeCallInfo * runtimeCallInfo)339 ArkUINativeModuleValue MarqueeBridge::ResetMarqueeOnFinish(ArkUIRuntimeCallInfo* runtimeCallInfo)
340 {
341     EcmaVM* vm = runtimeCallInfo->GetVM();
342     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
343     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
344     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
345     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
346     GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeOnFinish(nativeNode);
347     return panda::JSValueRef::Undefined(vm);
348 }
349 
SetInitialize(ArkUIRuntimeCallInfo * runtimeCallInfo)350 ArkUINativeModuleValue MarqueeBridge::SetInitialize(ArkUIRuntimeCallInfo* runtimeCallInfo)
351 {
352     EcmaVM* vm = runtimeCallInfo->GetVM();
353     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
354     Local<JSValueRef> nodeVal = runtimeCallInfo->GetCallArgRef(0);
355     Local<JSValueRef> startVal = runtimeCallInfo->GetCallArgRef(1);
356     Local<JSValueRef> stepVal = runtimeCallInfo->GetCallArgRef(2);
357     Local<JSValueRef> loopVal = runtimeCallInfo->GetCallArgRef(3);
358     Local<JSValueRef> fromStartVal = runtimeCallInfo->GetCallArgRef(4);
359     Local<JSValueRef> srcVal = runtimeCallInfo->GetCallArgRef(5);
360     CHECK_NULL_RETURN(nodeVal->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
361     auto nativeNode = nodePtr(nodeVal->ToNativePointer(vm)->Value());
362     bool fromStart = fromStartVal->IsBoolean() ? fromStartVal->ToBoolean(vm)->Value() : true;
363     SetMarqueeScrollAmount(vm, stepVal, nativeNode);
364     SetMarqueeLoop(vm, loopVal, nativeNode);
365     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueePlayerStatus(
366         nativeNode, startVal->IsBoolean() ? startVal->ToBoolean(vm)->Value() : false);
367     GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeDirection(nativeNode,
368         fromStart ? static_cast<int32_t>(MarqueeDirection::LEFT) : static_cast<int32_t>(MarqueeDirection::RIGHT));
369     if (srcVal->IsString(vm)) {
370         GetArkUINodeModifiers()->getMarqueeModifier()->setMarqueeSrcValue(
371             nativeNode, srcVal->ToString(vm)->ToString(vm).c_str());
372     } else {
373         GetArkUINodeModifiers()->getMarqueeModifier()->resetMarqueeSrcValue(nativeNode);
374     }
375     return panda::JSValueRef::Undefined(vm);
376 }
377 } // namespace OHOS::Ace::NG