• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.h"
16 #include <utility>
17 
18 #include "ark_native_engine.h"
19 #include "jsnapi_expo.h"
20 
21 #include "base/memory/ace_type.h"
22 #include "base/utils/string_utils.h"
23 #include "base/utils/utils.h"
24 #include "bridge/declarative_frontend/engine/functions/js_should_built_in_recognizer_parallel_with_function.h"
25 #include "bridge/declarative_frontend/engine/js_ref_ptr.h"
26 #include "bridge/declarative_frontend/engine/jsi/js_ui_index.h"
27 #include "bridge/declarative_frontend/engine/jsi/jsi_types.h"
28 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h"
29 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_utils_bridge.h"
30 #include "bridge/declarative_frontend/jsview/js_gesture.h"
31 #include "bridge/declarative_frontend/jsview/js_view_abstract.h"
32 #include "bridge/declarative_frontend/jsview/js_view_context.h"
33 #include "bridge/js_frontend/engine/jsi/ark_js_runtime.h"
34 #include "core/common/resource/resource_parse_utils.h"
35 #include "frameworks/bridge/declarative_frontend/engine/functions/js_accessibility_function.h"
36 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
37 #include "frameworks/bridge/declarative_frontend/jsview/js_shape_abstract.h"
38 #include "frameworks/core/components_ng/pattern/text/span_model_ng.h"
39 
40 #include "base/log/ace_scoring_log.h"
41 #include "bridge/declarative_frontend/jsview/js_view_abstract.h"
42 #include "bridge/declarative_frontend/jsview/js_utils.h"
43 #include "bridge/declarative_frontend/jsview/js_accessibility.h"
44 #include "bridge/declarative_frontend/jsview/js_popups.h"
45 #include "bridge/declarative_frontend/style_string/js_span_string.h"
46 using namespace OHOS::Ace::Framework;
47 
48 namespace OHOS::Ace::NG {
49 namespace {
50 constexpr uint32_t COLOR_ALPHA_VALUE = 0xFF000000;
51 constexpr uint32_t ALIGNMENT_TOP_LEFT = 0;
52 constexpr uint32_t ALIGNMENT_CENTER = 4;
53 constexpr int32_t DEFAULT_LAYOUT_SAFE_AREA_EDGE_FOR_COLOR_BACKGROUND = 6;
54 constexpr float DEFAULT_PROGRESS_TOTAL = 100.0f;
55 constexpr int NUM_0 = 0;
56 constexpr int NUM_1 = 1;
57 constexpr int NUM_2 = 2;
58 constexpr int NUM_3 = 3;
59 constexpr int NUM_4 = 4;
60 constexpr int NUM_5 = 5;
61 constexpr int NUM_6 = 6;
62 constexpr int NUM_7 = 7;
63 constexpr int NUM_8 = 8;
64 constexpr int NUM_9 = 9;
65 constexpr int NUM_10 = 10;
66 constexpr int NUM_11 = 11;
67 constexpr int NUM_12 = 12;
68 constexpr int NUM_13 = 13;
69 constexpr int SIZE_OF_ONE = 1;
70 constexpr int SIZE_OF_TWO = 2;
71 constexpr int SIZE_OF_THREE = 3;
72 constexpr int SIZE_OF_FOUR = 4;
73 constexpr int SIZE_OF_FIVE = 5;
74 constexpr int SIZE_OF_SEVEN = 7;
75 constexpr int SIZE_OF_EIGHT = 8;
76 constexpr int32_t ALIGN_RULES_NUM = 6;
77 constexpr int32_t ALIGN_DIRECTION_DEFAULT = 2;
78 constexpr double FULL_DIMENSION = 100.0;
79 constexpr double HALF_DIMENSION = 50.0;
80 constexpr uint32_t DEFAULT_DURATION = 1000;
81 constexpr int64_t MICROSEC_TO_MILLISEC = 1000;
82 constexpr int32_t MAX_ALIGN_VALUE = 8;
83 constexpr int32_t BACKWARD_COMPAT_MAGIC_NUMBER_OFFSCREEN = 1000;
84 constexpr SharedTransitionEffectType DEFAULT_SHARED_EFFECT = SharedTransitionEffectType::SHARED_EFFECT_EXCHANGE;
85 constexpr int32_t DEFAULT_TAP_FINGER = 1;
86 constexpr int32_t DEFAULT_TAP_COUNT = 1;
87 constexpr double DEFAULT_TAP_DISTANCE = std::numeric_limits<double>::infinity();
88 constexpr int32_t DEFAULT_LONG_PRESS_FINGER = 1;
89 constexpr int32_t DEFAULT_LONG_PRESS_DURATION = 500;
90 constexpr int32_t DEFAULT_PINCH_FINGER = 2;
91 constexpr int32_t DEFAULT_MAX_PINCH_FINGER = 5;
92 constexpr double DEFAULT_PINCH_DISTANCE = 5.0;
93 constexpr int32_t DEFAULT_PAN_FINGER = 1;
94 constexpr int32_t DEFAULT_MAX_FINGERS = 10;
95 constexpr OHOS::Ace::Dimension DEFAULT_PAN_DISTANCE = 5.0_vp;
96 constexpr OHOS::Ace::Dimension DEFAULT_PEN_PAN_DISTANCE = 8.0_vp;
97 constexpr int32_t DEFAULT_SLIDE_FINGER = DEFAULT_PAN_FINGER;
98 constexpr double DEFAULT_SLIDE_SPEED = 100.0;
99 constexpr int32_t DEFAULT_ROTATION_FINGER = 2;
100 constexpr int32_t DEFAULT_MAX_ROTATION_FINGER = 5;
101 constexpr double DEFAULT_ROTATION_ANGLE = 1.0;
102 constexpr double DEFAULT_MAX_ROTATION_ANGLE = 360.0;
103 const std::string BLOOM_RADIUS_SYS_RES_NAME = "sys.float.ohos_id_point_light_bloom_radius";
104 const std::string BLOOM_COLOR_SYS_RES_NAME = "sys.color.ohos_id_point_light_bloom_color";
105 const std::string ILLUMINATED_BORDER_WIDTH_SYS_RES_NAME = "sys.float.ohos_id_point_light_illuminated_border_width";
106 constexpr double VISIBLE_RATIO_MIN = 0.0;
107 constexpr double VISIBLE_RATIO_MAX = 1.0;
108 enum ParseResult { LENGTHMETRICS_SUCCESS, DIMENSION_SUCCESS, FAIL };
109 constexpr int32_t PARAMETER_LENGTH_SECOND = 2;
110 constexpr int32_t PARAMETER_LENGTH_THIRD = 3;
111 
ConvertBorderStyle(int32_t value)112 BorderStyle ConvertBorderStyle(int32_t value)
113 {
114     auto style = static_cast<BorderStyle>(value);
115     if (style < BorderStyle::SOLID || style > BorderStyle::NONE) {
116         style = BorderStyle::SOLID;
117     }
118     return style;
119 }
120 
ParseJsDouble(const EcmaVM * vm,const Local<JSValueRef> & value,double & result)121 bool ParseJsDouble(const EcmaVM *vm, const Local<JSValueRef> &value, double &result)
122 {
123     if (value->IsNumber()) {
124         result = value->ToNumber(vm)->Value();
125         return true;
126     }
127     if (value->IsString(vm)) {
128         return StringUtils::StringToDouble(value->ToString(vm)->ToString(vm), result);
129     }
130 
131     return false;
132 }
133 
ParseGradientColorStopsWithColorSpace(const EcmaVM * vm,const Local<JSValueRef> & value,std::vector<ArkUIInt32orFloat32> & colors,std::optional<ColorSpace> & colorSpace)134 void ParseGradientColorStopsWithColorSpace(const EcmaVM *vm, const Local<JSValueRef> &value,
135     std::vector<ArkUIInt32orFloat32> &colors, std::optional<ColorSpace> &colorSpace)
136 {
137     if (!value->IsArray(vm)) {
138         return;
139     }
140     auto array = panda::Local<panda::ArrayRef>(value);
141     auto length = array->Length(vm);
142     bool isValid = true;
143     for (uint32_t index = 0; index < length; index++) {
144         auto item = panda::ArrayRef::GetValueAt(vm, array, index);
145         if (!item->IsArray(vm)) {
146             continue;
147         }
148         auto itemArray = panda::Local<panda::ArrayRef>(item);
149         auto itemLength = itemArray->Length(vm);
150         if (itemLength < NUM_1) {
151             continue;
152         }
153         Color color;
154         auto colorParams = panda::ArrayRef::GetValueAt(vm, itemArray, NUM_0);
155         if (!ArkTSUtils::ParseJsColorAlpha(vm, colorParams, color)) {
156             continue;
157         }
158         // is valid
159         if (!colorSpace.has_value()) {
160             colorSpace = color.GetColorSpace();
161         } else if (color.GetColorSpace() != colorSpace.value()) {
162             isValid = false;
163             colors.clear();
164             colorSpace = ColorSpace::SRGB;
165             break;
166         }
167         bool hasDimension = false;
168         double dimension = 0.0;
169         if (itemLength > NUM_1) {
170             auto stopDimension = panda::ArrayRef::GetValueAt(vm, itemArray, NUM_1);
171             if (ArkTSUtils::ParseJsDouble(vm, stopDimension, dimension)) {
172                 hasDimension = true;
173             }
174         }
175         colors.push_back({.u32 = static_cast<ArkUI_Uint32>(color.GetValue())});
176         colors.push_back({.i32 = static_cast<ArkUI_Int32>(hasDimension)});
177         colors.push_back({.f32 = static_cast<ArkUI_Float32>(dimension)});
178     }
179 }
180 
ParseJsShadowColorStrategy(const EcmaVM * vm,const Local<JSValueRef> & value,ShadowColorStrategy & strategy)181 bool ParseJsShadowColorStrategy(const EcmaVM *vm, const Local<JSValueRef> &value, ShadowColorStrategy& strategy)
182 {
183     if (value->IsString(vm)) {
184         std::string colorStr = value->ToString(vm)->ToString(vm);
185         if (colorStr.compare("average") == 0) {
186             strategy = ShadowColorStrategy::AVERAGE;
187             return true;
188         } else if (colorStr.compare("primary") == 0) {
189             strategy = ShadowColorStrategy::PRIMARY;
190             return true;
191         }
192     }
193     return false;
194 }
195 
ParseJsShadowDimension(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimension,std::vector<RefPtr<ResourceObject>> & vectorResObj)196 bool ParseJsShadowDimension(const EcmaVM *vm, const Local<JSValueRef> &value, CalcDimension& dimension,
197     std::vector<RefPtr<ResourceObject>>& vectorResObj)
198 {
199     RefPtr<ResourceObject> shadowResObj;
200     bool ret = ArkTSUtils::ParseJsResource(vm, value, dimension, shadowResObj);
201     if (!ret) {
202         ret = ArkTSUtils::ParseJsDimensionVp(vm, value, dimension);
203     }
204     if (shadowResObj) {
205         vectorResObj.push_back(shadowResObj);
206     } else {
207         vectorResObj.push_back(nullptr);
208     }
209     return ret;
210 }
211 
ParseJsShadowColor(const EcmaVM * vm,const Local<JSValueRef> & colorArg,int32_t & type,uint32_t & colorValue,RefPtr<ResourceObject> & colorResObj,ArkUINodeHandle nativeNode)212 bool ParseJsShadowColor(const EcmaVM *vm, const Local<JSValueRef> &colorArg,
213     int32_t& type, uint32_t& colorValue, RefPtr<ResourceObject>& colorResObj,
214     ArkUINodeHandle nativeNode)
215 {
216     Color color;
217     ShadowColorStrategy shadowColorStrategy;
218     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
219     if (ParseJsShadowColorStrategy(vm, colorArg, shadowColorStrategy)) {
220         type = 1; // 1: has shadowColorStrategy
221         colorValue = static_cast<uint32_t>(shadowColorStrategy);
222         return true;
223     } else if (ArkTSUtils::ParseJsColorAlpha(vm, colorArg, color, colorResObj, nodeInfo)) {
224         type = 2; // 2: has shadowColor
225         colorValue = color.GetValue();
226         return true;
227     }
228     return false;
229 }
230 
ParseCalcDimensions(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t offset,uint32_t count,std::vector<std::optional<CalcDimension>> & results,const CalcDimension & defValue)231 bool ParseCalcDimensions(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, uint32_t count,
232     std::vector<std::optional<CalcDimension>>& results, const CalcDimension& defValue)
233 {
234     auto end = offset + count;
235     auto argsNumber = runtimeCallInfo->GetArgsNumber();
236     if (end > argsNumber) {
237         return false;
238     }
239     bool hasValue = false;
240     EcmaVM* vm = runtimeCallInfo->GetVM();
241     for (uint32_t index = offset; index < end; index++) {
242         auto arg = runtimeCallInfo->GetCallArgRef(index);
243         std::optional<CalcDimension> optCalcDimension;
244         CalcDimension dimension(defValue);
245         if (ArkTSUtils::ParseJsDimensionVp(vm, arg, dimension, false)) {
246             optCalcDimension = dimension;
247             hasValue = true;
248         }
249         results.push_back(optCalcDimension);
250     }
251     return hasValue;
252 }
253 
ParseCalcDimensionsNG(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t offset,uint32_t count,std::vector<std::optional<CalcDimension>> & results,std::vector<RefPtr<ResourceObject>> & edgesResObj,const CalcDimension & defValue)254 ParseResult ParseCalcDimensionsNG(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, uint32_t count,
255     std::vector<std::optional<CalcDimension>>& results, std::vector<RefPtr<ResourceObject>>& edgesResObj,
256     const CalcDimension& defValue)
257 {
258     auto end = offset + count;
259     auto argsNumber = runtimeCallInfo->GetArgsNumber();
260     if (end > argsNumber) {
261         return ParseResult::FAIL;
262     }
263     ParseResult res = ParseResult::FAIL;
264     EcmaVM* vm = runtimeCallInfo->GetVM();
265     for (uint32_t index = offset; index < end; index++) {
266         auto arg = runtimeCallInfo->GetCallArgRef(index);
267         std::optional<CalcDimension> optCalcDimension;
268         RefPtr<ResourceObject> resObj;
269         CalcDimension dimension(defValue);
270         // Parse string, '10abc' return false
271         if (ArkTSUtils::ParseJsDimensionVpNG(vm, arg, dimension, resObj, true)) {
272             optCalcDimension = dimension;
273             res = ParseResult::DIMENSION_SUCCESS;
274         } else if (ArkTSUtils::ParseJsLengthMetrics(vm, arg, dimension)) {
275             optCalcDimension = dimension;
276             res = ParseResult::LENGTHMETRICS_SUCCESS;
277         }
278         results.push_back(optCalcDimension);
279         if (SystemProperties::ConfigChangePerform()) {
280             edgesResObj.push_back(resObj);
281         }
282     }
283     return res;
284 }
285 
ParseTipsOptionsTime(EcmaVM * vm,ArkUIBindTipsOptionsTime & options,Local<JSValueRef> arg,ArkUI_Float32 & targetField)286 void ParseTipsOptionsTime(
287     EcmaVM* vm, ArkUIBindTipsOptionsTime& options, Local<JSValueRef> arg, ArkUI_Float32& targetField)
288 {
289     if (!arg->IsUndefined() && !arg->IsNull() && arg->IsNumber()) {
290         ArkUI_Float32 value = arg->ToNumber(vm)->Value();
291         if (value >= 0) {
292             targetField = value;
293         }
294     }
295 }
296 
ParseTipsOptionsArrowSize(EcmaVM * vm,Local<JSValueRef> arg,ArkUI_Float64 & targetValue,ArkUI_Int32 & targetUnit)297 void ParseTipsOptionsArrowSize(EcmaVM* vm, Local<JSValueRef> arg, ArkUI_Float64& targetValue, ArkUI_Int32& targetUnit)
298 {
299     CalcDimension dimension;
300     if (!arg->IsUndefined() && !arg->IsNull() && ArkTSUtils::ParseJsDimensionVp(vm, arg, dimension, true)) {
301         if (dimension.Value() > 0 && dimension.Unit() != DimensionUnit::PERCENT) {
302             targetValue = dimension.Value();
303             targetUnit = static_cast<ArkUI_Int32>(dimension.Unit());
304         }
305     }
306 }
307 
ParseTipsOptionsShowAtAnchor(EcmaVM * vm,Local<JSValueRef> showAtAnchorArg,ArkUIBindTipsOptionsArrow & options)308 void ParseTipsOptionsShowAtAnchor(EcmaVM* vm, Local<JSValueRef> showAtAnchorArg, ArkUIBindTipsOptionsArrow& options)
309 {
310     options.showAtAnchor = static_cast<int32_t>(TipsAnchorType::TARGET);
311     if (showAtAnchorArg->IsNumber()) {
312         int32_t temp = static_cast<int32_t>(showAtAnchorArg->ToNumber(vm)->Value());
313         if (temp <= static_cast<int32_t>(TipsAnchorType::CURSOR) &&
314             temp >= static_cast<int32_t>(TipsAnchorType::TARGET)) {
315             options.showAtAnchor = temp;
316             options.enableArrow = temp == static_cast<int32_t>(TipsAnchorType::CURSOR) ? false : options.enableArrow;
317         }
318     }
319 }
320 
ResetCalcDimensions(std::vector<std::optional<CalcDimension>> & optDimensions)321 void ResetCalcDimensions(std::vector<std::optional<CalcDimension>>& optDimensions)
322 {
323     for (uint32_t index = 0; index < optDimensions.size(); index++) {
324         auto optDimension = optDimensions[index];
325         optDimension.reset();
326     }
327 }
328 
PushDimensionsToVector(std::vector<ArkUIStringAndFloat> & results,const std::vector<std::optional<CalcDimension>> & optDimensions)329 void PushDimensionsToVector(std::vector<ArkUIStringAndFloat>& results,
330     const std::vector<std::optional<CalcDimension>>& optDimensions)
331 {
332     for (uint32_t index = 0; index < optDimensions.size(); index++) {
333         auto optDimension = optDimensions[index];
334         auto hasValue = optDimension.has_value();
335         DimensionUnit unit = DimensionUnit::PX;
336         ArkUIStringAndFloat value = { 0.0, nullptr };
337         if (hasValue) {
338             unit = optDimension.value().Unit();
339             if (unit == DimensionUnit::CALC) {
340                 value.valueStr = optDimension.value().CalcValue().c_str();
341             } else {
342                 value.value = optDimension.value().Value();
343             }
344         }
345         results.push_back(ArkUIStringAndFloat { static_cast<ArkUI_Float32>(hasValue), nullptr });
346         results.push_back(value);
347         results.push_back(ArkUIStringAndFloat { static_cast<ArkUI_Float32>(unit), nullptr });
348     }
349 }
350 
ParseBorderImageSlice(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,std::vector<std::optional<CalcDimension>> & optDimensions,uint8_t & bitsets)351 void ParseBorderImageSlice(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
352     std::vector<std::optional<CalcDimension>>& optDimensions, uint8_t& bitsets)
353 {
354     if (ParseCalcDimensions(runtimeCallInfo, offset, NUM_4, optDimensions, CalcDimension(0.0))) {
355         bitsets |= BorderImage::SLICE_BIT;
356     }
357     offset += NUM_4;
358 }
359 
ParseBorderImageWidth(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,std::vector<std::optional<CalcDimension>> & optDimensions,uint8_t & bitsets)360 void ParseBorderImageWidth(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
361     std::vector<std::optional<CalcDimension>>& optDimensions, uint8_t& bitsets)
362 {
363     if (ParseCalcDimensions(runtimeCallInfo, offset, NUM_4, optDimensions, CalcDimension(0.0))) {
364         bitsets |= BorderImage::WIDTH_BIT;
365     }
366     offset += NUM_4;
367 }
368 
ParseBorderImageOutset(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,std::vector<std::optional<CalcDimension>> & optDimensions,uint8_t & bitsets)369 void ParseBorderImageOutset(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
370     std::vector<std::optional<CalcDimension>>& optDimensions, uint8_t& bitsets)
371 {
372     if (ParseCalcDimensions(runtimeCallInfo, offset, NUM_4, optDimensions, CalcDimension(0.0))) {
373         bitsets |= BorderImage::OUTSET_BIT;
374     }
375     offset += NUM_4;
376 }
377 
ParseBorderImageRepeat(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,std::vector<ArkUIStringAndFloat> & options,uint8_t & bitsets)378 bool ParseBorderImageRepeat(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
379     std::vector<ArkUIStringAndFloat>& options, uint8_t& bitsets)
380 {
381     auto argsNumber = runtimeCallInfo->GetArgsNumber();
382     if ((offset + NUM_1) > argsNumber) {
383         return false;
384     }
385     auto vm = runtimeCallInfo->GetVM();
386     auto repeatArg = runtimeCallInfo->GetCallArgRef(offset);
387     auto repeatHasValue = repeatArg->IsString(vm);
388     auto repeatValue = BorderImageRepeat::STRETCH;
389     if (repeatHasValue) {
390         auto repeatStr = repeatArg->ToString(vm)->ToString(vm);
391         if (repeatStr == "Repeat") {
392             repeatValue = BorderImageRepeat::REPEAT;
393         } else if (repeatStr == "Round") {
394             repeatValue = BorderImageRepeat::ROUND;
395         } else if (repeatStr == "Space") {
396             repeatValue = BorderImageRepeat::SPACE;
397         } else {
398             repeatValue = BorderImageRepeat::STRETCH;
399         }
400     }
401     options.push_back(ArkUIStringAndFloat { static_cast<ArkUI_Float32>(repeatHasValue), nullptr });
402     options.push_back(ArkUIStringAndFloat { static_cast<ArkUI_Float32>(repeatValue), nullptr });
403     if (repeatHasValue) {
404         bitsets |= BorderImage::REPEAT_BIT;
405     }
406     offset += NUM_1;
407     return true;
408 }
409 
ParseBorderImageFill(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,std::vector<ArkUIStringAndFloat> & options)410 bool ParseBorderImageFill(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
411     std::vector<ArkUIStringAndFloat>& options)
412 {
413     auto argsNumber = runtimeCallInfo->GetArgsNumber();
414     if ((offset + NUM_1) > argsNumber) {
415         return false;
416     }
417     auto fillArg = runtimeCallInfo->GetCallArgRef(offset);
418     auto hasValue = fillArg->IsBoolean();
419     auto fill = (hasValue) ? fillArg->BooleaValue(runtimeCallInfo->GetVM()) : false;
420     options.push_back(ArkUIStringAndFloat {static_cast<ArkUI_Float32>(hasValue), nullptr });
421     options.push_back(ArkUIStringAndFloat {static_cast<ArkUI_Float32>(fill), nullptr });
422     offset += NUM_1;
423     return true;
424 }
425 
IsArgsUndefined(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t offset,uint32_t count)426 bool IsArgsUndefined(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, uint32_t count)
427 {
428     auto argsNumber = runtimeCallInfo->GetArgsNumber();
429     auto end = offset + count;
430     end = (end > argsNumber) ? argsNumber : end;
431     for (uint32_t index = offset; index < end; index++) {
432         auto jsArg = runtimeCallInfo->GetCallArgRef(index);
433         if (jsArg->IsUndefined()) {
434             continue;
435         }
436         return false;
437     }
438     return true;
439 }
440 
ParseBorderImageLinearGradient(ArkUINodeHandle node,ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t offset,uint8_t & bitsets)441 void ParseBorderImageLinearGradient(ArkUINodeHandle node,
442     ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset,
443     uint8_t& bitsets)
444 {
445     auto argsNumber = runtimeCallInfo->GetArgsNumber();
446     if ((offset + NUM_4) > argsNumber) {
447         return;
448     }
449     auto angleArg = runtimeCallInfo->GetCallArgRef(offset);
450     auto directionArg = runtimeCallInfo->GetCallArgRef(offset + NUM_1);
451     auto colorsArg = runtimeCallInfo->GetCallArgRef(offset + NUM_2);
452     auto repeatingArg = runtimeCallInfo->GetCallArgRef(offset + NUM_3);
453     if (angleArg->IsUndefined() && directionArg->IsUndefined() &&
454         colorsArg->IsUndefined() && repeatingArg->IsUndefined()) {
455         return;
456     }
457     auto vm = runtimeCallInfo->GetVM();
458     std::vector<ArkUIInt32orFloat32> options;
459     ArkTSUtils::ParseGradientAngle(vm, angleArg, options);
460     int32_t direction = static_cast<int32_t>(GradientDirection::NONE);
461     ArkTSUtils::ParseJsInt32(vm, directionArg, direction);
462     options.push_back({.i32 = static_cast<ArkUI_Int32>(direction)});
463 
464     std::vector<ArkUIInt32orFloat32> colors;
465     ArkTSUtils::ParseGradientColorStops(vm, colorsArg, colors);
466     auto repeating = repeatingArg->IsBoolean() ? repeatingArg->BooleaValue(runtimeCallInfo->GetVM()) : false;
467     options.push_back({.i32 = static_cast<ArkUI_Int32>(repeating)});
468     GetArkUINodeModifiers()->getCommonModifier()->setBorderImageGradient(node,
469         options.data(), options.size(), colors.data(), colors.size());
470 }
471 
ParseBorderImageSource(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t & offset,ArkUINodeHandle node,std::string & src,uint8_t & bitsets)472 bool ParseBorderImageSource(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t& offset,
473     ArkUINodeHandle node, std::string& src, uint8_t& bitsets)
474 {
475     auto argsNumber = runtimeCallInfo->GetArgsNumber();
476     if ((offset + NUM_5) > argsNumber) {
477         return false;
478     }
479     if (IsArgsUndefined(runtimeCallInfo, offset, NUM_5)) {
480         return false;
481     }
482     auto sourceArg = runtimeCallInfo->GetCallArgRef(offset); // use 1 args
483     offset += NUM_1;
484     auto vm = runtimeCallInfo->GetVM();
485     if (sourceArg->IsString(vm)) {
486         src = sourceArg->ToString(vm)->ToString(vm);
487         bitsets |= BorderImage::SOURCE_BIT;
488     } else {
489         if (ArkTSUtils::ParseJsMedia(vm, sourceArg, src)) {
490             bitsets |= BorderImage::SOURCE_BIT;
491         } else {
492             ParseBorderImageLinearGradient(node, runtimeCallInfo, offset, bitsets);
493         }
494     }
495     offset += NUM_4; // skip 4 args
496     return true;
497 }
498 
ParseChainedMoveTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)499 RefPtr<NG::ChainedTransitionEffect> ParseChainedMoveTransition(
500     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
501 {
502     int32_t edge = 0;
503     if (JSViewAbstract::ParseJsInt32(effectOption, edge)) {
504         if (edge < static_cast<int32_t>(NG::TransitionEdge::TOP) ||
505             edge > static_cast<int32_t>(NG::TransitionEdge::END)) {
506             edge = static_cast<int32_t>(NG::TransitionEdge::START);
507         }
508         return AceType::MakeRefPtr<NG::ChainedMoveEffect>(static_cast<NG::TransitionEdge>(edge));
509     }
510     return nullptr;
511 }
512 
ParseChainedOpacityTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)513 RefPtr<NG::ChainedTransitionEffect> ParseChainedOpacityTransition(
514     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
515 {
516     double opacity = 1.0;
517     if (Framework::JSViewAbstract::ParseJsDouble(effectOption, opacity)) {
518         if ((LessNotEqual(opacity, 0.0)) || opacity > 1.0) {
519             opacity = 1.0;
520         }
521         return AceType::MakeRefPtr<NG::ChainedOpacityEffect>(opacity);
522     }
523     return nullptr;
524 }
525 
ParseJsTranslate(const Framework::JSRef<Framework::JSVal> & jsValue,CalcDimension & translateX,CalcDimension & translateY,CalcDimension & translateZ)526 void ParseJsTranslate(const Framework::JSRef<Framework::JSVal>& jsValue, CalcDimension& translateX,
527     CalcDimension& translateY, CalcDimension& translateZ)
528 {
529     if (!jsValue->IsObject()) {
530         return;
531     }
532     Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(jsValue);
533     Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("x"), translateX);
534     Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("y"), translateY);
535     Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("z"), translateZ);
536 }
537 
ParseStrToUint(std::string safeAreaTypeStr)538 uint32_t ParseStrToUint(std::string safeAreaTypeStr)
539 {
540     uint32_t uintType = NG::SAFE_AREA_TYPE_NONE;
541     std::string delimiter = "|";
542     std::string type;
543     size_t pos = 0;
544     while ((pos = safeAreaTypeStr.find(delimiter)) != std::string::npos) {
545         type = safeAreaTypeStr.substr(0, pos);
546         uintType |= (1 << StringUtils::StringToUint(type));
547         safeAreaTypeStr.erase(0, pos + delimiter.length());
548     }
549     uintType |= (1 << StringUtils::StringToUint(safeAreaTypeStr));
550     return uintType;
551 }
552 
ParseLayoutSafeAreaTypeStr(std::string safeAreaTypeStr)553 uint32_t ParseLayoutSafeAreaTypeStr(std::string safeAreaTypeStr)
554 {
555     uint32_t uintType = NG::LAYOUT_SAFE_AREA_TYPE_NONE;
556     std::string delimiter = "|";
557     std::string type;
558     size_t pos = 0;
559     while ((pos = safeAreaTypeStr.find(delimiter)) != std::string::npos) {
560         type = safeAreaTypeStr.substr(0, pos);
561         uintType |= IgnoreLayoutSafeAreaOpts::TypeToMask(StringUtils::StringToUint(type));
562         safeAreaTypeStr.erase(0, pos + delimiter.length());
563     }
564     if (safeAreaTypeStr != "") {
565         uintType |= IgnoreLayoutSafeAreaOpts::TypeToMask(StringUtils::StringToUint(safeAreaTypeStr));
566     }
567     return uintType;
568 }
569 
ParseLayoutSafeAreaEdgesStr(std::string safeAreaEdgeStr)570 uint32_t ParseLayoutSafeAreaEdgesStr(std::string safeAreaEdgeStr)
571 {
572     uint32_t uintType = NG::LAYOUT_SAFE_AREA_EDGE_NONE;
573     std::string delimiter = "|";
574     std::string type;
575     size_t pos = 0;
576     while ((pos = safeAreaEdgeStr.find(delimiter)) != std::string::npos) {
577         type = safeAreaEdgeStr.substr(0, pos);
578         uintType |= IgnoreLayoutSafeAreaOpts::EdgeToMask(StringUtils::StringToUint(type));
579         safeAreaEdgeStr.erase(0, pos + delimiter.length());
580     }
581     if (safeAreaEdgeStr != "") {
582         uintType |= IgnoreLayoutSafeAreaOpts::EdgeToMask(StringUtils::StringToUint(safeAreaEdgeStr));
583     }
584     return uintType;
585 }
586 
ParseChainedTranslateTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)587 RefPtr<NG::ChainedTransitionEffect> ParseChainedTranslateTransition(
588     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
589 {
590     if (effectOption->IsObject()) {
591         // default: x, y, z (0.0, 0.0, 0.0)
592         NG::TranslateOptions translate;
593         ParseJsTranslate(effectOption, translate.x, translate.y, translate.z);
594         return AceType::MakeRefPtr<NG::ChainedTranslateEffect>(translate);
595     }
596     return nullptr;
597 }
598 
GetDefaultRotateVector(double & dx,double & dy,double & dz)599 void GetDefaultRotateVector(double& dx, double& dy, double& dz)
600 {
601     dx = 0.0;
602     dy = 0.0;
603     dz = 0.0;
604     if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_NINE)) {
605         dz = 1.0;
606     }
607 }
608 
ParseJsRotate(const Framework::JSRef<Framework::JSVal> & jsValue,NG::RotateOptions & rotate,std::optional<float> & angle)609 void ParseJsRotate(
610     const Framework::JSRef<Framework::JSVal>& jsValue, NG::RotateOptions& rotate, std::optional<float>& angle)
611 {
612     if (!jsValue->IsObject()) {
613         return;
614     }
615     // default: dx, dy, dz (0.0, 0.0, 0.0)
616     double dxVal = 0.0;
617     double dyVal = 0.0;
618     double dzVal = 0.0;
619     Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(jsValue);
620     if (!jsObj->HasProperty("x") && !jsObj->HasProperty("y") && !jsObj->HasProperty("z")) {
621         GetDefaultRotateVector(dxVal, dyVal, dzVal);
622     } else {
623         Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("x"), dxVal);
624         Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("y"), dyVal);
625         Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("z"), dzVal);
626     }
627     rotate.xDirection = static_cast<float>(dxVal);
628     rotate.yDirection = static_cast<float>(dyVal);
629     rotate.zDirection = static_cast<float>(dzVal);
630     // if specify centerX
631     if (!Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("centerX"), rotate.centerX)) {
632         rotate.centerX = Dimension(0.5f, DimensionUnit::PERCENT);
633     }
634     // if specify centerY
635     if (!Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("centerY"), rotate.centerY)) {
636         rotate.centerY = Dimension(0.5f, DimensionUnit::PERCENT);
637     }
638     // if specify centerZ
639     if (!Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("centerZ"), rotate.centerZ)) {
640         rotate.centerZ = Dimension(0.5f, DimensionUnit::PERCENT);
641     }
642     // if specify angle
643     Framework::JSViewAbstract::GetJsAngle(static_cast<int32_t>(ArkUIIndex::ANGLE), jsObj, angle);
644     rotate.perspective = 0.0f;
645     Framework::JSViewAbstract::GetJsPerspective(static_cast<int32_t>(ArkUIIndex::PERSPECTIVE), jsObj,
646         rotate.perspective);
647 }
648 
ParseChainedRotateTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)649 RefPtr<NG::ChainedTransitionEffect> ParseChainedRotateTransition(
650     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
651 {
652     RefPtr<NG::ChainedTransitionEffect> effect;
653     if (effectOption->IsObject()) {
654         NG::RotateOptions rotate(0.0f, 0.0f, 0.0f, 0.0f, 0.5_pct, 0.5_pct);
655         std::optional<float> angle;
656         ParseJsRotate(effectOption, rotate, angle);
657         if (angle.has_value()) {
658             rotate.angle = angle.value();
659             return AceType::MakeRefPtr<NG::ChainedRotateEffect>(rotate);
660         }
661     }
662     return nullptr;
663 }
664 
ParseJsScale(const Framework::JSRef<Framework::JSVal> & jsValue,float & scaleX,float & scaleY,float & scaleZ,CalcDimension & centerX,CalcDimension & centerY)665 void ParseJsScale(const Framework::JSRef<Framework::JSVal>& jsValue, float& scaleX, float& scaleY, float& scaleZ,
666     CalcDimension& centerX, CalcDimension& centerY)
667 {
668     double xVal = 1.0;
669     double yVal = 1.0;
670     double zVal = 1.0;
671     if (!jsValue->IsObject()) {
672         scaleX = static_cast<float>(xVal);
673         scaleY = static_cast<float>(yVal);
674         scaleZ = static_cast<float>(zVal);
675         CalcDimension length;
676         centerX = length;
677         centerY = length;
678         return;
679     }
680     Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(jsValue);
681     Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("x"), xVal);
682     Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("y"), yVal);
683     Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("z"), zVal);
684     scaleX = static_cast<float>(xVal);
685     scaleY = static_cast<float>(yVal);
686     scaleZ = static_cast<float>(zVal);
687     // if specify centerX
688     Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("centerX"), centerX);
689     // if specify centerY
690     Framework::JSViewAbstract::ParseJsDimensionVp(jsObj->GetProperty("centerY"), centerY);
691 }
692 
ParseChainedScaleTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)693 RefPtr<NG::ChainedTransitionEffect> ParseChainedScaleTransition(
694     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
695 {
696     if (effectOption->IsObject()) {
697         // default: x, y, z (1.0, 1.0, 1.0), centerX, centerY 50% 50%;
698         NG::ScaleOptions scale(1.0f, 1.0f, 1.0f, 0.5_pct, 0.5_pct);
699         ParseJsScale(effectOption, scale.xScale, scale.yScale, scale.zScale, scale.centerX, scale.centerY);
700         return AceType::MakeRefPtr<NG::ChainedScaleEffect>(scale);
701     }
702     return nullptr;
703 }
704 
705 RefPtr<NG::ChainedTransitionEffect> ParseChainedTransition(
706     const JSRef<JSObject>& object, const JSExecutionContext& context);
707 
ParseChainedAsymmetricTransition(const Framework::JSRef<Framework::JSVal> & effectOption,const JSExecutionContext & context)708 RefPtr<NG::ChainedTransitionEffect> ParseChainedAsymmetricTransition(
709     const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
710 {
711     if (effectOption->IsObject()) {
712         auto effectObj = Framework::JSRef<Framework::JSObject>::Cast(effectOption);
713         auto appearJsVal = effectObj->GetProperty("appear");
714         auto disappearJsVal = effectObj->GetProperty("disappear");
715         RefPtr<NG::ChainedTransitionEffect> appearEffect;
716         RefPtr<NG::ChainedTransitionEffect> disappearEffect;
717         if (appearJsVal->IsObject()) {
718             auto appearObj = Framework::JSRef<Framework::JSObject>::Cast(appearJsVal);
719             appearEffect = ParseChainedTransition(appearObj, context);
720         }
721         if (disappearJsVal->IsObject()) {
722             auto disappearObj = Framework::JSRef<Framework::JSObject>::Cast(disappearJsVal);
723             disappearEffect = ParseChainedTransition(disappearObj, context);
724         }
725         return AceType::MakeRefPtr<NG::ChainedAsymmetricEffect>(appearEffect, disappearEffect);
726     }
727     return nullptr;
728 }
729 
GetFormAnimationTimeInterval(const RefPtr<PipelineBase> & pipelineContext)730 int64_t GetFormAnimationTimeInterval(const RefPtr<PipelineBase>& pipelineContext)
731 {
732     CHECK_NULL_RETURN(pipelineContext, 0);
733     return (GetMicroTickCount() - pipelineContext->GetFormAnimationStartTime()) / MICROSEC_TO_MILLISEC;
734 }
735 
736 using ChainedTransitionEffectCreator = RefPtr<NG::ChainedTransitionEffect> (*)(
737     const Framework::JSRef<Framework::JSVal>&, const JSExecutionContext&);
738 
GetAnimationOptionResult(shared_ptr<AnimationOption> & animationOptionResult,const JSRef<JSObject> & propAnimationOption,const RefPtr<PipelineBase> & pipelineContext,const JSExecutionContext & context)739 void GetAnimationOptionResult(shared_ptr<AnimationOption>& animationOptionResult,
740     const JSRef<JSObject>& propAnimationOption, const RefPtr<PipelineBase>& pipelineContext,
741     const JSExecutionContext& context)
742 {
743     // The maximum of the form-animation-playback duration value is 1000 ms.
744     if (pipelineContext->IsFormRenderExceptDynamicComponent() && pipelineContext->IsFormAnimation()) {
745         auto formAnimationTimeInterval = GetFormAnimationTimeInterval(pipelineContext);
746         // If the duration exceeds 1000ms, init it to 0 ms.
747         if (formAnimationTimeInterval > DEFAULT_DURATION) {
748             animationOptionResult->SetDuration(0);
749         } else if (animationOptionResult->GetDuration() > (DEFAULT_DURATION - formAnimationTimeInterval)) {
750             // If remaining time is less than 1000ms, check for update duration.
751             animationOptionResult->SetDuration(DEFAULT_DURATION - formAnimationTimeInterval);
752             TAG_LOGI(AceLogTag::ACE_FORM, "[Form animation]  Form Transition SetDuration: %{public}lld ms",
753                 static_cast<long long>(DEFAULT_DURATION - formAnimationTimeInterval));
754         }
755     }
756     auto animationOptionObj = Framework::JSRef<Framework::JSObject>::Cast(propAnimationOption);
757     Framework::JSRef<Framework::JSVal> onFinish = animationOptionObj->GetProperty("onFinish");
758     if (onFinish->IsFunction()) {
759         RefPtr<JsFunction> jsFunc =
760             AceType::MakeRefPtr<JsFunction>(Framework::JSRef<Framework::JSObject>(), JSRef<JSFunc>::Cast(onFinish));
761         std::function<void()> onFinishEvent = [execCtx = context, func = std::move(jsFunc),
762                                                   id = Container::CurrentId()]() {
763             ContainerScope scope(id);
764             JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
765             func->Execute();
766         };
767         animationOptionResult->SetOnFinishEvent(onFinishEvent);
768     }
769 }
770 
ParseChainedTransition(const Framework::JSRef<Framework::JSObject> & object,const JSExecutionContext & context)771 RefPtr<NG::ChainedTransitionEffect> ParseChainedTransition(
772     const Framework::JSRef<Framework::JSObject>& object, const JSExecutionContext& context)
773 {
774     auto propType = object->GetProperty("type_");
775     if (!propType->IsString()) {
776         return nullptr;
777     }
778     std::string type = propType->ToString();
779     auto propEffectOption = object->GetProperty("effect_");
780     auto propAnimationOption = object->GetProperty("animation_");
781     auto propSuccessor = object->GetProperty("successor_");
782     static const LinearMapNode<ChainedTransitionEffectCreator> creatorMap[] = {
783         { "asymmetric", ParseChainedAsymmetricTransition },
784         { "identity",
785             [](const Framework::JSRef<Framework::JSVal>& effectOption, const JSExecutionContext& context)
786                 -> RefPtr<NG::ChainedTransitionEffect> { return AceType::MakeRefPtr<NG::ChainedIdentityEffect>(); } },
787         { "move", ParseChainedMoveTransition },
788         { "opacity", ParseChainedOpacityTransition },
789         { "rotate", ParseChainedRotateTransition },
790         { "scale", ParseChainedScaleTransition },
791         { "slideSwitch",
792             [](const Framework::JSRef<Framework::JSVal>& effectOption,
793                 const JSExecutionContext& context) -> RefPtr<NG::ChainedTransitionEffect> {
794                 return AceType::MakeRefPtr<NG::ChainedSlideSwitchEffect>();
795             } },
796         { "translate", ParseChainedTranslateTransition },
797     };
798     int64_t index = BinarySearchFindIndex(creatorMap, ArraySize(creatorMap), type.c_str());
799     if (index < 0) {
800         return nullptr;
801     }
802     RefPtr<NG::ChainedTransitionEffect> result = creatorMap[index].value(propEffectOption, context);
803     if (!result) {
804         return nullptr;
805     }
806     if (propAnimationOption->IsObject()) {
807         auto container = Container::Current();
808         CHECK_NULL_RETURN(container, nullptr);
809         auto pipelineContext = container->GetPipelineContext();
810         CHECK_NULL_RETURN(pipelineContext, nullptr);
811         auto animationOptionResult = std::make_shared<AnimationOption>(
812             JSViewContext::CreateAnimation(propAnimationOption, pipelineContext->IsFormRenderExceptDynamicComponent()));
813         GetAnimationOptionResult(animationOptionResult, propAnimationOption, pipelineContext, context);
814         result->SetAnimationOption(animationOptionResult);
815     }
816     if (propSuccessor->IsObject()) {
817         result->SetNext(ParseChainedTransition(Framework::JSRef<Framework::JSObject>::Cast(propSuccessor), context));
818     }
819     return result;
820 }
821 
ParseJsTransition(const Framework::JSRef<Framework::JSVal> & transitionArgs)822 NG::TransitionOptions ParseJsTransition(const Framework::JSRef<Framework::JSVal>& transitionArgs)
823 {
824     NG::TransitionOptions transitionOption;
825     if (!transitionArgs->IsObject()) {
826         return transitionOption;
827     }
828     Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(transitionArgs);
829     bool hasEffect = false;
830     transitionOption.Type = ParseTransitionType(jsObj->GetPropertyValue<std::string>("type", "All"));
831     if (jsObj->HasProperty("opacity")) {
832         double opacity = 1.0;
833         Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("opacity"), opacity);
834         opacity = std::clamp(opacity, 0.0, 1.0);
835         transitionOption.UpdateOpacity(static_cast<float>(opacity));
836         hasEffect = true;
837     }
838     if (jsObj->HasProperty("translate")) {
839         // default: x, y, z (0.0, 0.0, 0.0)
840         NG::TranslateOptions translate;
841         ParseJsTranslate(jsObj->GetProperty("translate"), translate.x, translate.y, translate.z);
842         transitionOption.UpdateTranslate(translate);
843         hasEffect = true;
844     }
845     if (jsObj->HasProperty("scale")) {
846         // default: x, y, z (1.0, 1.0, 1.0), centerX, centerY 50% 50%;
847         NG::ScaleOptions scale(1.0f, 1.0f, 1.0f, 0.5_pct, 0.5_pct);
848         ParseJsScale(
849             jsObj->GetProperty("scale"), scale.xScale, scale.yScale, scale.zScale, scale.centerX, scale.centerY);
850         transitionOption.UpdateScale(scale);
851         hasEffect = true;
852     }
853     if (jsObj->HasProperty("rotate")) {
854         // default: dx, dy, dz (0.0, 0.0, 0.0), angle 0, centerX, centerY 50% 50%;
855         NG::RotateOptions rotate(0.0f, 0.0f, 0.0f, 0.0f, 0.5_pct, 0.5_pct);
856         std::optional<float> angle;
857         ParseJsRotate(jsObj->GetProperty("rotate"), rotate, angle);
858         if (angle.has_value()) {
859             rotate.angle = angle.value();
860             transitionOption.UpdateRotate(rotate);
861             hasEffect = true;
862         }
863     }
864     if (!hasEffect) {
865         // default transition
866         transitionOption = NG::TransitionOptions::GetDefaultTransition(transitionOption.Type);
867     }
868     return transitionOption;
869 }
870 
ParseMotionPath(const Framework::JSRef<Framework::JSVal> & jsValue,MotionPathOption & option)871 bool ParseMotionPath(const Framework::JSRef<Framework::JSVal>& jsValue, MotionPathOption& option)
872 {
873     if (!jsValue->IsObject()) {
874         return false;
875     }
876 
877     Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(jsValue);
878     auto path = jsObj->GetPropertyValue<std::string>("path", "");
879     if (path.empty()) {
880         return false;
881     }
882     option.SetPath(path);
883     double from = 0.0;
884     double to = 1.0;
885     Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("from"), from);
886     Framework::JSViewAbstract::ParseJsDouble(jsObj->GetProperty("to"), to);
887     if (GreatNotEqual(from, 1.0) || LessNotEqual(from, 0.0)) {
888         from = 0.0;
889     }
890     if (GreatNotEqual(to, 1.0) || LessNotEqual(to, 0.0)) {
891         to = 1.0;
892     } else if (to < from) {
893         to = from;
894     }
895     option.SetBegin(static_cast<float>(from));
896     option.SetEnd(static_cast<float>(to));
897     option.SetRotate(jsObj->GetPropertyValue<bool>("rotatable", false));
898     return true;
899 }
900 
ParseJsDoublePair(const EcmaVM * vm,const Local<JSValueRef> & value,ArkUI_Float32 & first,ArkUI_Float32 & second)901 bool ParseJsDoublePair(const EcmaVM *vm, const Local<JSValueRef> &value, ArkUI_Float32 &first, ArkUI_Float32 &second)
902 {
903     if (!value->IsArray(vm)) {
904         return false;
905     }
906     auto array = panda::Local<panda::ArrayRef>(value);
907     if (array->Length(vm) != NUM_2) {
908         return false;
909     }
910     auto firstArg = panda::ArrayRef::GetValueAt(vm, array, NUM_0);
911     if (!firstArg->IsNumber()) {
912         return false;
913     }
914     auto secondArg = panda::ArrayRef::GetValueAt(vm, array, NUM_1);
915     if (!secondArg->IsNumber()) {
916         return false;
917     }
918     first = static_cast<ArkUI_Float32>(firstArg->ToNumber(vm)->Value());
919     second = static_cast<ArkUI_Float32>(secondArg->ToNumber(vm)->Value());
920     return true;
921 }
922 
PushOuterBorderDimensionVector(const std::optional<CalcDimension> & valueDim,std::vector<ArkUI_Float32> & options)923 void PushOuterBorderDimensionVector(const std::optional<CalcDimension>& valueDim, std::vector<ArkUI_Float32> &options)
924 {
925     options.push_back(static_cast<ArkUI_Float32>(valueDim.has_value()));
926     if (valueDim.has_value()) {
927         options.push_back(static_cast<ArkUI_Float32>(valueDim.value().Value()));
928         options.push_back(static_cast<ArkUI_Float32>(valueDim.value().Unit()));
929     } else {
930         options.push_back(0);
931         options.push_back(0);
932     }
933 }
934 
PushOuterBorderColorVector(const std::optional<Color> & valueColor,std::vector<uint32_t> & options)935 void PushOuterBorderColorVector(const std::optional<Color>& valueColor, std::vector<uint32_t> &options)
936 {
937     options.push_back(static_cast<uint32_t>(valueColor.has_value()));
938     if (valueColor.has_value()) {
939         options.push_back(static_cast<uint32_t>(valueColor.value().GetValue()));
940     } else {
941         options.push_back(0);
942     }
943 }
944 
ParseOuterBorderEdgeColor(EcmaVM * vm,Local<JSValueRef> & arg,std::optional<Color> & optColor,std::vector<RefPtr<ResourceObject>> & resObjs,const NodeInfo & nodeInfo)945 void ParseOuterBorderEdgeColor(EcmaVM* vm, Local<JSValueRef>& arg, std::optional<Color>& optColor,
946     std::vector<RefPtr<ResourceObject>>& resObjs, const NodeInfo& nodeInfo)
947 {
948     Color color;
949     auto result = ArkTSUtils::ParseJsColorAlpha(vm, arg, color, resObjs, nodeInfo);
950     if (!arg->IsUndefined() && result) {
951         optColor = color;
952     }
953 }
954 
ParseOuterBorderColor(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<uint32_t> & values,int32_t argsIndex,std::vector<RefPtr<ResourceObject>> & resObjs,const NodeInfo & nodeInfo,bool needLocalized=false)955 void ParseOuterBorderColor(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector<uint32_t>& values,
956     int32_t argsIndex, std::vector<RefPtr<ResourceObject>>& resObjs, const NodeInfo& nodeInfo,
957     bool needLocalized = false)
958 {
959     Local<JSValueRef> leftArg = runtimeCallInfo->GetCallArgRef(argsIndex);
960     Local<JSValueRef> rightArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1);
961     Local<JSValueRef> topArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_2);
962     Local<JSValueRef> bottomArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_3);
963 
964     std::optional<Color> leftColor;
965     std::optional<Color> rightColor;
966     std::optional<Color> topColor;
967     std::optional<Color> bottomColor;
968     std::optional<Color> startColor;
969     std::optional<Color> endColor;
970 
971     ParseOuterBorderEdgeColor(vm, leftArg, leftColor, resObjs, nodeInfo);
972     ParseOuterBorderEdgeColor(vm, rightArg, rightColor, resObjs, nodeInfo);
973     ParseOuterBorderEdgeColor(vm, topArg, topColor, resObjs, nodeInfo);
974     ParseOuterBorderEdgeColor(vm, bottomArg, bottomColor, resObjs, nodeInfo);
975     if (needLocalized) {
976         Local<JSValueRef> startArgs = runtimeCallInfo->GetCallArgRef(27); // 27: index of BorderColor.startColor
977         Local<JSValueRef> endArgs = runtimeCallInfo->GetCallArgRef(28);   // 28: index of BorderColor.endColor
978         ParseOuterBorderEdgeColor(vm, startArgs, startColor, resObjs, nodeInfo);
979         ParseOuterBorderEdgeColor(vm, endArgs, endColor, resObjs, nodeInfo);
980     }
981     if (startColor.has_value() || endColor.has_value()) {
982         PushOuterBorderColorVector(startColor, values);
983         PushOuterBorderColorVector(endColor, values);
984         if (SystemProperties::ConfigChangePerform()) {
985             if (resObjs[NUM_12]) {
986                 std::swap(resObjs[NUM_8], resObjs[NUM_12]);
987             }
988             if (resObjs[NUM_13]) {
989                 std::swap(resObjs[NUM_9], resObjs[NUM_13]);
990             }
991         }
992     } else {
993         PushOuterBorderColorVector(leftColor, values);
994         PushOuterBorderColorVector(rightColor, values);
995     }
996     PushOuterBorderColorVector(topColor, values);
997     PushOuterBorderColorVector(bottomColor, values);
998 }
999 
ParseOutLineColor(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<uint32_t> & values,int32_t argsIndex,std::vector<RefPtr<ResourceObject>> & resObjs,const NodeInfo & nodeInfo)1000 void ParseOutLineColor(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector<uint32_t>& values,
1001     int32_t argsIndex, std::vector<RefPtr<ResourceObject>>& resObjs, const NodeInfo& nodeInfo)
1002 {
1003     Local<JSValueRef> leftArg = runtimeCallInfo->GetCallArgRef(argsIndex);
1004     Local<JSValueRef> rightArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1);
1005     Local<JSValueRef> topArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_2);
1006     Local<JSValueRef> bottomArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_3);
1007 
1008     std::optional<Color> leftColor;
1009     std::optional<Color> rightColor;
1010     std::optional<Color> topColor;
1011     std::optional<Color> bottomColor;
1012 
1013     ParseOuterBorderEdgeColor(vm, leftArg, leftColor, resObjs, nodeInfo);
1014     ParseOuterBorderEdgeColor(vm, rightArg, rightColor, resObjs, nodeInfo);
1015     ParseOuterBorderEdgeColor(vm, topArg, topColor, resObjs, nodeInfo);
1016     ParseOuterBorderEdgeColor(vm, bottomArg, bottomColor, resObjs, nodeInfo);
1017 
1018     PushOuterBorderColorVector(topColor, values);
1019     PushOuterBorderColorVector(rightColor, values);
1020     PushOuterBorderColorVector(bottomColor, values);
1021     PushOuterBorderColorVector(leftColor, values);
1022 }
1023 
ParseLocalizedBorderRadius(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & result)1024 bool ParseLocalizedBorderRadius(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& result)
1025 {
1026     if (ArkTSUtils::ParseJsLengthMetrics(vm, value, result)) {
1027         if (result.IsNegative()) {
1028             result.Reset();
1029         }
1030         return true;
1031     }
1032     return false;
1033 }
1034 
ParseOuterBorder(EcmaVM * vm,const Local<JSValueRef> & args,std::optional<CalcDimension> & optionalDimension,std::vector<RefPtr<ResourceObject>> & resObjs)1035 void ParseOuterBorder(EcmaVM* vm, const Local<JSValueRef>& args, std::optional<CalcDimension>& optionalDimension,
1036     std::vector<RefPtr<ResourceObject>>& resObjs)
1037 {
1038     RefPtr<ResourceObject> resObj;
1039     ArkTSUtils::ParseOuterBorder(vm, args, optionalDimension, resObj);
1040     if (SystemProperties::ConfigChangePerform()) {
1041         resObjs.push_back(resObj);
1042     }
1043 }
1044 
ParseNullptrResObj(std::vector<RefPtr<ResourceObject>> & resObjs,int32_t index)1045 void ParseNullptrResObj(std::vector<RefPtr<ResourceObject>>& resObjs, int32_t index)
1046 {
1047     if (SystemProperties::ConfigChangePerform()) {
1048         for (int32_t i = 0; i < index; i++) {
1049             resObjs.push_back(nullptr);
1050         }
1051     }
1052 }
1053 
ParseOuterBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<ArkUI_Float32> & values,int32_t argsIndex,std::vector<RefPtr<ResourceObject>> & resObjs,bool needLocalized=false)1054 void ParseOuterBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector<ArkUI_Float32>& values,
1055     int32_t argsIndex, std::vector<RefPtr<ResourceObject>>& resObjs, bool needLocalized = false)
1056 {
1057     Local<JSValueRef> topLeftArgs = runtimeCallInfo->GetCallArgRef(argsIndex);
1058     Local<JSValueRef> topRightArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1);
1059     Local<JSValueRef> bottomLeftArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_2);
1060     Local<JSValueRef> bottomRightArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_3);
1061     if (needLocalized) {
1062         Local<JSValueRef> topStartArgs = runtimeCallInfo->GetCallArgRef(29);    // 29: index of BorderRadius.topStart
1063         Local<JSValueRef> topEndArgs = runtimeCallInfo->GetCallArgRef(30);      // 30: index of BorderRadius.topEnd
1064         Local<JSValueRef> bottomStartArgs = runtimeCallInfo->GetCallArgRef(31); // 31: index of BorderRadius.bottomStart
1065         Local<JSValueRef> bottomEndArgs = runtimeCallInfo->GetCallArgRef(32);   // 32: index of BorderRadius.bottomEnd
1066         // 35: index of is LocalizedBorderRadius or not
1067         Local<JSValueRef> isLocalizedBorderRadiusArg = runtimeCallInfo->GetCallArgRef(35);
1068         bool isLocalizedBorderRadius =
1069             (isLocalizedBorderRadiusArg->IsBoolean()) ? isLocalizedBorderRadiusArg->ToBoolean(vm)->Value() : false;
1070         if (isLocalizedBorderRadius) {
1071             CalcDimension topStartOptional;
1072             CalcDimension topEndOptional;
1073             CalcDimension bottomStartOptional;
1074             CalcDimension bottomEndOptional;
1075             ParseLocalizedBorderRadius(vm, topStartArgs, topStartOptional);
1076             ParseLocalizedBorderRadius(vm, topEndArgs, topEndOptional);
1077             ParseLocalizedBorderRadius(vm, bottomStartArgs, bottomStartOptional);
1078             ParseLocalizedBorderRadius(vm, bottomEndArgs, bottomEndOptional);
1079             PushOuterBorderDimensionVector(topStartOptional, values);
1080             PushOuterBorderDimensionVector(topEndOptional, values);
1081             PushOuterBorderDimensionVector(bottomStartOptional, values);
1082             PushOuterBorderDimensionVector(bottomEndOptional, values);
1083             ParseNullptrResObj(resObjs, NUM_4);
1084             return;
1085         }
1086     }
1087 
1088     std::optional<CalcDimension> topLeftOptional;
1089     std::optional<CalcDimension> topRightOptional;
1090     std::optional<CalcDimension> bottomLeftOptional;
1091     std::optional<CalcDimension> bottomRightOptional;
1092 
1093     ParseOuterBorder(vm, topLeftArgs, topLeftOptional, resObjs);
1094     ParseOuterBorder(vm, topRightArgs, topRightOptional, resObjs);
1095     ParseOuterBorder(vm, bottomLeftArgs, bottomLeftOptional, resObjs);
1096     ParseOuterBorder(vm, bottomRightArgs, bottomRightOptional, resObjs);
1097 
1098     PushOuterBorderDimensionVector(topLeftOptional, values);
1099     PushOuterBorderDimensionVector(topRightOptional, values);
1100     PushOuterBorderDimensionVector(bottomLeftOptional, values);
1101     PushOuterBorderDimensionVector(bottomRightOptional, values);
1102 }
1103 
PushOuterBorderStyleVector(const std::optional<BorderStyle> & value,std::vector<uint32_t> & options)1104 void PushOuterBorderStyleVector(const std::optional<BorderStyle>& value, std::vector<uint32_t> &options)
1105 {
1106     options.push_back(static_cast<uint32_t>(value.has_value()));
1107     if (value.has_value()) {
1108         options.push_back(static_cast<uint32_t>(value.value()));
1109     } else {
1110         options.push_back(0);
1111     }
1112 }
1113 
ParseOuterBorderStyle(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<uint32_t> & values,int32_t argsIndex)1114 void ParseOuterBorderStyle(
1115     ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector<uint32_t>& values, int32_t argsIndex)
1116 {
1117     std::optional<BorderStyle> styleLeft;
1118     std::optional<BorderStyle> styleRight;
1119     std::optional<BorderStyle> styleTop;
1120     std::optional<BorderStyle> styleBottom;
1121 
1122     auto topArg = runtimeCallInfo->GetCallArgRef(argsIndex);
1123     auto rightArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1);
1124     auto bottomArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_2);
1125     auto leftArg = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_3);
1126 
1127     if (!topArg->IsUndefined() && topArg->IsNumber()) {
1128         styleTop = ConvertBorderStyle(topArg->Int32Value(vm));
1129     }
1130     if (!rightArg->IsUndefined() && rightArg->IsNumber()) {
1131         styleRight = ConvertBorderStyle(rightArg->Int32Value(vm));
1132     }
1133     if (!bottomArg->IsUndefined() && bottomArg->IsNumber()) {
1134         styleBottom = ConvertBorderStyle(bottomArg->Int32Value(vm));
1135     }
1136     if (!leftArg->IsUndefined() && leftArg->IsNumber()) {
1137         styleLeft = ConvertBorderStyle(leftArg->Int32Value(vm));
1138     }
1139 
1140     PushOuterBorderStyleVector(styleLeft, values);
1141     PushOuterBorderStyleVector(styleRight, values);
1142     PushOuterBorderStyleVector(styleTop, values);
1143     PushOuterBorderStyleVector(styleBottom, values);
1144 }
1145 
ParseOuterBorderForDashParams(EcmaVM * vm,const Local<JSValueRef> & args,std::optional<CalcDimension> & optionalDimension,std::vector<RefPtr<ResourceObject>> & resObjs)1146 void ParseOuterBorderForDashParams(EcmaVM* vm, const Local<JSValueRef>& args,
1147     std::optional<CalcDimension>& optionalDimension, std::vector<RefPtr<ResourceObject>>& resObjs)
1148 {
1149     RefPtr<ResourceObject> resObj;
1150     ArkTSUtils::ParseOuterBorderForDashParams(vm, args, optionalDimension, resObj);
1151     if (SystemProperties::ConfigChangePerform()) {
1152         resObjs.push_back(resObj);
1153     }
1154 }
1155 
ParseOuterBorderDashParam(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<ArkUI_Float32> & values,int32_t argsIndex,std::vector<RefPtr<ResourceObject>> & resObjs)1156 void ParseOuterBorderDashParam(ArkUIRuntimeCallInfo *runtimeCallInfo, EcmaVM *vm, std::vector<ArkUI_Float32> &values,
1157     int32_t argsIndex, std::vector<RefPtr<ResourceObject>>& resObjs)
1158 {
1159     Local<JSValueRef> leftArgs = runtimeCallInfo->GetCallArgRef(argsIndex);
1160     Local<JSValueRef> rightArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1);
1161     Local<JSValueRef> topArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_2);
1162     Local<JSValueRef> bottomArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_3);
1163     std::optional<CalcDimension> leftDim;
1164     std::optional<CalcDimension> rightDim;
1165     std::optional<CalcDimension> topDim;
1166     std::optional<CalcDimension> bottomDim;
1167 
1168     ParseOuterBorderForDashParams(vm, leftArgs, leftDim, resObjs);
1169     ParseOuterBorderForDashParams(vm, rightArgs, rightDim, resObjs);
1170     ParseOuterBorderForDashParams(vm, topArgs, topDim, resObjs);
1171     ParseOuterBorderForDashParams(vm, bottomArgs, bottomDim, resObjs);
1172 
1173     PushOuterBorderDimensionVector(leftDim, values);
1174     PushOuterBorderDimensionVector(rightDim, values);
1175     PushOuterBorderDimensionVector(topDim, values);
1176     PushOuterBorderDimensionVector(bottomDim, values);
1177 }
1178 
SetBackgroundImagePositionAlign(double & value,DimensionUnit & type,double valueContent,const DimensionUnit & typeContent)1179 void SetBackgroundImagePositionAlign(double &value, DimensionUnit &type, double valueContent,
1180     const DimensionUnit &typeContent)
1181 {
1182     value = valueContent;
1183     type = typeContent;
1184 }
1185 
ParseBackgroundImagePositionAlign(const int32_t align,double & valueX,double & valueY,DimensionUnit & typeX,DimensionUnit & typeY)1186 void ParseBackgroundImagePositionAlign(const int32_t align, double &valueX, double &valueY, DimensionUnit &typeX,
1187     DimensionUnit &typeY)
1188 {
1189     switch (align) {
1190         case NUM_0:
1191             SetBackgroundImagePositionAlign(valueX, typeX, 0.0, DimensionUnit::PERCENT);
1192             SetBackgroundImagePositionAlign(valueY, typeY, 0.0, DimensionUnit::PERCENT);
1193             break;
1194         case NUM_1:
1195             SetBackgroundImagePositionAlign(valueX, typeX, HALF_DIMENSION, DimensionUnit::PERCENT);
1196             SetBackgroundImagePositionAlign(valueY, typeY, 0.0, DimensionUnit::PERCENT);
1197             break;
1198         case NUM_2:
1199             SetBackgroundImagePositionAlign(valueX, typeX, FULL_DIMENSION, DimensionUnit::PERCENT);
1200             SetBackgroundImagePositionAlign(valueY, typeY, 0.0, DimensionUnit::PERCENT);
1201             break;
1202         case NUM_3:
1203             SetBackgroundImagePositionAlign(valueX, typeX, 0.0, DimensionUnit::PERCENT);
1204             SetBackgroundImagePositionAlign(valueY, typeY, HALF_DIMENSION, DimensionUnit::PERCENT);
1205             break;
1206         case NUM_4:
1207             SetBackgroundImagePositionAlign(valueX, typeX, HALF_DIMENSION, DimensionUnit::PERCENT);
1208             SetBackgroundImagePositionAlign(valueY, typeY, HALF_DIMENSION, DimensionUnit::PERCENT);
1209             break;
1210         case NUM_5:
1211             SetBackgroundImagePositionAlign(valueX, typeX, FULL_DIMENSION, DimensionUnit::PERCENT);
1212             SetBackgroundImagePositionAlign(valueY, typeY, HALF_DIMENSION, DimensionUnit::PERCENT);
1213             break;
1214         case NUM_6:
1215             SetBackgroundImagePositionAlign(valueX, typeX, 0.0, DimensionUnit::PERCENT);
1216             SetBackgroundImagePositionAlign(valueY, typeY, FULL_DIMENSION, DimensionUnit::PERCENT);
1217             break;
1218         case NUM_7:
1219             SetBackgroundImagePositionAlign(valueX, typeX, HALF_DIMENSION, DimensionUnit::PERCENT);
1220             SetBackgroundImagePositionAlign(valueY, typeY, FULL_DIMENSION, DimensionUnit::PERCENT);
1221             break;
1222         case NUM_8:
1223             SetBackgroundImagePositionAlign(valueX, typeX, FULL_DIMENSION, DimensionUnit::PERCENT);
1224             SetBackgroundImagePositionAlign(valueY, typeY, FULL_DIMENSION, DimensionUnit::PERCENT);
1225             break;
1226         default:
1227             break;
1228     }
1229 }
1230 
ParseAxisDimensionVp(const EcmaVM * vm,const Local<JSValueRef> & jsValue,CalcDimension & result,bool checkIllegal=false)1231 bool ParseAxisDimensionVp(const EcmaVM *vm, const Local<JSValueRef> &jsValue, CalcDimension &result,
1232     bool checkIllegal = false)
1233 {
1234     if (jsValue->IsNumber()) {
1235         result = Dimension(jsValue->ToNumber(vm)->Value(), DimensionUnit::VP);
1236         return true;
1237     }
1238     if (jsValue->IsString(vm)) {
1239         if (checkIllegal) {
1240             return StringUtils::StringToDimensionWithUnitNG(jsValue->ToString(vm)->ToString(vm), result,
1241                 DimensionUnit::VP);
1242         }
1243         result = StringUtils::StringToCalcDimension(jsValue->ToString(vm)->ToString(vm), false, DimensionUnit::VP);
1244         return true;
1245     }
1246     return false;
1247 }
1248 
ParseDirection(EcmaVM * vm,const Local<JSValueRef> & directionArg,float & value)1249 void ParseDirection(EcmaVM *vm, const Local<JSValueRef> &directionArg, float &value)
1250 {
1251     if (directionArg->IsNumber()) {
1252         value = directionArg->ToNumber(vm)->Value();
1253     }
1254 }
1255 
GetJsAngle(const EcmaVM * vm,const Local<JSValueRef> & angleArg,std::optional<float> & angle)1256 void GetJsAngle(const EcmaVM* vm, const Local<JSValueRef>& angleArg, std::optional<float>& angle)
1257 {
1258     if (angleArg->IsString(vm)) {
1259         angle = static_cast<float>(StringUtils::StringToDegree(angleArg->ToString(vm)->ToString(vm)));
1260     } else if (angleArg->IsNumber()) {
1261         angle = static_cast<float>(angleArg->ToNumber(vm)->Value());
1262     } else {
1263         LOGE("Invalid value type");
1264     }
1265 }
1266 
GetJsAngleWithDefault(const EcmaVM * vm,const Local<JSValueRef> & angleArg,std::optional<float> & angle,float defaultValue)1267 void GetJsAngleWithDefault(
1268     const EcmaVM* vm, const Local<JSValueRef>& angleArg, std::optional<float>& angle, float defaultValue)
1269 {
1270     if (angleArg->IsString(vm)) {
1271         double temp = 0.0;
1272         if (StringUtils::StringToDegree(angleArg->ToString(vm)->ToString(vm), temp)) {
1273             angle = static_cast<float>(temp);
1274         } else {
1275             angle = defaultValue;
1276         }
1277     } else if (angleArg->IsNumber()) {
1278         angle = static_cast<float>(angleArg->ToNumber(vm)->Value());
1279     }
1280 }
1281 
ParseCenterDimension(const EcmaVM * vm,const Local<JSValueRef> & centerArg,CalcDimension & centerDimension)1282 void ParseCenterDimension(const EcmaVM* vm, const Local<JSValueRef>& centerArg, CalcDimension& centerDimension)
1283 {
1284     if (!ArkTSUtils::ParseJsDimensionVp(vm, centerArg, centerDimension, false)) {
1285         centerDimension = Dimension(0.5f, DimensionUnit::PERCENT);
1286     }
1287 }
1288 
ParseCenterZDimension(const EcmaVM * vm,const Local<JSValueRef> & centerArg,CalcDimension & centerDimension)1289 void ParseCenterZDimension(const EcmaVM* vm, const Local<JSValueRef>& centerArg, CalcDimension& centerDimension)
1290 {
1291     if (!ArkTSUtils::ParseJsDimensionVp(vm, centerArg, centerDimension, false)) {
1292         centerDimension = Dimension(0.0f, DimensionUnit::VP);
1293     }
1294 }
1295 
ParseRotateAngle(ArkUIRuntimeCallInfo * runtimeCallInfo,ArkUI_Float32 values[],int units[],int valuesLength,int unitsLength)1296 bool ParseRotateAngle(ArkUIRuntimeCallInfo *runtimeCallInfo, ArkUI_Float32 values[], int units[],
1297     int valuesLength, int unitsLength)
1298 {
1299     if (valuesLength != SIZE_OF_SEVEN || unitsLength != SIZE_OF_THREE) {
1300         return false;
1301     }
1302     EcmaVM *vm = runtimeCallInfo->GetVM();
1303     Local<JSValueRef> angleXArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1304     Local<JSValueRef> angleYArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1305     Local<JSValueRef> angleZArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1306     Local<JSValueRef> centerXArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1307     Local<JSValueRef> centerYArg = runtimeCallInfo->GetCallArgRef(NUM_5);
1308     Local<JSValueRef> centerZArg = runtimeCallInfo->GetCallArgRef(NUM_6);
1309     Local<JSValueRef> perspectiveArg = runtimeCallInfo->GetCallArgRef(NUM_7);
1310     float angleX = 0.0f;
1311     float angleY = 0.0f;
1312     float angleZ = 0.0f;
1313     std::optional<float> angleXOptional;
1314     std::optional<float> angleYOptional;
1315     std::optional<float> angleZOptional;
1316     CalcDimension centerX = 0.5_pct;
1317     CalcDimension centerY = 0.5_pct;
1318     CalcDimension centerZ = CalcDimension(0.0f, DimensionUnit::VP);
1319     GetJsAngleWithDefault(vm, angleXArg, angleXOptional, 0.0f);
1320     GetJsAngleWithDefault(vm, angleYArg, angleYOptional, 0.0f);
1321     GetJsAngleWithDefault(vm, angleZArg, angleZOptional, 0.0f);
1322 
1323     double perspective = 0.0;
1324 
1325     angleX = angleXOptional.value_or(0.0f);
1326     angleY = angleYOptional.value_or(0.0f);
1327     angleZ = angleZOptional.value_or(0.0f);
1328     ParseCenterDimension(vm, centerXArg, centerX);
1329     ParseCenterDimension(vm, centerYArg, centerY);
1330     ParseCenterZDimension(vm, centerZArg, centerZ);
1331     ArkTSUtils::ParseJsDouble(vm, perspectiveArg, perspective);
1332     values[NUM_0] = static_cast<ArkUI_Float32>(centerX.Value());
1333     units[NUM_0] = static_cast<int>(centerX.Unit());
1334     values[NUM_1] = static_cast<ArkUI_Float32>(centerY.Value());
1335     units[NUM_1] = static_cast<int>(centerY.Unit());
1336     values[NUM_2] = static_cast<ArkUI_Float32>(centerZ.Value());
1337     units[NUM_2] = static_cast<int>(centerZ.Unit());
1338     values[NUM_3] = static_cast<ArkUI_Float32>(angleX);
1339     values[NUM_4] = static_cast<ArkUI_Float32>(angleY);
1340     values[NUM_5] = static_cast<ArkUI_Float32>(angleZ);
1341     values[NUM_6] = static_cast<ArkUI_Float32>(perspective);
1342     return true;
1343 }
1344 
ParseRotate(ArkUIRuntimeCallInfo * runtimeCallInfo,ArkUI_Float32 values[],int units[],int valuesLength,int unitsLength)1345 bool ParseRotate(ArkUIRuntimeCallInfo *runtimeCallInfo, ArkUI_Float32 values[], int units[],
1346     int valuesLength, int unitsLength)
1347 {
1348     if (valuesLength != SIZE_OF_EIGHT || unitsLength != SIZE_OF_THREE) {
1349         return false;
1350     }
1351     EcmaVM *vm = runtimeCallInfo->GetVM();
1352     Local<JSValueRef> xDirectionArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1353     Local<JSValueRef> yDirectionArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1354     Local<JSValueRef> zDirectionArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1355     Local<JSValueRef> angleArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1356     Local<JSValueRef> centerXArg = runtimeCallInfo->GetCallArgRef(NUM_5);
1357     Local<JSValueRef> centerYArg = runtimeCallInfo->GetCallArgRef(NUM_6);
1358     Local<JSValueRef> centerZArg = runtimeCallInfo->GetCallArgRef(NUM_7);
1359     Local<JSValueRef> perspectiveArg = runtimeCallInfo->GetCallArgRef(NUM_8);
1360     float xDirection = 0.0f;
1361     float yDirection = 0.0f;
1362     float zDirection = 0.0f;
1363     float angle = 0.0f;
1364     std::optional<float> angleOptional;
1365     CalcDimension centerX = 0.5_pct;
1366     CalcDimension centerY = 0.5_pct;
1367     CalcDimension centerZ = CalcDimension(0.0f, DimensionUnit::VP);
1368     GetJsAngle(vm, angleArg, angleOptional);
1369     if (!angleOptional) {
1370         return false;
1371     }
1372     angle = angleOptional.value();
1373     double perspective = 0.0;
1374     if (!xDirectionArg->IsNumber() && !yDirectionArg->IsNumber() && !zDirectionArg->IsNumber()) {
1375         zDirection = 1.0f;
1376     }
1377     ParseDirection(vm, xDirectionArg, xDirection);
1378     ParseDirection(vm, yDirectionArg, yDirection);
1379     ParseDirection(vm, zDirectionArg, zDirection);
1380     ParseCenterDimension(vm, centerXArg, centerX);
1381     ParseCenterDimension(vm, centerYArg, centerY);
1382     ParseCenterDimension(vm, centerZArg, centerZ);
1383     ArkTSUtils::ParseJsDouble(vm, perspectiveArg, perspective);
1384     values[NUM_0] = static_cast<ArkUI_Float32>(centerX.Value());
1385     units[NUM_0] = static_cast<int>(centerX.Unit());
1386     values[NUM_1] = static_cast<ArkUI_Float32>(centerY.Value());
1387     units[NUM_1] = static_cast<int>(centerY.Unit());
1388     values[NUM_2] = static_cast<ArkUI_Float32>(centerZ.Value());
1389     units[NUM_2] = static_cast<int>(centerZ.Unit());
1390     values[NUM_3] = static_cast<ArkUI_Float32>(xDirection);
1391     values[NUM_4] = static_cast<ArkUI_Float32>(yDirection);
1392     values[NUM_5] = static_cast<ArkUI_Float32>(zDirection);
1393     values[NUM_6] = static_cast<ArkUI_Float32>(angle);
1394     values[NUM_7] = static_cast<ArkUI_Float32>(perspective);
1395     return true;
1396 }
1397 
ParseBlurOption(const EcmaVM * vm,const Local<JSValueRef> blurOptionsArg,BlurOption & blurOption)1398 void ParseBlurOption(const EcmaVM* vm, const Local<JSValueRef> blurOptionsArg, BlurOption& blurOption)
1399 {
1400     if (blurOptionsArg->IsArray(vm)) {
1401         Local<panda::ArrayRef> params = static_cast<Local<panda::ArrayRef>>(blurOptionsArg);
1402         auto grey1 = params->GetValueAt(vm, blurOptionsArg, 0)->Uint32Value(vm);
1403         auto grey2 = params->GetValueAt(vm, blurOptionsArg, 1)->Uint32Value(vm);
1404         std::vector<float> greyVec(2);
1405         greyVec[0] = grey1;
1406         greyVec[1] = grey2;
1407         blurOption.grayscale = greyVec;
1408     }
1409 }
1410 
ParseDynamicBrightnessOption(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,ArkUI_Float32 & rate,ArkUI_Float32 & lightUpDegree,ArkUI_Float32 & cubicCoeff,ArkUI_Float32 & quadCoeff,ArkUI_Float32 & saturation,std::vector<float> & posRGB,std::vector<float> & negRGB,ArkUI_Float32 & fraction)1411 void ParseDynamicBrightnessOption(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm,
1412     ArkUI_Float32& rate, ArkUI_Float32& lightUpDegree, ArkUI_Float32& cubicCoeff, ArkUI_Float32& quadCoeff,
1413     ArkUI_Float32& saturation, std::vector<float>& posRGB, std::vector<float>& negRGB, ArkUI_Float32& fraction)
1414 {
1415     Local<JSValueRef> rateArg = runtimeCallInfo->GetCallArgRef(1);
1416     Local<JSValueRef> lightUpDegreeArg = runtimeCallInfo->GetCallArgRef(2);
1417     Local<JSValueRef> cubicCoeffArg = runtimeCallInfo->GetCallArgRef(3);
1418     Local<JSValueRef> quadCoeffArg = runtimeCallInfo->GetCallArgRef(4);
1419     Local<JSValueRef> saturationArg = runtimeCallInfo->GetCallArgRef(5);
1420     Local<JSValueRef> posRGBArg = runtimeCallInfo->GetCallArgRef(6);
1421     Local<JSValueRef> negRGBArg = runtimeCallInfo->GetCallArgRef(7);
1422     Local<JSValueRef> fractionArg = runtimeCallInfo->GetCallArgRef(8);
1423     if (rateArg->IsNumber()) {
1424         rate = rateArg->ToNumber(vm)->Value();
1425     }
1426     if (lightUpDegreeArg->IsNumber()) {
1427         lightUpDegree = lightUpDegreeArg->ToNumber(vm)->Value();
1428     }
1429     if (cubicCoeffArg->IsNumber()) {
1430         cubicCoeff = cubicCoeffArg->ToNumber(vm)->Value();
1431     }
1432     if (quadCoeffArg->IsNumber()) {
1433         quadCoeff = quadCoeffArg->ToNumber(vm)->Value();
1434     }
1435     if (saturationArg->IsNumber()) {
1436         saturation = saturationArg->ToNumber(vm)->Value();
1437     }
1438     if (posRGBArg->IsArray(vm)) {
1439         Local<panda::ArrayRef> params = static_cast<Local<panda::ArrayRef>>(posRGBArg);
1440         auto r = params->GetValueAt(vm, posRGBArg, 0)->Uint32Value(vm);
1441         auto g = params->GetValueAt(vm, posRGBArg, 1)->Uint32Value(vm);
1442         auto b = params->GetValueAt(vm, posRGBArg, 2)->Uint32Value(vm);
1443         posRGB[0] = r;
1444         posRGB[1] = g;
1445         posRGB[2] = b;
1446     }
1447     if (negRGBArg->IsArray(vm)) {
1448         Local<panda::ArrayRef> params = static_cast<Local<panda::ArrayRef>>(negRGBArg);
1449         auto r = params->GetValueAt(vm, negRGBArg, 0)->Uint32Value(vm);
1450         auto g = params->GetValueAt(vm, negRGBArg, 1)->Uint32Value(vm);
1451         auto b = params->GetValueAt(vm, negRGBArg, 2)->Uint32Value(vm);
1452         negRGB[0] = r;
1453         negRGB[1] = g;
1454         negRGB[2] = b;
1455     }
1456     if (fractionArg->IsNumber()) {
1457         fraction = fractionArg->ToNumber(vm)->Value();
1458     }
1459 }
1460 
ParseCalcDimension(const EcmaVM * vm,ArkUINodeHandle node,const Local<JSValueRef> & value,CalcDimension & result,bool isWidth,RefPtr<ResourceObject> & resourceObject)1461 bool ParseCalcDimension(const EcmaVM* vm,
1462     ArkUINodeHandle node, const Local<JSValueRef>& value, CalcDimension& result, bool isWidth,
1463     RefPtr<ResourceObject>& resourceObject)
1464 {
1465     CHECK_NULL_RETURN(vm, false);
1466     bool undefined = value->IsUndefined();
1467     if (undefined) {
1468         GetArkUINodeModifiers()->getCommonModifier()->clearWidthOrHeight(node, isWidth);
1469         return true;
1470     }
1471     if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
1472         if (!ArkTSUtils::ParseJsDimensionVpNG(vm, value, result, resourceObject)) {
1473             GetArkUINodeModifiers()->getCommonModifier()->clearWidthOrHeight(node, isWidth);
1474             return false;
1475         }
1476     } else if (!ArkTSUtils::ParseJsDimensionVp(vm, value, result, resourceObject)) {
1477         return false;
1478     }
1479 
1480     if (LessNotEqual(result.Value(), 0.0)) {
1481         result.SetValue(0.0);
1482     }
1483     std::string calc = result.CalcValue();
1484     auto RawResObj = AceType::RawPtr(resourceObject);
1485     if (isWidth) {
1486         GetArkUINodeModifiers()->getCommonModifier()->setWidth(
1487             node, result.Value(), static_cast<int32_t>(result.Unit()), calc.c_str(), RawResObj);
1488     } else {
1489         GetArkUINodeModifiers()->getCommonModifier()->setHeight(
1490             node, result.Value(), static_cast<int32_t>(result.Unit()), calc.c_str(), RawResObj);
1491     }
1492     return true;
1493 }
1494 
ParseResizableCalcDimensions(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t offset,uint32_t count,std::vector<std::optional<CalcDimension>> & results,const CalcDimension & defValue,std::vector<RefPtr<ResourceObject>> & bgImageResizableResObjs)1495 void ParseResizableCalcDimensions(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, uint32_t count,
1496     std::vector<std::optional<CalcDimension>>& results, const CalcDimension& defValue,
1497     std::vector<RefPtr<ResourceObject>>& bgImageResizableResObjs)
1498 {
1499     auto end = offset + count;
1500     auto argsNumber = runtimeCallInfo->GetArgsNumber();
1501     if (end > argsNumber) {
1502         return;
1503     }
1504     CalcDimension defaultDimension(defValue);
1505     EcmaVM* vm = runtimeCallInfo->GetVM();
1506     for (uint32_t index = offset; index < end; index++) {
1507         auto arg = runtimeCallInfo->GetCallArgRef(index);
1508         std::optional<CalcDimension> optCalcDimension;
1509         CalcDimension dimension(defValue);
1510         RefPtr<ResourceObject> resObj;
1511         if (ArkTSUtils::ParseJsDimensionVp(vm, arg, dimension, resObj, false)) {
1512             optCalcDimension = dimension;
1513         } else {
1514             optCalcDimension = defaultDimension;
1515         }
1516         bgImageResizableResObjs.push_back(resObj);
1517         results.push_back(optCalcDimension);
1518     }
1519 }
1520 
ParseJsAlignRule(const EcmaVM * vm,const Local<JSValueRef> & arg,std::string & anchor,ArkUI_Int32 & direction)1521 bool ParseJsAlignRule(const EcmaVM* vm, const Local<JSValueRef> &arg, std::string& anchor, ArkUI_Int32 &direction)
1522 {
1523     if (arg->IsString(vm)) {
1524         std::string directionString = arg->ToString(vm)->ToString(vm);
1525         if (directionString.empty()) {
1526             return false;
1527         }
1528         size_t pos = directionString.find('|');
1529         if (pos == std::string::npos) {
1530             return false;
1531         }
1532         char* endPtr = nullptr;
1533         long alignValue = std::strtol(directionString.substr(0, pos).c_str(), &endPtr, 10);
1534         direction = static_cast<int8_t>(alignValue);
1535         anchor = directionString.substr(pos + 1);
1536         return true;
1537     }
1538     return false;
1539 }
1540 
ParseResponseRegion(const EcmaVM * vm,const Local<JSValueRef> & jsValue,ArkUI_Float32 regionValues[],int32_t regionUnits[],int32_t length)1541 bool ParseResponseRegion(const EcmaVM* vm, const Local<JSValueRef>& jsValue, ArkUI_Float32 regionValues[],
1542     int32_t regionUnits[], int32_t length)
1543 {
1544     if (jsValue->IsUndefined() || !jsValue->IsArray(vm)) {
1545         return false;
1546     }
1547 
1548     Local<panda::ArrayRef> transArray = static_cast<Local<panda::ArrayRef>>(jsValue);
1549     for (int32_t i = 0; i < length; i = i + NUM_4) {
1550         Local<JSValueRef> x = transArray->GetValueAt(vm, jsValue, i + NUM_0);
1551         Local<JSValueRef> y = transArray->GetValueAt(vm, jsValue, i + NUM_1);
1552         Local<JSValueRef> width = transArray->GetValueAt(vm, jsValue, i + NUM_2);
1553         Local<JSValueRef> height = transArray->GetValueAt(vm, jsValue, i + NUM_3);
1554         CalcDimension xDimen = CalcDimension(0.0, DimensionUnit::VP);
1555         CalcDimension yDimen = CalcDimension(0.0, DimensionUnit::VP);
1556         CalcDimension widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
1557         CalcDimension heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
1558         auto s1 = width->ToString(vm)->ToString(vm);
1559         auto s2 = height->ToString(vm)->ToString(vm);
1560         if (s1.find('-') != std::string::npos) {
1561             width = ToJSValue("100%");
1562         }
1563         if (s2.find('-') != std::string::npos) {
1564             height = ToJSValue("100%");
1565         }
1566         if (!ArkTSUtils::ParseJsDimensionNG(vm, x, xDimen, DimensionUnit::VP)) {
1567             xDimen = CalcDimension(0.0, DimensionUnit::VP);
1568         }
1569         if (!ArkTSUtils::ParseJsDimensionNG(vm, y, yDimen, DimensionUnit::VP)) {
1570             yDimen = CalcDimension(0.0, DimensionUnit::VP);
1571         }
1572         if (!ArkTSUtils::ParseJsDimensionNG(vm, width, widthDimen, DimensionUnit::VP)) {
1573             widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
1574         }
1575         if (!ArkTSUtils::ParseJsDimensionNG(vm, height, heightDimen, DimensionUnit::VP)) {
1576             heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
1577         }
1578         regionValues[i + NUM_0] = static_cast<ArkUI_Float32>(xDimen.Value());
1579         regionUnits[i + NUM_0] = static_cast<int32_t>(xDimen.Unit());
1580         regionValues[i + NUM_1] = static_cast<ArkUI_Float32>(yDimen.Value());
1581         regionUnits[i + NUM_1] = static_cast<int32_t>(yDimen.Unit());
1582         regionValues[i + NUM_2] = static_cast<ArkUI_Float32>(widthDimen.Value());
1583         regionUnits[i + NUM_2] = static_cast<int32_t>(widthDimen.Unit());
1584         regionValues[i + NUM_3] = static_cast<ArkUI_Float32>(heightDimen.Value());
1585         regionUnits[i + NUM_3] = static_cast<int32_t>(heightDimen.Unit());
1586     }
1587     return true;
1588 }
1589 
ParseTransitionCallback(const JSRef<JSFunc> & jsFunc,const JSExecutionContext & context,FrameNode * node)1590 std::function<void(bool)> ParseTransitionCallback(
1591     const JSRef<JSFunc>& jsFunc, const JSExecutionContext& context, FrameNode* node)
1592 {
1593     auto jsFuncFinish = AceType::MakeRefPtr<JsFunction>(JSRef<JSFunc>::Cast(jsFunc));
1594     auto targetNode = AceType::WeakClaim(node);
1595     auto finishCallback = [execCtx = context, jsFuncFinish, targetNode](bool isTransitionIn) {
1596         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
1597         NG::PipelineContext::SetCallBackNode(targetNode);
1598         JSRef<JSVal> newJSVal = JSRef<JSVal>::Make(ToJSValue(isTransitionIn));
1599         jsFuncFinish->ExecuteJS(1, &newJSVal);
1600     };
1601     return finishCallback;
1602 }
1603 
1604 const std::vector<AccessibilitySamePageMode> PAGE_MODE_TYPE = { AccessibilitySamePageMode::SEMI_SILENT,
1605     AccessibilitySamePageMode::FULL_SILENT };
1606 const std::vector<FocusDrawLevel> FOCUS_DRAW_LEVEL = { FocusDrawLevel::SELF, FocusDrawLevel::TOP };
1607 } // namespace
1608 
SetBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)1609 ArkUINativeModuleValue CommonBridge::SetBackground(ArkUIRuntimeCallInfo *runtimeCallInfo)
1610 {
1611     EcmaVM *vm = runtimeCallInfo->GetVM();
1612     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1613     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1614     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1615     Local<JSValueRef> fourthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1616     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1617     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
1618 
1619     // Parse color background
1620     Color color;
1621     RefPtr<ResourceObject> backgroundColorResObj;
1622     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, backgroundColorResObj, nodeInfo)) {
1623         return panda::JSValueRef::Undefined(vm);
1624     }
1625     ArkUIBackgroundContent content;
1626     content.color = color.GetValue();
1627     content.bgColorRawPtr = AceType::RawPtr(backgroundColorResObj);
1628 
1629     ArkUIBackgroundOptions options;
1630     options.align = ALIGNMENT_CENTER;
1631     // Parse ignoresLayoutSafeAreaEdges
1632     std::vector<ArkUI_Int32> edges;
1633     if (!ArkTSUtils::ParseJsIgnoresLayoutSafeAreaEdges(vm, fourthArg, edges)) {
1634         edges.emplace_back(DEFAULT_LAYOUT_SAFE_AREA_EDGE_FOR_COLOR_BACKGROUND);
1635     }
1636     options.ignoresLayoutSafeAreaEdges = edges.data();
1637     options.ignoresLayoutSafeAreaEdgesSize = edges.size();
1638 
1639     GetArkUINodeModifiers()->getCommonModifier()->setBackground(nativeNode, &content, &options);
1640     return panda::JSValueRef::Undefined(vm);
1641 }
1642 
ResetBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)1643 ArkUINativeModuleValue CommonBridge::ResetBackground(ArkUIRuntimeCallInfo *runtimeCallInfo)
1644 {
1645     EcmaVM *vm = runtimeCallInfo->GetVM();
1646     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1647     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1648     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1649     GetArkUINodeModifiers()->getCommonModifier()->resetBackground(nativeNode);
1650     return panda::JSValueRef::Undefined(vm);
1651 }
1652 
SetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1653 ArkUINativeModuleValue CommonBridge::SetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
1654 {
1655     EcmaVM *vm = runtimeCallInfo->GetVM();
1656     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1657     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1658     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1659     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1660     Color color;
1661     RefPtr<ResourceObject> backgroundColorResObj;
1662     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
1663     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, backgroundColorResObj, nodeInfo)) {
1664         GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundColor(nativeNode);
1665     } else {
1666         auto bgColorRawPtr = AceType::RawPtr(backgroundColorResObj);
1667         GetArkUINodeModifiers()->getCommonModifier()->setBackgroundColorWithColorSpace(
1668             nativeNode, color.GetValue(), color.GetColorSpace(), bgColorRawPtr);
1669     }
1670     return panda::JSValueRef::Undefined(vm);
1671 }
1672 
ResetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1673 ArkUINativeModuleValue CommonBridge::ResetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
1674 {
1675     EcmaVM *vm = runtimeCallInfo->GetVM();
1676     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1677     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1678     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1679     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundColor(nativeNode);
1680     return panda::JSValueRef::Undefined(vm);
1681 }
1682 
SetBorderWidthArray(const EcmaVM * vm,const Local<JSValueRef> & args,ArkUI_Float32 values[],int units[],int index,std::vector<RefPtr<ResourceObject>> & resObj)1683 void SetBorderWidthArray(const EcmaVM* vm, const Local<JSValueRef>& args, ArkUI_Float32 values[],
1684     int units[], int index, std::vector<RefPtr<ResourceObject>>& resObj)
1685 {
1686     CalcDimension borderDimension;
1687     RefPtr<ResourceObject> borderDimensionResObj;
1688     if (!args->IsUndefined()) {
1689         if (ArkTSUtils::ParseAllBorder(vm, args, borderDimension, borderDimensionResObj)) {
1690             values[index] = borderDimension.Value();
1691             units[index] = static_cast<int>(borderDimension.Unit());
1692         } else {
1693             values[index] = 0;
1694             units[index] = static_cast<int>(DimensionUnit::VP);
1695         }
1696         if (SystemProperties::ConfigChangePerform()) {
1697             resObj.push_back(borderDimensionResObj);
1698         }
1699     } else {
1700         values[index] = -1;
1701         units[index] = static_cast<int>(DimensionUnit::INVALID);
1702         ParseNullptrResObj(resObj, NUM_1);
1703     }
1704 }
1705 
ParseLocalizedBorderWidth(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimen)1706 bool ParseLocalizedBorderWidth(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& dimen)
1707 {
1708     if (ArkTSUtils::ParseJsLengthMetrics(vm, value, dimen)) {
1709         if (LessOrEqual(dimen.Value(), 0.0)) {
1710             dimen.SetValue(0.0);
1711             dimen.SetUnit(DimensionUnit::VP);
1712         }
1713         return true;
1714     }
1715     return false;
1716 }
1717 
SetBorderWidthArrayByDimen(CalcDimension & borderDimension,ArkUI_Float32 values[],int units[],int index)1718 void SetBorderWidthArrayByDimen(CalcDimension& borderDimension, ArkUI_Float32 values[], int units[], int index)
1719 {
1720     values[index] = borderDimension.Value();
1721     units[index] = static_cast<int>(borderDimension.Unit());
1722 }
1723 
ParseBorderWidthLengthMetrics(EcmaVM * vm,Local<JSValueRef> arg,CalcDimension & dimension,bool & isLengthMetrics)1724 void ParseBorderWidthLengthMetrics(EcmaVM* vm, Local<JSValueRef> arg, CalcDimension& dimension, bool& isLengthMetrics)
1725 {
1726     if (arg->IsObject(vm)) {
1727         isLengthMetrics |= ParseLocalizedBorderWidth(vm, arg, dimension);
1728     }
1729 }
1730 
SetBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)1731 ArkUINativeModuleValue CommonBridge::SetBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
1732 {
1733     EcmaVM* vm = runtimeCallInfo->GetVM();
1734     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1735     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1736     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1737     Local<JSValueRef> topArgs = runtimeCallInfo->GetCallArgRef(NUM_1);
1738     Local<JSValueRef> rightArgs = runtimeCallInfo->GetCallArgRef(NUM_2);
1739     Local<JSValueRef> bottomArgs = runtimeCallInfo->GetCallArgRef(NUM_3);
1740     Local<JSValueRef> leftArgs = runtimeCallInfo->GetCallArgRef(NUM_4);
1741     if (leftArgs->IsUndefined() && rightArgs->IsUndefined() && topArgs->IsUndefined() && bottomArgs->IsUndefined()) {
1742         GetArkUINodeModifiers()->getCommonModifier()->resetBorderWidth(nativeNode);
1743         return panda::JSValueRef::Undefined(vm);
1744     }
1745 
1746     CalcDimension top;
1747     CalcDimension right;
1748     CalcDimension bottom;
1749     CalcDimension left;
1750     bool isLengthMetrics = false;
1751 
1752     ParseBorderWidthLengthMetrics(vm, topArgs, top, isLengthMetrics);
1753     ParseBorderWidthLengthMetrics(vm, rightArgs, right, isLengthMetrics);
1754     ParseBorderWidthLengthMetrics(vm, bottomArgs, bottom, isLengthMetrics);
1755     ParseBorderWidthLengthMetrics(vm, leftArgs, left, isLengthMetrics);
1756 
1757     uint32_t size = SIZE_OF_FOUR;
1758     ArkUI_Float32 values[size];
1759     std::vector<RefPtr<ResourceObject>> resObj;
1760     int units[size];
1761 
1762     if (isLengthMetrics) {
1763         auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
1764         SetBorderWidthArrayByDimen(top, values, units, NUM_0);
1765         SetBorderWidthArrayByDimen(isRightToLeft ? left : right, values, units, NUM_1);
1766         SetBorderWidthArrayByDimen(bottom, values, units, NUM_2);
1767         SetBorderWidthArrayByDimen(isRightToLeft ? right : left, values, units, NUM_3);
1768         ParseNullptrResObj(resObj, NUM_4);
1769     } else {
1770         SetBorderWidthArray(vm, topArgs, values, units, NUM_0, resObj);
1771         SetBorderWidthArray(vm, rightArgs, values, units, NUM_1, resObj);
1772         SetBorderWidthArray(vm, bottomArgs, values, units, NUM_2, resObj);
1773         SetBorderWidthArray(vm, leftArgs, values, units, NUM_3, resObj);
1774     }
1775 
1776     auto rawPtr = static_cast<void*>(&resObj);
1777     GetArkUINodeModifiers()->getCommonModifier()->setBorderWidth(nativeNode, values, units, size, rawPtr);
1778     return panda::JSValueRef::Undefined(vm);
1779 }
1780 
ParseOuterBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<ArkUI_Float32> & values,bool needLocalized)1781 void CommonBridge::ParseOuterBorderWidth( ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm,
1782     std::vector<ArkUI_Float32>& values, bool needLocalized)
1783 {
1784     std::vector<RefPtr<ResourceObject>> resObj;
1785     ParseOuterBorderWidth(runtimeCallInfo, vm, values, resObj, needLocalized);
1786 }
1787 
ParseOuterBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,std::vector<ArkUI_Float32> & values,std::vector<RefPtr<ResourceObject>> & resObjs,bool needLocalized)1788 void CommonBridge::ParseOuterBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm,
1789     std::vector<ArkUI_Float32>& values, std::vector<RefPtr<ResourceObject>>& resObjs, bool needLocalized)
1790 {
1791     Local<JSValueRef> leftArgs = runtimeCallInfo->GetCallArgRef(NUM_1);
1792     Local<JSValueRef> rightArgs = runtimeCallInfo->GetCallArgRef(NUM_2);
1793     Local<JSValueRef> topArgs = runtimeCallInfo->GetCallArgRef(NUM_3);
1794     Local<JSValueRef> bottomArgs = runtimeCallInfo->GetCallArgRef(NUM_4);
1795 
1796     std::optional<CalcDimension> leftDim;
1797     std::optional<CalcDimension> rightDim;
1798     std::optional<CalcDimension> topDim;
1799     std::optional<CalcDimension> bottomDim;
1800     std::optional<CalcDimension> startDim;
1801     std::optional<CalcDimension> endDim;
1802 
1803     ParseOuterBorder(vm, leftArgs, leftDim, resObjs);
1804     ParseOuterBorder(vm, rightArgs, rightDim, resObjs);
1805     if (needLocalized) {
1806         Local<JSValueRef> startArgs = runtimeCallInfo->GetCallArgRef(25); // 25: index of BorderWidth.start
1807         Local<JSValueRef> endArgs = runtimeCallInfo->GetCallArgRef(26);   // 26: index of BorderWidth.end
1808         ArkTSUtils::ParseOuterBorderForDashParams(vm, startArgs, startDim);
1809         ArkTSUtils::ParseOuterBorderForDashParams(vm, endArgs, endDim);
1810         ArkTSUtils::ParseOuterBorderForDashParams(vm, topArgs, topDim);
1811         ArkTSUtils::ParseOuterBorderForDashParams(vm, bottomArgs, bottomDim);
1812         ParseNullptrResObj(resObjs, NUM_2);
1813     } else {
1814         ParseOuterBorder(vm, topArgs, topDim, resObjs);
1815         ParseOuterBorder(vm, bottomArgs, bottomDim, resObjs);
1816     }
1817 
1818     if (startDim.has_value() || endDim.has_value()) {
1819         PushOuterBorderDimensionVector(startDim, values);
1820         PushOuterBorderDimensionVector(endDim, values);
1821     } else {
1822         PushOuterBorderDimensionVector(leftDim, values);
1823         PushOuterBorderDimensionVector(rightDim, values);
1824     }
1825     PushOuterBorderDimensionVector(topDim, values);
1826     PushOuterBorderDimensionVector(bottomDim, values);
1827 }
1828 
ResetBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)1829 ArkUINativeModuleValue CommonBridge::ResetBorderWidth(ArkUIRuntimeCallInfo *runtimeCallInfo)
1830 {
1831     EcmaVM *vm = runtimeCallInfo->GetVM();
1832     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1833     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1834     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1835     GetArkUINodeModifiers()->getCommonModifier()->resetBorderWidth(nativeNode);
1836     return panda::JSValueRef::Undefined(vm);
1837 }
1838 
ParseMirrorDimen(ArkUI_Float32 values[],int units[],int idx,CalcDimension & calcDimen)1839 void ParseMirrorDimen(ArkUI_Float32 values[], int units[], int idx, CalcDimension& calcDimen)
1840 {
1841     values[idx] = calcDimen.Value();
1842     units[idx] = static_cast<int>(calcDimen.Unit());
1843 }
1844 
ParseJsDimensionVpResObj(EcmaVM * vm,const Local<JSValueRef> & refValue,CalcDimension & dimension,std::vector<RefPtr<ResourceObject>> & vectorResObj)1845 void ParseJsDimensionVpResObj(EcmaVM* vm, const Local<JSValueRef>& refValue, CalcDimension& dimension,
1846     std::vector<RefPtr<ResourceObject>>& vectorResObj)
1847 {
1848     RefPtr<ResourceObject> resObj;
1849     ArkTSUtils::ParseJsDimensionVp(vm, refValue, dimension, resObj);
1850     if (resObj) {
1851         vectorResObj.push_back(resObj);
1852     } else {
1853         vectorResObj.push_back(nullptr);
1854     }
1855 }
1856 
ParseJsShadowRadiusResObj(const EcmaVM * vm,const Local<JSValueRef> & radiusArg,double & radius,std::vector<RefPtr<ResourceObject>> & vectorResObj)1857 void ParseJsShadowRadiusResObj(const EcmaVM *vm, const Local<JSValueRef>& radiusArg, double& radius,
1858     std::vector<RefPtr<ResourceObject>>& vectorResObj)
1859 {
1860     RefPtr<ResourceObject> radiusResObj;
1861     ArkTSUtils::ParseJsDouble(vm, radiusArg, radius, radiusResObj);
1862     if (radiusResObj) {
1863         vectorResObj.push_back(radiusResObj);
1864     } else {
1865         vectorResObj.push_back(nullptr);
1866     }
1867 }
1868 
ParseJsShadowColorResObj(const EcmaVM * vm,const Local<JSValueRef> & colorArg,int32_t & type,uint32_t & color,std::vector<RefPtr<ResourceObject>> & vectorResObj,ArkUINodeHandle nativeNode)1869 bool ParseJsShadowColorResObj(const EcmaVM *vm, const Local<JSValueRef>& colorArg, int32_t& type, uint32_t& color,
1870     std::vector<RefPtr<ResourceObject>>& vectorResObj, ArkUINodeHandle nativeNode)
1871 {
1872     RefPtr<ResourceObject> colorResObj;
1873     bool ret = ParseJsShadowColor(vm, colorArg, type, color, colorResObj, nativeNode);
1874     if (colorResObj) {
1875         vectorResObj.push_back(colorResObj);
1876     } else {
1877         vectorResObj.push_back(nullptr);
1878     }
1879     return ret;
1880 }
1881 
SetBackShadowForShadowStyle(const ArkUINodeHandle nativeNode,const EcmaVM * vm,const Local<JSValueRef> & styleArg)1882 bool SetBackShadowForShadowStyle(const ArkUINodeHandle nativeNode, const EcmaVM *vm,
1883     const Local<JSValueRef>& styleArg)
1884 {
1885     int32_t shadowStyle = 0;
1886     if (ArkTSUtils::ParseJsInteger(vm, styleArg, shadowStyle)) {
1887         ArkUIInt32orFloat32 shadows[] = { {.i32 = shadowStyle} };
1888         GetArkUINodeModifiers()->getCommonModifier()->setBackShadow(nativeNode, shadows,
1889             (sizeof(shadows) / sizeof(shadows[NUM_0])), nullptr);
1890         return true;
1891     }
1892     return false;
1893 }
1894 
SetBorderRadiusArray(const EcmaVM * vm,const Local<JSValueRef> & args,CalcDimension & result,std::vector<RefPtr<ResourceObject>> & resObjs)1895 void SetBorderRadiusArray(const EcmaVM* vm, const Local<JSValueRef>& args, CalcDimension& result,
1896     std::vector<RefPtr<ResourceObject>>& resObjs)
1897 {
1898     RefPtr<ResourceObject> resObj;
1899     ArkTSUtils::ParseAllBorder(vm, args, result, resObj);
1900     if (SystemProperties::ConfigChangePerform()) {
1901         resObjs.push_back(resObj);
1902     }
1903 }
1904 
ParseBorderRadiusLengthMetrics(EcmaVM * vm,Local<JSValueRef> arg,CalcDimension & dimension,bool & isLengthMetrics)1905 void ParseBorderRadiusLengthMetrics(EcmaVM* vm, Local<JSValueRef> arg, CalcDimension& dimension, bool& isLengthMetrics)
1906 {
1907     if (arg->IsObject(vm)) {
1908         isLengthMetrics |= ParseLocalizedBorderRadius(vm, arg, dimension);
1909     }
1910 }
1911 
SetBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)1912 ArkUINativeModuleValue CommonBridge::SetBorderRadius(ArkUIRuntimeCallInfo *runtimeCallInfo)
1913 {
1914     EcmaVM *vm = runtimeCallInfo->GetVM();
1915     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1916     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1917     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1918     Local<JSValueRef> topLeftArgs = runtimeCallInfo->GetCallArgRef(NUM_1);
1919     Local<JSValueRef> topRightArgs = runtimeCallInfo->GetCallArgRef(NUM_2);
1920     Local<JSValueRef> bottomLeftArgs = runtimeCallInfo->GetCallArgRef(NUM_3);
1921     Local<JSValueRef> bottomRightArgs = runtimeCallInfo->GetCallArgRef(NUM_4);
1922     if (topLeftArgs->IsUndefined() && topRightArgs->IsUndefined() && bottomLeftArgs->IsUndefined() &&
1923         bottomRightArgs->IsUndefined()) {
1924         GetArkUINodeModifiers()->getCommonModifier()->resetBorderRadius(nativeNode);
1925         return panda::JSValueRef::Undefined(vm);
1926     }
1927     CalcDimension topLeft;
1928     CalcDimension topRight;
1929     CalcDimension bottomLeft;
1930     CalcDimension bottomRight;
1931     std::vector<RefPtr<ResourceObject>> resObj;
1932     bool isLengthMetrics = false;
1933     ParseBorderRadiusLengthMetrics(vm, topLeftArgs, topLeft, isLengthMetrics);
1934     ParseBorderRadiusLengthMetrics(vm, topRightArgs, topRight, isLengthMetrics);
1935     ParseBorderRadiusLengthMetrics(vm, bottomLeftArgs, bottomLeft, isLengthMetrics);
1936     ParseBorderRadiusLengthMetrics(vm, bottomRightArgs, bottomRight, isLengthMetrics);
1937     if (!isLengthMetrics) {
1938         SetBorderRadiusArray(vm, topLeftArgs, topLeft, resObj);
1939         SetBorderRadiusArray(vm, topRightArgs, topRight, resObj);
1940         SetBorderRadiusArray(vm, bottomLeftArgs, bottomLeft, resObj);
1941         SetBorderRadiusArray(vm, bottomRightArgs, bottomRight, resObj);
1942     } else {
1943         ParseNullptrResObj(resObj, NUM_4);
1944     }
1945     ArkUI_Float32 values[SIZE_OF_FOUR];
1946     int units[SIZE_OF_FOUR];
1947     bool isMirror = isLengthMetrics && AceApplicationInfo::GetInstance().IsRightToLeft();
1948     ParseMirrorDimen(values, units, NUM_0, isMirror ? topRight : topLeft);
1949     ParseMirrorDimen(values, units, NUM_1, isMirror ? topLeft : topRight);
1950     ParseMirrorDimen(values, units, NUM_2, isMirror ? bottomRight : bottomLeft);
1951     ParseMirrorDimen(values, units, NUM_3, isMirror ? bottomLeft : bottomRight);
1952     auto rawPtr = static_cast<void*>(&resObj);
1953     GetArkUINodeModifiers()->getCommonModifier()->setBorderRadius(nativeNode, values, units, SIZE_OF_FOUR, rawPtr);
1954     return panda::JSValueRef::Undefined(vm);
1955 }
1956 
ResetBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)1957 ArkUINativeModuleValue CommonBridge::ResetBorderRadius(ArkUIRuntimeCallInfo *runtimeCallInfo)
1958 {
1959     EcmaVM *vm = runtimeCallInfo->GetVM();
1960     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1961     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1962     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1963     GetArkUINodeModifiers()->getCommonModifier()->resetBorderRadius(nativeNode);
1964     return panda::JSValueRef::Undefined(vm);
1965 }
1966 
ParseLayoutPolicy(const std::string & layoutPolicy)1967 LayoutCalPolicy CommonBridge::ParseLayoutPolicy(const std::string& layoutPolicy)
1968 {
1969     if (layoutPolicy == "matchParent") {
1970         return LayoutCalPolicy::MATCH_PARENT;
1971     }
1972     if (layoutPolicy == "wrapContent") {
1973         return LayoutCalPolicy::WRAP_CONTENT;
1974     }
1975     if (layoutPolicy == "fixAtIdealSize") {
1976         return LayoutCalPolicy::FIX_AT_IDEAL_SIZE;
1977     }
1978     return LayoutCalPolicy::NO_MATCH;
1979 }
1980 
SetWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)1981 ArkUINativeModuleValue CommonBridge::SetWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
1982 {
1983     EcmaVM* vm = runtimeCallInfo->GetVM();
1984     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1985     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1986     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1987     Local<JSValueRef> jsValue = runtimeCallInfo->GetCallArgRef(NUM_1);
1988     CalcDimension width;
1989     RefPtr<ResourceObject> widthResObj;
1990     std::string calcStr;
1991     if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, width, widthResObj)) {
1992         GetArkUINodeModifiers()->getCommonModifier()->resetWidth(nativeNode);
1993         if (jsValue->IsObject(vm)) {
1994             auto obj = jsValue->ToObject(vm);
1995             auto layoutPolicy = obj->Get(vm, panda::StringRef::NewFromUtf8(vm, "id_"));
1996             if (layoutPolicy->IsString(vm)) {
1997                 auto policy = ParseLayoutPolicy(layoutPolicy->ToString(vm)->ToString(vm));
1998                 ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(policy, true);
1999                 return panda::JSValueRef::Undefined(vm);
2000             }
2001         }
2002     } else {
2003         if (LessNotEqual(width.Value(), 0.0)) {
2004             if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) {
2005                 GetArkUINodeModifiers()->getCommonModifier()->resetWidth(nativeNode);
2006                 ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, true);
2007                 return panda::JSValueRef::Undefined(vm);
2008             }
2009             width.SetValue(0.0);
2010         }
2011 
2012         auto widthRawResObj = AceType::RawPtr(widthResObj);
2013         if (width.Unit() == DimensionUnit::CALC) {
2014             GetArkUINodeModifiers()->getCommonModifier()->setWidth(
2015                 nativeNode, 0, static_cast<int32_t>(width.Unit()), width.CalcValue().c_str(), widthRawResObj);
2016         } else {
2017             GetArkUINodeModifiers()->getCommonModifier()->setWidth(
2018                 nativeNode, width.Value(), static_cast<int32_t>(width.Unit()), calcStr.c_str(), widthRawResObj);
2019         }
2020     }
2021     ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, true);
2022     return panda::JSValueRef::Undefined(vm);
2023 }
2024 
ResetWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)2025 ArkUINativeModuleValue CommonBridge::ResetWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
2026 {
2027     EcmaVM* vm = runtimeCallInfo->GetVM();
2028     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2029     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2030     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2031     GetArkUINodeModifiers()->getCommonModifier()->resetWidth(nativeNode);
2032     return panda::JSValueRef::Undefined(vm);
2033 }
2034 
SetHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)2035 ArkUINativeModuleValue CommonBridge::SetHeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
2036 {
2037     EcmaVM* vm = runtimeCallInfo->GetVM();
2038     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2039     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2040     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2041     Local<JSValueRef> jsValue = runtimeCallInfo->GetCallArgRef(NUM_1);
2042     CalcDimension height;
2043     RefPtr<ResourceObject> heightResObj;
2044     std::string calcStr;
2045     if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, height, heightResObj)) {
2046         GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode);
2047         if (jsValue->IsObject(vm)) {
2048             auto obj = jsValue->ToObject(vm);
2049             auto layoutPolicy = obj->Get(vm, panda::StringRef::NewFromUtf8(vm, "id_"));
2050             if (layoutPolicy->IsString(vm)) {
2051                 auto policy = ParseLayoutPolicy(layoutPolicy->ToString(vm)->ToString(vm));
2052                 ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(policy, false);
2053                 return panda::JSValueRef::Undefined(vm);
2054             }
2055         }
2056     } else {
2057         if (LessNotEqual(height.Value(), 0.0)) {
2058             if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) {
2059                 GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode);
2060                 ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, false);
2061                 return panda::JSValueRef::Undefined(vm);
2062             }
2063             height.SetValue(0.0);
2064         }
2065         auto heightRawResObj = AceType::RawPtr(heightResObj);
2066         if (height.Unit() == DimensionUnit::CALC) {
2067             GetArkUINodeModifiers()->getCommonModifier()->setHeight(nativeNode, height.Value(),
2068                 static_cast<int32_t>(height.Unit()), height.CalcValue().c_str(), heightRawResObj);
2069         } else {
2070             GetArkUINodeModifiers()->getCommonModifier()->setHeight(
2071                 nativeNode, height.Value(), static_cast<int32_t>(height.Unit()), calcStr.c_str(), heightRawResObj);
2072         }
2073     }
2074     ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, false);
2075     return panda::JSValueRef::Undefined(vm);
2076 }
2077 
ResetHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)2078 ArkUINativeModuleValue CommonBridge::ResetHeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
2079 {
2080     EcmaVM *vm = runtimeCallInfo->GetVM();
2081     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2082     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2083     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2084     GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode);
2085     return panda::JSValueRef::Undefined(vm);
2086 }
2087 
SetPosition(ArkUIRuntimeCallInfo * runtimeCallInfo)2088 ArkUINativeModuleValue CommonBridge::SetPosition(ArkUIRuntimeCallInfo* runtimeCallInfo)
2089 {
2090     EcmaVM* vm = runtimeCallInfo->GetVM();
2091     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2092     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2093     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2094     bool useEdges = runtimeCallInfo->GetCallArgRef(NUM_1)->ToBoolean(vm)->Value();
2095     std::vector<ArkUIStringAndFloat> options;
2096     std::vector<std::optional<CalcDimension>> edges;
2097     std::vector<RefPtr<ResourceObject>> edgesResObj;
2098 
2099     if (useEdges) {
2100         ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, edgesResObj, CalcDimension(0.0));
2101         if (res == ParseResult::LENGTHMETRICS_SUCCESS && AceApplicationInfo::GetInstance().IsRightToLeft()) {
2102             // Swap left and right
2103             std::swap(edges[NUM_1], edges[NUM_3]);
2104         }
2105         PushDimensionsToVector(options, edges);
2106         auto edgesRawPtr = static_cast<void*>(&edgesResObj);
2107         GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges(
2108             nativeNode, useEdges, options.data(), edgesRawPtr);
2109     } else {
2110         ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, edgesResObj, CalcDimension(0.0));
2111         PushDimensionsToVector(options, edges);
2112         auto edgesRawPtr = static_cast<void*>(&edgesResObj);
2113         GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges(
2114             nativeNode, useEdges, options.data(), edgesRawPtr);
2115     }
2116     return panda::JSValueRef::Undefined(vm);
2117 }
2118 
ResetPosition(ArkUIRuntimeCallInfo * runtimeCallInfo)2119 ArkUINativeModuleValue CommonBridge::ResetPosition(ArkUIRuntimeCallInfo *runtimeCallInfo)
2120 {
2121     EcmaVM *vm = runtimeCallInfo->GetVM();
2122     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2123     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2124     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2125     GetArkUINodeModifiers()->getCommonModifier()->resetPositionEdges(nativeNode);
2126     return panda::JSValueRef::Undefined(vm);
2127 }
2128 
SetTransform(ArkUIRuntimeCallInfo * runtimeCallInfo)2129 ArkUINativeModuleValue CommonBridge::SetTransform(ArkUIRuntimeCallInfo *runtimeCallInfo)
2130 {
2131     EcmaVM *vm = runtimeCallInfo->GetVM();
2132     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2133     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2134     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2135     Local<JSValueRef> jsValue = runtimeCallInfo->GetCallArgRef(NUM_1);
2136 
2137     if (!jsValue->IsArray(vm)) {
2138         GetArkUINodeModifiers()->getCommonModifier()->resetTransform(nativeNode);
2139         return panda::JSValueRef::Undefined(vm);
2140     }
2141 
2142     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
2143     float matrix[matrix4Len];
2144     Local<panda::ArrayRef> transArray = static_cast<Local<panda::ArrayRef>>(jsValue);
2145     for (size_t i = 0; i < transArray->Length(vm); i++) {
2146         Local<JSValueRef> value = transArray->GetValueAt(vm, jsValue, i);
2147         matrix[i] = value->ToNumber(vm)->Value();
2148     }
2149     GetArkUINodeModifiers()->getCommonModifier()->setTransform(nativeNode, matrix, matrix4Len);
2150     return panda::JSValueRef::Undefined(vm);
2151 }
2152 
ResetTransform(ArkUIRuntimeCallInfo * runtimeCallInfo)2153 ArkUINativeModuleValue CommonBridge::ResetTransform(ArkUIRuntimeCallInfo *runtimeCallInfo)
2154 {
2155     EcmaVM *vm = runtimeCallInfo->GetVM();
2156     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2157     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2158     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2159 
2160     GetArkUINodeModifiers()->getCommonModifier()->resetTransform(nativeNode);
2161     return panda::JSValueRef::Undefined(vm);
2162 }
2163 
SetTransform3D(ArkUIRuntimeCallInfo * runtimeCallInfo)2164 ArkUINativeModuleValue CommonBridge::SetTransform3D(ArkUIRuntimeCallInfo *runtimeCallInfo)
2165 {
2166     EcmaVM *vm = runtimeCallInfo->GetVM();
2167     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2168     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2169     if (firstArg->IsNull()) {
2170         return panda::NativePointerRef::New(vm, nullptr);
2171     }
2172     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2173     Local<JSValueRef> jsValue = runtimeCallInfo->GetCallArgRef(NUM_1);
2174 
2175     auto nodeModifiers = GetArkUINodeModifiers();
2176     CHECK_NULL_RETURN(nodeModifiers, panda::NativePointerRef::New(vm, nullptr));
2177 
2178     if (!jsValue->IsArray(vm)) {
2179         nodeModifiers->getCommonModifier()->resetTransform3D(nativeNode);
2180         return panda::JSValueRef::Undefined(vm);
2181     }
2182 
2183     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
2184     float matrix[matrix4Len];
2185     Local<panda::ArrayRef> transArray = static_cast<Local<panda::ArrayRef>>(jsValue);
2186     if (transArray->Length(vm) != matrix4Len) {
2187         TAG_LOGW(AceLogTag::ACE_VISUAL_EFFECT,
2188             "Invalid matrix parameter: Expected %{public}d elements, but transArray has %{public}u elements",
2189             matrix4Len, transArray->Length(vm));
2190         nodeModifiers->getCommonModifier()->resetTransform3D(nativeNode);
2191         return panda::JSValueRef::Undefined(vm);
2192     }
2193     for (size_t i = 0; i < transArray->Length(vm); i++) {
2194         Local<JSValueRef> value = transArray->GetValueAt(vm, jsValue, i);
2195         matrix[i] = value->ToNumber(vm)->Value();
2196     }
2197     nodeModifiers->getCommonModifier()->setTransform3D(nativeNode, matrix, matrix4Len);
2198     return panda::JSValueRef::Undefined(vm);
2199 }
2200 
ResetTransform3D(ArkUIRuntimeCallInfo * runtimeCallInfo)2201 ArkUINativeModuleValue CommonBridge::ResetTransform3D(ArkUIRuntimeCallInfo *runtimeCallInfo)
2202 {
2203     EcmaVM *vm = runtimeCallInfo->GetVM();
2204     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2205     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2206     if (firstArg->IsNull()) {
2207         return panda::NativePointerRef::New(vm, nullptr);
2208     }
2209     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2210 
2211     auto nodeModifiers = GetArkUINodeModifiers();
2212     CHECK_NULL_RETURN(nodeModifiers, panda::NativePointerRef::New(vm, nullptr));
2213     nodeModifiers->getCommonModifier()->resetTransform3D(nativeNode);
2214     return panda::JSValueRef::Undefined(vm);
2215 }
2216 
SetBorderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)2217 ArkUINativeModuleValue CommonBridge::SetBorderColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
2218 {
2219     EcmaVM *vm = runtimeCallInfo->GetVM();
2220     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2221     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2222     Local<JSValueRef> topArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2223     Local<JSValueRef> rightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2224     Local<JSValueRef> bottomArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2225     Local<JSValueRef> leftArg = runtimeCallInfo->GetCallArgRef(NUM_4);
2226     Local<JSValueRef> isLocalizedArg = runtimeCallInfo->GetCallArgRef(NUM_5);
2227     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2228     auto isLocalized = (isLocalizedArg->IsBoolean()) ? isLocalizedArg->ToBoolean(vm)->Value() : false;
2229     std::vector<RefPtr<ResourceObject>> resObj;
2230 
2231     Color topColor;
2232     Color rightColor;
2233     Color bottomColor;
2234     Color leftColor;
2235 
2236     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
2237     if (!ArkTSUtils::ParseJsColorAlpha(vm, topArg, topColor, resObj, nodeInfo)) {
2238         topColor.SetValue(COLOR_ALPHA_VALUE);
2239     }
2240     if (!ArkTSUtils::ParseJsColorAlpha(vm, rightArg, rightColor, resObj, nodeInfo)) {
2241         rightColor.SetValue(COLOR_ALPHA_VALUE);
2242     }
2243     if (!ArkTSUtils::ParseJsColorAlpha(vm, bottomArg, bottomColor, resObj, nodeInfo)) {
2244         bottomColor.SetValue(COLOR_ALPHA_VALUE);
2245     }
2246     if (!ArkTSUtils::ParseJsColorAlpha(vm, leftArg, leftColor, resObj, nodeInfo)) {
2247         leftColor.SetValue(COLOR_ALPHA_VALUE);
2248     }
2249     auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
2250     if (SystemProperties::ConfigChangePerform() && isRightToLeft && isLocalized) {
2251         std::swap(resObj[1], resObj[3]);
2252     }
2253     auto rawPtr = static_cast<void*>(&resObj);
2254     GetArkUINodeModifiers()->getCommonModifier()->setBorderColor(nativeNode,
2255         topColor.GetValue(),
2256         (isRightToLeft && isLocalized) ? leftColor.GetValue() : rightColor.GetValue(),
2257         bottomColor.GetValue(),
2258         (isRightToLeft && isLocalized) ? rightColor.GetValue() : leftColor.GetValue(), rawPtr);
2259     return panda::JSValueRef::Undefined(vm);
2260 }
2261 
ResetBorderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)2262 ArkUINativeModuleValue CommonBridge::ResetBorderColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
2263 {
2264     EcmaVM *vm = runtimeCallInfo->GetVM();
2265     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2266     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2267     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2268     GetArkUINodeModifiers()->getCommonModifier()->resetBorderColor(nativeNode);
2269     return panda::JSValueRef::Undefined(vm);
2270 }
2271 
SetOutlineColor(ArkUIRuntimeCallInfo * runtimeCallInfo)2272 ArkUINativeModuleValue CommonBridge::SetOutlineColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
2273 {
2274     EcmaVM* vm = runtimeCallInfo->GetVM();
2275     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2276     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2277     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2278     std::vector<uint32_t> colorOptions;
2279     std::vector<RefPtr<ResourceObject>> vectorResObj;
2280     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
2281     ParseOutLineColor(runtimeCallInfo, vm, colorOptions, NUM_1, vectorResObj, nodeInfo);
2282     auto rawPtr = static_cast<void*>(&vectorResObj);
2283     GetArkUINodeModifiers()->getCommonModifier()->setOutlineColor(
2284         nativeNode, colorOptions.data(), colorOptions.size(), rawPtr);
2285     return panda::JSValueRef::Undefined(vm);
2286 }
2287 
ResetOutlineColor(ArkUIRuntimeCallInfo * runtimeCallInfo)2288 ArkUINativeModuleValue CommonBridge::ResetOutlineColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
2289 {
2290     EcmaVM* vm = runtimeCallInfo->GetVM();
2291     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2292     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2293     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2294     GetArkUINodeModifiers()->getCommonModifier()->resetOutlineColor(nativeNode);
2295     return panda::JSValueRef::Undefined(vm);
2296 }
2297 
SetOutlineRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)2298 ArkUINativeModuleValue CommonBridge::SetOutlineRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
2299 {
2300     EcmaVM* vm = runtimeCallInfo->GetVM();
2301     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2302     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2303     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2304     std::vector<ArkUI_Float32> radiusOptions;
2305     std::vector<RefPtr<ResourceObject>> vectorResObj;
2306     ParseOuterBorderRadius(runtimeCallInfo, vm, radiusOptions, NUM_1, vectorResObj);
2307     auto rawPtr = static_cast<void*>(&vectorResObj);
2308     GetArkUINodeModifiers()->getCommonModifier()->setOutlineRadius(
2309         nativeNode, radiusOptions.data(), radiusOptions.size(), rawPtr);
2310     return panda::JSValueRef::Undefined(vm);
2311 }
2312 
ResetOutlineRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)2313 ArkUINativeModuleValue CommonBridge::ResetOutlineRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
2314 {
2315     EcmaVM* vm = runtimeCallInfo->GetVM();
2316     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2317     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2318     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2319     GetArkUINodeModifiers()->getCommonModifier()->resetOutlineRadius(nativeNode);
2320     return panda::JSValueRef::Undefined(vm);
2321 }
2322 
SetOutlineWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)2323 ArkUINativeModuleValue CommonBridge::SetOutlineWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
2324 {
2325     EcmaVM* vm = runtimeCallInfo->GetVM();
2326     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2327     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2328     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2329     std::vector<ArkUI_Float32> widthOptions;
2330     std::vector<RefPtr<ResourceObject>> vectorResObj;
2331     ParseOuterBorderWidth(runtimeCallInfo, vm, widthOptions, vectorResObj);
2332     auto rawPtr = static_cast<void*>(&vectorResObj);
2333     GetArkUINodeModifiers()->getCommonModifier()->setOutlineWidth(
2334         nativeNode, widthOptions.data(), widthOptions.size(), rawPtr);
2335     return panda::JSValueRef::Undefined(vm);
2336 }
2337 
ResetOutlineWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)2338 ArkUINativeModuleValue CommonBridge::ResetOutlineWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
2339 {
2340     EcmaVM* vm = runtimeCallInfo->GetVM();
2341     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2342     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2343     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2344     GetArkUINodeModifiers()->getCommonModifier()->resetOutlineWidth(nativeNode);
2345     return panda::JSValueRef::Undefined(vm);
2346 }
2347 
SetOutlineStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)2348 ArkUINativeModuleValue CommonBridge::SetOutlineStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
2349 {
2350     EcmaVM* vm = runtimeCallInfo->GetVM();
2351     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2352     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2353     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2354     std::vector<uint32_t> styleOptions;
2355     ParseOuterBorderStyle(runtimeCallInfo, vm, styleOptions, NUM_1);
2356     GetArkUINodeModifiers()->getCommonModifier()->setOutlineStyle(
2357         nativeNode, styleOptions.data(), styleOptions.size());
2358     return panda::JSValueRef::Undefined(vm);
2359 }
2360 
ResetOutlineStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)2361 ArkUINativeModuleValue CommonBridge::ResetOutlineStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
2362 {
2363     EcmaVM* vm = runtimeCallInfo->GetVM();
2364     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2365     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2366     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2367     GetArkUINodeModifiers()->getCommonModifier()->resetOutlineStyle(nativeNode);
2368     return panda::JSValueRef::Undefined(vm);
2369 }
2370 
SetOutline(ArkUIRuntimeCallInfo * runtimeCallInfo)2371 ArkUINativeModuleValue CommonBridge::SetOutline(ArkUIRuntimeCallInfo* runtimeCallInfo)
2372 {
2373     EcmaVM* vm = runtimeCallInfo->GetVM();
2374     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2375     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2376     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2377     std::vector<ArkUI_Float32> options;
2378     std::vector<RefPtr<ResourceObject>> vectorResObj;
2379     ParseOuterBorderWidth(runtimeCallInfo, vm, options, vectorResObj);         // Outline Width args start index from 1
2380     ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, vectorResObj); // Outline Radius args start index
2381 
2382     std::vector<uint32_t> colorAndStyleOptions;
2383     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
2384     ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, vectorResObj, nodeInfo);  // Outline Color args start index
2385     ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13); // Outline Style args start index
2386 
2387     auto resRawPtr = static_cast<void*>(&vectorResObj);
2388     GetArkUINodeModifiers()->getCommonModifier()->setOutline(
2389         nativeNode, options.data(), options.size(), colorAndStyleOptions.data(), colorAndStyleOptions.size(), resRawPtr);
2390     return panda::JSValueRef::Undefined(vm);
2391 }
2392 
ResetOutline(ArkUIRuntimeCallInfo * runtimeCallInfo)2393 ArkUINativeModuleValue CommonBridge::ResetOutline(ArkUIRuntimeCallInfo* runtimeCallInfo)
2394 {
2395     EcmaVM* vm = runtimeCallInfo->GetVM();
2396     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2397     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2398     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2399     GetArkUINodeModifiers()->getCommonModifier()->resetOutline(nativeNode);
2400     return panda::JSValueRef::Undefined(vm);
2401 }
2402 
SetBorderStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)2403 ArkUINativeModuleValue CommonBridge::SetBorderStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
2404 {
2405     EcmaVM *vm = runtimeCallInfo->GetVM();
2406     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2407     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2408     auto typeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2409     auto styleArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2410     auto topArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2411     auto rightArg = runtimeCallInfo->GetCallArgRef(NUM_4);
2412     auto bottomArg = runtimeCallInfo->GetCallArgRef(NUM_5);
2413     auto leftArg = runtimeCallInfo->GetCallArgRef(NUM_6);
2414     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2415     if ((!typeArg->IsBoolean()) || (!typeArg->BooleaValue(vm))) {
2416         int32_t styles[] = { static_cast<int32_t>(BorderStyle::SOLID) };
2417         GetArkUINodeModifiers()->getCommonModifier()->setBorderStyle(nativeNode, styles,
2418             (sizeof(styles) / sizeof(styles[NUM_0])));
2419         return panda::JSValueRef::Undefined(vm);
2420     }
2421     if (styleArg->IsInt()) {
2422         int32_t styles[] = { styleArg->Int32Value(vm) };
2423         GetArkUINodeModifiers()->getCommonModifier()->setBorderStyle(nativeNode, styles,
2424             (sizeof(styles) / sizeof(styles[NUM_0])));
2425         return panda::JSValueRef::Undefined(vm);
2426     }
2427     int32_t styles[] = { -1, -1, -1, -1 };
2428     if (topArg->IsInt()) {
2429         styles[NUM_0] = topArg->Int32Value(vm);
2430     }
2431     if (rightArg->IsInt()) {
2432         styles[NUM_1] = rightArg->Int32Value(vm);
2433     }
2434     if (bottomArg->IsInt()) {
2435         styles[NUM_2] = bottomArg->Int32Value(vm);
2436     }
2437     if (leftArg->IsInt()) {
2438         styles[NUM_3] = leftArg->Int32Value(vm);
2439     }
2440     GetArkUINodeModifiers()->getCommonModifier()->setBorderStyle(nativeNode, styles,
2441         (sizeof(styles) / sizeof(styles[NUM_0])));
2442     return panda::JSValueRef::Undefined(vm);
2443 }
2444 
ResetBorderStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)2445 ArkUINativeModuleValue CommonBridge::ResetBorderStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
2446 {
2447     EcmaVM *vm = runtimeCallInfo->GetVM();
2448     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2449     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2450     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2451     GetArkUINodeModifiers()->getCommonModifier()->resetBorderStyle(nativeNode);
2452     return panda::JSValueRef::Undefined(vm);
2453 }
2454 
SetShadow(ArkUIRuntimeCallInfo * runtimeCallInfo)2455 ArkUINativeModuleValue CommonBridge::SetShadow(ArkUIRuntimeCallInfo *runtimeCallInfo)
2456 {
2457     EcmaVM *vm = runtimeCallInfo->GetVM();
2458     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2459     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2460     auto styleArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2461     auto radiusArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2462     auto typeArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2463     auto colorArg = runtimeCallInfo->GetCallArgRef(NUM_4);
2464     auto offsetXArg = runtimeCallInfo->GetCallArgRef(NUM_5);
2465     auto offsetYArg = runtimeCallInfo->GetCallArgRef(NUM_6);
2466     auto fillArg = runtimeCallInfo->GetCallArgRef(NUM_7);
2467     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2468     if (SetBackShadowForShadowStyle(nativeNode, vm, styleArg)) {
2469         return panda::JSValueRef::Undefined(vm);
2470     }
2471     ArkUIInt32orFloat32 shadows[] = { { 0.0 }, { .i32 = 0  }, { 0.0 }, { 0.0 },
2472         { .i32 = static_cast<ArkUI_Int32>(ShadowType::COLOR) }, { .u32 = 0 }, { .i32 = 0 } };
2473     std::vector<RefPtr<ResourceObject>> vectorResObj;
2474     double radius;
2475     ParseJsShadowRadiusResObj(vm, radiusArg, radius, vectorResObj);
2476     shadows[NUM_0].f32 = radius;
2477 
2478     shadows[NUM_0].f32 = (LessNotEqual(shadows[NUM_0].f32, 0.0)) ? 0.0 : shadows[NUM_0].f32;
2479     CalcDimension offsetX;
2480     if (ParseJsShadowDimension(vm, offsetXArg, offsetX, vectorResObj)) {
2481         shadows[NUM_2].f32 = offsetX.Value();
2482     }
2483     CalcDimension offsetY;
2484     if (ParseJsShadowDimension(vm, offsetYArg, offsetY, vectorResObj)) {
2485         shadows[NUM_3].f32 = offsetY.Value();
2486     }
2487     if (typeArg->IsInt()) {
2488         uint32_t shadowType = typeArg->Uint32Value(vm);
2489         shadows[NUM_4].i32 =
2490             std::clamp(shadowType, static_cast<uint32_t>(ShadowType::COLOR), static_cast<uint32_t>(ShadowType::BLUR));
2491     }
2492     int32_t type = 0;
2493     uint32_t color = 0;
2494     if (ParseJsShadowColorResObj(vm, colorArg, type, color, vectorResObj, nativeNode)) {
2495         shadows[NUM_1].i32 = type;
2496         shadows[NUM_5].u32 = color;
2497     }
2498     shadows[NUM_6].i32 = fillArg->IsBoolean() ? fillArg->BooleaValue(vm) : false;
2499     auto resRawPtr = static_cast<void*>(&vectorResObj);
2500     GetArkUINodeModifiers()->getCommonModifier()->setBackShadow(nativeNode, shadows,
2501         (sizeof(shadows) / sizeof(shadows[NUM_0])), resRawPtr);
2502     return panda::JSValueRef::Undefined(vm);
2503 }
2504 
ResetShadow(ArkUIRuntimeCallInfo * runtimeCallInfo)2505 ArkUINativeModuleValue CommonBridge::ResetShadow(ArkUIRuntimeCallInfo *runtimeCallInfo)
2506 {
2507     EcmaVM *vm = runtimeCallInfo->GetVM();
2508     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2509     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2510     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2511     GetArkUINodeModifiers()->getCommonModifier()->resetBackShadow(nativeNode);
2512     return panda::JSValueRef::Undefined(vm);
2513 }
2514 
SetHitTestBehavior(ArkUIRuntimeCallInfo * runtimeCallInfo)2515 ArkUINativeModuleValue CommonBridge::SetHitTestBehavior(ArkUIRuntimeCallInfo *runtimeCallInfo)
2516 {
2517     EcmaVM *vm = runtimeCallInfo->GetVM();
2518     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2519     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2520     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
2521     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2522     if (secondArg->IsNumber()) {
2523         uint32_t hitTestModeNG = secondArg->Uint32Value(vm);
2524         GetArkUINodeModifiers()->getCommonModifier()->setHitTestBehavior(nativeNode, hitTestModeNG);
2525     } else {
2526         GetArkUINodeModifiers()->getCommonModifier()->resetHitTestBehavior(nativeNode);
2527     }
2528     return panda::JSValueRef::Undefined(vm);
2529 }
2530 
ResetHitTestBehavior(ArkUIRuntimeCallInfo * runtimeCallInfo)2531 ArkUINativeModuleValue CommonBridge::ResetHitTestBehavior(ArkUIRuntimeCallInfo *runtimeCallInfo)
2532 {
2533     EcmaVM *vm = runtimeCallInfo->GetVM();
2534     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2535     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2536     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2537     GetArkUINodeModifiers()->getCommonModifier()->resetHitTestBehavior(nativeNode);
2538     return panda::JSValueRef::Undefined(vm);
2539 }
2540 
SetZIndex(ArkUIRuntimeCallInfo * runtimeCallInfo)2541 ArkUINativeModuleValue CommonBridge::SetZIndex(ArkUIRuntimeCallInfo *runtimeCallInfo)
2542 {
2543     EcmaVM *vm = runtimeCallInfo->GetVM();
2544     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2545     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2546     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
2547     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2548     if (secondArg->IsNumber()) {
2549         int32_t value = secondArg->Int32Value(vm);
2550         GetArkUINodeModifiers()->getCommonModifier()->setZIndex(nativeNode, value);
2551     } else {
2552         GetArkUINodeModifiers()->getCommonModifier()->resetZIndex(nativeNode);
2553     }
2554     return panda::JSValueRef::Undefined(vm);
2555 }
2556 
ResetZIndex(ArkUIRuntimeCallInfo * runtimeCallInfo)2557 ArkUINativeModuleValue CommonBridge::ResetZIndex(ArkUIRuntimeCallInfo *runtimeCallInfo)
2558 {
2559     EcmaVM *vm = runtimeCallInfo->GetVM();
2560     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2561     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2562     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2563     GetArkUINodeModifiers()->getCommonModifier()->resetZIndex(nativeNode);
2564     return panda::JSValueRef::Undefined(vm);
2565 }
2566 
SetOpacity(ArkUIRuntimeCallInfo * runtimeCallInfo)2567 ArkUINativeModuleValue CommonBridge::SetOpacity(ArkUIRuntimeCallInfo *runtimeCallInfo)
2568 {
2569     EcmaVM *vm = runtimeCallInfo->GetVM();
2570     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2571     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2572     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
2573     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2574     double opacity;
2575     RefPtr<ResourceObject> opacityResObj;
2576     if (!ArkTSUtils::ParseJsDouble(vm, secondArg, opacity, opacityResObj)) {
2577         GetArkUINodeModifiers()->getCommonModifier()->resetOpacity(nativeNode);
2578     } else {
2579         auto opacityRawPtr = AceType::RawPtr(opacityResObj);
2580         GetArkUINodeModifiers()->getCommonModifier()->setOpacity(nativeNode, opacity, opacityRawPtr);
2581     }
2582     return panda::JSValueRef::Undefined(vm);
2583 }
2584 
ResetOpacity(ArkUIRuntimeCallInfo * runtimeCallInfo)2585 ArkUINativeModuleValue CommonBridge::ResetOpacity(ArkUIRuntimeCallInfo *runtimeCallInfo)
2586 {
2587     EcmaVM *vm = runtimeCallInfo->GetVM();
2588     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2589     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2590     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2591     GetArkUINodeModifiers()->getCommonModifier()->resetOpacity(nativeNode);
2592     return panda::JSValueRef::Undefined(vm);
2593 }
2594 
SetAlign(ArkUIRuntimeCallInfo * runtimeCallInfo)2595 ArkUINativeModuleValue CommonBridge::SetAlign(ArkUIRuntimeCallInfo *runtimeCallInfo)
2596 {
2597     EcmaVM *vm = runtimeCallInfo->GetVM();
2598     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2599     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2600     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2601     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2602     if (secondArg->IsNumber()) {
2603         GetArkUINodeModifiers()->getCommonModifier()->setAlign(nativeNode, secondArg->ToNumber(vm)->Value());
2604     } else if (secondArg->IsString(vm)) {
2605         GetArkUINodeModifiers()->getCommonModifier()->setLocalizedAlign(nativeNode, secondArg->ToString(vm)
2606             ->ToString(vm).c_str());
2607     } else {
2608         GetArkUINodeModifiers()->getCommonModifier()->resetAlign(nativeNode);
2609     }
2610     return panda::JSValueRef::Undefined(vm);
2611 }
2612 
ResetAlign(ArkUIRuntimeCallInfo * runtimeCallInfo)2613 ArkUINativeModuleValue CommonBridge::ResetAlign(ArkUIRuntimeCallInfo *runtimeCallInfo)
2614 {
2615     EcmaVM *vm = runtimeCallInfo->GetVM();
2616     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2617     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2618     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2619     GetArkUINodeModifiers()->getCommonModifier()->resetAlign(nativeNode);
2620     return panda::JSValueRef::Undefined(vm);
2621 }
2622 
SetLayoutGravity(ArkUIRuntimeCallInfo * runtimeCallInfo)2623 ArkUINativeModuleValue CommonBridge::SetLayoutGravity(ArkUIRuntimeCallInfo *runtimeCallInfo)
2624 {
2625     EcmaVM *vm = runtimeCallInfo->GetVM();
2626     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2627     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2628     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2629     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2630     if (secondArg->IsString(vm)) {
2631         GetArkUINodeModifiers()->getCommonModifier()->setLayoutGravity(
2632             nativeNode, secondArg->ToString(vm)->ToString(vm).c_str());
2633     } else {
2634         GetArkUINodeModifiers()->getCommonModifier()->resetLayoutGravity(nativeNode);
2635     }
2636     return panda::JSValueRef::Undefined(vm);
2637 }
2638 
ResetLayoutGravity(ArkUIRuntimeCallInfo * runtimeCallInfo)2639 ArkUINativeModuleValue CommonBridge::ResetLayoutGravity(ArkUIRuntimeCallInfo *runtimeCallInfo)
2640 {
2641     EcmaVM *vm = runtimeCallInfo->GetVM();
2642     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2643     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2644     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2645     GetArkUINodeModifiers()->getCommonModifier()->resetLayoutGravity(nativeNode);
2646     return panda::JSValueRef::Undefined(vm);
2647 }
2648 
SetBackdropBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)2649 ArkUINativeModuleValue CommonBridge::SetBackdropBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
2650 {
2651     EcmaVM *vm = runtimeCallInfo->GetVM();
2652     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2653     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2654     Local<JSValueRef> blurArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2655     Local<JSValueRef> blurOptionArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2656     Local<JSValueRef> disableSystemAdaptationArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2657     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2658 
2659     double blur = 0.0;
2660     if (!ArkTSUtils::ParseJsDouble(vm, blurArg, blur)) {
2661         GetArkUINodeModifiers()->getCommonModifier()->resetBackdropBlur(nativeNode);
2662         return panda::JSValueRef::Undefined(vm);
2663     }
2664     BlurOption blurOption;
2665     if (blurOptionArg->IsArray(vm)) {
2666         ParseBlurOption(vm, blurOptionArg, blurOption);
2667     }
2668     bool disableSystemAdaptation = false;
2669     if (disableSystemAdaptationArg->IsBoolean()) {
2670         disableSystemAdaptation = disableSystemAdaptationArg->ToBoolean(vm)->Value();
2671     }
2672     GetArkUINodeModifiers()->getCommonModifier()->setBackdropBlur(
2673         nativeNode, blur, blurOption.grayscale.data(), blurOption.grayscale.size(), disableSystemAdaptation);
2674     return panda::JSValueRef::Undefined(vm);
2675 }
2676 
ResetBackdropBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)2677 ArkUINativeModuleValue CommonBridge::ResetBackdropBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
2678 {
2679     EcmaVM *vm = runtimeCallInfo->GetVM();
2680     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2681     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2682     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2683     GetArkUINodeModifiers()->getCommonModifier()->resetBackdropBlur(nativeNode);
2684     return panda::JSValueRef::Undefined(vm);
2685 }
2686 
SetHueRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)2687 ArkUINativeModuleValue CommonBridge::SetHueRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
2688 {
2689     EcmaVM *vm = runtimeCallInfo->GetVM();
2690     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2691     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2692     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2693     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2694     std::optional<float> degree;
2695     if (secondArg->IsString(vm)) {
2696         degree = static_cast<float>(StringUtils::StringToDegree(secondArg->ToString(vm)->ToString(vm)));
2697     } else if (secondArg->IsNumber()) {
2698         degree = static_cast<float>(secondArg->ToNumber(vm)->Value());
2699     } else {
2700         GetArkUINodeModifiers()->getCommonModifier()->resetHueRotate(nativeNode);
2701         return panda::JSValueRef::Undefined(vm);
2702     }
2703 
2704     float deg = 0.0f;
2705     if (degree) {
2706         deg = degree.value();
2707         degree.reset();
2708     }
2709     GetArkUINodeModifiers()->getCommonModifier()->setHueRotate(nativeNode, deg);
2710     return panda::JSValueRef::Undefined(vm);
2711 }
2712 
ResetHueRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)2713 ArkUINativeModuleValue CommonBridge::ResetHueRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
2714 {
2715     EcmaVM *vm = runtimeCallInfo->GetVM();
2716     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2717     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2718     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2719     GetArkUINodeModifiers()->getCommonModifier()->resetHueRotate(nativeNode);
2720     return panda::JSValueRef::Undefined(vm);
2721 }
2722 
SetInvert(ArkUIRuntimeCallInfo * runtimeCallInfo)2723 ArkUINativeModuleValue CommonBridge::SetInvert(ArkUIRuntimeCallInfo *runtimeCallInfo)
2724 {
2725     EcmaVM* vm = runtimeCallInfo->GetVM();
2726     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2727     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2728     Local<JSValueRef> invertValueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2729     Local<JSValueRef> optionLowArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2730     Local<JSValueRef> optionHighArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2731     Local<JSValueRef> optionThresholdArg = runtimeCallInfo->GetCallArgRef(NUM_4);
2732     Local<JSValueRef> optionThresholdRangeArg = runtimeCallInfo->GetCallArgRef(NUM_5);
2733     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2734 
2735     if (!invertValueArg->IsUndefined()) {
2736         double invertValue = 0.0;
2737         if (ArkTSUtils::ParseJsDouble(vm, invertValueArg, invertValue)) {
2738             ArkUI_Float32 invert[] = { static_cast<ArkUI_Float32>(invertValue) };
2739             GetArkUINodeModifiers()->getCommonModifier()->setInvert(nativeNode, invert, NUM_1);
2740         } else {
2741             GetArkUINodeModifiers()->getCommonModifier()->resetInvert(nativeNode);
2742         }
2743     } else {
2744         ArkUI_Float32 invert[] = { 0.0, 0.0, 0.0, 0.0 };
2745         double low = 0.0;
2746         double high = 0.0;
2747         double threshold = 0.0;
2748         double thresholdRange = 0.0;
2749         if (ArkTSUtils::ParseJsDouble(vm, optionLowArg, low)) {
2750             invert[NUM_0] = std::clamp(low, 0.0, 1.0);
2751         }
2752         if (ArkTSUtils::ParseJsDouble(vm, optionHighArg, high)) {
2753             invert[NUM_1] = std::clamp(high, 0.0, 1.0);
2754         }
2755         if (ArkTSUtils::ParseJsDouble(vm, optionThresholdArg, threshold)) {
2756             invert[NUM_2] = std::clamp(threshold, 0.0, 1.0);
2757         }
2758         if (ArkTSUtils::ParseJsDouble(vm, optionThresholdRangeArg, thresholdRange)) {
2759             invert[NUM_3] = std::clamp(thresholdRange, 0.0, 1.0);
2760         }
2761         GetArkUINodeModifiers()->getCommonModifier()->setInvert(nativeNode, invert, NUM_4);
2762     }
2763 
2764     return panda::JSValueRef::Undefined(vm);
2765 }
2766 
ResetInvert(ArkUIRuntimeCallInfo * runtimeCallInfo)2767 ArkUINativeModuleValue CommonBridge::ResetInvert(ArkUIRuntimeCallInfo *runtimeCallInfo)
2768 {
2769     EcmaVM *vm = runtimeCallInfo->GetVM();
2770     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2771     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2772     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2773     GetArkUINodeModifiers()->getCommonModifier()->resetInvert(nativeNode);
2774     return panda::JSValueRef::Undefined(vm);
2775 }
2776 
SetSepia(ArkUIRuntimeCallInfo * runtimeCallInfo)2777 ArkUINativeModuleValue CommonBridge::SetSepia(ArkUIRuntimeCallInfo *runtimeCallInfo)
2778 {
2779     EcmaVM *vm = runtimeCallInfo->GetVM();
2780     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2781     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2782     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2783     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2784     if (secondArg->IsNumber()) {
2785         GetArkUINodeModifiers()->getCommonModifier()->setSepia(nativeNode, secondArg->ToNumber(vm)->Value());
2786     } else {
2787         GetArkUINodeModifiers()->getCommonModifier()->resetSepia(nativeNode);
2788     }
2789     return panda::JSValueRef::Undefined(vm);
2790 }
2791 
ResetSepia(ArkUIRuntimeCallInfo * runtimeCallInfo)2792 ArkUINativeModuleValue CommonBridge::ResetSepia(ArkUIRuntimeCallInfo *runtimeCallInfo)
2793 {
2794     EcmaVM *vm = runtimeCallInfo->GetVM();
2795     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2796     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2797     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2798     GetArkUINodeModifiers()->getCommonModifier()->resetSepia(nativeNode);
2799     return panda::JSValueRef::Undefined(vm);
2800 }
2801 
SetSaturate(ArkUIRuntimeCallInfo * runtimeCallInfo)2802 ArkUINativeModuleValue CommonBridge::SetSaturate(ArkUIRuntimeCallInfo *runtimeCallInfo)
2803 {
2804     EcmaVM *vm = runtimeCallInfo->GetVM();
2805     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2806     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2807     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2808     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2809     if (secondArg->IsNumber()) {
2810         GetArkUINodeModifiers()->getCommonModifier()->setSaturate(nativeNode, secondArg->ToNumber(vm)->Value());
2811     } else {
2812         GetArkUINodeModifiers()->getCommonModifier()->resetSaturate(nativeNode);
2813     }
2814     return panda::JSValueRef::Undefined(vm);
2815 }
2816 
ResetSaturate(ArkUIRuntimeCallInfo * runtimeCallInfo)2817 ArkUINativeModuleValue CommonBridge::ResetSaturate(ArkUIRuntimeCallInfo *runtimeCallInfo)
2818 {
2819     EcmaVM *vm = runtimeCallInfo->GetVM();
2820     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2821     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2822     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2823     GetArkUINodeModifiers()->getCommonModifier()->resetSaturate(nativeNode);
2824     return panda::JSValueRef::Undefined(vm);
2825 }
2826 
SetColorBlend(ArkUIRuntimeCallInfo * runtimeCallInfo)2827 ArkUINativeModuleValue CommonBridge::SetColorBlend(ArkUIRuntimeCallInfo *runtimeCallInfo)
2828 {
2829     EcmaVM *vm = runtimeCallInfo->GetVM();
2830     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2831     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2832     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2833     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2834     Color color;
2835     RefPtr<ResourceObject> colorBlendObj;
2836     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
2837     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, colorBlendObj, nodeInfo)) {
2838         GetArkUINodeModifiers()->getCommonModifier()->resetColorBlend(nativeNode);
2839         } else {
2840             auto cbColorRawPtr = AceType::RawPtr(colorBlendObj);
2841             GetArkUINodeModifiers()->getCommonModifier()->setColorBlend(nativeNode, color.GetValue(), cbColorRawPtr);
2842         }
2843     return panda::JSValueRef::Undefined(vm);
2844 }
2845 
ResetColorBlend(ArkUIRuntimeCallInfo * runtimeCallInfo)2846 ArkUINativeModuleValue CommonBridge::ResetColorBlend(ArkUIRuntimeCallInfo *runtimeCallInfo)
2847 {
2848     EcmaVM *vm = runtimeCallInfo->GetVM();
2849     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2850     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2851     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2852     GetArkUINodeModifiers()->getCommonModifier()->resetColorBlend(nativeNode);
2853     return panda::JSValueRef::Undefined(vm);
2854 }
2855 
SetGrayscale(ArkUIRuntimeCallInfo * runtimeCallInfo)2856 ArkUINativeModuleValue CommonBridge::SetGrayscale(ArkUIRuntimeCallInfo *runtimeCallInfo)
2857 {
2858     EcmaVM *vm = runtimeCallInfo->GetVM();
2859     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2860     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2861     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2862     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2863     if (secondArg->IsNumber()) {
2864         GetArkUINodeModifiers()->getCommonModifier()->setGrayscale(nativeNode, secondArg->ToNumber(vm)->Value());
2865     } else {
2866         GetArkUINodeModifiers()->getCommonModifier()->resetGrayscale(nativeNode);
2867     }
2868     return panda::JSValueRef::Undefined(vm);
2869 }
2870 
ResetGrayscale(ArkUIRuntimeCallInfo * runtimeCallInfo)2871 ArkUINativeModuleValue CommonBridge::ResetGrayscale(ArkUIRuntimeCallInfo *runtimeCallInfo)
2872 {
2873     EcmaVM *vm = runtimeCallInfo->GetVM();
2874     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2875     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2876     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2877     GetArkUINodeModifiers()->getCommonModifier()->resetGrayscale(nativeNode);
2878     return panda::JSValueRef::Undefined(vm);
2879 }
2880 
SetContrast(ArkUIRuntimeCallInfo * runtimeCallInfo)2881 ArkUINativeModuleValue CommonBridge::SetContrast(ArkUIRuntimeCallInfo *runtimeCallInfo)
2882 {
2883     EcmaVM *vm = runtimeCallInfo->GetVM();
2884     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2885     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2886     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2887     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2888     if (secondArg->IsNumber()) {
2889         GetArkUINodeModifiers()->getCommonModifier()->setContrast(nativeNode, secondArg->ToNumber(vm)->Value());
2890     } else {
2891         GetArkUINodeModifiers()->getCommonModifier()->resetContrast(nativeNode);
2892     }
2893     return panda::JSValueRef::Undefined(vm);
2894 }
2895 
ResetContrast(ArkUIRuntimeCallInfo * runtimeCallInfo)2896 ArkUINativeModuleValue CommonBridge::ResetContrast(ArkUIRuntimeCallInfo *runtimeCallInfo)
2897 {
2898     EcmaVM *vm = runtimeCallInfo->GetVM();
2899     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2900     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2901     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2902     GetArkUINodeModifiers()->getCommonModifier()->resetContrast(nativeNode);
2903     return panda::JSValueRef::Undefined(vm);
2904 }
2905 
SetBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)2906 ArkUINativeModuleValue CommonBridge::SetBrightness(ArkUIRuntimeCallInfo *runtimeCallInfo)
2907 {
2908     EcmaVM *vm = runtimeCallInfo->GetVM();
2909     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2910     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2911     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2912     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2913     if (secondArg->IsNumber()) {
2914         GetArkUINodeModifiers()->getCommonModifier()->setBrightness(nativeNode, secondArg->ToNumber(vm)->Value());
2915     } else {
2916         GetArkUINodeModifiers()->getCommonModifier()->resetBrightness(nativeNode);
2917     }
2918     return panda::JSValueRef::Undefined(vm);
2919 }
2920 
ResetBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)2921 ArkUINativeModuleValue CommonBridge::ResetBrightness(ArkUIRuntimeCallInfo *runtimeCallInfo)
2922 {
2923     EcmaVM *vm = runtimeCallInfo->GetVM();
2924     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2925     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2926     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2927     GetArkUINodeModifiers()->getCommonModifier()->resetBrightness(nativeNode);
2928     return panda::JSValueRef::Undefined(vm);
2929 }
2930 
SetBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)2931 ArkUINativeModuleValue CommonBridge::SetBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
2932 {
2933     EcmaVM *vm = runtimeCallInfo->GetVM();
2934     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2935     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2936     Local<JSValueRef> blurArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2937     Local<JSValueRef> blurOptionArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2938     Local<JSValueRef> disableSystemAdaptationArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2939     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2940     double blur = 0.0;
2941     if (!ArkTSUtils::ParseJsDouble(vm, blurArg, blur)) {
2942         GetArkUINodeModifiers()->getCommonModifier()->resetBlur(nativeNode);
2943         return panda::JSValueRef::Undefined(vm);
2944     }
2945     BlurOption blurOption;
2946     if (blurOptionArg->IsArray(vm)) {
2947         ParseBlurOption(vm, blurOptionArg, blurOption);
2948     }
2949     bool disableSystemAdaptation = false;
2950     if (disableSystemAdaptationArg->IsBoolean()) {
2951         disableSystemAdaptation = disableSystemAdaptationArg->ToBoolean(vm)->Value();
2952     }
2953     GetArkUINodeModifiers()->getCommonModifier()->setBlur(
2954         nativeNode, blur, blurOption.grayscale.data(), blurOption.grayscale.size(), disableSystemAdaptation);
2955 
2956     return panda::JSValueRef::Undefined(vm);
2957 }
2958 
ResetBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)2959 ArkUINativeModuleValue CommonBridge::ResetBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
2960 {
2961     EcmaVM *vm = runtimeCallInfo->GetVM();
2962     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2963     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2964     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2965     GetArkUINodeModifiers()->getCommonModifier()->resetBlur(nativeNode);
2966     return panda::JSValueRef::Undefined(vm);
2967 }
2968 
SetLinearGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)2969 ArkUINativeModuleValue CommonBridge::SetLinearGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
2970 {
2971     EcmaVM *vm = runtimeCallInfo->GetVM();
2972     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2973     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2974     auto angleArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2975     auto directionArg = runtimeCallInfo->GetCallArgRef(NUM_2);
2976     auto colorsArg = runtimeCallInfo->GetCallArgRef(NUM_3);
2977     auto repeatingArg = runtimeCallInfo->GetCallArgRef(NUM_4);
2978     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2979 
2980     std::vector<ArkUIInt32orFloat32> values;
2981     ArkTSUtils::ParseGradientAngle(vm, angleArg, values);
2982     int32_t direction = static_cast<int32_t>(GradientDirection::NONE);
2983     ArkTSUtils::ParseJsInt32(vm, directionArg, direction);
2984     values.push_back({.i32 = static_cast<ArkUI_Int32>(direction)});
2985 
2986     std::vector<ArkUIInt32orFloat32> colors;
2987     std::vector<RefPtr<ResourceObject>> vectorResObj;
2988     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
2989     ArkTSUtils::ParseGradientColorStops(vm, colorsArg, colors, vectorResObj, nodeInfo);
2990     auto repeating = repeatingArg->IsBoolean() ? repeatingArg->BooleaValue(vm) : false;
2991     values.push_back({.i32 = static_cast<ArkUI_Int32>(repeating)});
2992     auto colorRawPtr = static_cast<void*>(&vectorResObj);
2993     GetArkUINodeModifiers()->getCommonModifier()->setLinearGradient(nativeNode, values.data(), values.size(),
2994         colors.data(), colors.size(), colorRawPtr);
2995     return panda::JSValueRef::Undefined(vm);
2996 }
2997 
ResetLinearGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)2998 ArkUINativeModuleValue CommonBridge::ResetLinearGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
2999 {
3000     EcmaVM *vm = runtimeCallInfo->GetVM();
3001     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3002     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3003     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3004     GetArkUINodeModifiers()->getCommonModifier()->resetLinearGradient(nativeNode);
3005     return panda::JSValueRef::Undefined(vm);
3006 }
3007 
SetSweepGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)3008 ArkUINativeModuleValue CommonBridge::SetSweepGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
3009 {
3010     EcmaVM *vm = runtimeCallInfo->GetVM();
3011     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3012     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3013     auto centerArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3014     auto startArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3015     auto endArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3016     auto rotationArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3017     auto colorsArg = runtimeCallInfo->GetCallArgRef(NUM_5);
3018     auto metricsColorsArg = runtimeCallInfo->GetCallArgRef(NUM_6);
3019     auto repeatingArg = runtimeCallInfo->GetCallArgRef(NUM_7);
3020     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3021     std::vector<ArkUIInt32orFloat32> values;
3022     std::vector<RefPtr<ResourceObject>> vectorResObj;
3023     ArkTSUtils::ParseGradientCenter(vm, centerArg, values, vectorResObj);
3024     ArkTSUtils::ParseGradientAngle(vm, startArg, values);
3025     ArkTSUtils::ParseGradientAngle(vm, endArg, values);
3026     ArkTSUtils::ParseGradientAngle(vm, rotationArg, values);
3027     std::vector<ArkUIInt32orFloat32> colors;
3028     std::optional<ColorSpace> colorSpace;
3029     if (metricsColorsArg->IsArray(vm)) {
3030         ParseGradientColorStopsWithColorSpace(vm, metricsColorsArg, colors, colorSpace);
3031     } else {
3032         auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
3033         ArkTSUtils::ParseGradientColorStops(vm, colorsArg, colors, vectorResObj, nodeInfo);
3034     }
3035     if (!colorSpace.has_value()) {
3036         colorSpace = ColorSpace::SRGB;
3037     }
3038     auto repeating = repeatingArg->IsBoolean() ? repeatingArg->BooleaValue(vm) : false;
3039     values.push_back({.i32 = static_cast<ArkUI_Int32>(repeating)});
3040     auto resRawPtr = static_cast<void*>(&vectorResObj);
3041     GetArkUINodeModifiers()->getCommonModifier()->setSweepGradient(nativeNode, values.data(), values.size(),
3042         colors.data(), colors.size(), colorSpace.value(), resRawPtr);
3043     return panda::JSValueRef::Undefined(vm);
3044 }
3045 
ResetSweepGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)3046 ArkUINativeModuleValue CommonBridge::ResetSweepGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
3047 {
3048     EcmaVM *vm = runtimeCallInfo->GetVM();
3049     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3050     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3051     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3052     GetArkUINodeModifiers()->getCommonModifier()->resetSweepGradient(nativeNode);
3053     return panda::JSValueRef::Undefined(vm);
3054 }
3055 
SetRadialGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)3056 ArkUINativeModuleValue CommonBridge::SetRadialGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
3057 {
3058     EcmaVM *vm = runtimeCallInfo->GetVM();
3059     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3060     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3061     auto centerArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3062     auto radiusArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3063     auto colorsArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3064     auto repeatingArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3065     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3066     std::vector<ArkUIInt32orFloat32> values;
3067     std::vector<RefPtr<ResourceObject>> vectorResObj;
3068     ArkTSUtils::ParseGradientCenter(vm, centerArg, values, vectorResObj);
3069     CalcDimension radius;
3070     RefPtr<ResourceObject> radiusResObj;
3071     auto hasRadius = ArkTSUtils::ParseJsDimensionVp(vm, radiusArg, radius, radiusResObj, false);
3072     if (radiusResObj) {
3073         vectorResObj.push_back(radiusResObj);
3074     } else {
3075         vectorResObj.push_back(nullptr);
3076     }
3077     values.push_back({.i32 = static_cast<ArkUI_Int32>(hasRadius)});
3078     values.push_back({.f32 = static_cast<ArkUI_Float32>(radius.Value())});
3079     values.push_back({.i32 = static_cast<ArkUI_Int32>(radius.Unit())});
3080     std::vector<ArkUIInt32orFloat32> colors;
3081     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
3082     ArkTSUtils::ParseGradientColorStops(vm, colorsArg, colors, vectorResObj, nodeInfo);
3083     auto repeating = repeatingArg->IsBoolean() ? repeatingArg->BooleaValue(vm) : false;
3084     values.push_back({.i32 = static_cast<ArkUI_Int32>(repeating)});
3085     auto resRawPtr = static_cast<void*>(&vectorResObj);
3086     GetArkUINodeModifiers()->getCommonModifier()->setRadialGradient(nativeNode, values.data(), values.size(),
3087         colors.data(), colors.size(), resRawPtr);
3088     return panda::JSValueRef::Undefined(vm);
3089 }
3090 
ResetRadialGradient(ArkUIRuntimeCallInfo * runtimeCallInfo)3091 ArkUINativeModuleValue CommonBridge::ResetRadialGradient(ArkUIRuntimeCallInfo *runtimeCallInfo)
3092 {
3093     EcmaVM *vm = runtimeCallInfo->GetVM();
3094     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3095     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3096     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3097     GetArkUINodeModifiers()->getCommonModifier()->resetRadialGradient(nativeNode);
3098     return panda::JSValueRef::Undefined(vm);
3099 }
3100 
SetOverlay(ArkUIRuntimeCallInfo * runtimeCallInfo)3101 ArkUINativeModuleValue CommonBridge::SetOverlay(ArkUIRuntimeCallInfo* runtimeCallInfo)
3102 {
3103     EcmaVM* vm = runtimeCallInfo->GetVM();
3104     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3105     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3106     auto valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3107     auto alignArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3108     auto offsetXArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3109     auto offsetYArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3110     auto hasOptionsArg = runtimeCallInfo->GetCallArgRef(NUM_5);
3111     auto hasOffsetArg = runtimeCallInfo->GetCallArgRef(NUM_6);
3112     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3113 
3114     std::optional<std::string> text;
3115     if (valueArg->IsString(vm)) {
3116         text = valueArg->ToString(vm)->ToString(vm);
3117     }
3118     int32_t align = ALIGNMENT_TOP_LEFT;
3119     auto hasAlign = ArkTSUtils::ParseJsInteger(vm, alignArg, align);
3120     std::optional<CalcDimension> offsetX = CalcDimension(0);
3121     std::optional<CalcDimension> offsetY = CalcDimension(0);
3122     CalcDimension dimensionX;
3123     if (ArkTSUtils::ParseJsDimensionVp(vm, offsetXArg, dimensionX, false)) {
3124         offsetX = dimensionX;
3125     }
3126     CalcDimension dimensionY;
3127     if (ArkTSUtils::ParseJsDimensionVp(vm, offsetYArg, dimensionY, false)) {
3128         offsetY = dimensionY;
3129     }
3130     auto hasOptions = (hasOptionsArg->IsBoolean()) ? hasOptionsArg->ToBoolean(vm)->Value(): false;
3131     auto hasOffset = (hasOffsetArg->IsBoolean()) ? hasOffsetArg->ToBoolean(vm)->Value(): false;
3132     std::vector<ArkUI_Float32> options;
3133     options.push_back(static_cast<ArkUI_Float32>(hasAlign));
3134     options.push_back(static_cast<ArkUI_Float32>(align));
3135     options.push_back(static_cast<ArkUI_Float32>(offsetX.has_value()));
3136     options.push_back(static_cast<ArkUI_Float32>(offsetX.value().Value()));
3137     options.push_back(static_cast<ArkUI_Float32>(offsetX.value().Unit()));
3138     options.push_back(static_cast<ArkUI_Float32>(offsetY.has_value()));
3139     options.push_back(static_cast<ArkUI_Float32>(offsetY.value().Value()));
3140     options.push_back(static_cast<ArkUI_Float32>(offsetY.value().Unit()));
3141     options.push_back(static_cast<ArkUI_Float32>(hasOptions));
3142     options.push_back(static_cast<ArkUI_Float32>(hasOffset));
3143     auto textPtr = (text.has_value()) ? text.value().c_str() : nullptr;
3144     GetArkUINodeModifiers()->getCommonModifier()->setOverlay(nativeNode, textPtr, options.data(), options.size());
3145     return panda::JSValueRef::Undefined(vm);
3146 }
3147 
ResetOverlay(ArkUIRuntimeCallInfo * runtimeCallInfo)3148 ArkUINativeModuleValue CommonBridge::ResetOverlay(ArkUIRuntimeCallInfo* runtimeCallInfo)
3149 {
3150     EcmaVM* vm = runtimeCallInfo->GetVM();
3151     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3152     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3153     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3154     GetArkUINodeModifiers()->getCommonModifier()->resetOverlay(nativeNode);
3155     return panda::JSValueRef::Undefined(vm);
3156 }
3157 
SetBorderImage(ArkUIRuntimeCallInfo * runtimeCallInfo)3158 ArkUINativeModuleValue CommonBridge::SetBorderImage(ArkUIRuntimeCallInfo* runtimeCallInfo)
3159 {
3160     EcmaVM* vm = runtimeCallInfo->GetVM();
3161     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3162     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3163     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3164     auto argsNumber = runtimeCallInfo->GetArgsNumber();
3165     if (IsArgsUndefined(runtimeCallInfo, NUM_1, argsNumber - NUM_1)) {
3166         return panda::JSValueRef::Undefined(vm);
3167     }
3168     std::string src;
3169     std::vector<ArkUIStringAndFloat> options;
3170     uint8_t bitsets = 0;
3171     uint32_t offset = NUM_1;
3172     std::vector<std::optional<CalcDimension>> sliceDimensions;
3173     ParseBorderImageSlice(runtimeCallInfo, offset, sliceDimensions, bitsets); // use 4 args
3174     PushDimensionsToVector(options, sliceDimensions);
3175     ParseBorderImageRepeat(runtimeCallInfo, offset, options, bitsets); // use 1 args
3176     if (!ParseBorderImageSource(runtimeCallInfo, offset, nativeNode, src, bitsets)) { // use 5 args
3177         return panda::JSValueRef::Undefined(vm);
3178     }
3179     std::vector<std::optional<CalcDimension>> widthDimensions;
3180     ParseBorderImageWidth(runtimeCallInfo, offset, widthDimensions, bitsets); // use 4 args
3181     PushDimensionsToVector(options, widthDimensions);
3182     std::vector<std::optional<CalcDimension>> outsetDimensions;
3183     ParseBorderImageOutset(runtimeCallInfo, offset, outsetDimensions, bitsets); // use 4 args
3184     PushDimensionsToVector(options, outsetDimensions);
3185     ParseBorderImageFill(runtimeCallInfo, offset, options); // use 1 args
3186     options.push_back(ArkUIStringAndFloat { static_cast<ArkUI_Float32>(bitsets), nullptr });
3187     GetArkUINodeModifiers()->getCommonModifier()->setBorderImage(nativeNode,
3188         src.c_str(), options.data(), options.size());
3189     ResetCalcDimensions(sliceDimensions);
3190     ResetCalcDimensions(widthDimensions);
3191     ResetCalcDimensions(outsetDimensions);
3192     return panda::JSValueRef::Undefined(vm);
3193 }
3194 
ResetBorderImage(ArkUIRuntimeCallInfo * runtimeCallInfo)3195 ArkUINativeModuleValue CommonBridge::ResetBorderImage(ArkUIRuntimeCallInfo* runtimeCallInfo)
3196 {
3197     EcmaVM* vm = runtimeCallInfo->GetVM();
3198     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3199     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3200     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3201     GetArkUINodeModifiers()->getCommonModifier()->resetBorderImage(nativeNode);
3202     return panda::JSValueRef::Undefined(vm);
3203 }
3204 
SetForegroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)3205 ArkUINativeModuleValue CommonBridge::SetForegroundBlurStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
3206 {
3207     EcmaVM *vm = runtimeCallInfo->GetVM();
3208     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3209     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3210     auto blurStyleArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3211     auto colorModeArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3212     auto adaptiveColorArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3213     auto scaleArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3214     auto blurOptionsArg = runtimeCallInfo->GetCallArgRef(NUM_5);
3215     auto disableSystemAdaptationArg = runtimeCallInfo->GetCallArgRef(NUM_6);
3216     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3217     int32_t blurStyle = -1;
3218     if (blurStyleArg->IsNumber()) {
3219         blurStyle = blurStyleArg->Int32Value(vm);
3220     }
3221     bool isHasOptions = !(colorModeArg->IsUndefined() && adaptiveColorArg->IsUndefined() && scaleArg->IsUndefined() &&
3222                           blurOptionsArg->IsUndefined());
3223     int32_t colorMode = static_cast<int32_t>(ThemeColorMode::SYSTEM);
3224     int32_t adaptiveColor = static_cast<int32_t>(AdaptiveColor::DEFAULT);
3225     double scale = 1.0;
3226     BlurOption blurOption;
3227     if (isHasOptions) {
3228         ArkTSUtils::ParseJsInt32(vm, colorModeArg, colorMode);
3229         ArkTSUtils::ParseJsInt32(vm, adaptiveColorArg, adaptiveColor);
3230         if (scaleArg->IsNumber()) {
3231             scale = scaleArg->ToNumber(vm)->Value();
3232         }
3233         if (blurOptionsArg->IsArray(vm)) {
3234             ParseBlurOption(vm, blurOptionsArg, blurOption);
3235         }
3236     }
3237     int32_t intArray[NUM_3];
3238     intArray[NUM_0] = blurStyle;
3239     intArray[NUM_1] = colorMode;
3240     intArray[NUM_2] = adaptiveColor;
3241     bool disableSystemAdaptation = false;
3242     if (disableSystemAdaptationArg->IsBoolean()) {
3243         disableSystemAdaptation = disableSystemAdaptationArg->ToBoolean(vm)->Value();
3244     }
3245     GetArkUINodeModifiers()->getCommonModifier()->setForegroundBlurStyle(nativeNode, &intArray, scale,
3246         blurOption.grayscale.data(), blurOption.grayscale.size(), disableSystemAdaptation);
3247     return panda::JSValueRef::Undefined(vm);
3248 }
3249 
ResetForegroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)3250 ArkUINativeModuleValue CommonBridge::ResetForegroundBlurStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
3251 {
3252     EcmaVM *vm = runtimeCallInfo->GetVM();
3253     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3254     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3255     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3256     GetArkUINodeModifiers()->getCommonModifier()->resetForegroundBlurStyle(nativeNode);
3257     return panda::JSValueRef::Undefined(vm);
3258 }
3259 
SetLinearGradientBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)3260 ArkUINativeModuleValue CommonBridge::SetLinearGradientBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
3261 {
3262     EcmaVM *vm = runtimeCallInfo->GetVM();
3263     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3264     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3265     auto blurRadiusArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3266     auto fractionStopsArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3267     auto directionArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3268     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3269     double blurRadius = 0.0;
3270     ParseJsDouble(vm, blurRadiusArg, blurRadius);
3271     auto direction = static_cast<int32_t>(GradientDirection::BOTTOM);
3272     if (directionArg->IsInt()) {
3273         direction = directionArg->Int32Value(vm);
3274     }
3275     std::vector<ArkUI_Float32> fractionStops;
3276     if (fractionStopsArg->IsArray(vm)) {
3277         auto array = panda::Local<panda::ArrayRef>(fractionStopsArg);
3278         auto length = array->Length(vm);
3279         for (uint32_t index = 0; index < length; index++) {
3280             auto fractionStop = panda::ArrayRef::GetValueAt(vm, array, index);
3281             ArkUI_Float32 first = 0.0;
3282             ArkUI_Float32 second = 0.0;
3283             if (!ParseJsDoublePair(vm, fractionStop, first, second)) {
3284                 continue;
3285             }
3286             fractionStops.push_back(first);
3287             fractionStops.push_back(second);
3288         }
3289     }
3290     GetArkUINodeModifiers()->getCommonModifier()->setLinearGradientBlur(nativeNode, blurRadius, fractionStops.data(),
3291         fractionStops.size(), direction);
3292     return panda::JSValueRef::Undefined(vm);
3293 }
3294 
ResetLinearGradientBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)3295 ArkUINativeModuleValue CommonBridge::ResetLinearGradientBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
3296 {
3297     EcmaVM *vm = runtimeCallInfo->GetVM();
3298     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3299     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3300     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3301     GetArkUINodeModifiers()->getCommonModifier()->resetLinearGradientBlur(nativeNode);
3302     return panda::JSValueRef::Undefined(vm);
3303 }
3304 
SetBackgroundBlurStyleParam(ArkUIRuntimeCallInfo * runtimeCallInfo,bool & isValidColor,Color & inactiveColor,int32_t & policy,int32_t & blurType,ArkUINodeHandle nativeNode,RefPtr<ResourceObject> & resourceObject)3305 void SetBackgroundBlurStyleParam(ArkUIRuntimeCallInfo* runtimeCallInfo, bool& isValidColor, Color& inactiveColor,
3306     int32_t& policy, int32_t& blurType, ArkUINodeHandle nativeNode, RefPtr<ResourceObject>& resourceObject)
3307 {
3308     EcmaVM *vm = runtimeCallInfo->GetVM();
3309     auto policyArg = runtimeCallInfo->GetCallArgRef(NUM_6);
3310     auto inactiveColorArg = runtimeCallInfo->GetCallArgRef(NUM_7);
3311     auto typeArg = runtimeCallInfo->GetCallArgRef(NUM_8);
3312 
3313     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
3314     if (ArkTSUtils::ParseJsColor(vm, inactiveColorArg, inactiveColor, resourceObject, nodeInfo)) {
3315         isValidColor = true;
3316     }
3317     ArkTSUtils::ParseJsInt32(vm, policyArg, policy);
3318     if (policy < static_cast<int32_t>(BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) ||
3319         policy > static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_INACTIVE)) {
3320         policy = static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_ACTIVE);
3321     }
3322     ArkTSUtils::ParseJsInt32(vm, typeArg, blurType);
3323     if (blurType < static_cast<int32_t>(BlurType::WITHIN_WINDOW) ||
3324         blurType > static_cast<int32_t>(BlurType::BEHIND_WINDOW)) {
3325         blurType = static_cast<int32_t>(BlurType::WITHIN_WINDOW);
3326     }
3327 }
3328 
ParseBackgroundBlurStyleParams(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & colorMode,int32_t & adaptiveColor,double & scale,BlurOption & blurOption)3329 void ParseBackgroundBlurStyleParams(ArkUIRuntimeCallInfo *runtimeCallInfo, int32_t& colorMode, int32_t& adaptiveColor,
3330     double& scale, BlurOption& blurOption)
3331 {
3332     EcmaVM *vm = runtimeCallInfo->GetVM();
3333     auto colorModeArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3334     auto adaptiveColorArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3335     auto scaleArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3336     auto blurOptionsArg = runtimeCallInfo->GetCallArgRef(NUM_5);
3337     bool isHasOptions = !(colorModeArg->IsUndefined() && adaptiveColorArg->IsUndefined() && scaleArg->IsUndefined() &&
3338                           blurOptionsArg->IsUndefined());
3339     if (isHasOptions) {
3340         colorMode = static_cast<int32_t>(ThemeColorMode::SYSTEM);
3341         ArkTSUtils::ParseJsInt32(vm, colorModeArg, colorMode);
3342         adaptiveColor = static_cast<int32_t>(AdaptiveColor::DEFAULT);
3343         ArkTSUtils::ParseJsInt32(vm, adaptiveColorArg, adaptiveColor);
3344         scale = 1.0;
3345         if (scaleArg->IsNumber()) {
3346             scale = scaleArg->ToNumber(vm)->Value();
3347         }
3348         if (blurOptionsArg->IsArray(vm)) {
3349             ParseBlurOption(vm, blurOptionsArg, blurOption);
3350         }
3351     }
3352 }
3353 
SetBackgroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)3354 ArkUINativeModuleValue CommonBridge::SetBackgroundBlurStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
3355 {
3356     EcmaVM *vm = runtimeCallInfo->GetVM();
3357     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3358     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3359     auto blurStyleArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3360     auto disableSystemAdaptationArg = runtimeCallInfo->GetCallArgRef(NUM_9);
3361     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3362     int32_t blurStyle = -1;
3363     if (blurStyleArg->IsNumber()) {
3364         blurStyle = blurStyleArg->Int32Value(vm);
3365     }
3366     int32_t colorMode = -1;
3367     int32_t adaptiveColor = -1;
3368     double scale = -1.0;
3369     BlurOption blurOption;
3370     ParseBackgroundBlurStyleParams(runtimeCallInfo, colorMode, adaptiveColor, scale, blurOption);
3371     bool isValidColor = false;
3372     Color inactiveColor = Color::TRANSPARENT;
3373     auto policy = static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_ACTIVE);
3374     auto blurType = static_cast<int32_t>(BlurType::WITHIN_WINDOW);
3375     RefPtr<ResourceObject> inactiveColorResObj;
3376     SetBackgroundBlurStyleParam(
3377         runtimeCallInfo, isValidColor, inactiveColor, policy, blurType, nativeNode, inactiveColorResObj);
3378     int32_t intArray[NUM_5];
3379     intArray[NUM_0] = blurStyle;
3380     intArray[NUM_1] = colorMode;
3381     intArray[NUM_2] = adaptiveColor;
3382     intArray[NUM_3] = policy;
3383     intArray[NUM_4] = blurType;
3384     bool disableSystemAdaptation = false;
3385     if (disableSystemAdaptationArg->IsBoolean()) {
3386         disableSystemAdaptation = disableSystemAdaptationArg->ToBoolean(vm)->Value();
3387     }
3388     auto inactiveColorRawPtr = AceType::RawPtr(inactiveColorResObj);
3389     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundBlurStyle(
3390         nativeNode, &intArray, scale, blurOption.grayscale.data(), blurOption.grayscale.size(),
3391         isValidColor, inactiveColor.GetValue(), disableSystemAdaptation, inactiveColorRawPtr);
3392     return panda::JSValueRef::Undefined(vm);
3393 }
3394 
ResetBackgroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)3395 ArkUINativeModuleValue CommonBridge::ResetBackgroundBlurStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
3396 {
3397     EcmaVM *vm = runtimeCallInfo->GetVM();
3398     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3399     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3400     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3401     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundBlurStyle(nativeNode);
3402     return panda::JSValueRef::Undefined(vm);
3403 }
3404 
SetBorder(ArkUIRuntimeCallInfo * runtimeCallInfo)3405 ArkUINativeModuleValue CommonBridge::SetBorder(ArkUIRuntimeCallInfo* runtimeCallInfo)
3406 {
3407     EcmaVM *vm = runtimeCallInfo->GetVM();
3408     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3409     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3410     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3411 
3412     std::vector<ArkUI_Float32> options;
3413     std::vector<RefPtr<ResourceObject>> resObj;
3414     ParseOuterBorderWidth(runtimeCallInfo, vm, options, resObj);         // Border Width args start index from 1
3415     ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, resObj); // Border Radius args start index
3416 
3417     std::vector<uint32_t> colorAndStyleOptions;
3418     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
3419     ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, resObj, nodeInfo);  // Border Color args start index
3420     ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13); // Border Style args start index
3421 
3422     auto rawPtr = static_cast<void*>(&resObj);
3423     GetArkUINodeModifiers()->getCommonModifier()->setBorder(nativeNode, options.data(), options.size(),
3424         colorAndStyleOptions.data(), colorAndStyleOptions.size(), false, false, false, rawPtr);
3425     return panda::JSValueRef::Undefined(vm);
3426 }
3427 
SetLocalizedBorder(ArkUIRuntimeCallInfo * runtimeCallInfo)3428 ArkUINativeModuleValue CommonBridge::SetLocalizedBorder(ArkUIRuntimeCallInfo* runtimeCallInfo)
3429 {
3430     EcmaVM *vm = runtimeCallInfo->GetVM();
3431     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3432     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3433     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::NativePointerRef::New(vm, nullptr));
3434     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3435 
3436     std::vector<ArkUI_Float32> options;
3437     std::vector<RefPtr<ResourceObject>> resObj;
3438     ParseOuterBorderWidth(runtimeCallInfo, vm, options, resObj, true);         // Border Width args start index from 1
3439     ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, resObj, true); // Border Radius args start index
3440 
3441     std::vector<uint32_t> colorAndStyleOptions;
3442     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
3443     ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, resObj, nodeInfo, true);  // Border Color args start index
3444     ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13); // Border Style args start index
3445 
3446     int32_t isLocalizedBorderWidth = 0;
3447     int32_t isLocalizedBorderColor = 0;
3448     int32_t isLocalizedBorderRadius = 0;
3449     ParseLocalizedBorder(runtimeCallInfo, isLocalizedBorderWidth, isLocalizedBorderColor, isLocalizedBorderRadius);
3450 
3451     auto rawPtr = static_cast<void*>(&resObj);
3452     GetArkUINodeModifiers()->getCommonModifier()->setBorder(nativeNode, options.data(), options.size(),
3453         colorAndStyleOptions.data(), colorAndStyleOptions.size(), isLocalizedBorderWidth, isLocalizedBorderColor,
3454         isLocalizedBorderRadius, rawPtr);
3455     return panda::JSValueRef::Undefined(vm);
3456 }
3457 
ParseLocalizedBorder(ArkUIRuntimeCallInfo * runtimeCallInfo,int & isLocalizedBorderWidth,int & isLocalizedBorderColor,int & isLocalizedBorderRadius)3458 void CommonBridge::ParseLocalizedBorder(ArkUIRuntimeCallInfo* runtimeCallInfo, int& isLocalizedBorderWidth,
3459     int& isLocalizedBorderColor, int& isLocalizedBorderRadius)
3460 {
3461     EcmaVM* vm = runtimeCallInfo->GetVM();
3462     CHECK_NULL_VOID(vm);
3463     Local<JSValueRef> isLocalizedBorderWidthArg =
3464         runtimeCallInfo->GetCallArgRef(33); // 33: index of is LocalizedBorderWidth or not
3465     Local<JSValueRef> isLocalizedBorderColorArg =
3466         runtimeCallInfo->GetCallArgRef(34); // 34: index of is LocalizedBorderColor or not
3467     Local<JSValueRef> isLocalizedBorderRadiusArg =
3468         runtimeCallInfo->GetCallArgRef(35); // 35: index of is LocalizedBorderRadius or not
3469     isLocalizedBorderWidth =
3470         (isLocalizedBorderWidthArg->IsBoolean()) ? isLocalizedBorderWidthArg->ToBoolean(vm)->Value() : false;
3471     isLocalizedBorderColor =
3472         (isLocalizedBorderColorArg->IsBoolean()) ? isLocalizedBorderColorArg->ToBoolean(vm)->Value() : false;
3473     isLocalizedBorderRadius =
3474         (isLocalizedBorderRadiusArg->IsBoolean()) ? isLocalizedBorderRadiusArg->ToBoolean(vm)->Value() : false;
3475 }
3476 
SetBorderWithDashParams(ArkUIRuntimeCallInfo * runtimeCallInfo)3477 ArkUINativeModuleValue CommonBridge::SetBorderWithDashParams(ArkUIRuntimeCallInfo* runtimeCallInfo)
3478 {
3479     int32_t isLocalizedBorderWidth = 0;
3480     int32_t isLocalizedBorderColor = 0;
3481     int32_t isLocalizedBorderRadius = 0;
3482     ParseLocalizedBorder(runtimeCallInfo, isLocalizedBorderWidth, isLocalizedBorderColor, isLocalizedBorderRadius);
3483     if (isLocalizedBorderWidth || isLocalizedBorderColor || isLocalizedBorderRadius) {
3484         CommonBridge::SetLocalizedBorder(runtimeCallInfo);
3485     } else {
3486         CommonBridge::SetBorder(runtimeCallInfo);
3487     }
3488 
3489     EcmaVM *vm = runtimeCallInfo->GetVM();
3490     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3491     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3492     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3493 
3494     std::vector<ArkUI_Float32> dashOptions;
3495     std::vector<RefPtr<ResourceObject>> resObj;
3496     ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 17, resObj); // Border DashGap args start index from 17
3497     Local<JSValueRef> startDashGap = runtimeCallInfo->GetCallArgRef(36); // Border DashGap args start index from 36
3498     Local<JSValueRef> endDashGap = runtimeCallInfo->GetCallArgRef(37); // Border DashGap args end index from 37
3499     std::optional<CalcDimension> startDashGapDim;
3500     std::optional<CalcDimension> endDashGapDim;
3501     ArkTSUtils::ParseOuterBorderForDashParams(vm, startDashGap, startDashGapDim);
3502     ArkTSUtils::ParseOuterBorderForDashParams(vm, endDashGap, endDashGapDim);
3503     ArkTSUtils::PushOuterBorderDimensionVector(startDashGapDim, dashOptions);
3504     ArkTSUtils::PushOuterBorderDimensionVector(endDashGapDim, dashOptions);
3505 
3506     ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 21, resObj); // Border DashWidth args start index from 21
3507     Local<JSValueRef> startDashWidth = runtimeCallInfo->GetCallArgRef(38); // Border DashWidth args start index from 38
3508     Local<JSValueRef> endDashWidth = runtimeCallInfo->GetCallArgRef(39); // Border DashWidth args end index from 39
3509     std::optional<CalcDimension> startDashWidthDim;
3510     std::optional<CalcDimension> endDashWidthDim;
3511     ArkTSUtils::ParseOuterBorderForDashParams(vm, startDashWidth, startDashWidthDim);
3512     ArkTSUtils::ParseOuterBorderForDashParams(vm, endDashWidth, endDashWidthDim);
3513     ArkTSUtils::PushOuterBorderDimensionVector(startDashWidthDim, dashOptions);
3514     ArkTSUtils::PushOuterBorderDimensionVector(endDashWidthDim, dashOptions);
3515 
3516     auto rawPtr = static_cast<void*>(&resObj);
3517     GetArkUINodeModifiers()->getCommonModifier()->setBorderDashParams(nativeNode, dashOptions.data(),
3518         dashOptions.size(), rawPtr);
3519     return panda::JSValueRef::Undefined(vm);
3520 }
3521 
ResetBorder(ArkUIRuntimeCallInfo * runtimeCallInfo)3522 ArkUINativeModuleValue CommonBridge::ResetBorder(ArkUIRuntimeCallInfo *runtimeCallInfo)
3523 {
3524     EcmaVM *vm = runtimeCallInfo->GetVM();
3525     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3526     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3527     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3528     GetArkUINodeModifiers()->getCommonModifier()->resetBorder(nativeNode);
3529     return panda::JSValueRef::Undefined(vm);
3530 }
3531 
SetBackgroundImagePosition(ArkUIRuntimeCallInfo * runtimeCallInfo)3532 ArkUINativeModuleValue CommonBridge::SetBackgroundImagePosition(ArkUIRuntimeCallInfo *runtimeCallInfo)
3533 {
3534     EcmaVM *vm = runtimeCallInfo->GetVM();
3535     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3536     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3537     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3538     Local<JSValueRef> xArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3539     Local<JSValueRef> yArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3540     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3541     double valueX = 0.0;
3542     double valueY = 0.0;
3543     DimensionUnit typeX = DimensionUnit::PX;
3544     DimensionUnit typeY = DimensionUnit::PX;
3545     bool isAlign = false;
3546     RefPtr<ResourceObject> resObjX;
3547     RefPtr<ResourceObject> resObjY;
3548 
3549     if (secondArg->IsNumber()) {
3550         int32_t align = secondArg->ToNumber(vm)->Value();
3551         ParseBackgroundImagePositionAlign(align, valueX, valueY, typeX, typeY);
3552         isAlign = true;
3553     } else {
3554         CalcDimension x(0, DimensionUnit::VP);
3555         CalcDimension y(0, DimensionUnit::VP);
3556         ArkTSUtils::ParseJsDimensionVp(vm, xArg, x, resObjX);
3557         ArkTSUtils::ParseJsDimensionVp(vm, yArg, y, resObjY);
3558         valueX = x.ConvertToPx();
3559         valueY = y.ConvertToPx();
3560         if (x.Unit() == DimensionUnit::PERCENT) {
3561             valueX = x.Value();
3562             typeX = DimensionUnit::PERCENT;
3563         }
3564         if (y.Unit() == DimensionUnit::PERCENT) {
3565             valueY = y.Value();
3566             typeY = DimensionUnit::PERCENT;
3567         }
3568     }
3569 
3570     ArkUI_Float32 values[SIZE_OF_TWO];
3571     int32_t types[SIZE_OF_TWO];
3572     values[NUM_0] = static_cast<ArkUI_Float32>(valueX);
3573     types[NUM_0] = static_cast<int32_t>(typeX);
3574     values[NUM_1] = static_cast<ArkUI_Float32>(valueY);
3575     types[NUM_1] = static_cast<int32_t>(typeY);
3576 
3577     auto bgImageXRawPtr = AceType::RawPtr(resObjX);
3578     auto bgImageYRawPtr = AceType::RawPtr(resObjY);
3579     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImagePosition(nativeNode, values, types, isAlign,
3580         SIZE_OF_TWO, bgImageXRawPtr, bgImageYRawPtr);
3581     return panda::JSValueRef::Undefined(vm);
3582 }
3583 
ResetBackgroundImagePosition(ArkUIRuntimeCallInfo * runtimeCallInfo)3584 ArkUINativeModuleValue CommonBridge::ResetBackgroundImagePosition(ArkUIRuntimeCallInfo *runtimeCallInfo)
3585 {
3586     EcmaVM *vm = runtimeCallInfo->GetVM();
3587     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3588     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3589     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3590     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImagePosition(nativeNode);
3591     return panda::JSValueRef::Undefined(vm);
3592 }
3593 
SetBackgroundImageResizable(ArkUIRuntimeCallInfo * runtimeCallInfo)3594 ArkUINativeModuleValue CommonBridge::SetBackgroundImageResizable(ArkUIRuntimeCallInfo *runtimeCallInfo)
3595 {
3596     EcmaVM* vm = runtimeCallInfo->GetVM();
3597     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3598     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3599 
3600     std::vector<ArkUIStringAndFloat> options;
3601     std::vector<std::optional<CalcDimension>> sliceDimensions;
3602     std::vector<RefPtr<ResourceObject>> bgImageResizableResObjs;
3603     ParseResizableCalcDimensions(
3604         runtimeCallInfo, NUM_1, NUM_4, sliceDimensions, CalcDimension(0.0), bgImageResizableResObjs);
3605     PushDimensionsToVector(options, sliceDimensions);
3606     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImageResizable(nativeNode, options.data(),
3607         static_cast<ArkUI_Int32>(options.size()), static_cast<void*>(&bgImageResizableResObjs));
3608     return panda::JSValueRef::Undefined(vm);
3609 }
3610 
ResetBackgroundImageResizable(ArkUIRuntimeCallInfo * runtimeCallInfo)3611 ArkUINativeModuleValue CommonBridge::ResetBackgroundImageResizable(ArkUIRuntimeCallInfo *runtimeCallInfo)
3612 {
3613     EcmaVM* vm = runtimeCallInfo->GetVM();
3614     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
3615     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3616     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImageResizable(nativeNode);
3617     return panda::JSValueRef::Undefined(vm);
3618 }
3619 
SetBackgroundImageSize(ArkUIRuntimeCallInfo * runtimeCallInfo)3620 ArkUINativeModuleValue CommonBridge::SetBackgroundImageSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
3621 {
3622     EcmaVM *vm = runtimeCallInfo->GetVM();
3623     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3624     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3625     Local<JSValueRef> imageSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3626     Local<JSValueRef> widthArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3627     Local<JSValueRef> heightArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3628     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3629 
3630     OHOS::Ace::BackgroundImageSizeType typeWidth = OHOS::Ace::BackgroundImageSizeType::AUTO;
3631     double valueWidth = 0.0;
3632     OHOS::Ace::BackgroundImageSizeType typeHeight = OHOS::Ace::BackgroundImageSizeType::AUTO;
3633     double valueHeight = 0.0;
3634     RefPtr<ResourceObject> resObjWidth;
3635     RefPtr<ResourceObject> resObjHeight;
3636 
3637     if (imageSizeArg->IsNumber()) {
3638         auto sizeType = imageSizeArg->ToNumber(vm)->Value();
3639         if (sizeType < static_cast<uint32_t>(BackgroundImageSizeType::CONTAIN) ||
3640             sizeType > static_cast<uint32_t>(BackgroundImageSizeType::FILL)) {
3641             sizeType = static_cast<uint32_t>(BackgroundImageSizeType::AUTO);
3642         }
3643         typeWidth = static_cast<OHOS::Ace::BackgroundImageSizeType>(sizeType);
3644         typeHeight = static_cast<OHOS::Ace::BackgroundImageSizeType>(sizeType);
3645     } else {
3646         CalcDimension width;
3647         CalcDimension height;
3648         ArkTSUtils::ParseJsDimensionVp(vm, widthArg, width, resObjWidth);
3649         ArkTSUtils::ParseJsDimensionVp(vm, heightArg, height, resObjHeight);
3650 
3651         valueWidth = width.ConvertToPx();
3652         valueHeight = height.ConvertToPx();
3653         typeWidth = BackgroundImageSizeType::LENGTH;
3654         typeHeight = BackgroundImageSizeType::LENGTH;
3655         if (width.Unit() == DimensionUnit::PERCENT) {
3656             typeWidth = BackgroundImageSizeType::PERCENT;
3657             valueWidth = width.Value() * FULL_DIMENSION;
3658         }
3659         if (height.Unit() == DimensionUnit::PERCENT) {
3660             typeHeight = BackgroundImageSizeType::PERCENT;
3661             valueHeight = height.Value() * FULL_DIMENSION;
3662         }
3663     }
3664     auto bgImageSizeWidthRawPtr = AceType::RawPtr(resObjWidth);
3665     auto bgImageSizeHeightRawPtr = AceType::RawPtr(resObjHeight);
3666     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImageSize(nativeNode, valueWidth, valueHeight,
3667         static_cast<int32_t>(typeWidth), static_cast<int32_t>(typeHeight), bgImageSizeWidthRawPtr,
3668         bgImageSizeHeightRawPtr);
3669     return panda::JSValueRef::Undefined(vm);
3670 }
3671 
ResetBackgroundImageSize(ArkUIRuntimeCallInfo * runtimeCallInfo)3672 ArkUINativeModuleValue CommonBridge::ResetBackgroundImageSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
3673 {
3674     EcmaVM *vm = runtimeCallInfo->GetVM();
3675     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3676     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3677     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3678     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImageSize(nativeNode);
3679     return panda::JSValueRef::Undefined(vm);
3680 }
3681 
ParseJsBackgroundImageOptions(const EcmaVM * vm,const Local<JSValueRef> & value,int32_t & repeatIndex,bool & syncMode)3682 bool ParseJsBackgroundImageOptions(
3683     const EcmaVM* vm, const Local<JSValueRef>& value, int32_t& repeatIndex, bool& syncMode)
3684 {
3685     if (!value->IsObject(vm)) {
3686         return false;
3687     }
3688     auto jsObj = value->ToObject(vm);
3689     auto repeat = jsObj->Get(vm, panda::StringRef::NewFromUtf8(vm, "repeat"));
3690     if (repeat->IsNumber()) {
3691         repeatIndex = repeat->ToNumber(vm)->Value();
3692     }
3693     auto syncLoad = jsObj->Get(vm, panda::StringRef::NewFromUtf8(vm, "syncLoad"));
3694     if (syncLoad->IsBoolean()) {
3695         syncMode = syncLoad->ToBoolean(vm)->Value();
3696     }
3697     return true;
3698 }
3699 
SetBackgroundImage(ArkUIRuntimeCallInfo * runtimeCallInfo)3700 ArkUINativeModuleValue CommonBridge::SetBackgroundImage(ArkUIRuntimeCallInfo *runtimeCallInfo)
3701 {
3702     EcmaVM *vm = runtimeCallInfo->GetVM();
3703     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3704     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3705     Local<JSValueRef> srcArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3706     Local<JSValueRef> repeatArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3707     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3708     std::string src;
3709     std::string bundle;
3710     std::string module;
3711     int32_t repeatIndex = 0;
3712     bool syncMode = false;
3713     RefPtr<PixelMap> pixmap = nullptr;
3714     if (repeatArg->IsNumber()) {
3715         repeatIndex = repeatArg->ToNumber(vm)->Value();
3716     }
3717     if (ParseJsBackgroundImageOptions(vm, repeatArg, repeatIndex, syncMode)) {
3718         GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImageSyncMode(nativeNode, syncMode);
3719     } else {
3720         GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImageSyncMode(nativeNode);
3721     }
3722     RefPtr<ResourceObject> backgroundImageResObj;
3723     auto bgImageRawPtr = AceType::RawPtr(backgroundImageResObj);
3724     if (srcArg->IsString(vm)) {
3725         src = srcArg->ToString(vm)->ToString(vm);
3726         GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImage(
3727             nativeNode, src.c_str(), bundle.c_str(), module.c_str(), repeatIndex, bgImageRawPtr);
3728     } else if (ArkTSUtils::ParseJsMedia(vm, srcArg, src, backgroundImageResObj)) {
3729         ArkTSUtils::GetJsMediaBundleInfo(vm, srcArg, bundle, module);
3730         bgImageRawPtr = AceType::RawPtr(backgroundImageResObj);
3731         GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImage(
3732             nativeNode, src.c_str(), bundle.c_str(), module.c_str(), repeatIndex, bgImageRawPtr);
3733     } else {
3734 #if defined(PIXEL_MAP_SUPPORTED)
3735         if (ArkTSUtils::IsDrawable(vm, srcArg)) {
3736             pixmap = ArkTSUtils::GetDrawablePixmap(vm, srcArg);
3737         } else {
3738             pixmap = ArkTSUtils::CreatePixelMapFromNapiValue(vm, srcArg);
3739         }
3740 #endif
3741         if (pixmap) {
3742             auto pixelMapSharedPtr = pixmap->GetPixelMapSharedPtr();
3743             GetArkUINodeModifiers()->getCommonModifier()->setBackgroundImagePixelMapByPixelMapPtr(
3744                 nativeNode, &pixelMapSharedPtr, repeatIndex);
3745         } else {
3746             GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImage(nativeNode);
3747         }
3748     }
3749     return panda::JSValueRef::Undefined(vm);
3750 }
3751 
ResetBackgroundImage(ArkUIRuntimeCallInfo * runtimeCallInfo)3752 ArkUINativeModuleValue CommonBridge::ResetBackgroundImage(ArkUIRuntimeCallInfo *runtimeCallInfo)
3753 {
3754     EcmaVM *vm = runtimeCallInfo->GetVM();
3755     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3756     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
3757     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3758     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImageSyncMode(nativeNode);
3759     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundImage(nativeNode);
3760     return panda::JSValueRef::Undefined(vm);
3761 }
3762 
SetTranslate(ArkUIRuntimeCallInfo * runtimeCallInfo)3763 ArkUINativeModuleValue CommonBridge::SetTranslate(ArkUIRuntimeCallInfo *runtimeCallInfo)
3764 {
3765     EcmaVM *vm = runtimeCallInfo->GetVM();
3766     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3767     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3768     Local<JSValueRef> xArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3769     Local<JSValueRef> yArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3770     Local<JSValueRef> zArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3771     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3772     if (!xArg->IsNumber() && !xArg->IsString(vm) && !yArg->IsNumber() && !yArg->IsString(vm) && !zArg->IsNumber() &&
3773         !zArg->IsString(vm)) {
3774         GetArkUINodeModifiers()->getCommonModifier()->resetTranslate(nativeNode);
3775     } else {
3776         auto translateX = CalcDimension(0.0);
3777         auto translateY = CalcDimension(0.0);
3778         auto translateZ = CalcDimension(0.0);
3779         bool hasX = ParseAxisDimensionVp(vm, xArg, translateX, true);
3780         bool hasY = ParseAxisDimensionVp(vm, yArg, translateY, true);
3781         bool hasZ = ParseAxisDimensionVp(vm, zArg, translateZ, true);
3782         if (hasX || hasY || hasZ) {
3783             uint32_t size = SIZE_OF_THREE;
3784             ArkUI_Float32 values[size];
3785             int units[size];
3786 
3787             values[NUM_0] = static_cast<ArkUI_Float32>(translateX.Value());
3788             units[NUM_0] = static_cast<int>(translateX.Unit());
3789             values[NUM_1] = static_cast<ArkUI_Float32>(translateY.Value());
3790             units[NUM_1] = static_cast<int>(translateY.Unit());
3791             values[NUM_2] = static_cast<ArkUI_Float32>(translateZ.Value());
3792             units[NUM_2] = static_cast<int>(translateZ.Unit());
3793             GetArkUINodeModifiers()->getCommonModifier()->setTranslate(nativeNode, values, units, size);
3794         } else {
3795             GetArkUINodeModifiers()->getCommonModifier()->resetTranslate(nativeNode);
3796         }
3797     }
3798     return panda::JSValueRef::Undefined(vm);
3799 }
3800 
ResetTranslate(ArkUIRuntimeCallInfo * runtimeCallInfo)3801 ArkUINativeModuleValue CommonBridge::ResetTranslate(ArkUIRuntimeCallInfo *runtimeCallInfo)
3802 {
3803     EcmaVM *vm = runtimeCallInfo->GetVM();
3804     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3805     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
3806     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3807     GetArkUINodeModifiers()->getCommonModifier()->resetTranslate(nativeNode);
3808     return panda::JSValueRef::Undefined(vm);
3809 }
3810 
SetScale(ArkUIRuntimeCallInfo * runtimeCallInfo)3811 ArkUINativeModuleValue CommonBridge::SetScale(ArkUIRuntimeCallInfo *runtimeCallInfo)
3812 {
3813     EcmaVM *vm = runtimeCallInfo->GetVM();
3814     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3815     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3816     Local<JSValueRef> xArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3817     Local<JSValueRef> yArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3818     Local<JSValueRef> zArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3819     Local<JSValueRef> centerXArg = runtimeCallInfo->GetCallArgRef(NUM_4);
3820     Local<JSValueRef> centerYArg = runtimeCallInfo->GetCallArgRef(NUM_5);
3821     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3822     if (xArg->IsNumber() || yArg->IsNumber() || zArg->IsNumber()) {
3823         auto scaleX = 1.0f;
3824         auto scaleY = 1.0f;
3825         auto scaleZ = 1.0f;
3826 
3827         CalcDimension centerX = 0.5_pct;
3828         CalcDimension centerY = 0.5_pct;
3829 
3830         if (xArg->IsNumber()) {
3831             scaleX = xArg->ToNumber(vm)->Value();
3832         }
3833         if (yArg->IsNumber()) {
3834             scaleY = yArg->ToNumber(vm)->Value();
3835         }
3836         if (zArg->IsNumber()) {
3837             scaleZ = zArg->ToNumber(vm)->Value();
3838         }
3839         if (centerXArg->IsNumber() || centerXArg->IsString(vm)) {
3840             ParseAxisDimensionVp(vm, centerXArg, centerX, true);
3841         }
3842         if (centerYArg->IsNumber() || centerYArg->IsString(vm)) {
3843             ParseAxisDimensionVp(vm, centerYArg, centerY, true);
3844         }
3845 
3846         ArkUI_Float32 values[SIZE_OF_FIVE];
3847         int units[SIZE_OF_TWO];
3848 
3849         values[NUM_0] = static_cast<ArkUI_Float32>(scaleX);
3850         values[NUM_1] = static_cast<ArkUI_Float32>(scaleY);
3851         values[NUM_2] = static_cast<ArkUI_Float32>(scaleZ);
3852         values[NUM_3] = static_cast<ArkUI_Float32>(centerX.Value());
3853         values[NUM_4] = static_cast<ArkUI_Float32>(centerY.Value());
3854         units[NUM_0] = static_cast<int>(centerX.Unit());
3855         units[NUM_1] = static_cast<int>(centerY.Unit());
3856         GetArkUINodeModifiers()->getCommonModifier()->setScale(nativeNode, values, SIZE_OF_FIVE, units, SIZE_OF_TWO);
3857     } else {
3858         GetArkUINodeModifiers()->getCommonModifier()->resetScale(nativeNode);
3859     }
3860 
3861     return panda::JSValueRef::Undefined(vm);
3862 }
3863 
ResetScale(ArkUIRuntimeCallInfo * runtimeCallInfo)3864 ArkUINativeModuleValue CommonBridge::ResetScale(ArkUIRuntimeCallInfo *runtimeCallInfo)
3865 {
3866     EcmaVM *vm = runtimeCallInfo->GetVM();
3867     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3868     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
3869     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3870     GetArkUINodeModifiers()->getCommonModifier()->resetScale(nativeNode);
3871     return panda::JSValueRef::Undefined(vm);
3872 }
3873 
SetRotateAngle(ArkUIRuntimeCallInfo * runtimeCallInfo)3874 ArkUINativeModuleValue CommonBridge::SetRotateAngle(ArkUIRuntimeCallInfo* runtimeCallInfo)
3875 {
3876     EcmaVM* vm = runtimeCallInfo->GetVM();
3877     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3878     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3879     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3880 
3881     ArkUI_Float32 values[SIZE_OF_SEVEN];
3882     int units[SIZE_OF_THREE];
3883 
3884     if (ParseRotateAngle(runtimeCallInfo, values, units, SIZE_OF_SEVEN, SIZE_OF_THREE)) {
3885         GetArkUINodeModifiers()->getCommonModifier()->setRotateAngle(
3886             nativeNode, values, SIZE_OF_SEVEN, units, SIZE_OF_THREE);
3887     } else {
3888         GetArkUINodeModifiers()->getCommonModifier()->resetRotateAngle(nativeNode);
3889     }
3890     return panda::JSValueRef::Undefined(vm);
3891 }
3892 
ResetRotateAngle(ArkUIRuntimeCallInfo * runtimeCallInfo)3893 ArkUINativeModuleValue CommonBridge::ResetRotateAngle(ArkUIRuntimeCallInfo* runtimeCallInfo)
3894 {
3895     EcmaVM* vm = runtimeCallInfo->GetVM();
3896     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3897     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3898     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3899     GetArkUINodeModifiers()->getCommonModifier()->resetRotateAngle(nativeNode);
3900     return panda::JSValueRef::Undefined(vm);
3901 }
3902 
SetRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)3903 ArkUINativeModuleValue CommonBridge::SetRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
3904 {
3905     EcmaVM *vm = runtimeCallInfo->GetVM();
3906     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3907     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3908     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3909 
3910     ArkUI_Float32 values[SIZE_OF_EIGHT];
3911     int units[SIZE_OF_THREE];
3912 
3913     if (ParseRotate(runtimeCallInfo, values, units, SIZE_OF_EIGHT, SIZE_OF_THREE)) {
3914         GetArkUINodeModifiers()->getCommonModifier()->setRotate(
3915             nativeNode, values, SIZE_OF_EIGHT, units, SIZE_OF_THREE);
3916     } else {
3917         GetArkUINodeModifiers()->getCommonModifier()->resetRotate(nativeNode);
3918     }
3919     return panda::JSValueRef::Undefined(vm);
3920 }
3921 
ResetRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)3922 ArkUINativeModuleValue CommonBridge::ResetRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
3923 {
3924     EcmaVM *vm = runtimeCallInfo->GetVM();
3925     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3926     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3927     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3928     GetArkUINodeModifiers()->getCommonModifier()->resetRotate(nativeNode);
3929     return panda::JSValueRef::Undefined(vm);
3930 }
3931 
SetGeometryTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)3932 ArkUINativeModuleValue CommonBridge::SetGeometryTransition(ArkUIRuntimeCallInfo *runtimeCallInfo)
3933 {
3934     EcmaVM *vm = runtimeCallInfo->GetVM();
3935     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3936     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
3937     Local<JSValueRef> idArg = runtimeCallInfo->GetCallArgRef(NUM_1);
3938     Local<JSValueRef> followArg = runtimeCallInfo->GetCallArgRef(NUM_2);
3939     Local<JSValueRef> hierarchyStrategyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
3940     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3941     if (idArg->IsUndefined() || idArg->IsNull() || !idArg->IsString(vm)) {
3942         GetArkUINodeModifiers()->getCommonModifier()->resetGeometryTransition(nativeNode);
3943         return panda::JSValueRef::Undefined(vm);
3944     }
3945     std::string id = idArg->ToString(vm)->ToString(vm);
3946     ArkUIGeometryTransitionOptions options = {false, static_cast<int32_t>(TransitionHierarchyStrategy::ADAPTIVE)};
3947     if (followArg->IsBoolean()) {
3948         options.follow = followArg->ToBoolean(vm)->Value();
3949     }
3950     if (hierarchyStrategyArg->IsInt()) {
3951         options.hierarchyStrategy = hierarchyStrategyArg->Int32Value(vm);
3952         if (options.hierarchyStrategy < static_cast<int32_t>(TransitionHierarchyStrategy::NONE) ||
3953             options.hierarchyStrategy > static_cast<int32_t>(TransitionHierarchyStrategy::ADAPTIVE)) {
3954             options.hierarchyStrategy = static_cast<int32_t>(TransitionHierarchyStrategy::ADAPTIVE);
3955         }
3956     }
3957     GetArkUINodeModifiers()->getCommonModifier()->setGeometryTransition(nativeNode, id.c_str(), &options);
3958     return panda::JSValueRef::Undefined(vm);
3959 }
3960 
ResetGeometryTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)3961 ArkUINativeModuleValue CommonBridge::ResetGeometryTransition(ArkUIRuntimeCallInfo *runtimeCallInfo)
3962 {
3963     EcmaVM *vm = runtimeCallInfo->GetVM();
3964     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3965     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
3966     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
3967     GetArkUINodeModifiers()->getCommonModifier()->resetGeometryTransition(nativeNode);
3968     return panda::JSValueRef::Undefined(vm);
3969 }
3970 
SetBindMenu(ArkUIRuntimeCallInfo * runtimeCallInfo)3971 ArkUINativeModuleValue CommonBridge::SetBindMenu(ArkUIRuntimeCallInfo* runtimeCallInfo)
3972 {
3973     EcmaVM* vm = runtimeCallInfo->GetVM();
3974     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
3975     Framework::JSCallbackInfo info = Framework::JSCallbackInfo(runtimeCallInfo);
3976     NG::MenuParam menuParam;
3977     if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
3978         menuParam.placement = Placement::BOTTOM_LEFT;
3979     }
3980     size_t builderIndex = NUM_1;
3981     JSViewPopups::GetMenuShowInSubwindow(menuParam);
3982     if (info.Length() > PARAMETER_LENGTH_SECOND) {
3983         auto jsVal = info[builderIndex];
3984         if (jsVal->IsBoolean()) {
3985             menuParam.isShow = jsVal->ToBoolean();
3986             menuParam.setShow = true;
3987             builderIndex = NUM_2;
3988             if (info.Length() > PARAMETER_LENGTH_THIRD) {
3989                 JSViewPopups::ParseBindOptionParam(info, menuParam, builderIndex + 1);
3990             }
3991         } else if (jsVal->IsUndefined()) {
3992             menuParam.setShow = true;
3993             menuParam.isShow = false;
3994             builderIndex = NUM_2;
3995             if (info.Length() > PARAMETER_LENGTH_THIRD) {
3996                 JSViewPopups::ParseBindOptionParam(info, menuParam, builderIndex + 1);
3997             }
3998         } else if (jsVal->IsObject()) {
3999             JSRef<JSObject> callbackObj = JSRef<JSObject>::Cast(jsVal);
4000             menuParam.onStateChange = JSViewPopups::ParseDoubleBindCallback(info, callbackObj, "$value");
4001             auto isShowObj = callbackObj->GetProperty(static_cast<int32_t>(ArkUIIndex::VALUE));
4002             if (isShowObj->IsBoolean()) {
4003                 menuParam.isShow = isShowObj->ToBoolean();
4004                 menuParam.setShow = true;
4005                 builderIndex = NUM_2;
4006                 if (info.Length() > PARAMETER_LENGTH_THIRD) {
4007                     JSViewPopups::ParseBindOptionParam(info, menuParam, builderIndex + 1);
4008                 }
4009             } else {
4010                 JSViewPopups::ParseBindOptionParam(info, menuParam, builderIndex + 1);
4011             }
4012         }
4013     }
4014     if (info[builderIndex]->IsArray()) {
4015         std::vector<NG::OptionParam> optionsParam = JSViewPopups::ParseBindOptionParam(info, builderIndex);
4016         ViewAbstractModel::GetInstance()->BindMenu(std::move(optionsParam), nullptr, menuParam);
4017     }
4018     return panda::JSValueRef::Undefined(vm);
4019 }
4020 
ParseTipsMessage(ArkUIRuntimeCallInfo * runtimeCallInfo,const EcmaVM * vm,std::string & message,RefPtr<SpanString> & styledString)4021 bool ParseTipsMessage(
4022     ArkUIRuntimeCallInfo* runtimeCallInfo, const EcmaVM* vm, std::string& message, RefPtr<SpanString>& styledString)
4023 {
4024     bool parseRuslut = false;
4025     Local<JSValueRef> messageArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4026     if (messageArg->IsString(vm)) {
4027         message = messageArg->ToString(vm)->ToString(vm);
4028         parseRuslut = true;
4029     } else if (messageArg->IsObject(vm)) {
4030         Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
4031         Framework::JSRef<Framework::JSVal> args = info[1];
4032         auto* spanString = Framework::JSRef<Framework::JSObject>::Cast(args)->Unwrap<Framework::JSSpanString>();
4033         if (!spanString) {
4034             ArkTSUtils::ParseJsString(vm, messageArg, message);
4035         } else {
4036             styledString = spanString->GetController();
4037         }
4038         parseRuslut = true;
4039     }
4040     return parseRuslut;
4041 }
4042 
ParseTipsParam(const RefPtr<PopupParam> & tipsParam,const ArkUIBindTipsOptionsTime & timeOptions,const ArkUIBindTipsOptionsArrow & arrowOptions)4043 void ParseTipsParam(const RefPtr<PopupParam>& tipsParam, const ArkUIBindTipsOptionsTime& timeOptions,
4044     const ArkUIBindTipsOptionsArrow& arrowOptions)
4045 {
4046     CHECK_NULL_VOID(tipsParam);
4047     tipsParam->SetShowInSubWindow(true);
4048     tipsParam->SetAppearingTime(timeOptions.appearingTime);
4049     tipsParam->SetDisappearingTime(timeOptions.disappearingTime);
4050     tipsParam->SetAppearingTimeWithContinuousOperation(timeOptions.appearingTimeWithContinuousOperation);
4051     tipsParam->SetDisappearingTimeWithContinuousOperation(timeOptions.disappearingTimeWithContinuousOperation);
4052     tipsParam->SetEnableArrow(arrowOptions.enableArrow);
4053     if (arrowOptions.arrowPointPosition && arrowOptions.enableArrow) {
4054         CalcDimension offset;
4055         char* pEnd = nullptr;
4056         std::strtod(arrowOptions.arrowPointPosition, &pEnd);
4057         if (pEnd != nullptr) {
4058             if (std::strcmp(pEnd, "Start") == 0) {
4059                 offset = 0.0_pct; // 0.0_pct : The offset is 0%
4060             }
4061             if (std::strcmp(pEnd, "Center") == 0) {
4062                 offset = 0.5_pct; // 0.5_pct : The offset is 50%
4063             }
4064             if (std::strcmp(pEnd, "End") == 0) {
4065                 offset = 1.0_pct; // 1.0_pct : The offset is 100%
4066             }
4067             tipsParam->SetArrowOffset(offset);
4068         }
4069     }
4070     CalcDimension arrowWidth(arrowOptions.arrowWidthValue, static_cast<DimensionUnit>(arrowOptions.arrowWidthUnit));
4071     bool setArrowWidthError = true;
4072     if (arrowOptions.arrowWidthValue > 0 &&
4073         static_cast<DimensionUnit>(arrowOptions.arrowWidthUnit) != DimensionUnit::PERCENT) {
4074         tipsParam->SetArrowWidth(arrowWidth);
4075         setArrowWidthError = false;
4076     }
4077     tipsParam->SetErrorArrowWidth(setArrowWidthError);
4078     CalcDimension arrowHeight(arrowOptions.arrowHeightValue, static_cast<DimensionUnit>(arrowOptions.arrowHeightUnit));
4079     bool setArrowHeightError = true;
4080     if (arrowOptions.arrowHeightValue > 0 &&
4081         static_cast<DimensionUnit>(arrowOptions.arrowHeightUnit) != DimensionUnit::PERCENT) {
4082         tipsParam->SetArrowHeight(arrowHeight);
4083         setArrowHeightError = false;
4084     }
4085     tipsParam->SetErrorArrowHeight(setArrowHeightError);
4086     tipsParam->SetBlockEvent(false);
4087     tipsParam->SetTipsFlag(true);
4088     tipsParam->SetAnchorType(static_cast<TipsAnchorType>(arrowOptions.showAtAnchor));
4089 }
4090 
SetBindTips(ArkUIRuntimeCallInfo * runtimeCallInfo)4091 ArkUINativeModuleValue CommonBridge::SetBindTips(ArkUIRuntimeCallInfo* runtimeCallInfo)
4092 {
4093     EcmaVM* vm = runtimeCallInfo->GetVM();
4094     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4095     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4096     Local<JSValueRef> appearingTimeArg = runtimeCallInfo->GetCallArgRef(NUM_2);
4097     Local<JSValueRef> disappearingTimeArg = runtimeCallInfo->GetCallArgRef(NUM_3);
4098     Local<JSValueRef> appearingTimeWithContinuousOperationArg = runtimeCallInfo->GetCallArgRef(NUM_4);
4099     Local<JSValueRef> disappearingTimeWithContinuousOperationArg = runtimeCallInfo->GetCallArgRef(NUM_5);
4100     Local<JSValueRef> enableArrowArg = runtimeCallInfo->GetCallArgRef(NUM_6);
4101     Local<JSValueRef> arrowPointPositionArg = runtimeCallInfo->GetCallArgRef(NUM_7);
4102     Local<JSValueRef> arrowWidthArg = runtimeCallInfo->GetCallArgRef(NUM_8);
4103     Local<JSValueRef> arrowHeightArg = runtimeCallInfo->GetCallArgRef(NUM_9);
4104     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
4105     std::string message;
4106     RefPtr<SpanString> styledString;
4107     if (!ParseTipsMessage(runtimeCallInfo, vm, message, styledString)) {
4108         return panda::JSValueRef::Undefined(vm);
4109     }
4110     ArkUIBindTipsOptionsTime timeOptions {
4111         .appearingTime = 700.0f,                         // 700.0f : Default appearing time
4112         .disappearingTime = 300.0f,                      // 300.0f : Default disappearing time
4113         .appearingTimeWithContinuousOperation = 300.0f,  // 300.0f : Default continous appearing time
4114         .disappearingTimeWithContinuousOperation = 0.0f  // 0.0f : Default continous disappearing time
4115     };
4116     ParseTipsOptionsTime(vm, timeOptions, appearingTimeArg, timeOptions.appearingTime);
4117     ParseTipsOptionsTime(vm, timeOptions, disappearingTimeArg, timeOptions.disappearingTime);
4118     ParseTipsOptionsTime(
4119         vm, timeOptions, appearingTimeWithContinuousOperationArg, timeOptions.appearingTimeWithContinuousOperation);
4120     ParseTipsOptionsTime(vm, timeOptions, disappearingTimeWithContinuousOperationArg,
4121         timeOptions.disappearingTimeWithContinuousOperation);
4122     ArkUIBindTipsOptionsArrow arrowOptions;
4123     arrowOptions.enableArrow = (enableArrowArg->IsBoolean()) ? enableArrowArg->ToBoolean(vm)->Value() : true;
4124     std::string arrowPointPosition;
4125     if (arrowPointPositionArg->IsString(vm)) {
4126         arrowPointPosition = arrowPointPositionArg->ToString(vm)->ToString(vm);
4127         arrowOptions.arrowPointPosition = arrowPointPosition.c_str();
4128     }
4129     ParseTipsOptionsShowAtAnchor(vm, runtimeCallInfo->GetCallArgRef(NUM_10), arrowOptions);
4130     ParseTipsOptionsArrowSize(vm, arrowWidthArg, arrowOptions.arrowWidthValue, arrowOptions.arrowWidthUnit);
4131     ParseTipsOptionsArrowSize(vm, arrowHeightArg, arrowOptions.arrowHeightValue, arrowOptions.arrowHeightUnit);
4132     if (styledString) {
4133         auto tipsParam = AceType::MakeRefPtr<PopupParam>();
4134         ParseTipsParam(tipsParam, timeOptions, arrowOptions);
4135         ViewAbstract::BindTips(tipsParam, AceType::Claim(reinterpret_cast<FrameNode*>(nativeNode)), styledString);
4136     } else {
4137         GetArkUINodeModifiers()->getCommonModifier()->setBindTips(
4138             nativeNode, message.c_str(), timeOptions, arrowOptions);
4139     }
4140     return panda::JSValueRef::Undefined(vm);
4141 }
4142 
ResetBindTips(ArkUIRuntimeCallInfo * runtimeCallInfo)4143 ArkUINativeModuleValue CommonBridge::ResetBindTips(ArkUIRuntimeCallInfo *runtimeCallInfo)
4144 {
4145     EcmaVM *vm = runtimeCallInfo->GetVM();
4146     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4147     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4148     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4149     GetArkUINodeModifiers()->getCommonModifier()->resetBindTips(nativeNode);
4150     return panda::JSValueRef::Undefined(vm);
4151 }
4152 
ResetClip(ArkUIRuntimeCallInfo * runtimeCallInfo)4153 ArkUINativeModuleValue CommonBridge::ResetClip(ArkUIRuntimeCallInfo *runtimeCallInfo)
4154 {
4155     EcmaVM *vm = runtimeCallInfo->GetVM();
4156     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4157     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4158     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4159     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
4160     ViewAbstract::SetClipEdge(frameNode, false);
4161     return panda::JSValueRef::Undefined(vm);
4162 }
4163 
SetClip(ArkUIRuntimeCallInfo * runtimeCallInfo)4164 ArkUINativeModuleValue CommonBridge::SetClip(ArkUIRuntimeCallInfo *runtimeCallInfo)
4165 {
4166     EcmaVM *vm = runtimeCallInfo->GetVM();
4167     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4168     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4169     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4170     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
4171 
4172     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
4173     if (info[NUM_1]->IsUndefined()) {
4174         ViewAbstract::SetClipEdge(frameNode, false);
4175         return panda::JSValueRef::Undefined(vm);
4176     }
4177     if (info[NUM_1]->IsObject()) {
4178         Framework::JSShapeAbstract *clipShape =
4179             Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1])->Unwrap<Framework::JSShapeAbstract>();
4180         if (clipShape == nullptr) {
4181             return panda::JSValueRef::Undefined(vm);
4182         }
4183         ViewAbstractModelNG::RemoveResObj(frameNode, "clipShape");
4184         ViewAbstract::SetClipShape(frameNode, clipShape->GetBasicShape());
4185     } else if (info[NUM_1]->IsBoolean()) {
4186         ViewAbstract::SetClipEdge(frameNode, info[NUM_1]->ToBoolean());
4187     }
4188     return panda::JSValueRef::Undefined(vm);
4189 }
4190 
SetClipShape(ArkUIRuntimeCallInfo * runtimeCallInfo)4191 ArkUINativeModuleValue CommonBridge::SetClipShape(ArkUIRuntimeCallInfo *runtimeCallInfo)
4192 {
4193     EcmaVM *vm = runtimeCallInfo->GetVM();
4194     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4195     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4196     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4197     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
4198 
4199     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
4200     if (info[NUM_1]->IsObject()) {
4201         Framework::JSShapeAbstract *clipShape =
4202             Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1])->Unwrap<Framework::JSShapeAbstract>();
4203         if (clipShape == nullptr) {
4204             return panda::JSValueRef::Undefined(vm);
4205         }
4206         ViewAbstractModelNG::RemoveResObj(frameNode, "clipShape");
4207         ViewAbstract::SetClipShape(frameNode, clipShape->GetBasicShape());
4208     }
4209     return panda::JSValueRef::Undefined(vm);
4210 }
4211 
ResetClipShape(ArkUIRuntimeCallInfo * runtimeCallInfo)4212 ArkUINativeModuleValue CommonBridge::ResetClipShape(ArkUIRuntimeCallInfo *runtimeCallInfo)
4213 {
4214     EcmaVM *vm = runtimeCallInfo->GetVM();
4215     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4216     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4217     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4218     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
4219     ViewAbstract::SetClipEdge(frameNode, false);
4220     return panda::JSValueRef::Undefined(vm);
4221 }
4222 
SetMaskColorResObj(Framework::JSRef<Framework::JSVal> & jColor,Color & colorVal,RefPtr<ProgressMaskProperty> & progressMask)4223 void SetMaskColorResObj(Framework::JSRef<Framework::JSVal>& jColor, Color& colorVal,
4224     RefPtr<ProgressMaskProperty>& progressMask)
4225 {
4226     RefPtr<ResourceObject> colorResObj;
4227     auto parseJsColor = Framework::JSViewAbstract::ParseJsColor(jColor, colorVal, colorResObj);
4228     if (colorResObj) {
4229         progressMask->SetColor(colorVal);
4230         auto&& updateFunc = [](const RefPtr<ResourceObject>& resObj, NG::ProgressMaskProperty& progressMask) {
4231             Color color;
4232             ResourceParseUtils::ParseResColor(resObj, color);
4233             progressMask.SetColor(color);
4234         };
4235         progressMask->AddResource("progressMask.color", colorResObj, std::move(updateFunc));
4236     } else if (parseJsColor) {
4237         progressMask->SetColor(colorVal);
4238     } else {
4239         auto theme = Framework::JSShapeAbstract::GetTheme<ProgressTheme>();
4240         progressMask->SetColor(theme->GetMaskColor());
4241         RefPtr<ResourceObject> resObj = AceType::MakeRefPtr<ResourceObject>("", "", -1);
4242         auto&& updateFunc = [](const RefPtr<ResourceObject>& resObj, NG::ProgressMaskProperty& progressMask) {
4243             RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
4244             progressMask.SetColor(theme->GetMaskColor());
4245         };
4246         progressMask->AddResource("progressMask.color", resObj, std::move(updateFunc));
4247     }
4248 }
4249 
ParseJsMaskProperty(FrameNode * frameNode,const Framework::JSRef<Framework::JSObject> & paramObject)4250 void ParseJsMaskProperty(FrameNode* frameNode, const Framework::JSRef<Framework::JSObject>& paramObject)
4251 {
4252     auto progressMask = AceType::MakeRefPtr<NG::ProgressMaskProperty>();
4253     Framework::JSRef<Framework::JSVal> jValue = paramObject->GetProperty("value");
4254     auto value = jValue->IsNumber() ? jValue->ToNumber<float>() : 0.0f;
4255     if (value < 0.0f) {
4256         value = 0.0f;
4257     }
4258     progressMask->SetValue(value);
4259     Framework::JSRef<Framework::JSVal> jTotal = paramObject->GetProperty("total");
4260     auto total = jTotal->IsNumber() ? jTotal->ToNumber<float>() : DEFAULT_PROGRESS_TOTAL;
4261     if (total < 0.0f) {
4262         total = DEFAULT_PROGRESS_TOTAL;
4263     }
4264     progressMask->SetMaxValue(total);
4265     Framework::JSRef<Framework::JSVal> jEnableBreathe = paramObject->GetProperty("breathe");
4266     if (jEnableBreathe->IsBoolean()) {
4267         progressMask->SetEnableBreathe(jEnableBreathe->ToBoolean());
4268     }
4269     Framework::JSRef<Framework::JSVal> jColor = paramObject->GetProperty("color");
4270     Color colorVal;
4271     if (!SystemProperties::ConfigChangePerform()) {
4272         if (Framework::JSViewAbstract::ParseJsColor(jColor, colorVal)) {
4273             progressMask->SetColor(colorVal);
4274         } else {
4275             auto theme = Framework::JSShapeAbstract::GetTheme<ProgressTheme>();
4276             progressMask->SetColor(theme->GetMaskColor());
4277         }
4278         ViewAbstract::SetProgressMask(frameNode, progressMask);
4279     } else {
4280         ViewAbstractModelNG::RemoveResObj(frameNode, "ProgressMask");
4281         SetMaskColorResObj(jColor, colorVal, progressMask);
4282         ViewAbstract::SetProgressMask(frameNode, progressMask);
4283     }
4284 }
4285 
SetPixelStretchEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4286 ArkUINativeModuleValue CommonBridge::SetPixelStretchEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4287 {
4288     EcmaVM *vm = runtimeCallInfo->GetVM();
4289     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4290     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4291     auto topArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4292     auto rightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
4293     auto bottomArg = runtimeCallInfo->GetCallArgRef(NUM_3);
4294     auto leftArg = runtimeCallInfo->GetCallArgRef(NUM_4);
4295     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4296     std::vector<RefPtr<ResourceObject>> vectorResObj;
4297     CalcDimension left;
4298     ParseJsDimensionVpResObj(vm, leftArg, left, vectorResObj);
4299     CalcDimension right;
4300     ParseJsDimensionVpResObj(vm, rightArg, right, vectorResObj);
4301     CalcDimension top;
4302     ParseJsDimensionVpResObj(vm, topArg, top, vectorResObj);
4303     CalcDimension bottom;
4304     ParseJsDimensionVpResObj(vm, bottomArg, bottom, vectorResObj);
4305     auto rawPtr = static_cast<void*>(&vectorResObj);
4306     ArkUI_Float32 values[] = { static_cast<ArkUI_Float32>(left.Value()), static_cast<ArkUI_Float32>(top.Value()),
4307         static_cast<ArkUI_Float32>(right.Value()), static_cast<ArkUI_Float32>(bottom.Value()) };
4308     int units[] = { static_cast<int>(left.Unit()), static_cast<int>(top.Unit()), static_cast<int>(right.Unit()),
4309                     static_cast<int>(bottom.Unit()) };
4310     GetArkUINodeModifiers()->getCommonModifier()->setPixelStretchEffect(nativeNode, values, units,
4311         (sizeof(values) / sizeof(values[NUM_0])), rawPtr);
4312     return panda::JSValueRef::Undefined(vm);
4313 }
4314 
ResetPixelStretchEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4315 ArkUINativeModuleValue CommonBridge::ResetPixelStretchEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4316 {
4317     EcmaVM *vm = runtimeCallInfo->GetVM();
4318     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4319     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4320     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4321     GetArkUINodeModifiers()->getCommonModifier()->resetPixelStretchEffect(nativeNode);
4322     return panda::JSValueRef::Undefined(vm);
4323 }
4324 
SetLightUpEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4325 ArkUINativeModuleValue CommonBridge::SetLightUpEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4326 {
4327     EcmaVM *vm = runtimeCallInfo->GetVM();
4328     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4329     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4330     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4331     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4332     auto radio = 1.0;
4333     if (secondArg->IsNumber()) {
4334         radio = secondArg->ToNumber(vm)->Value();
4335     }
4336     GetArkUINodeModifiers()->getCommonModifier()->setLightUpEffect(nativeNode, radio);
4337     return panda::JSValueRef::Undefined(vm);
4338 }
4339 
ResetLightUpEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4340 ArkUINativeModuleValue CommonBridge::ResetLightUpEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4341 {
4342     EcmaVM *vm = runtimeCallInfo->GetVM();
4343     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4344     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4345     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4346     GetArkUINodeModifiers()->getCommonModifier()->resetLightUpEffect(nativeNode);
4347     return panda::JSValueRef::Undefined(vm);
4348 }
4349 
SetSphericalEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4350 ArkUINativeModuleValue CommonBridge::SetSphericalEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4351 {
4352     EcmaVM *vm = runtimeCallInfo->GetVM();
4353     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4354     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4355     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4356     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4357     auto radio = 0.0;
4358     if (secondArg->IsNumber()) {
4359         radio = secondArg->ToNumber(vm)->Value();
4360     }
4361     GetArkUINodeModifiers()->getCommonModifier()->setSphericalEffect(nativeNode, radio);
4362     return panda::JSValueRef::Undefined(vm);
4363 }
4364 
ResetSphericalEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4365 ArkUINativeModuleValue CommonBridge::ResetSphericalEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4366 {
4367     EcmaVM *vm = runtimeCallInfo->GetVM();
4368     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4369     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4370     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4371     GetArkUINodeModifiers()->getCommonModifier()->resetSphericalEffect(nativeNode);
4372     return panda::JSValueRef::Undefined(vm);
4373 }
4374 
SetRenderGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)4375 ArkUINativeModuleValue CommonBridge::SetRenderGroup(ArkUIRuntimeCallInfo *runtimeCallInfo)
4376 {
4377     EcmaVM *vm = runtimeCallInfo->GetVM();
4378     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4379     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4380     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4381     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4382     auto isRenderGroup = false;
4383     if (secondArg->IsBoolean()) {
4384         isRenderGroup = secondArg->ToBoolean(vm)->Value();
4385     }
4386     GetArkUINodeModifiers()->getCommonModifier()->setRenderGroup(nativeNode, isRenderGroup);
4387     return panda::JSValueRef::Undefined(vm);
4388 }
4389 
ResetRenderGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)4390 ArkUINativeModuleValue CommonBridge::ResetRenderGroup(ArkUIRuntimeCallInfo *runtimeCallInfo)
4391 {
4392     EcmaVM *vm = runtimeCallInfo->GetVM();
4393     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4394     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4395     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4396     GetArkUINodeModifiers()->getCommonModifier()->resetRenderGroup(nativeNode);
4397     return panda::JSValueRef::Undefined(vm);
4398 }
4399 
SetRenderFit(ArkUIRuntimeCallInfo * runtimeCallInfo)4400 ArkUINativeModuleValue CommonBridge::SetRenderFit(ArkUIRuntimeCallInfo *runtimeCallInfo)
4401 {
4402     EcmaVM *vm = runtimeCallInfo->GetVM();
4403     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4404     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4405     auto fitModeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4406     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4407     auto renderFit = static_cast<int32_t>(RenderFit::TOP_LEFT);
4408     if (fitModeArg->IsNumber()) {
4409         renderFit = fitModeArg->Int32Value(vm);
4410     }
4411     GetArkUINodeModifiers()->getCommonModifier()->setRenderFit(nativeNode, renderFit);
4412     return panda::JSValueRef::Undefined(vm);
4413 }
4414 
ResetRenderFit(ArkUIRuntimeCallInfo * runtimeCallInfo)4415 ArkUINativeModuleValue CommonBridge::ResetRenderFit(ArkUIRuntimeCallInfo *runtimeCallInfo)
4416 {
4417     EcmaVM *vm = runtimeCallInfo->GetVM();
4418     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4419     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4420     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4421     GetArkUINodeModifiers()->getCommonModifier()->resetRenderFit(nativeNode);
4422     return panda::JSValueRef::Undefined(vm);
4423 }
4424 
SetUseEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4425 ArkUINativeModuleValue CommonBridge::SetUseEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4426 {
4427     EcmaVM *vm = runtimeCallInfo->GetVM();
4428     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4429     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4430     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4431     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
4432     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4433     auto useEffect = false;
4434     if (secondArg->IsBoolean()) {
4435         useEffect = secondArg->ToBoolean(vm)->Value();
4436     }
4437     auto effectTypeDefault = EffectType::DEFAULT;
4438     auto effectTypeParam = effectTypeDefault;
4439     auto effectTypeValue = static_cast<int32_t>(effectTypeDefault);
4440 
4441     if (thirdArg->IsNumber()) {
4442         effectTypeValue = thirdArg->Int32Value(vm);
4443         if (effectTypeValue >= static_cast<int32_t>(effectTypeDefault) &&
4444             effectTypeValue <= static_cast<int32_t>(EffectType::WINDOW_EFFECT)) {
4445             effectTypeParam = static_cast<EffectType>(effectTypeValue);
4446         }
4447     }
4448     auto effectType =  static_cast<ArkUI_Int32>(effectTypeParam);
4449     GetArkUINodeModifiers()->getCommonModifier()->setUseEffect(nativeNode, useEffect, effectType);
4450     return panda::JSValueRef::Undefined(vm);
4451 }
4452 
ResetUseEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)4453 ArkUINativeModuleValue CommonBridge::ResetUseEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
4454 {
4455     EcmaVM *vm = runtimeCallInfo->GetVM();
4456     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4457     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4458     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4459     GetArkUINodeModifiers()->getCommonModifier()->resetUseEffect(nativeNode);
4460     return panda::JSValueRef::Undefined(vm);
4461 }
4462 
SetForegroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)4463 ArkUINativeModuleValue CommonBridge::SetForegroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
4464 {
4465     EcmaVM *vm = runtimeCallInfo->GetVM();
4466     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4467     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4468     auto colorArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4469     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4470     if (colorArg->IsString(vm)) {
4471         std::string colorStr = colorArg->ToString(vm)->ToString(vm);
4472         colorStr.erase(std::remove(colorStr.begin(), colorStr.end(), ' '), colorStr.end());
4473         std::transform(colorStr.begin(), colorStr.end(), colorStr.begin(), ::tolower);
4474         if (colorStr.compare("invert") == 0) {
4475             auto strategy = static_cast<uint32_t>(ForegroundColorStrategy::INVERT);
4476             GetArkUINodeModifiers()->getCommonModifier()->setForegroundColor(nativeNode, false, strategy, nullptr);
4477             return panda::JSValueRef::Undefined(vm);
4478         }
4479     }
4480     Color foregroundColor = Color::TRANSPARENT;
4481     RefPtr<ResourceObject> colorResObj;
4482     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
4483     ArkTSUtils::ParseJsColorAlpha(vm, colorArg, foregroundColor, colorResObj, nodeInfo);
4484     auto fgColorRawPtr = AceType::RawPtr(colorResObj);
4485     GetArkUINodeModifiers()->getCommonModifier()->setForegroundColor(nativeNode, true, foregroundColor.GetValue(), fgColorRawPtr);
4486     return panda::JSValueRef::Undefined(vm);
4487 }
4488 
ResetForegroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)4489 ArkUINativeModuleValue CommonBridge::ResetForegroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
4490 {
4491     EcmaVM *vm = runtimeCallInfo->GetVM();
4492     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4493     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4494     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4495     GetArkUINodeModifiers()->getCommonModifier()->resetForegroundColor(nativeNode);
4496     return panda::JSValueRef::Undefined(vm);
4497 }
4498 
SetMotionPath(ArkUIRuntimeCallInfo * runtimeCallInfo)4499 ArkUINativeModuleValue CommonBridge::SetMotionPath(ArkUIRuntimeCallInfo *runtimeCallInfo)
4500 {
4501     EcmaVM *vm = runtimeCallInfo->GetVM();
4502     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4503     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4504     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4505     auto pathArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4506     auto fromArg = runtimeCallInfo->GetCallArgRef(NUM_2);
4507     auto toArg = runtimeCallInfo->GetCallArgRef(NUM_3);
4508     auto rotatableArg = runtimeCallInfo->GetCallArgRef(NUM_4);
4509     std::string pathStringValue;
4510     if (pathArg->IsString(vm)) {
4511         pathStringValue = pathArg->ToString(vm)->ToString(vm);
4512     }
4513     float fromValue = (fromArg->IsNumber()) ? fromArg->ToNumber(vm)->Value() : 0.0f;
4514     float toValue = (toArg->IsNumber()) ? toArg->ToNumber(vm)->Value() : 1.0f;
4515     if (fromValue > 1.0f || fromValue < 0.0f) {
4516         fromValue = 0.0f;
4517     }
4518     if (toValue > 1.0f || toValue < 0.0f) {
4519         toValue = 1.0f;
4520     } else if (toValue < fromValue) {
4521         toValue = fromValue;
4522     }
4523     bool rotatableValue = (rotatableArg->IsBoolean()) ? rotatableArg->ToBoolean(vm)->Value() : false;
4524     GetArkUINodeModifiers()->getCommonModifier()->setMotionPath(nativeNode, pathStringValue.c_str(), fromValue,
4525         toValue, rotatableValue);
4526     return panda::JSValueRef::Undefined(vm);
4527 }
4528 
ResetMotionPath(ArkUIRuntimeCallInfo * runtimeCallInfo)4529 ArkUINativeModuleValue CommonBridge::ResetMotionPath(ArkUIRuntimeCallInfo *runtimeCallInfo)
4530 {
4531     EcmaVM *vm = runtimeCallInfo->GetVM();
4532     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4533     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4534     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4535     GetArkUINodeModifiers()->getCommonModifier()->resetMotionPath(nativeNode);
4536     return panda::JSValueRef::Undefined(vm);
4537 }
4538 
4539 
SetMotionBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)4540 ArkUINativeModuleValue CommonBridge::SetMotionBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
4541 {
4542     EcmaVM *vm = runtimeCallInfo->GetVM();
4543     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4544     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4545     Local<JSValueRef> radiusArg = runtimeCallInfo->GetCallArgRef(NUM_1);
4546     Local<JSValueRef> xArg = runtimeCallInfo->GetCallArgRef(NUM_2);
4547     Local<JSValueRef> yArg = runtimeCallInfo->GetCallArgRef(NUM_3);
4548     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4549     double radius = 0.0;
4550     if (!ArkTSUtils::ParseJsDouble(vm, radiusArg, radius) || LessNotEqual(radius, 0.0)) {
4551         radius = 0.0;
4552     }
4553     double x = 0.0;
4554     double y = 0.0;
4555     if (!ArkTSUtils::ParseJsDouble(vm, xArg, x) || LessNotEqual(x, 0.0)) {
4556         x = 0.0;
4557     }
4558     if (!ArkTSUtils::ParseJsDouble(vm, yArg, y) || LessNotEqual(y, 0.0)) {
4559         y = 0.0;
4560     }
4561     x = std::clamp(x, 0.0, 1.0);
4562     y = std::clamp(y, 0.0, 1.0);
4563     GetArkUINodeModifiers()->getCommonModifier()->setMotionBlur(nativeNode, radius, x, y);
4564     return panda::JSValueRef::Undefined(vm);
4565 }
4566 
ResetMotionBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)4567 ArkUINativeModuleValue CommonBridge::ResetMotionBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
4568 {
4569     EcmaVM *vm = runtimeCallInfo->GetVM();
4570     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4571     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4572     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4573     GetArkUINodeModifiers()->getCommonModifier()->resetMotionBlur(nativeNode);
4574     return panda::JSValueRef::Undefined(vm);
4575 }
4576 
SetGroupDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)4577 ArkUINativeModuleValue CommonBridge::SetGroupDefaultFocus(ArkUIRuntimeCallInfo *runtimeCallInfo)
4578 {
4579     EcmaVM *vm = runtimeCallInfo->GetVM();
4580     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4581     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4582     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4583     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4584     if (secondArg->IsBoolean()) {
4585         bool groupDefaultFocus = secondArg->ToBoolean(vm)->Value();
4586         GetArkUINodeModifiers()->getCommonModifier()->setGroupDefaultFocus(nativeNode, groupDefaultFocus);
4587     } else {
4588         GetArkUINodeModifiers()->getCommonModifier()->resetGroupDefaultFocus(nativeNode);
4589     }
4590     return panda::JSValueRef::Undefined(vm);
4591 }
4592 
ResetGroupDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)4593 ArkUINativeModuleValue CommonBridge::ResetGroupDefaultFocus(ArkUIRuntimeCallInfo *runtimeCallInfo)
4594 {
4595     EcmaVM *vm = runtimeCallInfo->GetVM();
4596     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4597     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4598     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4599     GetArkUINodeModifiers()->getCommonModifier()->resetGroupDefaultFocus(nativeNode);
4600     return panda::JSValueRef::Undefined(vm);
4601 }
4602 
SetFocusOnTouch(ArkUIRuntimeCallInfo * runtimeCallInfo)4603 ArkUINativeModuleValue CommonBridge::SetFocusOnTouch(ArkUIRuntimeCallInfo *runtimeCallInfo)
4604 {
4605     EcmaVM *vm = runtimeCallInfo->GetVM();
4606     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4607     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4608     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4609     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4610     if (secondArg->IsBoolean()) {
4611         bool focusOnTouch = secondArg->ToBoolean(vm)->Value();
4612         GetArkUINodeModifiers()->getCommonModifier()->setFocusOnTouch(nativeNode, focusOnTouch);
4613     } else {
4614         GetArkUINodeModifiers()->getCommonModifier()->resetFocusOnTouch(nativeNode);
4615     }
4616     return panda::JSValueRef::Undefined(vm);
4617 }
4618 
ResetFocusOnTouch(ArkUIRuntimeCallInfo * runtimeCallInfo)4619 ArkUINativeModuleValue CommonBridge::ResetFocusOnTouch(ArkUIRuntimeCallInfo *runtimeCallInfo)
4620 {
4621     EcmaVM *vm = runtimeCallInfo->GetVM();
4622     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4623     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4624     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4625     GetArkUINodeModifiers()->getCommonModifier()->resetFocusOnTouch(nativeNode);
4626     return panda::JSValueRef::Undefined(vm);
4627 }
4628 
SetFocusable(ArkUIRuntimeCallInfo * runtimeCallInfo)4629 ArkUINativeModuleValue CommonBridge::SetFocusable(ArkUIRuntimeCallInfo* runtimeCallInfo)
4630 {
4631     EcmaVM* vm = runtimeCallInfo->GetVM();
4632     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4633     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4634     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4635     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4636     if (secondArg->IsBoolean()) {
4637         bool focusable = secondArg->ToBoolean(vm)->Value();
4638         GetArkUINodeModifiers()->getCommonModifier()->setFocusable(nativeNode, focusable);
4639     }
4640     return panda::JSValueRef::Undefined(vm);
4641 }
4642 
ResetFocusable(ArkUIRuntimeCallInfo * runtimeCallInfo)4643 ArkUINativeModuleValue CommonBridge::ResetFocusable(ArkUIRuntimeCallInfo* runtimeCallInfo)
4644 {
4645     EcmaVM* vm = runtimeCallInfo->GetVM();
4646     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4647     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4648     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4649     GetArkUINodeModifiers()->getCommonModifier()->resetFocusable(nativeNode);
4650     return panda::JSValueRef::Undefined(vm);
4651 }
4652 
SetTabStop(ArkUIRuntimeCallInfo * runtimeCallInfo)4653 ArkUINativeModuleValue CommonBridge::SetTabStop(ArkUIRuntimeCallInfo* runtimeCallInfo)
4654 {
4655     EcmaVM* vm = runtimeCallInfo->GetVM();
4656     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4657     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4658     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4659     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4660     if (secondArg->IsBoolean()) {
4661         bool tabStop = secondArg->ToBoolean(vm)->Value();
4662         GetArkUINodeModifiers()->getCommonModifier()->setTabStop(nativeNode, tabStop);
4663     } else {
4664         GetArkUINodeModifiers()->getCommonModifier()->setTabStop(nativeNode, false);
4665     }
4666     return panda::JSValueRef::Undefined(vm);
4667 }
4668 
ResetTabStop(ArkUIRuntimeCallInfo * runtimeCallInfo)4669 ArkUINativeModuleValue CommonBridge::ResetTabStop(ArkUIRuntimeCallInfo* runtimeCallInfo)
4670 {
4671     EcmaVM* vm = runtimeCallInfo->GetVM();
4672     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4673     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4674     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4675     GetArkUINodeModifiers()->getCommonModifier()->setTabStop(nativeNode, false);
4676     return panda::JSValueRef::Undefined(vm);
4677 }
4678 
SetTouchable(ArkUIRuntimeCallInfo * runtimeCallInfo)4679 ArkUINativeModuleValue CommonBridge::SetTouchable(ArkUIRuntimeCallInfo* runtimeCallInfo)
4680 {
4681     EcmaVM* vm = runtimeCallInfo->GetVM();
4682     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4683     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4684     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4685     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4686     if (secondArg->IsBoolean()) {
4687         bool touchable = secondArg->ToBoolean(vm)->Value();
4688         GetArkUINodeModifiers()->getCommonModifier()->setTouchable(nativeNode, touchable);
4689     } else {
4690         GetArkUINodeModifiers()->getCommonModifier()->resetTouchable(nativeNode);
4691     }
4692     return panda::JSValueRef::Undefined(vm);
4693 }
4694 
ResetTouchable(ArkUIRuntimeCallInfo * runtimeCallInfo)4695 ArkUINativeModuleValue CommonBridge::ResetTouchable(ArkUIRuntimeCallInfo* runtimeCallInfo)
4696 {
4697     EcmaVM* vm = runtimeCallInfo->GetVM();
4698     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4699     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4700     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4701     GetArkUINodeModifiers()->getCommonModifier()->resetTouchable(nativeNode);
4702     return panda::JSValueRef::Undefined(vm);
4703 }
4704 
SetDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)4705 ArkUINativeModuleValue CommonBridge::SetDefaultFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
4706 {
4707     EcmaVM* vm = runtimeCallInfo->GetVM();
4708     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4709     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4710     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4711     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4712     if (secondArg->IsBoolean()) {
4713         bool defaultFocus = secondArg->ToBoolean(vm)->Value();
4714         GetArkUINodeModifiers()->getCommonModifier()->setDefaultFocus(nativeNode, defaultFocus);
4715     } else {
4716         GetArkUINodeModifiers()->getCommonModifier()->resetDefaultFocus(nativeNode);
4717     }
4718     return panda::JSValueRef::Undefined(vm);
4719 }
4720 
ResetDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)4721 ArkUINativeModuleValue CommonBridge::ResetDefaultFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
4722 {
4723     EcmaVM* vm = runtimeCallInfo->GetVM();
4724     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4725     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4726     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4727     GetArkUINodeModifiers()->getCommonModifier()->resetDefaultFocus(nativeNode);
4728     return panda::JSValueRef::Undefined(vm);
4729 }
4730 
SetDisplayPriority(ArkUIRuntimeCallInfo * runtimeCallInfo)4731 ArkUINativeModuleValue CommonBridge::SetDisplayPriority(ArkUIRuntimeCallInfo* runtimeCallInfo)
4732 {
4733     EcmaVM* vm = runtimeCallInfo->GetVM();
4734     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4735     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4736     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4737     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4738     if (secondArg->IsNumber()) {
4739         double value = secondArg->ToNumber(vm)->Value();
4740         GetArkUINodeModifiers()->getCommonModifier()->setDisplayPriority(nativeNode, value);
4741     } else {
4742         GetArkUINodeModifiers()->getCommonModifier()->resetDisplayPriority(nativeNode);
4743     }
4744     return panda::JSValueRef::Undefined(vm);
4745 }
4746 
ResetDisplayPriority(ArkUIRuntimeCallInfo * runtimeCallInfo)4747 ArkUINativeModuleValue CommonBridge::ResetDisplayPriority(ArkUIRuntimeCallInfo* runtimeCallInfo)
4748 {
4749     EcmaVM* vm = runtimeCallInfo->GetVM();
4750     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4751     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4752     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4753     GetArkUINodeModifiers()->getCommonModifier()->resetDisplayPriority(nativeNode);
4754     return panda::JSValueRef::Undefined(vm);
4755 }
4756 
SetAccessibilityLevel(ArkUIRuntimeCallInfo * runtimeCallInfo)4757 ArkUINativeModuleValue CommonBridge::SetAccessibilityLevel(ArkUIRuntimeCallInfo* runtimeCallInfo)
4758 {
4759     EcmaVM* vm = runtimeCallInfo->GetVM();
4760     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4761     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4762     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4763     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4764     if (secondArg->IsString(vm)) {
4765         std::string stringValue = secondArg->ToString(vm)->ToString(vm);
4766         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityLevel(nativeNode, stringValue.c_str());
4767     } else {
4768         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityLevel(nativeNode);
4769     }
4770     return panda::JSValueRef::Undefined(vm);
4771 }
4772 
ResetAccessibilityLevel(ArkUIRuntimeCallInfo * runtimeCallInfo)4773 ArkUINativeModuleValue CommonBridge::ResetAccessibilityLevel(ArkUIRuntimeCallInfo* runtimeCallInfo)
4774 {
4775     EcmaVM* vm = runtimeCallInfo->GetVM();
4776     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4777     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4778     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4779     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityLevel(nativeNode);
4780     return panda::JSValueRef::Undefined(vm);
4781 }
4782 
SetAccessibilityRoleType(ArkUIRuntimeCallInfo * runtimeCallInfo)4783 ArkUINativeModuleValue CommonBridge::SetAccessibilityRoleType(ArkUIRuntimeCallInfo* runtimeCallInfo)
4784 {
4785     EcmaVM* vm = runtimeCallInfo->GetVM();
4786     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4787     if (runtimeCallInfo->GetArgsNumber() < NUM_2) {
4788         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set role params num is invalid");
4789         return panda::NativePointerRef::New(vm, nullptr);
4790     }
4791     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4792     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4793     if (!firstArg->IsNativePointer(vm)) {
4794         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set role first param is invalid");
4795         return panda::NativePointerRef::New(vm, nullptr);
4796     }
4797     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4798     if (secondArg->IsInt()) {
4799         auto index = secondArg->Int32Value(vm);
4800         AccessibilityRoleType roleType = static_cast<AccessibilityRoleType>(index);
4801         std::string role = JSAccessibilityAbstract::GetRoleByType(roleType);
4802         if (!role.empty()) {
4803             GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityCustomRole(nativeNode, role.c_str());
4804         } else {
4805             GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityCustomRole(nativeNode);
4806         }
4807     } else {
4808         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityCustomRole(nativeNode);
4809     }
4810     return panda::JSValueRef::Undefined(vm);
4811 }
4812 
ResetAccessibilityRoleType(ArkUIRuntimeCallInfo * runtimeCallInfo)4813 ArkUINativeModuleValue CommonBridge::ResetAccessibilityRoleType(ArkUIRuntimeCallInfo* runtimeCallInfo)
4814 {
4815     EcmaVM* vm = runtimeCallInfo->GetVM();
4816     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4817     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
4818         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset role params num is invalid");
4819         return panda::NativePointerRef::New(vm, nullptr);
4820     }
4821     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4822     if (!firstArg->IsNativePointer(vm)) {
4823         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset role first param is invalid");
4824         return panda::NativePointerRef::New(vm, nullptr);
4825     }
4826     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4827     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityCustomRole(nativeNode);
4828     return panda::JSValueRef::Undefined(vm);
4829 }
4830 
SetAccessibilityFocusCallback(ArkUIRuntimeCallInfo * runtimeCallInfo)4831 ArkUINativeModuleValue CommonBridge::SetAccessibilityFocusCallback(ArkUIRuntimeCallInfo* runtimeCallInfo)
4832 {
4833     EcmaVM* vm = runtimeCallInfo->GetVM();
4834     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4835     if (runtimeCallInfo->GetArgsNumber() < NUM_2) {
4836         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set focus callback params num is invalid");
4837         return panda::NativePointerRef::New(vm, nullptr);
4838     }
4839     auto* frameNode = GetFrameNode(runtimeCallInfo);
4840     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4841     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4842     if (!secondArg->IsFunction(vm)) {
4843         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set focus callback params is invalid, reset callback");
4844         ViewAbstractModelNG::ResetOnAccessibilityFocus(frameNode);
4845         return panda::JSValueRef::Undefined(vm);
4846     }
4847     auto obj = secondArg->ToObject(vm);
4848     auto containerId = Container::CurrentId();
4849     panda::Local<panda::FunctionRef> func = obj;
4850     auto focusCallback = [vm, func = panda::CopyableGlobal(vm, func), node = AceType::WeakClaim(frameNode),
4851         containerId](bool isFocus) {
4852         panda::LocalScope pandaScope(vm);
4853         panda::TryCatch trycatch(vm);
4854         ContainerScope scope(containerId);
4855         PipelineContext::SetCallBackNode(node);
4856         auto newJSVal = panda::BooleanRef::New(vm, isFocus);
4857         panda::Local<panda::JSValueRef> params[] = { newJSVal };
4858         func->Call(vm, func.ToLocal(), params, 1);
4859     };
4860     ViewAbstractModelNG::SetOnAccessibilityFocus(frameNode, std::move(focusCallback));
4861     return panda::JSValueRef::Undefined(vm);
4862 }
4863 
ResetAccessibilityFocusCallback(ArkUIRuntimeCallInfo * runtimeCallInfo)4864 ArkUINativeModuleValue CommonBridge::ResetAccessibilityFocusCallback(ArkUIRuntimeCallInfo* runtimeCallInfo)
4865 {
4866     EcmaVM* vm = runtimeCallInfo->GetVM();
4867     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4868     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
4869         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset focus callback params num is invalid");
4870         return panda::NativePointerRef::New(vm, nullptr);
4871     }
4872     auto* frameNode = GetFrameNode(runtimeCallInfo);
4873     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4874     ViewAbstractModelNG::ResetOnAccessibilityFocus(frameNode);
4875     return panda::JSValueRef::Undefined(vm);
4876 }
4877 
SetOnAccessibilityActionIntercept(ArkUIRuntimeCallInfo * runtimeCallInfo)4878 ArkUINativeModuleValue CommonBridge::SetOnAccessibilityActionIntercept(ArkUIRuntimeCallInfo* runtimeCallInfo)
4879 {
4880     EcmaVM* vm = runtimeCallInfo->GetVM();
4881     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
4882     auto* frameNode = GetFrameNode(runtimeCallInfo);
4883     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4884     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
4885     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
4886     auto jsVal = info[1];
4887     if (!JSViewAbstract::CheckJSCallbackInfo("onAccessibilityActionIntercept", jsVal, checkList)) {
4888         return panda::JSValueRef::Undefined(vm);
4889     }
4890     auto jsInterceptFunc = AceType::MakeRefPtr<JsAccessibilityActionInterceptFunction>(JSRef<JSFunc>::Cast(jsVal));
4891     auto onAccessibilityActionIntercept = [execCtx = info.GetExecutionContext(), func = std::move(jsInterceptFunc),
4892         node = AceType::WeakClaim<NG::FrameNode>(frameNode)](AccessibilityInterfaceAction action) ->
4893             AccessibilityActionInterceptResult {
4894         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, AccessibilityActionInterceptResult::ACTION_CONTINUE);
4895         PipelineContext::SetCallBackNode(node);
4896         return func->Execute(action);
4897     };
4898     ViewAbstractModelNG::SetOnAccessibilityActionIntercept(frameNode, std::move(onAccessibilityActionIntercept));
4899     return panda::JSValueRef::Undefined(vm);
4900 }
4901 
ResetOnAccessibilityActionIntercept(ArkUIRuntimeCallInfo * runtimeCallInfo)4902 ArkUINativeModuleValue CommonBridge::ResetOnAccessibilityActionIntercept(ArkUIRuntimeCallInfo* runtimeCallInfo)
4903 {
4904     EcmaVM* vm = runtimeCallInfo->GetVM();
4905     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4906     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
4907         return panda::NativePointerRef::New(vm, nullptr);
4908     }
4909     auto* frameNode = GetFrameNode(runtimeCallInfo);
4910     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4911     ViewAbstractModelNG::SetOnAccessibilityActionIntercept(frameNode, nullptr);
4912     return panda::JSValueRef::Undefined(vm);
4913 }
4914 
SetAccessibilityHoverTransparent(ArkUIRuntimeCallInfo * runtimeCallInfo)4915 ArkUINativeModuleValue CommonBridge::SetAccessibilityHoverTransparent(ArkUIRuntimeCallInfo* runtimeCallInfo)
4916 {
4917     EcmaVM* vm = runtimeCallInfo->GetVM();
4918     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
4919     auto* frameNode = GetFrameNode(runtimeCallInfo);
4920     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4921     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
4922     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
4923     auto jsVal = info[1];
4924     if (!JSViewAbstract::CheckJSCallbackInfo("onAccessibilityHoverTransparent", jsVal, checkList)) {
4925         return panda::JSValueRef::Undefined(vm);
4926     }
4927     auto jsOnHoverTransparentFunc =
4928         AceType::MakeRefPtr<JsAccessibilityHoverTransparentFunction>(JSRef<JSFunc>::Cast(jsVal));
4929     auto onHoverTransparentFunc = [execCtx = info.GetExecutionContext(),
4930                                       func = std::move(jsOnHoverTransparentFunc),
4931                                       node = AceType::WeakClaim<NG::FrameNode>(frameNode)](TouchEventInfo& info) {
4932         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
4933         PipelineContext::SetCallBackNode(node);
4934         func->Execute(info);
4935     };
4936     ViewAbstractModelNG::SetOnAccessibilityHoverTransparent(frameNode, std::move(onHoverTransparentFunc));
4937     return panda::JSValueRef::Undefined(vm);
4938 }
4939 
ResetAccessibilityHoverTransparent(ArkUIRuntimeCallInfo * runtimeCallInfo)4940 ArkUINativeModuleValue CommonBridge::ResetAccessibilityHoverTransparent(ArkUIRuntimeCallInfo* runtimeCallInfo)
4941 {
4942     EcmaVM* vm = runtimeCallInfo->GetVM();
4943     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4944     auto* frameNode = GetFrameNode(runtimeCallInfo);
4945     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
4946     ViewAbstractModelNG::SetOnAccessibilityHoverTransparent(frameNode, nullptr);
4947     return panda::JSValueRef::Undefined(vm);
4948 }
4949 
SetAccessibilityDescription(ArkUIRuntimeCallInfo * runtimeCallInfo)4950 ArkUINativeModuleValue CommonBridge::SetAccessibilityDescription(ArkUIRuntimeCallInfo* runtimeCallInfo)
4951 {
4952     EcmaVM* vm = runtimeCallInfo->GetVM();
4953     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4954     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4955     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
4956     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4957     std::string value;
4958     if (ArkTSUtils::ParseJsString(vm, secondArg, value)) {
4959         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityDescription(nativeNode, value.c_str());
4960     } else {
4961         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityDescription(nativeNode);
4962     }
4963     return panda::JSValueRef::Undefined(vm);
4964 }
4965 
ResetAccessibilityDescription(ArkUIRuntimeCallInfo * runtimeCallInfo)4966 ArkUINativeModuleValue CommonBridge::ResetAccessibilityDescription(ArkUIRuntimeCallInfo* runtimeCallInfo)
4967 {
4968     EcmaVM* vm = runtimeCallInfo->GetVM();
4969     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4970     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
4971     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4972     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityDescription(nativeNode);
4973     return panda::JSValueRef::Undefined(vm);
4974 }
4975 
SetOffset(ArkUIRuntimeCallInfo * runtimeCallInfo)4976 ArkUINativeModuleValue CommonBridge::SetOffset(ArkUIRuntimeCallInfo* runtimeCallInfo)
4977 {
4978     EcmaVM* vm = runtimeCallInfo->GetVM();
4979     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
4980     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
4981     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
4982     bool useEdges = runtimeCallInfo->GetCallArgRef(NUM_1)->ToBoolean(vm)->Value();
4983     std::vector<ArkUIStringAndFloat> options;
4984     std::vector<std::optional<CalcDimension>> edges;
4985     std::vector<RefPtr<ResourceObject>> edgesResObj;
4986 
4987     if (useEdges) {
4988         ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, edgesResObj, CalcDimension(0.0));
4989         if (res == ParseResult::LENGTHMETRICS_SUCCESS && AceApplicationInfo::GetInstance().IsRightToLeft()) {
4990             // Swap left and right
4991             std::swap(edges[NUM_1], edges[NUM_3]);
4992         }
4993         PushDimensionsToVector(options, edges);
4994         auto edgesRawPtr = static_cast<void*>(&edgesResObj);
4995         GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data(), edgesRawPtr);
4996     } else {
4997         ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, edgesResObj, CalcDimension(0.0));
4998         PushDimensionsToVector(options, edges);
4999         auto edgesRawPtr = static_cast<void*>(&edgesResObj);
5000         GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data(), edgesRawPtr);
5001     }
5002     return panda::JSValueRef::Undefined(vm);
5003 }
5004 
ResetOffset(ArkUIRuntimeCallInfo * runtimeCallInfo)5005 ArkUINativeModuleValue CommonBridge::ResetOffset(ArkUIRuntimeCallInfo *runtimeCallInfo)
5006 {
5007     EcmaVM *vm = runtimeCallInfo->GetVM();
5008     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5009     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5010     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5011 
5012     GetArkUINodeModifiers()->getCommonModifier()->resetOffset(nativeNode);
5013     return panda::JSValueRef::Undefined(vm);
5014 }
5015 
ParsePadding(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimen,ArkUISizeType & result,std::vector<RefPtr<ResourceObject>> & resObjs)5016 void ParsePadding(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& dimen, ArkUISizeType& result,
5017     std::vector<RefPtr<ResourceObject>>& resObjs)
5018 {
5019     RefPtr<ResourceObject> resObj;
5020     if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen, resObj)) {
5021         if (LessOrEqual(dimen.Value(), 0.0)) {
5022             dimen.SetValue(0.0);
5023             dimen.SetUnit(DimensionUnit::VP);
5024         }
5025         result.unit = static_cast<int8_t>(dimen.Unit());
5026         if (dimen.CalcValue() != "") {
5027             result.string = dimen.CalcValue().c_str();
5028         } else {
5029             result.value = dimen.Value();
5030         }
5031     }
5032     if (SystemProperties::ConfigChangePerform()) {
5033         resObjs.push_back(resObj);
5034     }
5035 }
5036 
ParseLocalizedPadding(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimen,ArkUISizeType & result)5037 bool ParseLocalizedPadding(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& dimen,
5038     ArkUISizeType& result)
5039 {
5040     if (ArkTSUtils::ParseJsLengthMetrics(vm, value, dimen)) {
5041         if (LessOrEqual(dimen.Value(), 0.0)) {
5042             dimen.SetValue(0.0);
5043             dimen.SetUnit(DimensionUnit::VP);
5044         }
5045         result.unit = static_cast<int8_t>(dimen.Unit());
5046         if (dimen.CalcValue() != "") {
5047             result.string = dimen.CalcValue().c_str();
5048         } else {
5049             result.value = dimen.Value();
5050         }
5051         return true;
5052     }
5053     return false;
5054 }
5055 
SetPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)5056 ArkUINativeModuleValue CommonBridge::SetPadding(ArkUIRuntimeCallInfo *runtimeCallInfo)
5057 {
5058     EcmaVM *vm = runtimeCallInfo->GetVM();
5059     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5060     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5061     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5062     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5063     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5064     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
5065     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
5066 
5067     struct ArkUISizeType top = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5068     struct ArkUISizeType right = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5069     struct ArkUISizeType bottom = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5070     struct ArkUISizeType left = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5071 
5072     CalcDimension topDimen(0, DimensionUnit::VP);
5073     CalcDimension rightDimen(0, DimensionUnit::VP);
5074     CalcDimension bottomDimen(0, DimensionUnit::VP);
5075     CalcDimension leftDimen(0, DimensionUnit::VP);
5076     std::vector<RefPtr<ResourceObject>> resObj;
5077 
5078     bool isLengthMetrics = false;
5079     if (secondArg->IsObject(vm)) {
5080         isLengthMetrics |= ParseLocalizedPadding(vm, secondArg, topDimen, top);
5081     }
5082     if (thirdArg->IsObject(vm)) {
5083         isLengthMetrics |= ParseLocalizedPadding(vm, thirdArg, rightDimen, right);
5084     }
5085     if (forthArg->IsObject(vm)) {
5086         isLengthMetrics |= ParseLocalizedPadding(vm, forthArg, bottomDimen, bottom);
5087     }
5088     if (fifthArg->IsObject(vm)) {
5089         isLengthMetrics |= ParseLocalizedPadding(vm, fifthArg, leftDimen, left);
5090     }
5091 
5092     if (isLengthMetrics) {
5093         auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
5094         GetArkUINodeModifiers()->getCommonModifier()->setPadding(nativeNode,
5095             &top,
5096             isRightToLeft ? &left : &right,
5097             &bottom,
5098             isRightToLeft ? &right : &left,
5099             nullptr);
5100         return panda::JSValueRef::Undefined(vm);
5101     }
5102 
5103     ParsePadding(vm, secondArg, topDimen, top, resObj);
5104     ParsePadding(vm, thirdArg, rightDimen, right, resObj);
5105     ParsePadding(vm, forthArg, bottomDimen, bottom, resObj);
5106     ParsePadding(vm, fifthArg, leftDimen, left, resObj);
5107     auto rawPtr = static_cast<void*>(&resObj);
5108     GetArkUINodeModifiers()->getCommonModifier()->setPadding(nativeNode, &top, &right, &bottom, &left, rawPtr);
5109 
5110     return panda::JSValueRef::Undefined(vm);
5111 }
5112 
ResetPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)5113 ArkUINativeModuleValue CommonBridge::ResetPadding(ArkUIRuntimeCallInfo *runtimeCallInfo)
5114 {
5115     EcmaVM *vm = runtimeCallInfo->GetVM();
5116     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5117     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5118     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5119     GetArkUINodeModifiers()->getCommonModifier()->resetPadding(nativeNode);
5120     return panda::JSValueRef::Undefined(vm);
5121 }
5122 
ParseLocalizedMargin(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimen,ArkUISizeType & result)5123 bool ParseLocalizedMargin(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& dimen, ArkUISizeType& result)
5124 {
5125     if (ArkTSUtils::ParseJsLengthMetrics(vm, value, dimen)) {
5126         result.unit = static_cast<int8_t>(dimen.Unit());
5127         if (dimen.CalcValue() != "") {
5128             result.string = dimen.CalcValue().c_str();
5129         } else {
5130             result.value = dimen.Value();
5131         }
5132         return true;
5133     }
5134     return false;
5135 }
5136 
ParseMargin(const EcmaVM * vm,const Local<JSValueRef> & value,CalcDimension & dimen,ArkUISizeType & result,std::vector<RefPtr<ResourceObject>> & resObjs)5137 void ParseMargin(const EcmaVM* vm, const Local<JSValueRef>& value, CalcDimension& dimen, ArkUISizeType& result,
5138     std::vector<RefPtr<ResourceObject>>& resObjs)
5139 {
5140     RefPtr<ResourceObject> resObj;
5141     if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen, resObj)) {
5142         result.unit = static_cast<int8_t>(dimen.Unit());
5143         if (dimen.CalcValue() != "") {
5144             result.string = dimen.CalcValue().c_str();
5145         } else {
5146             result.value = dimen.Value();
5147         }
5148     }
5149     if (SystemProperties::ConfigChangePerform()) {
5150         resObjs.push_back(resObj);
5151     }
5152 }
5153 
ParseMarginLengthMetrics(EcmaVM * vm,Local<JSValueRef> arg,CalcDimension & dimension,ArkUISizeType & sizeType,bool & isLengthMetrics)5154 void ParseMarginLengthMetrics(EcmaVM* vm, Local<JSValueRef> arg, CalcDimension& dimension, ArkUISizeType& sizeType,
5155     bool& isLengthMetrics)
5156 {
5157     if (arg->IsObject(vm)) {
5158         isLengthMetrics |= ParseLocalizedMargin(vm, arg, dimension, sizeType);
5159     }
5160 }
5161 
SetMargin(ArkUIRuntimeCallInfo * runtimeCallInfo)5162 ArkUINativeModuleValue CommonBridge::SetMargin(ArkUIRuntimeCallInfo *runtimeCallInfo)
5163 {
5164     EcmaVM *vm = runtimeCallInfo->GetVM();
5165     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5166     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5167     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5168     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5169     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5170     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
5171     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
5172     ArkUISizeType top = { 0.0, static_cast<int8_t>(DimensionUnit::VP), nullptr };
5173     ArkUISizeType right = { 0.0, static_cast<int8_t>(DimensionUnit::VP), nullptr };
5174     ArkUISizeType bottom = { 0.0, static_cast<int8_t>(DimensionUnit::VP), nullptr };
5175     ArkUISizeType left = { 0.0, static_cast<int8_t>(DimensionUnit::VP), nullptr };
5176     CalcDimension topDimen(0, DimensionUnit::VP);
5177     CalcDimension rightDimen(0, DimensionUnit::VP);
5178     CalcDimension bottomDimen(0, DimensionUnit::VP);
5179     CalcDimension leftDimen(0, DimensionUnit::VP);
5180     std::vector<RefPtr<ResourceObject>> resObj;
5181 
5182     bool isLengthMetrics = false;
5183     ParseMarginLengthMetrics(vm, secondArg, topDimen, top, isLengthMetrics);
5184     ParseMarginLengthMetrics(vm, thirdArg, rightDimen, right, isLengthMetrics);
5185     ParseMarginLengthMetrics(vm, forthArg, bottomDimen, bottom, isLengthMetrics);
5186     ParseMarginLengthMetrics(vm, fifthArg, leftDimen, left, isLengthMetrics);
5187     if (isLengthMetrics) {
5188         auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
5189         GetArkUINodeModifiers()->getCommonModifier()->setMargin(nativeNode,
5190             &top,
5191             isRightToLeft ? &left : &right,
5192             &bottom,
5193             isRightToLeft ? &right : &left,
5194             nullptr);
5195         ParseNullptrResObj(resObj, NUM_4);
5196         return panda::JSValueRef::Undefined(vm);
5197     }
5198     ParseMargin(vm, secondArg, topDimen, top, resObj);
5199     ParseMargin(vm, thirdArg, rightDimen, right, resObj);
5200     ParseMargin(vm, forthArg, bottomDimen, bottom, resObj);
5201     ParseMargin(vm, fifthArg, leftDimen, left, resObj);
5202     auto rawPtr = static_cast<void*>(&resObj);
5203     GetArkUINodeModifiers()->getCommonModifier()->setMargin(nativeNode, &top, &right, &bottom, &left, rawPtr);
5204     return panda::JSValueRef::Undefined(vm);
5205 }
5206 
ResetMargin(ArkUIRuntimeCallInfo * runtimeCallInfo)5207 ArkUINativeModuleValue CommonBridge::ResetMargin(ArkUIRuntimeCallInfo *runtimeCallInfo)
5208 {
5209     EcmaVM *vm = runtimeCallInfo->GetVM();
5210     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5211     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5212     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5213     GetArkUINodeModifiers()->getCommonModifier()->resetMargin(nativeNode);
5214     return panda::JSValueRef::Undefined(vm);
5215 }
5216 
SetSafeAreaPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)5217 ArkUINativeModuleValue CommonBridge::SetSafeAreaPadding(ArkUIRuntimeCallInfo* runtimeCallInfo)
5218 {
5219     EcmaVM* vm = runtimeCallInfo->GetVM();
5220     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5221     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5222     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5223     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5224     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5225     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
5226     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
5227     struct ArkUISizeType top = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5228     struct ArkUISizeType end = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5229     struct ArkUISizeType bottom = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5230     struct ArkUISizeType start = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
5231     CalcDimension topDimen(0, DimensionUnit::VP);
5232     CalcDimension endDimen(0, DimensionUnit::VP);
5233     CalcDimension bottomDimen(0, DimensionUnit::VP);
5234     CalcDimension startDimen(0, DimensionUnit::VP);
5235     bool isLengthMetrics = false;
5236     std::vector<RefPtr<ResourceObject>> resObj;
5237     if (secondArg->IsObject(vm)) {
5238         isLengthMetrics |= ParseLocalizedPadding(vm, secondArg, topDimen, top);
5239     }
5240     if (thirdArg->IsObject(vm)) {
5241         isLengthMetrics |= ParseLocalizedPadding(vm, thirdArg, endDimen, end);
5242     }
5243     if (forthArg->IsObject(vm)) {
5244         isLengthMetrics |= ParseLocalizedPadding(vm, forthArg, bottomDimen, bottom);
5245     }
5246     if (fifthArg->IsObject(vm)) {
5247         isLengthMetrics |= ParseLocalizedPadding(vm, fifthArg, startDimen, start);
5248     }
5249     if (!isLengthMetrics) {
5250         ParsePadding(vm, secondArg, topDimen, top, resObj);
5251         ParsePadding(vm, thirdArg, endDimen, end, resObj);
5252         ParsePadding(vm, forthArg, bottomDimen, bottom, resObj);
5253         ParsePadding(vm, fifthArg, startDimen, start, resObj);
5254     } else {
5255         ParseNullptrResObj(resObj, NUM_4);
5256     }
5257     struct ArkUIPaddingType localizedPadding;
5258     localizedPadding.top = top;
5259     localizedPadding.end = end;
5260     localizedPadding.bottom = bottom;
5261     localizedPadding.start = start;
5262     auto rawPtr = static_cast<void*>(&resObj);
5263     GetArkUINodeModifiers()->getCommonModifier()->setSafeAreaPadding(nativeNode, &localizedPadding, isLengthMetrics,
5264         rawPtr);
5265     return panda::JSValueRef::Undefined(vm);
5266 }
5267 
ResetSafeAreaPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)5268 ArkUINativeModuleValue CommonBridge::ResetSafeAreaPadding(ArkUIRuntimeCallInfo *runtimeCallInfo)
5269 {
5270     EcmaVM *vm = runtimeCallInfo->GetVM();
5271     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5272     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5273     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5274     GetArkUINodeModifiers()->getCommonModifier()->resetSafeAreaPadding(nativeNode);
5275     return panda::JSValueRef::Undefined(vm);
5276 }
5277 
SetMarkAnchor(ArkUIRuntimeCallInfo * runtimeCallInfo)5278 ArkUINativeModuleValue CommonBridge::SetMarkAnchor(ArkUIRuntimeCallInfo* runtimeCallInfo)
5279 {
5280     EcmaVM* vm = runtimeCallInfo->GetVM();
5281     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5282     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5283     Local<JSValueRef> xArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5284     Local<JSValueRef> yArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5285     auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value());
5286     CalcDimension x(0.0, DimensionUnit::VP);
5287     CalcDimension y(0.0, DimensionUnit::VP);
5288     RefPtr<ResourceObject> xResObj;
5289     RefPtr<ResourceObject> yResObj;
5290     bool useLengthMetrics = ArkTSUtils::ParseJsLengthMetrics(vm, xArg, x);
5291     useLengthMetrics = ArkTSUtils::ParseJsLengthMetrics(vm, yArg, y) || useLengthMetrics;
5292     if (useLengthMetrics && AceApplicationInfo::GetInstance().IsRightToLeft()) {
5293         x.SetValue(-x.Value());
5294     }
5295     bool hasX = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, xArg, x, DimensionUnit::VP, xResObj);
5296     bool hasY = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, yArg, y, DimensionUnit::VP, yResObj);
5297     if (useLengthMetrics || hasX || hasY) {
5298         auto xRawPtr = AceType::RawPtr(xResObj);
5299         auto yRawPtr = AceType::RawPtr(yResObj);
5300         GetArkUINodeModifiers()->getCommonModifier()->setMarkAnchor(
5301             nativeNode, x.Value(), static_cast<int32_t>(x.Unit()), y.Value(), static_cast<int32_t>(y.Unit()),
5302             xRawPtr, yRawPtr);
5303     } else {
5304         GetArkUINodeModifiers()->getCommonModifier()->resetMarkAnchor(nativeNode);
5305     }
5306     return panda::JSValueRef::Undefined(vm);
5307 }
5308 
ResetMarkAnchor(ArkUIRuntimeCallInfo * runtimeCallInfo)5309 ArkUINativeModuleValue CommonBridge::ResetMarkAnchor(ArkUIRuntimeCallInfo *runtimeCallInfo)
5310 {
5311     EcmaVM *vm = runtimeCallInfo->GetVM();
5312     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5313     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(0);
5314     auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value());
5315     GetArkUINodeModifiers()->getCommonModifier()->resetMarkAnchor(nativeNode);
5316     return panda::JSValueRef::Undefined(vm);
5317 }
5318 
SetVisibility(ArkUIRuntimeCallInfo * runtimeCallInfo)5319 ArkUINativeModuleValue CommonBridge::SetVisibility(ArkUIRuntimeCallInfo *runtimeCallInfo)
5320 {
5321     EcmaVM *vm = runtimeCallInfo->GetVM();
5322     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5323     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5324     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
5325     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5326     int32_t value = 0;
5327     if (secondArg->IsNumber()) {
5328         value = secondArg->Int32Value(vm);
5329         if (value<NUM_0 || value>NUM_2) {
5330             value = 0;
5331         }
5332     }
5333     GetArkUINodeModifiers()->getCommonModifier()->setVisibility(nativeNode, value);
5334     return panda::JSValueRef::Undefined(vm);
5335 }
5336 
ResetVisibility(ArkUIRuntimeCallInfo * runtimeCallInfo)5337 ArkUINativeModuleValue CommonBridge::ResetVisibility(ArkUIRuntimeCallInfo *runtimeCallInfo)
5338 {
5339     EcmaVM *vm = runtimeCallInfo->GetVM();
5340     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5341     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5342     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5343     GetArkUINodeModifiers()->getCommonModifier()->resetVisibility(nativeNode);
5344     return panda::JSValueRef::Undefined(vm);
5345 }
5346 
SetAccessibilityText(ArkUIRuntimeCallInfo * runtimeCallInfo)5347 ArkUINativeModuleValue CommonBridge::SetAccessibilityText(ArkUIRuntimeCallInfo* runtimeCallInfo)
5348 {
5349     EcmaVM* vm = runtimeCallInfo->GetVM();
5350     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5351     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5352     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
5353     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5354     std::string value;
5355     if (ArkTSUtils::ParseJsString(vm, secondArg, value)) {
5356         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityText(nativeNode, value.c_str());
5357     } else {
5358         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityText(nativeNode);
5359     }
5360     return panda::JSValueRef::Undefined(vm);
5361 }
5362 
ResetAccessibilityText(ArkUIRuntimeCallInfo * runtimeCallInfo)5363 ArkUINativeModuleValue CommonBridge::ResetAccessibilityText(ArkUIRuntimeCallInfo* runtimeCallInfo)
5364 {
5365     EcmaVM* vm = runtimeCallInfo->GetVM();
5366     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5367     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5368     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5369     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityText(nativeNode);
5370     return panda::JSValueRef::Undefined(vm);
5371 }
5372 
SetAccessibilityTextHint(ArkUIRuntimeCallInfo * runtimeCallInfo)5373 ArkUINativeModuleValue CommonBridge::SetAccessibilityTextHint(ArkUIRuntimeCallInfo* runtimeCallInfo)
5374 {
5375     EcmaVM* vm = runtimeCallInfo->GetVM();
5376     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5377     if (runtimeCallInfo->GetArgsNumber() < NUM_2) {
5378         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set text hint params num is invalid");
5379         return panda::NativePointerRef::New(vm, nullptr);
5380     }
5381     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5382     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
5383     if (!firstArg->IsNativePointer(vm)) {
5384         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set text hint first param is invalid");
5385         return panda::NativePointerRef::New(vm, nullptr);
5386     }
5387     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5388     std::string value;
5389     if (ArkTSUtils::ParseJsString(vm, secondArg, value)) {
5390         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityTextHint(nativeNode, value.c_str());
5391     } else {
5392         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityTextHint(nativeNode);
5393     }
5394     return panda::JSValueRef::Undefined(vm);
5395 }
5396 
ResetAccessibilityTextHint(ArkUIRuntimeCallInfo * runtimeCallInfo)5397 ArkUINativeModuleValue CommonBridge::ResetAccessibilityTextHint(ArkUIRuntimeCallInfo* runtimeCallInfo)
5398 {
5399     EcmaVM* vm = runtimeCallInfo->GetVM();
5400     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5401     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
5402         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset text hint params num is invalid");
5403         return panda::NativePointerRef::New(vm, nullptr);
5404     }
5405     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5406     if (!firstArg->IsNativePointer(vm)) {
5407         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset text hint first param is invalid");
5408         return panda::NativePointerRef::New(vm, nullptr);
5409     }
5410     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5411     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityTextHint(nativeNode);
5412     return panda::JSValueRef::Undefined(vm);
5413 }
5414 
SetAccessibilityChecked(ArkUIRuntimeCallInfo * runtimeCallInfo)5415 ArkUINativeModuleValue CommonBridge::SetAccessibilityChecked(ArkUIRuntimeCallInfo* runtimeCallInfo)
5416 {
5417     EcmaVM* vm = runtimeCallInfo->GetVM();
5418     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5419     if (runtimeCallInfo->GetArgsNumber() < NUM_2) {
5420         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set checked params num is invalid");
5421         return panda::NativePointerRef::New(vm, nullptr);
5422     }
5423     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5424     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5425     if (!firstArg->IsNativePointer(vm)) {
5426         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set checked first param is invalid");
5427         return panda::NativePointerRef::New(vm, nullptr);
5428     }
5429     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5430     if (secondArg->IsBoolean()) {
5431         bool boolValue = secondArg->ToBoolean(vm)->Value();
5432         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityChecked(nativeNode, boolValue);
5433     } else {
5434         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityChecked(nativeNode);
5435     }
5436     return panda::JSValueRef::Undefined(vm);
5437 }
5438 
ResetAccessibilityChecked(ArkUIRuntimeCallInfo * runtimeCallInfo)5439 ArkUINativeModuleValue CommonBridge::ResetAccessibilityChecked(ArkUIRuntimeCallInfo* runtimeCallInfo)
5440 {
5441     EcmaVM* vm = runtimeCallInfo->GetVM();
5442     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5443     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
5444         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset checked params num is invalid");
5445         return panda::NativePointerRef::New(vm, nullptr);
5446     }
5447     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5448     if (!firstArg->IsNativePointer(vm)) {
5449         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset checked first param is invalid");
5450         return panda::NativePointerRef::New(vm, nullptr);
5451     }
5452     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5453     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityChecked(nativeNode);
5454     return panda::JSValueRef::Undefined(vm);
5455 }
5456 
SetAccessibilitySelected(ArkUIRuntimeCallInfo * runtimeCallInfo)5457 ArkUINativeModuleValue CommonBridge::SetAccessibilitySelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
5458 {
5459     EcmaVM* vm = runtimeCallInfo->GetVM();
5460     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5461     if (runtimeCallInfo->GetArgsNumber() < NUM_2) {
5462         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set selected params num is invalid");
5463         return panda::NativePointerRef::New(vm, nullptr);
5464     }
5465     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5466     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5467     if (!firstArg->IsNativePointer(vm)) {
5468         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "set selected first param is invalid");
5469         return panda::NativePointerRef::New(vm, nullptr);
5470     }
5471     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5472     if (secondArg->IsBoolean()) {
5473         bool boolValue = secondArg->ToBoolean(vm)->Value();
5474         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilitySelected(nativeNode, boolValue);
5475     } else {
5476         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilitySelected(nativeNode);
5477     }
5478     return panda::JSValueRef::Undefined(vm);
5479 }
5480 
ResetAccessibilitySelected(ArkUIRuntimeCallInfo * runtimeCallInfo)5481 ArkUINativeModuleValue CommonBridge::ResetAccessibilitySelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
5482 {
5483     EcmaVM* vm = runtimeCallInfo->GetVM();
5484     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5485     if (runtimeCallInfo->GetArgsNumber() < NUM_1) {
5486         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset selected params num is invalid");
5487         return panda::NativePointerRef::New(vm, nullptr);
5488     }
5489     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5490     if (!firstArg->IsNativePointer(vm)) {
5491         TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "reset selected first param is invalid");
5492         return panda::NativePointerRef::New(vm, nullptr);
5493     }
5494     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5495     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilitySelected(nativeNode);
5496     return panda::JSValueRef::Undefined(vm);
5497 }
5498 
SetConstraintSize(ArkUIRuntimeCallInfo * runtimeCallInfo)5499 ArkUINativeModuleValue CommonBridge::SetConstraintSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
5500 {
5501     EcmaVM* vm = runtimeCallInfo->GetVM();
5502     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5503     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5504     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5505     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5506     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
5507     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
5508     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5509     CalcDimension minWidth;
5510     CalcDimension maxWidth;
5511     CalcDimension minHeight;
5512     CalcDimension maxHeight;
5513     struct ArkUISizeType minWidthValue = {0.0, 0};
5514     struct ArkUISizeType maxWidthValue = {0.0, 0};
5515     struct ArkUISizeType minHeightValue = {0.0, 0};
5516     struct ArkUISizeType maxHeightValue = {0.0, 0};
5517 
5518     RefPtr<ResourceObject> minWidthResObj;
5519     RefPtr<ResourceObject> maxWidthResObj;
5520     RefPtr<ResourceObject> minHeightResObj;
5521     RefPtr<ResourceObject> maxHeightResObj;
5522     bool version10OrLarger = Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN);
5523     if (ArkTSUtils::ParseJsDimensionVp(vm, secondArg, minWidth, minWidthResObj, false)) {
5524         if (minWidth.CalcValue() != "") {
5525             minWidthValue.string = minWidth.CalcValue().c_str();
5526         } else {
5527             minWidthValue.value = minWidth.Value();
5528             minWidthValue.unit = static_cast<int8_t>(minWidth.Unit());
5529         }
5530         auto minWidthRawResPtr = AceType::RawPtr(minWidthResObj);
5531         GetArkUINodeModifiers()->getCommonModifier()->setMinWidth(nativeNode, &minWidthValue, minWidthRawResPtr);
5532     } else if (version10OrLarger) {
5533         GetArkUINodeModifiers()->getCommonModifier()->resetMinWidth(nativeNode);
5534     }
5535 
5536     if (ArkTSUtils::ParseJsDimensionVp(vm, thirdArg, maxWidth, maxWidthResObj, false)) {
5537         if (maxWidth.CalcValue() != "") {
5538             maxWidthValue.string = maxWidth.CalcValue().c_str();
5539         } else {
5540             maxWidthValue.value = maxWidth.Value();
5541             maxWidthValue.unit = static_cast<int8_t>(maxWidth.Unit());
5542         }
5543         auto maxWidthRawResPtr = AceType::RawPtr(maxWidthResObj);
5544         GetArkUINodeModifiers()->getCommonModifier()->setMaxWidth(nativeNode, &maxWidthValue, maxWidthRawResPtr);
5545     } else if (version10OrLarger) {
5546         GetArkUINodeModifiers()->getCommonModifier()->resetMaxWidth(nativeNode);
5547     }
5548 
5549     if (ArkTSUtils::ParseJsDimensionVp(vm, forthArg, minHeight, minHeightResObj, false)) {
5550         if (minHeight.CalcValue() != "") {
5551             minHeightValue.string = minHeight.CalcValue().c_str();
5552         } else {
5553             minHeightValue.value = minHeight.Value();
5554             minHeightValue.unit = static_cast<int8_t>(minHeight.Unit());
5555         }
5556         auto minHeightRawResPtr = AceType::RawPtr(minHeightResObj);
5557         GetArkUINodeModifiers()->getCommonModifier()->setMinHeight(nativeNode, &minHeightValue, minHeightRawResPtr);
5558     } else if (version10OrLarger) {
5559         GetArkUINodeModifiers()->getCommonModifier()->resetMinHeight(nativeNode);
5560     }
5561 
5562     if (ArkTSUtils::ParseJsDimensionVp(vm, fifthArg, maxHeight, maxHeightResObj, false)) {
5563         if (maxHeight.CalcValue() != "") {
5564             maxHeightValue.string = maxHeight.CalcValue().c_str();
5565         } else {
5566             maxHeightValue.value = maxHeight.Value();
5567             maxHeightValue.unit = static_cast<int8_t>(maxHeight.Unit());
5568         }
5569         auto maxHeightRawResPtr = AceType::RawPtr(maxHeightResObj);
5570         GetArkUINodeModifiers()->getCommonModifier()->setMaxHeight(nativeNode, &maxHeightValue, maxHeightRawResPtr);
5571     } else if (version10OrLarger) {
5572         GetArkUINodeModifiers()->getCommonModifier()->resetMaxHeight(nativeNode);
5573     }
5574     return panda::JSValueRef::Undefined(vm);
5575 }
5576 
ResetConstraintSize(ArkUIRuntimeCallInfo * runtimeCallInfo)5577 ArkUINativeModuleValue CommonBridge::ResetConstraintSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
5578 {
5579     EcmaVM* vm = runtimeCallInfo->GetVM();
5580     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5581     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5582     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5583     GetArkUINodeModifiers()->getCommonModifier()->resetMaxHeight(nativeNode);
5584     GetArkUINodeModifiers()->getCommonModifier()->resetMaxWidth(nativeNode);
5585     GetArkUINodeModifiers()->getCommonModifier()->resetMinHeight(nativeNode);
5586     GetArkUINodeModifiers()->getCommonModifier()->resetMinWidth(nativeNode);
5587     return panda::JSValueRef::Undefined(vm);
5588 }
5589 
SetDirection(ArkUIRuntimeCallInfo * runtimeCallInfo)5590 ArkUINativeModuleValue CommonBridge::SetDirection(ArkUIRuntimeCallInfo* runtimeCallInfo)
5591 {
5592     EcmaVM* vm = runtimeCallInfo->GetVM();
5593     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5594     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5595     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5596     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5597     std::string dir;
5598     int32_t direction = NUM_3;
5599     if (secondArg->IsString(vm)) {
5600         dir = secondArg->ToString(vm)->ToString(vm);
5601         if (dir == "Ltr") {
5602             direction = NUM_0;
5603         } else if (dir == "Rtl") {
5604             direction = NUM_1;
5605         } else if (dir == "Auto") {
5606             direction = NUM_3;
5607         } else if (dir == "undefined" && Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
5608             direction = NUM_3;
5609         }
5610     }
5611     GetArkUINodeModifiers()->getCommonModifier()->setDirection(nativeNode, direction);
5612     return panda::JSValueRef::Undefined(vm);
5613 }
5614 
ResetDirection(ArkUIRuntimeCallInfo * runtimeCallInfo)5615 ArkUINativeModuleValue CommonBridge::ResetDirection(ArkUIRuntimeCallInfo* runtimeCallInfo)
5616 {
5617     EcmaVM* vm = runtimeCallInfo->GetVM();
5618     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5619     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5620     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5621     GetArkUINodeModifiers()->getCommonModifier()->resetDirection(nativeNode);
5622     return panda::JSValueRef::Undefined(vm);
5623 }
5624 
SetLayoutWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)5625 ArkUINativeModuleValue CommonBridge::SetLayoutWeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
5626 {
5627     EcmaVM* vm = runtimeCallInfo->GetVM();
5628     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5629     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5630     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5631     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5632     float layoutWeight = 0.0f;
5633     if (secondArg->IsNumber()) {
5634         if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE)) {
5635             layoutWeight = secondArg->ToNumber(vm)->Value();
5636         } else {
5637             layoutWeight = secondArg->Int32Value(vm);
5638         }
5639     } else if (secondArg->IsString(vm)) {
5640         if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE)) {
5641             layoutWeight = StringUtils::StringToFloat(secondArg->ToString(vm)->ToString(vm));
5642         } else {
5643             layoutWeight = StringUtils::StringToInt(secondArg->ToString(vm)->ToString(vm));
5644         }
5645     }
5646     GetArkUINodeModifiers()->getCommonModifier()->setLayoutWeight(nativeNode, layoutWeight);
5647     return panda::JSValueRef::Undefined(vm);
5648 }
5649 
ResetLayoutWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)5650 ArkUINativeModuleValue CommonBridge::ResetLayoutWeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
5651 {
5652     EcmaVM* vm = runtimeCallInfo->GetVM();
5653     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5654     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
5655     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5656     GetArkUINodeModifiers()->getCommonModifier()->resetLayoutWeight(nativeNode);
5657     return panda::JSValueRef::Undefined(vm);
5658 }
5659 
SetSize(ArkUIRuntimeCallInfo * runtimeCallInfo)5660 ArkUINativeModuleValue CommonBridge::SetSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
5661 {
5662     EcmaVM* vm = runtimeCallInfo->GetVM();
5663     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5664     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5665     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5666     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5667     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5668     CalcDimension wVal(0.0, DimensionUnit::VP);
5669     CalcDimension hVal(0.0, DimensionUnit::VP);
5670     RefPtr<ResourceObject> widthResObj;
5671     RefPtr<ResourceObject> heightResObj;
5672     ParseCalcDimension(vm, nativeNode, secondArg, wVal, true, widthResObj);
5673     ParseCalcDimension(vm, nativeNode, thirdArg, hVal, false, heightResObj);
5674     return panda::JSValueRef::Undefined(vm);
5675 }
5676 
ResetSize(ArkUIRuntimeCallInfo * runtimeCallInfo)5677 ArkUINativeModuleValue CommonBridge::ResetSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
5678 {
5679     EcmaVM* vm = runtimeCallInfo->GetVM();
5680     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5681     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5682     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5683     GetArkUINodeModifiers()->getCommonModifier()->resetWidth(nativeNode);
5684     GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode);
5685     return panda::JSValueRef::Undefined(vm);
5686 }
5687 
SetAlignSelf(ArkUIRuntimeCallInfo * runtimeCallInfo)5688 ArkUINativeModuleValue CommonBridge::SetAlignSelf(ArkUIRuntimeCallInfo* runtimeCallInfo)
5689 {
5690     EcmaVM* vm = runtimeCallInfo->GetVM();
5691     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5692     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5693     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5694     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5695 
5696     if (secondArg->IsNumber() && secondArg->ToNumber(vm)->Value() >= 0 &&
5697         secondArg->ToNumber(vm)->Value() <= MAX_ALIGN_VALUE) {
5698         GetArkUINodeModifiers()->getCommonModifier()->setAlignSelf(nativeNode, secondArg->Int32Value(vm));
5699     } else {
5700         GetArkUINodeModifiers()->getCommonModifier()->resetAlignSelf(nativeNode);
5701     }
5702     return panda::JSValueRef::Undefined(vm);
5703 }
5704 
ResetAlignSelf(ArkUIRuntimeCallInfo * runtimeCallInfo)5705 ArkUINativeModuleValue CommonBridge::ResetAlignSelf(ArkUIRuntimeCallInfo* runtimeCallInfo)
5706 {
5707     EcmaVM* vm = runtimeCallInfo->GetVM();
5708     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5709     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5710     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5711     GetArkUINodeModifiers()->getCommonModifier()->resetAlignSelf(nativeNode);
5712     return panda::JSValueRef::Undefined(vm);
5713 }
5714 
SetAspectRatio(ArkUIRuntimeCallInfo * runtimeCallInfo)5715 ArkUINativeModuleValue CommonBridge::SetAspectRatio(ArkUIRuntimeCallInfo* runtimeCallInfo)
5716 {
5717     EcmaVM* vm = runtimeCallInfo->GetVM();
5718     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5719     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5720     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5721     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5722 
5723     if (secondArg->IsNumber()) {
5724         double value = secondArg->ToNumber(vm)->Value();
5725         GetArkUINodeModifiers()->getCommonModifier()->setAspectRatio(nativeNode, value);
5726     } else {
5727         GetArkUINodeModifiers()->getCommonModifier()->resetAspectRatio(nativeNode);
5728     }
5729     return panda::JSValueRef::Undefined(vm);
5730 }
5731 
ResetAspectRatio(ArkUIRuntimeCallInfo * runtimeCallInfo)5732 ArkUINativeModuleValue CommonBridge::ResetAspectRatio(ArkUIRuntimeCallInfo* runtimeCallInfo)
5733 {
5734     EcmaVM* vm = runtimeCallInfo->GetVM();
5735     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5736     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5737     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5738     GetArkUINodeModifiers()->getCommonModifier()->resetAspectRatio(nativeNode);
5739     return panda::JSValueRef::Undefined(vm);
5740 }
5741 
SetFlexGrow(ArkUIRuntimeCallInfo * runtimeCallInfo)5742 ArkUINativeModuleValue CommonBridge::SetFlexGrow(ArkUIRuntimeCallInfo* runtimeCallInfo)
5743 {
5744     EcmaVM* vm = runtimeCallInfo->GetVM();
5745     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5746     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5747     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5748     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5749 
5750     if (secondArg->IsNumber()) {
5751         double value = secondArg->ToNumber(vm)->Value();
5752         GetArkUINodeModifiers()->getCommonModifier()->setFlexGrow(nativeNode, value);
5753     } else {
5754         GetArkUINodeModifiers()->getCommonModifier()->resetFlexGrow(nativeNode);
5755     }
5756     return panda::JSValueRef::Undefined(vm);
5757 }
5758 
ResetFlexGrow(ArkUIRuntimeCallInfo * runtimeCallInfo)5759 ArkUINativeModuleValue CommonBridge::ResetFlexGrow(ArkUIRuntimeCallInfo* runtimeCallInfo)
5760 {
5761     EcmaVM* vm = runtimeCallInfo->GetVM();
5762     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5763     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5764     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5765     GetArkUINodeModifiers()->getCommonModifier()->resetFlexGrow(nativeNode);
5766     return panda::JSValueRef::Undefined(vm);
5767 }
5768 
SetFlexShrink(ArkUIRuntimeCallInfo * runtimeCallInfo)5769 ArkUINativeModuleValue CommonBridge::SetFlexShrink(ArkUIRuntimeCallInfo* runtimeCallInfo)
5770 {
5771     EcmaVM* vm = runtimeCallInfo->GetVM();
5772     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5773     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5774     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5775     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5776 
5777     if (secondArg->IsNumber()) {
5778         double value = secondArg->ToNumber(vm)->Value();
5779         GetArkUINodeModifiers()->getCommonModifier()->setFlexShrink(nativeNode, value);
5780     } else {
5781         GetArkUINodeModifiers()->getCommonModifier()->resetFlexShrink(nativeNode);
5782     }
5783     return panda::JSValueRef::Undefined(vm);
5784 }
5785 
ResetFlexShrink(ArkUIRuntimeCallInfo * runtimeCallInfo)5786 ArkUINativeModuleValue CommonBridge::ResetFlexShrink(ArkUIRuntimeCallInfo* runtimeCallInfo)
5787 {
5788     EcmaVM* vm = runtimeCallInfo->GetVM();
5789     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5790     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5791     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5792     GetArkUINodeModifiers()->getCommonModifier()->resetFlexShrink(nativeNode);
5793     return panda::JSValueRef::Undefined(vm);
5794 }
5795 
SetGridOffset(ArkUIRuntimeCallInfo * runtimeCallInfo)5796 ArkUINativeModuleValue CommonBridge::SetGridOffset(ArkUIRuntimeCallInfo *runtimeCallInfo)
5797 {
5798     EcmaVM* vm = runtimeCallInfo->GetVM();
5799     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5800     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5801     Local<JSValueRef> offsetArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5802     auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value());
5803     int32_t offset = 0;
5804     if (offsetArg->IsNumber()) {
5805         offset = offsetArg->Int32Value(vm);
5806         GetArkUINodeModifiers()->getCommonModifier()->setGridOffset(nativeNode, offset);
5807     } else {
5808         GetArkUINodeModifiers()->getCommonModifier()->resetGridOffset(nativeNode);
5809     }
5810     return panda::JSValueRef::Undefined(vm);
5811 }
5812 
ResetGridOffset(ArkUIRuntimeCallInfo * runtimeCallInfo)5813 ArkUINativeModuleValue CommonBridge::ResetGridOffset(ArkUIRuntimeCallInfo* runtimeCallInfo)
5814 {
5815     EcmaVM* vm = runtimeCallInfo->GetVM();
5816     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5817     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5818     auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value());
5819     GetArkUINodeModifiers()->getCommonModifier()->resetGridOffset(nativeNode);
5820     return panda::JSValueRef::Undefined(vm);
5821 }
5822 
SetGridSpan(ArkUIRuntimeCallInfo * runtimeCallInfo)5823 ArkUINativeModuleValue CommonBridge::SetGridSpan(ArkUIRuntimeCallInfo *runtimeCallInfo)
5824 {
5825     EcmaVM* vm = runtimeCallInfo->GetVM();
5826     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5827     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5828     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5829     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5830     int32_t value = 0;
5831     if (secondArg->IsNumber()) {
5832         value = secondArg->Int32Value(vm);
5833         GetArkUINodeModifiers()->getCommonModifier()->setGridSpan(nativeNode, value);
5834     } else {
5835         GetArkUINodeModifiers()->getCommonModifier()->resetGridSpan(nativeNode);
5836     }
5837     return panda::JSValueRef::Undefined(vm);
5838 }
5839 
ResetGridSpan(ArkUIRuntimeCallInfo * runtimeCallInfo)5840 ArkUINativeModuleValue CommonBridge::ResetGridSpan(ArkUIRuntimeCallInfo *runtimeCallInfo)
5841 {
5842     EcmaVM* vm = runtimeCallInfo->GetVM();
5843     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5844     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5845     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5846     GetArkUINodeModifiers()->getCommonModifier()->resetGridSpan(nativeNode);
5847     return panda::JSValueRef::Undefined(vm);
5848 }
5849 
SetIgnoreLayoutSafeArea(ArkUIRuntimeCallInfo * runtimeCallInfo)5850 ArkUINativeModuleValue CommonBridge::SetIgnoreLayoutSafeArea(ArkUIRuntimeCallInfo* runtimeCallInfo)
5851 {
5852     EcmaVM* vm = runtimeCallInfo->GetVM();
5853     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5854     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5855     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5856     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5857     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5858     std::string typeCppStr = "";
5859     std::string edgesCppStr = "";
5860     LayoutSafeAreaType layoutSafeAreaType = NG::LAYOUT_SAFE_AREA_TYPE_SYSTEM;
5861     LayoutSafeAreaEdge layoutSafeAreaEdges = NG::LAYOUT_SAFE_AREA_EDGE_ALL;
5862     if (secondArg->IsString(vm)) {
5863         typeCppStr = secondArg->ToString(vm)->ToString(vm);
5864         layoutSafeAreaType = ParseLayoutSafeAreaTypeStr(typeCppStr);
5865     }
5866     if (thirdArg->IsString(vm)) {
5867         edgesCppStr = thirdArg->ToString(vm)->ToString(vm);
5868         layoutSafeAreaEdges = ParseLayoutSafeAreaEdgesStr(edgesCppStr);
5869     }
5870     GetArkUINodeModifiers()->getCommonModifier()->setIgnoreLayoutSafeArea(
5871         nativeNode, layoutSafeAreaType, layoutSafeAreaEdges);
5872     return panda::JSValueRef::Undefined(vm);
5873 }
5874 
ResetIgnoreLayoutSafeArea(ArkUIRuntimeCallInfo * runtimeCallInfo)5875 ArkUINativeModuleValue CommonBridge::ResetIgnoreLayoutSafeArea(ArkUIRuntimeCallInfo* runtimeCallInfo)
5876 {
5877     EcmaVM* vm = runtimeCallInfo->GetVM();
5878     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5879     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5880     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5881     GetArkUINodeModifiers()->getCommonModifier()->resetIgnoreLayoutSafeArea(nativeNode);
5882     return panda::JSValueRef::Undefined(vm);
5883 }
5884 
SetExpandSafeArea(ArkUIRuntimeCallInfo * runtimeCallInfo)5885 ArkUINativeModuleValue CommonBridge::SetExpandSafeArea(ArkUIRuntimeCallInfo *runtimeCallInfo)
5886 {
5887     EcmaVM* vm = runtimeCallInfo->GetVM();
5888     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5889     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5890     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5891     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5892     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5893     std::string typeCppStr = "";
5894     std::string edgesCppStr = "";
5895     uint32_t safeAreaType = NG::SAFE_AREA_TYPE_NONE;
5896     uint32_t safeAreaEdge = NG::SAFE_AREA_EDGE_NONE;
5897     if (secondArg->IsString(vm)) {
5898         typeCppStr = secondArg->ToString(vm)->ToString(vm);
5899         safeAreaType = ParseStrToUint(typeCppStr);
5900     } else {
5901         safeAreaType = NG::SAFE_AREA_TYPE_ALL;
5902     }
5903 
5904     if (thirdArg->IsString(vm)) {
5905         edgesCppStr = thirdArg->ToString(vm)->ToString(vm);
5906         safeAreaEdge = ParseStrToUint(edgesCppStr);
5907     } else {
5908         safeAreaEdge = NG::SAFE_AREA_EDGE_ALL;
5909     }
5910     GetArkUINodeModifiers()->getCommonModifier()->setExpandSafeArea(nativeNode, safeAreaType, safeAreaEdge);
5911     return panda::JSValueRef::Undefined(vm);
5912 }
5913 
ResetExpandSafeArea(ArkUIRuntimeCallInfo * runtimeCallInfo)5914 ArkUINativeModuleValue CommonBridge::ResetExpandSafeArea(ArkUIRuntimeCallInfo* runtimeCallInfo)
5915 {
5916     EcmaVM* vm = runtimeCallInfo->GetVM();
5917     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5918     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5919     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5920     GetArkUINodeModifiers()->getCommonModifier()->resetExpandSafeArea(nativeNode);
5921     return panda::JSValueRef::Undefined(vm);
5922 }
5923 
SetAlignRules(ArkUIRuntimeCallInfo * runtimeCallInfo)5924 ArkUINativeModuleValue CommonBridge::SetAlignRules(ArkUIRuntimeCallInfo* runtimeCallInfo)
5925 {
5926     EcmaVM* vm = runtimeCallInfo->GetVM();
5927     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5928     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5929     Local<JSValueRef> leftArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5930     Local<JSValueRef> middleArg = runtimeCallInfo->GetCallArgRef(NUM_2);
5931     Local<JSValueRef> rightArg = runtimeCallInfo->GetCallArgRef(NUM_3);
5932     Local<JSValueRef> topArg = runtimeCallInfo->GetCallArgRef(NUM_4);
5933     Local<JSValueRef> centerArg = runtimeCallInfo->GetCallArgRef(NUM_5);
5934     Local<JSValueRef> bottomArg = runtimeCallInfo->GetCallArgRef(NUM_6);
5935     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5936 
5937     auto anchors = std::make_unique<std::string []>(ALIGN_RULES_NUM);
5938     auto direction = std::make_unique<ArkUI_Int32 []>(ALIGN_RULES_NUM);
5939     for (int32_t i = 0; i < ALIGN_RULES_NUM; i++) {
5940         anchors[i] = "";
5941         direction[i] = ALIGN_DIRECTION_DEFAULT;
5942     }
5943     bool leftParseResult = ParseJsAlignRule(vm, leftArg, anchors[0], direction[0]);
5944     bool middleParseResult = ParseJsAlignRule(vm, middleArg, anchors[1], direction[1]);
5945     bool rightParseResult = ParseJsAlignRule(vm, rightArg, anchors[2], direction[2]);
5946     bool topParseResult = ParseJsAlignRule(vm, topArg, anchors[3], direction[3]);
5947     bool centerParseResult = ParseJsAlignRule(vm, centerArg, anchors[4], direction[4]);
5948     bool bottomParseResult = ParseJsAlignRule(vm, bottomArg, anchors[5], direction[5]);
5949     if (!leftParseResult && !middleParseResult && !rightParseResult && !topParseResult && !centerParseResult &&
5950         !bottomParseResult) {
5951         GetArkUINodeModifiers()->getCommonModifier()->resetAlignRules(nativeNode);
5952         return panda::JSValueRef::Undefined(vm);
5953     }
5954     auto realAnchors = std::make_unique<char* []>(ALIGN_RULES_NUM);
5955     for (int32_t i = 0; i < ALIGN_RULES_NUM; i++) {
5956         realAnchors[i] = const_cast<char*>(anchors[i].c_str());
5957     }
5958     GetArkUINodeModifiers()->getCommonModifier()->setAlignRules(nativeNode, realAnchors.get(), direction.get(),
5959         ALIGN_RULES_NUM);
5960     return panda::JSValueRef::Undefined(vm);
5961 }
5962 
ResetAlignRules(ArkUIRuntimeCallInfo * runtimeCallInfo)5963 ArkUINativeModuleValue CommonBridge::ResetAlignRules(ArkUIRuntimeCallInfo* runtimeCallInfo)
5964 {
5965     EcmaVM* vm = runtimeCallInfo->GetVM();
5966     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5967     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5968     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5969     GetArkUINodeModifiers()->getCommonModifier()->resetAlignRules(nativeNode);
5970     return panda::JSValueRef::Undefined(vm);
5971 }
5972 
SetFlexBasis(ArkUIRuntimeCallInfo * runtimeCallInfo)5973 ArkUINativeModuleValue CommonBridge::SetFlexBasis(ArkUIRuntimeCallInfo* runtimeCallInfo)
5974 {
5975     EcmaVM* vm = runtimeCallInfo->GetVM();
5976     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5977     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
5978     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
5979     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
5980     struct ArkUIStringAndFloat flexBasis { 0.0, nullptr};
5981     std::string tempValueStr = "";
5982     if (secondArg->IsNumber()) {
5983         flexBasis.value = secondArg->ToNumber(vm)->Value();
5984         GetArkUINodeModifiers()->getCommonModifier()->setFlexBasis(nativeNode, &flexBasis);
5985     } else if (secondArg->IsString(vm)) {
5986         tempValueStr = secondArg->ToString(vm)->ToString(vm);
5987         flexBasis.valueStr = tempValueStr.c_str();
5988         GetArkUINodeModifiers()->getCommonModifier()->setFlexBasis(nativeNode, &flexBasis);
5989     } else {
5990         GetArkUINodeModifiers()->getCommonModifier()->resetFlexBasis(nativeNode);
5991     }
5992     return panda::JSValueRef::Undefined(vm);
5993 }
5994 
ResetFlexBasis(ArkUIRuntimeCallInfo * runtimeCallInfo)5995 ArkUINativeModuleValue CommonBridge::ResetFlexBasis(ArkUIRuntimeCallInfo* runtimeCallInfo)
5996 {
5997     EcmaVM* vm = runtimeCallInfo->GetVM();
5998     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
5999     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6000     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6001     GetArkUINodeModifiers()->getCommonModifier()->resetFlexBasis(nativeNode);
6002     return panda::JSValueRef::Undefined(vm);
6003 }
6004 
SetAllowDrop(ArkUIRuntimeCallInfo * runtimeCallInfo)6005 ArkUINativeModuleValue CommonBridge::SetAllowDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
6006 {
6007     EcmaVM* vm = runtimeCallInfo->GetVM();
6008     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6009     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6010     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6011     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6012     if (secondArg->IsUndefined()) {
6013         GetArkUINodeModifiers()->getCommonModifier()->resetAllowDrop(nativeNode);
6014         return panda::JSValueRef::Undefined(vm);
6015     }
6016     Local<panda::ArrayRef> allowDropArray = static_cast<Local<panda::ArrayRef>>(secondArg);
6017     auto length = allowDropArray->Length(vm);
6018     if (length <= 0) {
6019         GetArkUINodeModifiers()->getCommonModifier()->resetAllowDrop(nativeNode);
6020         return panda::JSValueRef::Undefined(vm);
6021     }
6022     std::vector<std::string> keepStr(length);
6023     std::vector<const char*> strList;
6024     for (size_t i = 0; i < length; i++) {
6025         Local<JSValueRef> objValue = allowDropArray->GetValueAt(vm, secondArg, i);
6026         keepStr[i] = objValue->ToString(vm)->ToString(vm);
6027         strList.push_back(keepStr[i].c_str());
6028     }
6029     GetArkUINodeModifiers()->getCommonModifier()->setAllowDrop(nativeNode, strList.data(), strList.size());
6030     return panda::JSValueRef::Undefined(vm);
6031 }
6032 
ResetAllowDrop(ArkUIRuntimeCallInfo * runtimeCallInfo)6033 ArkUINativeModuleValue CommonBridge::ResetAllowDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
6034 {
6035     EcmaVM* vm = runtimeCallInfo->GetVM();
6036     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6037     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6038     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6039     GetArkUINodeModifiers()->getCommonModifier()->resetAllowDrop(nativeNode);
6040     return panda::JSValueRef::Undefined(vm);
6041 }
6042 
SetId(ArkUIRuntimeCallInfo * runtimeCallInfo)6043 ArkUINativeModuleValue CommonBridge::SetId(ArkUIRuntimeCallInfo* runtimeCallInfo)
6044 {
6045     EcmaVM* vm = runtimeCallInfo->GetVM();
6046     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6047     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6048     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6049     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6050     if (secondArg->IsString(vm)) {
6051         std::string stringValue = secondArg->ToString(vm)->ToString(vm);
6052         GetArkUINodeModifiers()->getCommonModifier()->setId(nativeNode, stringValue.c_str());
6053     } else {
6054         GetArkUINodeModifiers()->getCommonModifier()->resetId(nativeNode);
6055     }
6056     return panda::JSValueRef::Undefined(vm);
6057 }
6058 
ResetId(ArkUIRuntimeCallInfo * runtimeCallInfo)6059 ArkUINativeModuleValue CommonBridge::ResetId(ArkUIRuntimeCallInfo* runtimeCallInfo)
6060 {
6061     EcmaVM* vm = runtimeCallInfo->GetVM();
6062     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6063     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6064     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6065     GetArkUINodeModifiers()->getCommonModifier()->resetId(nativeNode);
6066     return panda::JSValueRef::Undefined(vm);
6067 }
6068 
SetKey(ArkUIRuntimeCallInfo * runtimeCallInfo)6069 ArkUINativeModuleValue CommonBridge::SetKey(ArkUIRuntimeCallInfo* runtimeCallInfo)
6070 {
6071     EcmaVM* vm = runtimeCallInfo->GetVM();
6072     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6073     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6074     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6075     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6076     if (secondArg->IsString(vm)) {
6077         std::string stringValue = secondArg->ToString(vm)->ToString(vm);
6078         GetArkUINodeModifiers()->getCommonModifier()->setKey(nativeNode, stringValue.c_str());
6079     } else {
6080         GetArkUINodeModifiers()->getCommonModifier()->resetKey(nativeNode);
6081     }
6082     return panda::JSValueRef::Undefined(vm);
6083 }
6084 
ResetKey(ArkUIRuntimeCallInfo * runtimeCallInfo)6085 ArkUINativeModuleValue CommonBridge::ResetKey(ArkUIRuntimeCallInfo* runtimeCallInfo)
6086 {
6087     EcmaVM* vm = runtimeCallInfo->GetVM();
6088     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6089     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6090     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6091     GetArkUINodeModifiers()->getCommonModifier()->resetKey(nativeNode);
6092     return panda::JSValueRef::Undefined(vm);
6093 }
6094 
SetRestoreId(ArkUIRuntimeCallInfo * runtimeCallInfo)6095 ArkUINativeModuleValue CommonBridge::SetRestoreId(ArkUIRuntimeCallInfo* runtimeCallInfo)
6096 {
6097     EcmaVM* vm = runtimeCallInfo->GetVM();
6098     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6099     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6100     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6101     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6102     if (secondArg->IsNumber()) {
6103         uint32_t value = secondArg->Uint32Value(vm);
6104         GetArkUINodeModifiers()->getCommonModifier()->setRestoreId(nativeNode, value);
6105     } else {
6106         GetArkUINodeModifiers()->getCommonModifier()->resetRestoreId(nativeNode);
6107     }
6108     return panda::JSValueRef::Undefined(vm);
6109 }
6110 
ResetRestoreId(ArkUIRuntimeCallInfo * runtimeCallInfo)6111 ArkUINativeModuleValue CommonBridge::ResetRestoreId(ArkUIRuntimeCallInfo* runtimeCallInfo)
6112 {
6113     EcmaVM* vm = runtimeCallInfo->GetVM();
6114     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6115     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6116     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6117     GetArkUINodeModifiers()->getCommonModifier()->resetRestoreId(nativeNode);
6118     return panda::JSValueRef::Undefined(vm);
6119 }
6120 
SetTabIndex(ArkUIRuntimeCallInfo * runtimeCallInfo)6121 ArkUINativeModuleValue CommonBridge::SetTabIndex(ArkUIRuntimeCallInfo* runtimeCallInfo)
6122 {
6123     EcmaVM* vm = runtimeCallInfo->GetVM();
6124     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6125     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6126     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6127     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6128     if (secondArg->IsNumber()) {
6129         int32_t index = secondArg->Int32Value(vm);
6130         GetArkUINodeModifiers()->getCommonModifier()->setTabIndex(nativeNode, index);
6131     } else {
6132         GetArkUINodeModifiers()->getCommonModifier()->resetTabIndex(nativeNode);
6133     }
6134     return panda::JSValueRef::Undefined(vm);
6135 }
6136 
ResetTabIndex(ArkUIRuntimeCallInfo * runtimeCallInfo)6137 ArkUINativeModuleValue CommonBridge::ResetTabIndex(ArkUIRuntimeCallInfo* runtimeCallInfo)
6138 {
6139     EcmaVM* vm = runtimeCallInfo->GetVM();
6140     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6141     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6142     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6143     GetArkUINodeModifiers()->getCommonModifier()->resetTabIndex(nativeNode);
6144     return panda::JSValueRef::Undefined(vm);
6145 }
6146 
SetObscured(ArkUIRuntimeCallInfo * runtimeCallInfo)6147 ArkUINativeModuleValue CommonBridge::SetObscured(ArkUIRuntimeCallInfo* runtimeCallInfo)
6148 {
6149     EcmaVM* vm = runtimeCallInfo->GetVM();
6150     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6151     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6152     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
6153     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6154 
6155     if (secondArg->IsUndefined() || !secondArg->IsArray(vm)) {
6156         GetArkUINodeModifiers()->getCommonModifier()->resetObscured(nativeNode);
6157         return panda::JSValueRef::Undefined(vm);
6158     }
6159     Local<panda::ArrayRef> transArray = static_cast<Local<panda::ArrayRef>>(secondArg);
6160     auto length = transArray->Length(vm);
6161     int32_t reasonArray[length];
6162 
6163     for (size_t i = 0; i < length; i++) {
6164         Local<JSValueRef> value = transArray->GetValueAt(vm, secondArg, i);
6165         reasonArray[i] = value->Int32Value(vm);
6166     }
6167     GetArkUINodeModifiers()->getCommonModifier()->setObscured(nativeNode, reasonArray, length);
6168     return panda::JSValueRef::Undefined(vm);
6169 }
6170 
ResetObscured(ArkUIRuntimeCallInfo * runtimeCallInfo)6171 ArkUINativeModuleValue CommonBridge::ResetObscured(ArkUIRuntimeCallInfo* runtimeCallInfo)
6172 {
6173     EcmaVM* vm = runtimeCallInfo->GetVM();
6174     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6175     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6176     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6177     GetArkUINodeModifiers()->getCommonModifier()->resetObscured(nativeNode);
6178     return panda::JSValueRef::Undefined(vm);
6179 }
6180 
SetForegroundEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)6181 ArkUINativeModuleValue CommonBridge::SetForegroundEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
6182 {
6183     EcmaVM* vm = runtimeCallInfo->GetVM();
6184     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6185     Local<JSValueRef> radiusArg = runtimeCallInfo->GetCallArgRef(1);
6186     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6187     CalcDimension radius;
6188     if (!ArkTSUtils::ParseJsDimensionVp(vm, radiusArg, radius) || LessNotEqual(radius.Value(), 0.0f)) {
6189         radius.SetValue(0.0f);
6190     }
6191     ArkUI_Float32 radiusArk = static_cast<ArkUI_Int32>(radius.Value());
6192     GetArkUINodeModifiers()->getCommonModifier()->setForegroundEffect(nativeNode, radiusArk);
6193     return panda::JSValueRef::Undefined(vm);
6194 }
6195 
ResetForegroundEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)6196 ArkUINativeModuleValue CommonBridge::ResetForegroundEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
6197 {
6198     EcmaVM* vm = runtimeCallInfo->GetVM();
6199     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6200     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6201     GetArkUINodeModifiers()->getCommonModifier()->resetForegroundEffect(nativeNode);
6202     return panda::JSValueRef::Undefined(vm);
6203 }
6204 
SetBackgroundEffectParam(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & policy,int32_t & blurType,Color & inactiveColor,bool & isValidColor,ArkUINodeHandle nativeNode,RefPtr<ResourceObject> & resourceObject)6205 void SetBackgroundEffectParam(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& policy, int32_t& blurType,
6206     Color& inactiveColor, bool& isValidColor, ArkUINodeHandle nativeNode, RefPtr<ResourceObject>& resourceObject)
6207 {
6208     EcmaVM* vm = runtimeCallInfo->GetVM();
6209     Local<JSValueRef> policyArg = runtimeCallInfo->GetCallArgRef(7);        // 7:index of parameter policy
6210     Local<JSValueRef> inactiveColorArg = runtimeCallInfo->GetCallArgRef(8); // 8:index of parameter inactiveColor
6211     Local<JSValueRef> typeArg = runtimeCallInfo->GetCallArgRef(9);          // 9:index of parameter type
6212 
6213     ArkTSUtils::ParseJsInt32(vm, policyArg, policy);
6214     if (policy < static_cast<int32_t>(BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) ||
6215         policy > static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_INACTIVE)) {
6216         policy = static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_ACTIVE);
6217     }
6218     ArkTSUtils::ParseJsInt32(vm, typeArg, blurType);
6219     if (blurType < static_cast<int32_t>(BlurType::WITHIN_WINDOW) ||
6220         blurType > static_cast<int32_t>(BlurType::BEHIND_WINDOW)) {
6221         blurType = static_cast<int32_t>(BlurType::WITHIN_WINDOW);
6222     }
6223 
6224     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
6225     if (ArkTSUtils::ParseJsColor(vm, inactiveColorArg, inactiveColor, resourceObject, nodeInfo)) {
6226         isValidColor = true;
6227     }
6228 }
6229 
SetAdaptiveColorParam(ArkUIRuntimeCallInfo * runtimeCallInfo,AdaptiveColor & adaptiveColor)6230 void SetAdaptiveColorParam(ArkUIRuntimeCallInfo* runtimeCallInfo, AdaptiveColor& adaptiveColor)
6231 {
6232     EcmaVM* vm = runtimeCallInfo->GetVM();
6233     Local<JSValueRef> adaptiveColorArg = runtimeCallInfo->GetCallArgRef(5); // 5:index of parameter adaptiveColor
6234     auto adaptiveColorValue = static_cast<int32_t>(AdaptiveColor::DEFAULT);
6235     if (adaptiveColorArg->IsNumber()) {
6236         adaptiveColorValue = adaptiveColorArg->Int32Value(vm);
6237         if (adaptiveColorValue >= static_cast<int32_t>(AdaptiveColor::DEFAULT) &&
6238             adaptiveColorValue <= static_cast<int32_t>(AdaptiveColor::AVERAGE)) {
6239             adaptiveColor = static_cast<AdaptiveColor>(adaptiveColorValue);
6240         }
6241     }
6242 }
6243 
ParseBackgroundEffectParams(const Local<JSValueRef> & saturationArg,const Local<JSValueRef> & brightnessArg,const EcmaVM * vm,ArkUI_Float32 & saturationVal,ArkUI_Float32 & brightnessVal)6244 void ParseBackgroundEffectParams(const Local<JSValueRef>& saturationArg, const Local<JSValueRef>& brightnessArg,
6245     const EcmaVM* vm, ArkUI_Float32& saturationVal, ArkUI_Float32& brightnessVal)
6246 {
6247     ArkUI_Float32 saturation = 1.0f;
6248     if (saturationArg->IsNumber()) {
6249         saturation = saturationArg->ToNumber(vm)->Value();
6250         saturation = (saturation > 0.0f || NearZero(saturation)) ? saturation : 1.0f;
6251     }
6252     saturationVal = saturation;
6253     ArkUI_Float32 brightness = 1.0f;
6254     if (brightnessArg->IsNumber()) {
6255         brightness = brightnessArg->ToNumber(vm)->Value();
6256         brightness = (brightness > 0.0f || NearZero(brightness)) ? brightness : 1.0f;
6257     }
6258     brightnessVal = brightness;
6259 }
6260 
SetBackgroundEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)6261 ArkUINativeModuleValue CommonBridge::SetBackgroundEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
6262 {
6263     EcmaVM* vm = runtimeCallInfo->GetVM();
6264     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6265     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);     // 0:index of parameter frameNode
6266     Local<JSValueRef> radiusArg = runtimeCallInfo->GetCallArgRef(1);        // 1:index of parameter radius
6267     Local<JSValueRef> saturationArg = runtimeCallInfo->GetCallArgRef(2);    // 2:index of parameter saturation
6268     Local<JSValueRef> brightnessArg = runtimeCallInfo->GetCallArgRef(3);    // 3:index of parameter brightness
6269     Local<JSValueRef> colorArg = runtimeCallInfo->GetCallArgRef(4);         // 4:index of parameter color
6270     Local<JSValueRef> blurOptionsArg = runtimeCallInfo->GetCallArgRef(6);   // 6:index of parameter blurOptions
6271     Local<JSValueRef> disableSystemAdaptationArg = runtimeCallInfo->GetCallArgRef(NUM_10);
6272     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6273     CalcDimension radius;
6274     if (!ArkTSUtils::ParseJsDimensionVp(vm, radiusArg, radius) || LessNotEqual(radius.Value(), 0.0f)) {
6275         radius.SetValue(0.0f);
6276     }
6277     ArkUI_Float32 saturation = 1.0f;
6278     ArkUI_Float32 brightness = 1.0f;
6279     ParseBackgroundEffectParams(saturationArg, brightnessArg, vm, saturation, brightness);
6280     Color color = Color::TRANSPARENT;
6281     RefPtr<ResourceObject> colorResObj;
6282 
6283     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
6284     if (!ArkTSUtils::ParseJsColor(vm, colorArg, color, colorResObj, nodeInfo)) {
6285         color.SetValue(Color::TRANSPARENT.GetValue());
6286     }
6287     auto adaptiveColor = AdaptiveColor::DEFAULT;
6288     SetAdaptiveColorParam(runtimeCallInfo, adaptiveColor);
6289     BlurOption blurOption;
6290     if (blurOptionsArg->IsArray(vm)) {
6291         ParseBlurOption(vm, blurOptionsArg, blurOption);
6292     }
6293     auto policy = static_cast<int32_t>(BlurStyleActivePolicy::ALWAYS_ACTIVE);
6294     auto blurType = static_cast<int32_t>(BlurType::WITHIN_WINDOW);
6295     Color inactiveColor = Color::TRANSPARENT;
6296     bool isValidColor = false;
6297     RefPtr<ResourceObject> inactiveColorResObj;
6298     SetBackgroundEffectParam(
6299         runtimeCallInfo, policy, blurType, inactiveColor, isValidColor, nativeNode, inactiveColorResObj);
6300     bool disableSystemAdaptation = false;
6301     if (disableSystemAdaptationArg->IsBoolean()) {
6302         disableSystemAdaptation = disableSystemAdaptationArg->ToBoolean(vm)->Value();
6303     }
6304     auto colorRawPtr = AceType::RawPtr(colorResObj);
6305     auto inactiveColorRawPtr = AceType::RawPtr(inactiveColorResObj);
6306     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundEffect(nativeNode,
6307         static_cast<ArkUI_Float32>(radius.Value()), saturation, brightness, color.GetValue(),
6308         static_cast<ArkUI_Int32>(adaptiveColor), blurOption.grayscale.data(), blurOption.grayscale.size(), policy,
6309         blurType, isValidColor, inactiveColor.GetValue(), disableSystemAdaptation, colorRawPtr, inactiveColorRawPtr);
6310     return panda::JSValueRef::Undefined(vm);
6311 }
6312 
ResetBackgroundEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)6313 ArkUINativeModuleValue CommonBridge::ResetBackgroundEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
6314 {
6315     EcmaVM* vm = runtimeCallInfo->GetVM();
6316     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6317     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6318     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6319     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundEffect(nativeNode);
6320     return panda::JSValueRef::Undefined(vm);
6321 }
6322 
SetBackgroundBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)6323 ArkUINativeModuleValue CommonBridge::SetBackgroundBrightness(ArkUIRuntimeCallInfo* runtimeCallInfo)
6324 {
6325     EcmaVM* vm = runtimeCallInfo->GetVM();
6326     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6327     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);     // 0:index of parameter frameNode
6328     Local<JSValueRef> ratedArg = runtimeCallInfo->GetCallArgRef(1);         // 1:index of parameter ratedArg
6329     Local<JSValueRef> lightUpDegreeArg = runtimeCallInfo->GetCallArgRef(2); // 2:index of parameter lightUpDegreeArg
6330     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6331     double rate = 0.0;
6332     double lightUpDegree = 0.0;
6333     if (!ArkTSUtils::ParseJsDouble(vm, ratedArg, rate)) {
6334         return panda::JSValueRef::Undefined(vm);
6335     }
6336     if (!ArkTSUtils::ParseJsDouble(vm, lightUpDegreeArg, lightUpDegree)) {
6337         return panda::JSValueRef::Undefined(vm);
6338     }
6339     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundBrightness(nativeNode, rate, lightUpDegree);
6340     return panda::JSValueRef::Undefined(vm);
6341 }
6342 
ResetBackgroundBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)6343 ArkUINativeModuleValue CommonBridge::ResetBackgroundBrightness(ArkUIRuntimeCallInfo* runtimeCallInfo)
6344 {
6345     EcmaVM* vm = runtimeCallInfo->GetVM();
6346     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6347     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6348     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6349     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundBrightness(nativeNode);
6350     return panda::JSValueRef::Undefined(vm);
6351 }
6352 
SetBackgroundBrightnessInternal(ArkUIRuntimeCallInfo * runtimeCallInfo)6353 ArkUINativeModuleValue CommonBridge::SetBackgroundBrightnessInternal(ArkUIRuntimeCallInfo* runtimeCallInfo)
6354 {
6355     EcmaVM* vm = runtimeCallInfo->GetVM();
6356     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6357     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6358     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6359     ArkUI_Float32 rate = 1.0f;
6360     ArkUI_Float32 lightUpDegree = 0.0f;
6361     ArkUI_Float32 cubicCoeff = 0.0f;
6362     ArkUI_Float32 quadCoeff = 0.0f;
6363     ArkUI_Float32 saturation = 1.0f;
6364     std::vector<float> posRGB(3, 0.0);
6365     std::vector<float> negRGB(3, 0.0);
6366     ArkUI_Float32 fraction = 1.0f;
6367     ParseDynamicBrightnessOption(runtimeCallInfo, vm, rate, lightUpDegree,
6368         cubicCoeff, quadCoeff, saturation, posRGB, negRGB, fraction);
6369     GetArkUINodeModifiers()->getCommonModifier()->setBackgroundBrightnessInternal(
6370         nativeNode, rate, lightUpDegree, cubicCoeff, quadCoeff, saturation,
6371         posRGB.data(), posRGB.size(), negRGB.data(), negRGB.size(), fraction);
6372     return panda::JSValueRef::Undefined(vm);
6373 }
6374 
ResetBackgroundBrightnessInternal(ArkUIRuntimeCallInfo * runtimeCallInfo)6375 ArkUINativeModuleValue CommonBridge::ResetBackgroundBrightnessInternal(ArkUIRuntimeCallInfo* runtimeCallInfo)
6376 {
6377     EcmaVM* vm = runtimeCallInfo->GetVM();
6378     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6379     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6380     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6381     GetArkUINodeModifiers()->getCommonModifier()->resetBackgroundBrightnessInternal(nativeNode);
6382     return panda::JSValueRef::Undefined(vm);
6383 }
6384 
SetForegroundBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)6385 ArkUINativeModuleValue CommonBridge::SetForegroundBrightness(ArkUIRuntimeCallInfo* runtimeCallInfo)
6386 {
6387     EcmaVM* vm = runtimeCallInfo->GetVM();
6388     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6389     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6390     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6391     ArkUI_Float32 rate = 1.0f;
6392     ArkUI_Float32 lightUpDegree = 0.0f;
6393     ArkUI_Float32 cubicCoeff = 0.0f;
6394     ArkUI_Float32 quadCoeff = 0.0f;
6395     ArkUI_Float32 saturation = 1.0f;
6396     std::vector<float> posRGB(3, 0.0);
6397     std::vector<float> negRGB(3, 0.0);
6398     ArkUI_Float32 fraction = 1.0f;
6399     ParseDynamicBrightnessOption(runtimeCallInfo, vm, rate, lightUpDegree,
6400         cubicCoeff, quadCoeff, saturation, posRGB, negRGB, fraction);
6401     GetArkUINodeModifiers()->getCommonModifier()->setForegroundBrightness(
6402         nativeNode, rate, lightUpDegree, cubicCoeff, quadCoeff, saturation,
6403         posRGB.data(), posRGB.size(), negRGB.data(), negRGB.size(), fraction);
6404     return panda::JSValueRef::Undefined(vm);
6405 }
6406 
ResetForegroundBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)6407 ArkUINativeModuleValue CommonBridge::ResetForegroundBrightness(ArkUIRuntimeCallInfo* runtimeCallInfo)
6408 {
6409     EcmaVM* vm = runtimeCallInfo->GetVM();
6410     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6411     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6412     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6413     GetArkUINodeModifiers()->getCommonModifier()->resetForegroundBrightness(nativeNode);
6414     return panda::JSValueRef::Undefined(vm);
6415 }
6416 
ParseDragPreViewOptions(ArkUIRuntimeCallInfo * runtimeCallInfo,Local<JSValueRef> & valueObj,ArkUIDragPreViewOptions & preViewOptions)6417 void ParseDragPreViewOptions(ArkUIRuntimeCallInfo* runtimeCallInfo, Local<JSValueRef>& valueObj,
6418     ArkUIDragPreViewOptions& preViewOptions)
6419 {
6420     EcmaVM* vm = runtimeCallInfo->GetVM();
6421     CHECK_NULL_VOID(vm);
6422     if (!valueObj->IsObject(vm)) {
6423         return;
6424     }
6425     auto obj = valueObj->ToObject(vm);
6426     auto mode = obj->Get(vm, "mode");
6427     if (mode->IsNumber()) {
6428         preViewOptions.isModeArray = false;
6429         preViewOptions.mode = mode->Int32Value(vm);
6430     } else if (mode->IsArray(vm)) {
6431         Local<panda::ArrayRef> modeArray = static_cast<Local<panda::ArrayRef>>(mode);
6432         int32_t arrLength = static_cast<int32_t>(modeArray->Length(vm));
6433         if (arrLength > NUM_4) {
6434             arrLength = NUM_4;
6435         }
6436         preViewOptions.modeArray = new int32_t[arrLength];
6437         for (int32_t i = 0; i < arrLength; i++) {
6438             Local<JSValueRef> objValue = modeArray->GetValueAt(vm, modeArray, i);
6439             preViewOptions.modeArray[i] = objValue->Int32Value(vm);
6440         }
6441         preViewOptions.isModeArray = true;
6442         preViewOptions.modeArrayLength = static_cast<ArkUI_Int32>(arrLength);
6443     }
6444 
6445     auto sizeChangeEffect = obj->Get(vm, "sizeChangeEffect");
6446     if (sizeChangeEffect->IsNumber()) {
6447         preViewOptions.sizeChangeEffect = sizeChangeEffect->Int32Value(vm);
6448     }
6449 
6450     auto numberBadge = obj->Get(vm, "numberBadge");
6451     if (numberBadge->IsBoolean()) {
6452         preViewOptions.isBadgeNumber = false;
6453         preViewOptions.isShowBadge = numberBadge->ToBoolean(vm)->Value();
6454     } else if (numberBadge->IsNumber()) {
6455         preViewOptions.isBadgeNumber = true;
6456         preViewOptions.badgeNumber = numberBadge->Int32Value(vm);
6457     }
6458 }
6459 
ParseDragInteractionOptions(ArkUIRuntimeCallInfo * runtimeCallInfo,Local<JSValueRef> & valueObj,ArkUIDragInteractionOptions & interactionOptions)6460 void ParseDragInteractionOptions(ArkUIRuntimeCallInfo* runtimeCallInfo, Local<JSValueRef>& valueObj,
6461     ArkUIDragInteractionOptions& interactionOptions)
6462 {
6463     EcmaVM* vm = runtimeCallInfo->GetVM();
6464     CHECK_NULL_VOID(vm);
6465     if (!valueObj->IsObject(vm)) {
6466         return;
6467     }
6468     auto obj = valueObj->ToObject(vm);
6469 
6470     Local<JSValueRef> isMultiSelectionEnabled = obj->Get(vm, "isMultiSelectionEnabled");
6471     if (isMultiSelectionEnabled->IsBoolean()) {
6472         interactionOptions.isMultiSelectionEnabled = isMultiSelectionEnabled->ToBoolean(vm)->Value();
6473     }
6474     Local<JSValueRef> defaultAnimationBeforeLifting = obj->Get(vm, "defaultAnimationBeforeLifting");
6475     if (defaultAnimationBeforeLifting->IsBoolean()) {
6476         interactionOptions.defaultAnimationBeforeLifting = defaultAnimationBeforeLifting->ToBoolean(vm)->Value();
6477     }
6478     Local<JSValueRef> enableEdgeAutoScroll = obj->Get(vm, "enableEdgeAutoScroll");
6479     if (enableEdgeAutoScroll->IsBoolean()) {
6480         interactionOptions.enableEdgeAutoScroll = enableEdgeAutoScroll->ToBoolean(vm)->Value();
6481     }
6482     Local<JSValueRef> enableHapticFeedback = obj->Get(vm, "enableHapticFeedback");
6483     if (enableHapticFeedback->IsBoolean()) {
6484         interactionOptions.enableHapticFeedback = enableHapticFeedback->ToBoolean(vm)->Value();
6485     }
6486     Local<JSValueRef> isLiftingDisabled = obj->Get(vm, "isLiftingDisabled");
6487     if (isLiftingDisabled->IsBoolean()) {
6488         interactionOptions.isLiftingDisabled = isLiftingDisabled->ToBoolean(vm)->Value();
6489     }
6490 }
6491 
SetDragPreviewOptions(ArkUIRuntimeCallInfo * runtimeCallInfo)6492 ArkUINativeModuleValue CommonBridge::SetDragPreviewOptions(ArkUIRuntimeCallInfo* runtimeCallInfo)
6493 {
6494     EcmaVM* vm = runtimeCallInfo->GetVM();
6495     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6496     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6497     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6498 
6499     Local<JSValueRef> valueObj = runtimeCallInfo->GetCallArgRef(NUM_1);
6500     struct ArkUIDragPreViewOptions preViewOptions = { 1, 0, 0, 0, nullptr, false, true, false };
6501     struct ArkUIDragInteractionOptions interactionOptions = { false, false, true, false, false };
6502     ParseDragPreViewOptions(runtimeCallInfo, valueObj, preViewOptions);
6503     ParseDragInteractionOptions(runtimeCallInfo, valueObj, interactionOptions);
6504 
6505     GetArkUINodeModifiers()->getCommonModifier()->setDragPreviewOptions(
6506         nativeNode, preViewOptions, interactionOptions);
6507     delete[] preViewOptions.modeArray;
6508     return panda::JSValueRef::Undefined(vm);
6509 }
6510 
ResetDragPreviewOptions(ArkUIRuntimeCallInfo * runtimeCallInfo)6511 ArkUINativeModuleValue CommonBridge::ResetDragPreviewOptions(ArkUIRuntimeCallInfo* runtimeCallInfo)
6512 {
6513     EcmaVM* vm = runtimeCallInfo->GetVM();
6514     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6515     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6516     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6517     GetArkUINodeModifiers()->getCommonModifier()->resetDragPreviewOptions(nativeNode);
6518     return panda::JSValueRef::Undefined(vm);
6519 }
6520 
SetDragPreview(ArkUIRuntimeCallInfo * runtimeCallInfo)6521 ArkUINativeModuleValue CommonBridge::SetDragPreview(ArkUIRuntimeCallInfo* runtimeCallInfo)
6522 {
6523     EcmaVM* vm = runtimeCallInfo->GetVM();
6524     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6525     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6526     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6527     Local<JSValueRef> valueObj = runtimeCallInfo->GetCallArgRef(NUM_1);
6528     struct ArkUIDragPreview dragPreview = { "" };
6529     std::string stringValue;
6530     std::string extraInfoValue;
6531     RefPtr<PixelMap> pixmap = nullptr;
6532     std::shared_ptr<Media::PixelMap> pixelMapSharedPtr = nullptr;
6533     if (valueObj->IsObject(vm)) {
6534         auto obj = valueObj->ToObject(vm);
6535         auto inspectorId = obj->Get(vm, "inspetorId");
6536         if (inspectorId->IsString(vm)) {
6537             stringValue = inspectorId->ToString(vm)->ToString(vm);
6538             dragPreview.inspectorId = stringValue.c_str();
6539         }
6540         auto onlyForLifting = obj->Get(vm, "onlyForLifting");
6541         if (onlyForLifting->IsBoolean()) {
6542             dragPreview.onlyForLifting = onlyForLifting->ToBoolean(vm)->Value();
6543         }
6544         auto extraInfo = obj->Get(vm, "extraInfo");
6545         if (extraInfo->IsString(vm)) {
6546             extraInfoValue = extraInfo->ToString(vm)->ToString(vm);
6547             dragPreview.extraInfo = extraInfoValue.c_str();
6548         }
6549         auto pixelMap = obj->Get(vm, "pixelMap");
6550         if (!pixelMap->IsUndefined()) {
6551 #if defined(PIXEL_MAP_SUPPORTED)
6552             pixmap = ArkTSUtils::CreatePixelMapFromNapiValue(vm, pixelMap);
6553 #endif
6554             if (pixmap) {
6555                 pixelMapSharedPtr = pixmap->GetPixelMapSharedPtr();
6556                 dragPreview.pixelMap = static_cast<void*>(&pixelMapSharedPtr);
6557             }
6558         }
6559     }
6560     GetArkUINodeModifiers()->getCommonModifier()->setDragPreview(nativeNode, dragPreview);
6561     return panda::JSValueRef::Undefined(vm);
6562 }
6563 
ResetDragPreview(ArkUIRuntimeCallInfo * runtimeCallInfo)6564 ArkUINativeModuleValue CommonBridge::ResetDragPreview(ArkUIRuntimeCallInfo* runtimeCallInfo)
6565 {
6566     EcmaVM* vm = runtimeCallInfo->GetVM();
6567     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6568     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6569     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6570     GetArkUINodeModifiers()->getCommonModifier()->resetDragPreview(nativeNode);
6571     return panda::JSValueRef::Undefined(vm);
6572 }
6573 
SetResponseRegion(ArkUIRuntimeCallInfo * runtimeCallInfo)6574 ArkUINativeModuleValue CommonBridge::SetResponseRegion(ArkUIRuntimeCallInfo* runtimeCallInfo)
6575 {
6576     EcmaVM* vm = runtimeCallInfo->GetVM();
6577     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6578     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6579     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
6580     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
6581     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6582     int32_t length = thirdArg->Int32Value(vm);
6583     ArkUI_Float32 regionArray[length];
6584     int32_t regionUnits[length];
6585     if (!ParseResponseRegion(vm, secondArg, regionArray, regionUnits, length)) {
6586         GetArkUINodeModifiers()->getCommonModifier()->resetResponseRegion(nativeNode);
6587         return panda::JSValueRef::Undefined(vm);
6588     }
6589     GetArkUINodeModifiers()->getCommonModifier()->setResponseRegion(nativeNode, regionArray, regionUnits, length);
6590     return panda::JSValueRef::Undefined(vm);
6591 }
6592 
ResetResponseRegion(ArkUIRuntimeCallInfo * runtimeCallInfo)6593 ArkUINativeModuleValue CommonBridge::ResetResponseRegion(ArkUIRuntimeCallInfo* runtimeCallInfo)
6594 {
6595     EcmaVM* vm = runtimeCallInfo->GetVM();
6596     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6597     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6598     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6599     GetArkUINodeModifiers()->getCommonModifier()->resetResponseRegion(nativeNode);
6600     return panda::JSValueRef::Undefined(vm);
6601 }
6602 
ResetTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)6603 ArkUINativeModuleValue CommonBridge::ResetTransition(ArkUIRuntimeCallInfo* runtimeCallInfo)
6604 {
6605     EcmaVM* vm = runtimeCallInfo->GetVM();
6606     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6607     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6608     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6609     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6610     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6611     ViewAbstract::CleanTransition(frameNode);
6612     ViewAbstract::SetChainedTransition(frameNode, nullptr, nullptr);
6613     return panda::JSValueRef::Undefined(vm);
6614 }
6615 
SetTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)6616 ArkUINativeModuleValue CommonBridge::SetTransition(ArkUIRuntimeCallInfo* runtimeCallInfo)
6617 {
6618     EcmaVM* vm = runtimeCallInfo->GetVM();
6619     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6620     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6621     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6622     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6623     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6624     if (!info[1]->IsObject()) {
6625         ViewAbstract::CleanTransition(frameNode);
6626         ViewAbstract::SetChainedTransition(frameNode, nullptr, nullptr);
6627         return panda::JSValueRef::Undefined(vm);
6628     }
6629     auto obj = Framework::JSRef<Framework::JSObject>::Cast(info[1]);
6630     if (!obj->GetProperty("successor_")->IsUndefined()) {
6631         auto chainedEffect = ParseChainedTransition(obj, info.GetExecutionContext());
6632         std::function<void(bool)> finishCallback;
6633         if (info.Length() > 2 && info[2]->IsFunction()) {
6634             finishCallback =
6635                 ParseTransitionCallback(JSRef<JSFunc>::Cast(info[2]), info.GetExecutionContext(), frameNode);
6636         }
6637         ViewAbstract::SetChainedTransition(frameNode, chainedEffect, std::move(finishCallback));
6638         return panda::JSValueRef::Undefined(vm);
6639     }
6640     auto options = ParseJsTransition(info[1]);
6641     ViewAbstract::SetTransition(frameNode, options);
6642     return panda::JSValueRef::Undefined(vm);
6643 }
6644 
ResetTransitionPassThrough(ArkUIRuntimeCallInfo * runtimeCallInfo)6645 ArkUINativeModuleValue CommonBridge::ResetTransitionPassThrough(ArkUIRuntimeCallInfo* runtimeCallInfo)
6646 {
6647     return CommonBridge::ResetTransition(runtimeCallInfo);
6648 }
6649 
SetTransitionPassThrough(ArkUIRuntimeCallInfo * runtimeCallInfo)6650 ArkUINativeModuleValue CommonBridge::SetTransitionPassThrough(ArkUIRuntimeCallInfo* runtimeCallInfo)
6651 {
6652     return CommonBridge::SetTransition(runtimeCallInfo);
6653 }
6654 
ResetSharedTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)6655 ArkUINativeModuleValue CommonBridge::ResetSharedTransition(ArkUIRuntimeCallInfo* runtimeCallInfo)
6656 {
6657     EcmaVM* vm = runtimeCallInfo->GetVM();
6658     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6659     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6660     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6661     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6662     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6663     if (!info[1]->IsString() || info[1]->ToString().empty()) {
6664         return panda::JSValueRef::Undefined(vm);
6665     }
6666     auto id = info[1]->ToString();
6667     std::shared_ptr<SharedTransitionOption> sharedOption;
6668     sharedOption = std::make_shared<SharedTransitionOption>();
6669     sharedOption->duration = DEFAULT_DURATION;
6670     sharedOption->delay = NUM_0;
6671     sharedOption->curve = Curves::LINEAR;
6672     sharedOption->zIndex = NUM_0;
6673     sharedOption->type = DEFAULT_SHARED_EFFECT;
6674 
6675     ViewAbstract::SetSharedTransition(frameNode, id, sharedOption);
6676     return panda::JSValueRef::Undefined(vm);
6677 }
6678 
SetSharedTransition(ArkUIRuntimeCallInfo * runtimeCallInfo)6679 ArkUINativeModuleValue CommonBridge::SetSharedTransition(ArkUIRuntimeCallInfo* runtimeCallInfo)
6680 {
6681     EcmaVM* vm = runtimeCallInfo->GetVM();
6682     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6683     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6684     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6685     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6686     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6687     if (!info[NUM_1]->IsString() || info[NUM_1]->ToString().empty()) {
6688         return panda::JSValueRef::Undefined(vm);
6689     }
6690     auto id = info[NUM_1]->ToString();
6691     std::shared_ptr<SharedTransitionOption> sharedOption;
6692     if (info[NUM_2]->IsObject()) {
6693         Framework::JSRef<Framework::JSObject> jsObj = Framework::JSRef<Framework::JSObject>::Cast(info[NUM_2]);
6694         sharedOption = std::make_shared<SharedTransitionOption>();
6695         sharedOption->duration = jsObj->GetPropertyValue<int32_t>("duration", DEFAULT_DURATION);
6696         if (sharedOption->duration < 0) {
6697             sharedOption->duration = DEFAULT_DURATION;
6698         }
6699         sharedOption->delay = jsObj->GetPropertyValue<int32_t>("delay", 0);
6700         if (sharedOption->delay < 0) {
6701             sharedOption->delay = 0;
6702         }
6703         RefPtr<Curve> curve;
6704         Framework::JSRef<Framework::JSVal> curveArgs = jsObj->GetProperty("curve");
6705         if (curveArgs->IsString()) {
6706             curve = Framework::CreateCurve(jsObj->GetPropertyValue<std::string>("curve", "linear"), false);
6707         } else if (curveArgs->IsObject()) {
6708             Framework::JSRef<Framework::JSVal> curveString =
6709                 Framework::JSRef<Framework::JSObject>::Cast(curveArgs)->GetProperty("__curveString");
6710             if (!curveString->IsString()) {
6711                 return panda::JSValueRef::Undefined(vm);
6712             }
6713             curve = Framework::CreateCurve(curveString->ToString(), false);
6714         }
6715         if (!curve) {
6716             curve = Curves::LINEAR;
6717         }
6718         sharedOption->curve = curve;
6719         if (jsObj->HasProperty("motionPath")) {
6720             MotionPathOption motionPathOption;
6721             if (ParseMotionPath(jsObj->GetProperty("motionPath"), motionPathOption)) {
6722                 sharedOption->motionPathOption = motionPathOption;
6723             }
6724         }
6725         sharedOption->zIndex = jsObj->GetPropertyValue<int32_t>("zIndex", 0);
6726         int32_t type = jsObj->GetPropertyValue<int32_t>("type", static_cast<int32_t>(DEFAULT_SHARED_EFFECT));
6727         sharedOption->type = static_cast<SharedTransitionEffectType>(type);
6728     }
6729     ViewAbstract::SetSharedTransition(frameNode, id, sharedOption);
6730     return panda::JSValueRef::Undefined(vm);
6731 }
SetMask(ArkUIRuntimeCallInfo * runtimeCallInfo)6732 ArkUINativeModuleValue CommonBridge::SetMask(ArkUIRuntimeCallInfo* runtimeCallInfo)
6733 {
6734     EcmaVM* vm = runtimeCallInfo->GetVM();
6735     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6736     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6737     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6738     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6739 
6740     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6741     if (!info[NUM_1]->IsObject()) {
6742         ViewAbstract::SetProgressMask(frameNode, nullptr);
6743         return panda::JSValueRef::Undefined(vm);
6744     }
6745     auto paramObject = Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1]);
6746     Framework::JSRef<Framework::JSVal> typeParam = paramObject->GetProperty("type");
6747     if (!typeParam->IsNull() && !typeParam->IsUndefined() && typeParam->IsString() &&
6748         typeParam->ToString() == "ProgressMask") {
6749         ParseJsMaskProperty(frameNode, paramObject);
6750     } else {
6751         Framework::JSShapeAbstract* maskShape =
6752             Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1])->Unwrap<Framework::JSShapeAbstract>();
6753         if (maskShape == nullptr) {
6754             return panda::JSValueRef::Undefined(vm);
6755         };
6756         ViewAbstractModelNG::RemoveResObj(frameNode, "maskShape");
6757         ViewAbstract::SetMask(frameNode, maskShape->GetBasicShape());
6758     }
6759     return panda::JSValueRef::Undefined(vm);
6760 }
6761 
ResetMask(ArkUIRuntimeCallInfo * runtimeCallInfo)6762 ArkUINativeModuleValue CommonBridge::ResetMask(ArkUIRuntimeCallInfo* runtimeCallInfo)
6763 {
6764     EcmaVM* vm = runtimeCallInfo->GetVM();
6765     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6766     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6767     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6768     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6769     ViewAbstractModelNG::RemoveResObj(frameNode, "ProgressMask");
6770     ViewAbstract::SetProgressMask(frameNode, nullptr);
6771     return panda::JSValueRef::Undefined(vm);
6772 }
6773 
SetMaskShape(ArkUIRuntimeCallInfo * runtimeCallInfo)6774 ArkUINativeModuleValue CommonBridge::SetMaskShape(ArkUIRuntimeCallInfo* runtimeCallInfo)
6775 {
6776     EcmaVM* vm = runtimeCallInfo->GetVM();
6777     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6778     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6779     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6780     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6781 
6782     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
6783     if (!info[NUM_1]->IsObject()) {
6784         return panda::JSValueRef::Undefined(vm);
6785     }
6786     ViewAbstractModelNG::RemoveResObj(frameNode, "maskShape");
6787 
6788     Framework::JSShapeAbstract* maskShape =
6789         Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1])->Unwrap<Framework::JSShapeAbstract>();
6790     if (maskShape == nullptr) {
6791         return panda::JSValueRef::Undefined(vm);
6792     };
6793     ViewAbstract::SetMask(frameNode, maskShape->GetBasicShape());
6794 
6795     return panda::JSValueRef::Undefined(vm);
6796 }
6797 
ResetMaskShape(ArkUIRuntimeCallInfo * runtimeCallInfo)6798 ArkUINativeModuleValue CommonBridge::ResetMaskShape(ArkUIRuntimeCallInfo* runtimeCallInfo)
6799 {
6800     EcmaVM* vm = runtimeCallInfo->GetVM();
6801     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6802     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6803     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6804     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
6805     ViewAbstractModelNG::RemoveResObj(frameNode, "ProgressMask");
6806     ViewAbstract::SetProgressMask(frameNode, nullptr);
6807     return panda::JSValueRef::Undefined(vm);
6808 }
6809 
SetMouseResponseRegion(ArkUIRuntimeCallInfo * runtimeCallInfo)6810 ArkUINativeModuleValue CommonBridge::SetMouseResponseRegion(ArkUIRuntimeCallInfo* runtimeCallInfo)
6811 {
6812     EcmaVM* vm = runtimeCallInfo->GetVM();
6813     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6814     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6815     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
6816     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
6817     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6818     int32_t length = thirdArg->Int32Value(vm);
6819     ArkUI_Float32 regionArray[length];
6820     int32_t regionUnits[length];
6821     if (!ParseResponseRegion(vm, secondArg, regionArray, regionUnits, length)) {
6822         GetArkUINodeModifiers()->getCommonModifier()->resetMouseResponseRegion(nativeNode);
6823         return panda::JSValueRef::Undefined(vm);
6824     }
6825     GetArkUINodeModifiers()->getCommonModifier()->setMouseResponseRegion(nativeNode, regionArray, regionUnits, length);
6826     return panda::JSValueRef::Undefined(vm);
6827 }
6828 
ResetMouseResponseRegion(ArkUIRuntimeCallInfo * runtimeCallInfo)6829 ArkUINativeModuleValue CommonBridge::ResetMouseResponseRegion(ArkUIRuntimeCallInfo* runtimeCallInfo)
6830 {
6831     EcmaVM* vm = runtimeCallInfo->GetVM();
6832     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6833     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
6834     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6835     GetArkUINodeModifiers()->getCommonModifier()->resetMouseResponseRegion(nativeNode);
6836     return panda::JSValueRef::Undefined(vm);
6837 }
6838 
SetEnabled(ArkUIRuntimeCallInfo * runtimeCallInfo)6839 ArkUINativeModuleValue CommonBridge::SetEnabled(ArkUIRuntimeCallInfo* runtimeCallInfo)
6840 {
6841     EcmaVM* vm = runtimeCallInfo->GetVM();
6842     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6843     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6844     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
6845     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6846     if (secondArg->IsBoolean()) {
6847         bool boolValue = secondArg->ToBoolean(vm)->Value();
6848         GetArkUINodeModifiers()->getCommonModifier()->setEnabled(nativeNode, boolValue);
6849     } else {
6850         GetArkUINodeModifiers()->getCommonModifier()->resetEnabled(nativeNode);
6851     }
6852     return panda::JSValueRef::Undefined(vm);
6853 }
6854 
ResetEnabled(ArkUIRuntimeCallInfo * runtimeCallInfo)6855 ArkUINativeModuleValue CommonBridge::ResetEnabled(ArkUIRuntimeCallInfo* runtimeCallInfo)
6856 {
6857     EcmaVM* vm = runtimeCallInfo->GetVM();
6858     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6859     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
6860     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
6861     GetArkUINodeModifiers()->getCommonModifier()->resetEnabled(nativeNode);
6862     return panda::JSValueRef::Undefined(vm);
6863 }
6864 
SetUseShadowBatching(ArkUIRuntimeCallInfo * runtimeCallInfo)6865 ArkUINativeModuleValue CommonBridge::SetUseShadowBatching(ArkUIRuntimeCallInfo* runtimeCallInfo)
6866 {
6867     EcmaVM* vm = runtimeCallInfo->GetVM();
6868     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6869     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6870     Local<JSValueRef> booleanArg = runtimeCallInfo->GetCallArgRef(1);
6871     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6872     if (booleanArg->IsBoolean()) {
6873         bool boolValue = booleanArg->ToBoolean(vm)->Value();
6874         GetArkUINodeModifiers()->getCommonModifier()->setUseShadowBatching(nativeNode, boolValue);
6875     } else {
6876         GetArkUINodeModifiers()->getCommonModifier()->resetUseShadowBatching(nativeNode);
6877     }
6878     return panda::JSValueRef::Undefined(vm);
6879 }
6880 
ResetUseShadowBatching(ArkUIRuntimeCallInfo * runtimeCallInfo)6881 ArkUINativeModuleValue CommonBridge::ResetUseShadowBatching(ArkUIRuntimeCallInfo* runtimeCallInfo)
6882 {
6883     EcmaVM* vm = runtimeCallInfo->GetVM();
6884     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6885     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6886     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6887     GetArkUINodeModifiers()->getCommonModifier()->resetUseShadowBatching(nativeNode);
6888     return panda::JSValueRef::Undefined(vm);
6889 }
6890 
SetBlendMode(ArkUIRuntimeCallInfo * runtimeCallInfo)6891 ArkUINativeModuleValue CommonBridge::SetBlendMode(ArkUIRuntimeCallInfo *runtimeCallInfo)
6892 {
6893     EcmaVM* vm = runtimeCallInfo->GetVM();
6894     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6895     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);      // 0: index of parameter frameNode
6896     Local<JSValueRef> blendModeArg = runtimeCallInfo->GetCallArgRef(1);      // 1: index of parameter blendMode
6897     Local<JSValueRef> blendApplyTypeArg = runtimeCallInfo->GetCallArgRef(2); // 2: index of parameter blendApplyType
6898     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6899     int32_t blendModeValue = static_cast<int32_t>(OHOS::Ace::BlendMode::NONE);
6900     int32_t blendApplyTypeValue = static_cast<int32_t>(OHOS::Ace::BlendApplyType::FAST);
6901     if (blendModeArg->IsNumber()) {
6902         int32_t blendModeNum = blendModeArg->Int32Value(vm);
6903         if (blendModeNum >= static_cast<int32_t>(OHOS::Ace::BlendMode::NONE) &&
6904             blendModeNum <= static_cast<int32_t>(OHOS::Ace::BlendMode::LUMINOSITY)) {
6905             blendModeValue = blendModeNum;
6906         } else if (blendModeNum == BACKWARD_COMPAT_MAGIC_NUMBER_OFFSCREEN) {
6907             blendModeValue = static_cast<int32_t>(OHOS::Ace::BlendMode::SRC_OVER);
6908             blendApplyTypeValue = static_cast<int32_t>(OHOS::Ace::BlendApplyType::OFFSCREEN);
6909         }
6910         if (blendApplyTypeArg->IsNumber()) {
6911             int32_t blendApplyTypeNum = blendApplyTypeArg->Int32Value(vm);
6912             if (blendApplyTypeNum >= static_cast<int>(OHOS::Ace::BlendApplyType::FAST) &&
6913                 blendApplyTypeNum <= static_cast<int>(OHOS::Ace::BlendApplyType::OFFSCREEN)) {
6914                 blendApplyTypeValue = blendApplyTypeNum;
6915             }
6916         }
6917         GetArkUINodeModifiers()->getCommonModifier()->setBlendMode(nativeNode, blendModeValue, blendApplyTypeValue);
6918     } else {
6919         GetArkUINodeModifiers()->getCommonModifier()->resetBlendMode(nativeNode);
6920     }
6921     return panda::JSValueRef::Undefined(vm);
6922 }
6923 
ResetBlendMode(ArkUIRuntimeCallInfo * runtimeCallInfo)6924 ArkUINativeModuleValue CommonBridge::ResetBlendMode(ArkUIRuntimeCallInfo *runtimeCallInfo)
6925 {
6926     EcmaVM *vm = runtimeCallInfo->GetVM();
6927     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6928     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6929     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6930     GetArkUINodeModifiers()->getCommonModifier()->resetBlendMode(nativeNode);
6931     return panda::JSValueRef::Undefined(vm);
6932 }
6933 
SetAdvancedBlendMode(ArkUIRuntimeCallInfo * runtimeCallInfo)6934 ArkUINativeModuleValue CommonBridge::SetAdvancedBlendMode(ArkUIRuntimeCallInfo *runtimeCallInfo)
6935 {
6936     EcmaVM* vm = runtimeCallInfo->GetVM();
6937     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
6938     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);      // 0: index of parameter frameNode
6939     Local<JSValueRef> blendModeArg = runtimeCallInfo->GetCallArgRef(1);      // 1: index of parameter blendMode
6940     Local<JSValueRef> blendApplyTypeArg = runtimeCallInfo->GetCallArgRef(2); // 2: index of parameter blendApplyType
6941     CHECK_NULL_RETURN(frameNodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
6942     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6943     int32_t blendModeValue = static_cast<int32_t>(OHOS::Ace::BlendMode::NONE);
6944     int32_t blendApplyTypeValue = static_cast<int32_t>(OHOS::Ace::BlendApplyType::FAST);
6945     if (blendApplyTypeArg->IsNumber()) {
6946         int32_t blendApplyTypeNum = blendApplyTypeArg->Int32Value(vm);
6947         if (blendApplyTypeNum >= static_cast<int>(OHOS::Ace::BlendApplyType::FAST) &&
6948             blendApplyTypeNum <= static_cast<int>(OHOS::Ace::BlendApplyType::OFFSCREEN)) {
6949             blendApplyTypeValue = blendApplyTypeNum;
6950         }
6951     }
6952     if (blendModeArg->IsNumber()) {
6953         int32_t blendModeNum = blendModeArg->Int32Value(vm);
6954         if (blendModeNum >= static_cast<int32_t>(OHOS::Ace::BlendMode::NONE) &&
6955             blendModeNum <= static_cast<int32_t>(OHOS::Ace::BlendMode::LUMINOSITY)) {
6956             blendModeValue = blendModeNum;
6957         } else if (blendModeNum == BACKWARD_COMPAT_MAGIC_NUMBER_OFFSCREEN) {
6958             blendModeValue = static_cast<int32_t>(OHOS::Ace::BlendMode::SRC_OVER);
6959             blendApplyTypeValue = static_cast<int32_t>(OHOS::Ace::BlendApplyType::OFFSCREEN);
6960         }
6961         GetArkUINodeModifiers()->getCommonModifier()->setBlendMode(nativeNode, blendModeValue, blendApplyTypeValue);
6962     } else if (blendModeArg->IsObject(vm)) {
6963         auto arkBlender = ArkTSUtils::CreateRSBrightnessBlenderFromNapiValue(vm, blendModeArg);
6964         auto blender = reinterpret_cast<ArkUINodeHandle>(arkBlender);
6965         GetArkUINodeModifiers()->getCommonModifier()->setBlendModeByBlender(nativeNode, blender, blendApplyTypeValue);
6966     } else {
6967         GetArkUINodeModifiers()->getCommonModifier()->resetBlendMode(nativeNode);
6968     }
6969     return panda::JSValueRef::Undefined(vm);
6970 }
6971 
ResetAdvancedBlendMode(ArkUIRuntimeCallInfo * runtimeCallInfo)6972 ArkUINativeModuleValue CommonBridge::ResetAdvancedBlendMode(ArkUIRuntimeCallInfo *runtimeCallInfo)
6973 {
6974     EcmaVM *vm = runtimeCallInfo->GetVM();
6975     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
6976     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6977     CHECK_NULL_RETURN(frameNodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
6978     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6979     GetArkUINodeModifiers()->getCommonModifier()->resetBlendMode(nativeNode);
6980     return panda::JSValueRef::Undefined(vm);
6981 }
6982 
SetMonopolizeEvents(ArkUIRuntimeCallInfo * runtimeCallInfo)6983 ArkUINativeModuleValue CommonBridge::SetMonopolizeEvents(ArkUIRuntimeCallInfo* runtimeCallInfo)
6984 {
6985     EcmaVM* vm = runtimeCallInfo->GetVM();
6986     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
6987     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
6988     Local<JSValueRef> booleanArg = runtimeCallInfo->GetCallArgRef(1);
6989     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
6990     if (booleanArg->IsBoolean()) {
6991         bool boolValue = booleanArg->ToBoolean(vm)->Value();
6992         GetArkUINodeModifiers()->getCommonModifier()->setMonopolizeEvents(nativeNode, boolValue);
6993     } else {
6994         GetArkUINodeModifiers()->getCommonModifier()->resetMonopolizeEvents(nativeNode);
6995     }
6996     return panda::JSValueRef::Undefined(vm);
6997 }
6998 
ResetMonopolizeEvents(ArkUIRuntimeCallInfo * runtimeCallInfo)6999 ArkUINativeModuleValue CommonBridge::ResetMonopolizeEvents(ArkUIRuntimeCallInfo* runtimeCallInfo)
7000 {
7001     EcmaVM* vm = runtimeCallInfo->GetVM();
7002     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7003     Local<JSValueRef> frameNodeArg = runtimeCallInfo->GetCallArgRef(0);
7004     auto nativeNode = nodePtr(frameNodeArg->ToNativePointer(vm)->Value());
7005     GetArkUINodeModifiers()->getCommonModifier()->resetMonopolizeEvents(nativeNode);
7006     return panda::JSValueRef::Undefined(vm);
7007 }
7008 
SetDraggable(ArkUIRuntimeCallInfo * runtimeCallInfo)7009 ArkUINativeModuleValue CommonBridge::SetDraggable(ArkUIRuntimeCallInfo* runtimeCallInfo)
7010 {
7011     EcmaVM* vm = runtimeCallInfo->GetVM();
7012     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7013     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7014     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7015     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7016     if (secondArg->IsBoolean()) {
7017         bool boolValue = secondArg->ToBoolean(vm)->Value();
7018         GetArkUINodeModifiers()->getCommonModifier()->setDraggable(nativeNode, boolValue);
7019     } else {
7020         GetArkUINodeModifiers()->getCommonModifier()->resetDraggable(nativeNode);
7021     }
7022     return panda::JSValueRef::Undefined(vm);
7023 }
7024 
ResetDraggable(ArkUIRuntimeCallInfo * runtimeCallInfo)7025 ArkUINativeModuleValue CommonBridge::ResetDraggable(ArkUIRuntimeCallInfo* runtimeCallInfo)
7026 {
7027     EcmaVM* vm = runtimeCallInfo->GetVM();
7028     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7029     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7030     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7031     GetArkUINodeModifiers()->getCommonModifier()->resetDraggable(nativeNode);
7032     return panda::JSValueRef::Undefined(vm);
7033 }
7034 
SetAccessibilityGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)7035 ArkUINativeModuleValue CommonBridge::SetAccessibilityGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
7036 {
7037     EcmaVM* vm = runtimeCallInfo->GetVM();
7038     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7039     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7040     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7041     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7042     if (secondArg->IsBoolean()) {
7043         bool boolValue = secondArg->ToBoolean(vm)->Value();
7044         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityGroup(nativeNode, boolValue);
7045     } else {
7046         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityGroup(nativeNode);
7047     }
7048     return panda::JSValueRef::Undefined(vm);
7049 }
7050 
ResetAccessibilityGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)7051 ArkUINativeModuleValue CommonBridge::ResetAccessibilityGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
7052 {
7053     EcmaVM* vm = runtimeCallInfo->GetVM();
7054     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7055     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7056     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7057     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityGroup(nativeNode);
7058     return panda::JSValueRef::Undefined(vm);
7059 }
7060 
SetAccessibilityNextFocusId(ArkUIRuntimeCallInfo * runtimeCallInfo)7061 ArkUINativeModuleValue CommonBridge::SetAccessibilityNextFocusId(ArkUIRuntimeCallInfo* runtimeCallInfo)
7062 {
7063     EcmaVM* vm = runtimeCallInfo->GetVM();
7064     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7065     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7066     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7067     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7068     if (secondArg->IsString(vm)) {
7069         std::string stringValue = secondArg->ToString(vm)->ToString(vm);
7070         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityNextFocusId(nativeNode, stringValue.c_str());
7071     } else {
7072         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityNextFocusId(nativeNode);
7073     }
7074     return panda::JSValueRef::Undefined(vm);
7075 }
7076 
ResetAccessibilityNextFocusId(ArkUIRuntimeCallInfo * runtimeCallInfo)7077 ArkUINativeModuleValue CommonBridge::ResetAccessibilityNextFocusId(ArkUIRuntimeCallInfo* runtimeCallInfo)
7078 {
7079     EcmaVM* vm = runtimeCallInfo->GetVM();
7080     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7081     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7082     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7083     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityNextFocusId(nativeNode);
7084     return panda::JSValueRef::Undefined(vm);
7085 }
7086 
SetAccessibilityDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)7087 ArkUINativeModuleValue CommonBridge::SetAccessibilityDefaultFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
7088 {
7089     EcmaVM* vm = runtimeCallInfo->GetVM();
7090     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7091     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7092     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7093     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7094     if (secondArg->IsBoolean()) {
7095         bool boolValue = secondArg->ToBoolean(vm)->Value();
7096         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityDefaultFocus(nativeNode, boolValue);
7097     } else {
7098         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityDefaultFocus(nativeNode);
7099     }
7100     return panda::JSValueRef::Undefined(vm);
7101 }
7102 
ResetAccessibilityDefaultFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)7103 ArkUINativeModuleValue CommonBridge::ResetAccessibilityDefaultFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
7104 {
7105     EcmaVM* vm = runtimeCallInfo->GetVM();
7106     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7107     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7108     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7109     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityDefaultFocus(nativeNode);
7110     return panda::JSValueRef::Undefined(vm);
7111 }
7112 
SetAccessibilityUseSamePage(ArkUIRuntimeCallInfo * runtimeCallInfo)7113 ArkUINativeModuleValue CommonBridge::SetAccessibilityUseSamePage(ArkUIRuntimeCallInfo* runtimeCallInfo)
7114 {
7115     EcmaVM* vm = runtimeCallInfo->GetVM();
7116     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7117     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7118     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7119     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7120 
7121     if (secondArg->IsUndefined() || !secondArg->IsNumber()) {
7122         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityUseSamePage(nativeNode);
7123         return panda::JSValueRef::Undefined(vm);
7124     }
7125     int32_t intValue = secondArg->Int32Value(vm);
7126     if (intValue >= 0 && intValue < static_cast<int32_t>(PAGE_MODE_TYPE.size())) {
7127         bool isFullSilent = static_cast<bool>(PAGE_MODE_TYPE[intValue]);
7128         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityUseSamePage(nativeNode, isFullSilent);
7129     } else {
7130         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityUseSamePage(nativeNode);
7131     }
7132     return panda::JSValueRef::Undefined(vm);
7133 }
7134 
ResetAccessibilityUseSamePage(ArkUIRuntimeCallInfo * runtimeCallInfo)7135 ArkUINativeModuleValue CommonBridge::ResetAccessibilityUseSamePage(ArkUIRuntimeCallInfo* runtimeCallInfo)
7136 {
7137     EcmaVM* vm = runtimeCallInfo->GetVM();
7138     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7139     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7140     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7141     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityUseSamePage(nativeNode);
7142     return panda::JSValueRef::Undefined(vm);
7143 }
7144 
SetAccessibilityScrollTriggerable(ArkUIRuntimeCallInfo * runtimeCallInfo)7145 ArkUINativeModuleValue CommonBridge::SetAccessibilityScrollTriggerable(ArkUIRuntimeCallInfo* runtimeCallInfo)
7146 {
7147     EcmaVM* vm = runtimeCallInfo->GetVM();
7148     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7149     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7150     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7151     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7152     if (secondArg->IsBoolean()) {
7153         bool boolValue = secondArg->ToBoolean(vm)->Value();
7154         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityScrollTriggerable(nativeNode, boolValue);
7155     } else {
7156         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityScrollTriggerable(nativeNode);
7157     }
7158     return panda::JSValueRef::Undefined(vm);
7159 }
7160 
ResetAccessibilityScrollTriggerable(ArkUIRuntimeCallInfo * runtimeCallInfo)7161 ArkUINativeModuleValue CommonBridge::ResetAccessibilityScrollTriggerable(ArkUIRuntimeCallInfo* runtimeCallInfo)
7162 {
7163     EcmaVM* vm = runtimeCallInfo->GetVM();
7164     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7165     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7166     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7167     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityScrollTriggerable(nativeNode);
7168     return panda::JSValueRef::Undefined(vm);
7169 }
7170 
SetAccessibilityFocusDrawLevel(ArkUIRuntimeCallInfo * runtimeCallInfo)7171 ArkUINativeModuleValue CommonBridge::SetAccessibilityFocusDrawLevel(ArkUIRuntimeCallInfo* runtimeCallInfo)
7172 {
7173     EcmaVM* vm = runtimeCallInfo->GetVM();
7174     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7175     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7176     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7177     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7178 
7179     if (secondArg->IsUndefined() || !secondArg->IsNumber()) {
7180         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityFocusDrawLevel(nativeNode);
7181         return panda::JSValueRef::Undefined(vm);
7182     }
7183     int32_t intValue = secondArg->Int32Value(vm);
7184     if (intValue >= 0 && intValue < static_cast<int32_t>(FOCUS_DRAW_LEVEL.size())) {
7185         GetArkUINodeModifiers()->getCommonModifier()->setAccessibilityFocusDrawLevel(nativeNode, intValue);
7186     } else {
7187         GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityFocusDrawLevel(nativeNode);
7188     }
7189     return panda::JSValueRef::Undefined(vm);
7190 }
7191 
ResetAccessibilityFocusDrawLevel(ArkUIRuntimeCallInfo * runtimeCallInfo)7192 ArkUINativeModuleValue CommonBridge::ResetAccessibilityFocusDrawLevel(ArkUIRuntimeCallInfo* runtimeCallInfo)
7193 {
7194     EcmaVM* vm = runtimeCallInfo->GetVM();
7195     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7196     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7197     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7198     GetArkUINodeModifiers()->getCommonModifier()->resetAccessibilityFocusDrawLevel(nativeNode);
7199     return panda::JSValueRef::Undefined(vm);
7200 }
7201 
SetHoverEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)7202 ArkUINativeModuleValue CommonBridge::SetHoverEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
7203 {
7204     EcmaVM* vm = runtimeCallInfo->GetVM();
7205     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7206     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7207     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7208     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7209 
7210     if (secondArg->IsUndefined() || !secondArg->IsNumber()) {
7211         GetArkUINodeModifiers()->getCommonModifier()->resetHoverEffect(nativeNode);
7212         return panda::JSValueRef::Undefined(vm);
7213     }
7214     int32_t intValue = secondArg->Int32Value(vm);
7215     GetArkUINodeModifiers()->getCommonModifier()->setHoverEffect(nativeNode, intValue);
7216     return panda::JSValueRef::Undefined(vm);
7217 }
7218 
ResetHoverEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)7219 ArkUINativeModuleValue CommonBridge::ResetHoverEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
7220 {
7221     EcmaVM* vm = runtimeCallInfo->GetVM();
7222     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7223     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7224     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7225     GetArkUINodeModifiers()->getCommonModifier()->resetHoverEffect(nativeNode);
7226     return panda::JSValueRef::Undefined(vm);
7227 }
7228 
SetClickEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)7229 ArkUINativeModuleValue CommonBridge::SetClickEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
7230 {
7231     EcmaVM* vm = runtimeCallInfo->GetVM();
7232     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7233     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7234     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7235     Local<JSValueRef> levelArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7236     Local<JSValueRef> scaleArg = runtimeCallInfo->GetCallArgRef(NUM_2);
7237 
7238     int32_t clickEffectLevelValue = 0;
7239     if (levelArg->IsNumber()) {
7240         clickEffectLevelValue = levelArg->Int32Value(vm);
7241         if (clickEffectLevelValue < static_cast<int32_t>(OHOS::Ace::ClickEffectLevel::LIGHT) ||
7242             clickEffectLevelValue > static_cast<int32_t>(OHOS::Ace::ClickEffectLevel::HEAVY)) {
7243             clickEffectLevelValue = 0;
7244         }
7245     }
7246     float scaleNumberValue = 0.9f;
7247     if (!scaleArg->IsNumber()) {
7248         if ((OHOS::Ace::ClickEffectLevel)clickEffectLevelValue == OHOS::Ace::ClickEffectLevel::MIDDLE ||
7249             (OHOS::Ace::ClickEffectLevel)clickEffectLevelValue == OHOS::Ace::ClickEffectLevel::HEAVY) {
7250             scaleNumberValue = 0.95f;
7251         }
7252     } else {
7253         scaleNumberValue = scaleArg->ToNumber(vm)->Value();
7254         if (LessNotEqual(scaleNumberValue, 0.0) || GreatNotEqual(scaleNumberValue, 1.0)) {
7255             if ((OHOS::Ace::ClickEffectLevel)clickEffectLevelValue == OHOS::Ace::ClickEffectLevel::MIDDLE ||
7256                 (OHOS::Ace::ClickEffectLevel)clickEffectLevelValue == OHOS::Ace::ClickEffectLevel::HEAVY) {
7257                 scaleNumberValue = 0.95f;
7258             } else {
7259                 scaleNumberValue = 0.9f;
7260             }
7261         }
7262     }
7263     GetArkUINodeModifiers()->getCommonModifier()->setClickEffect(nativeNode, clickEffectLevelValue,
7264         scaleNumberValue);
7265     return panda::JSValueRef::Undefined(vm);
7266 }
7267 
ResetClickEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)7268 ArkUINativeModuleValue CommonBridge::ResetClickEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
7269 {
7270     EcmaVM* vm = runtimeCallInfo->GetVM();
7271     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7272     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7273     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7274     GetArkUINodeModifiers()->getCommonModifier()->resetClickEffect(nativeNode);
7275     return panda::JSValueRef::Undefined(vm);
7276 }
7277 
SetKeyBoardShortCut(ArkUIRuntimeCallInfo * runtimeCallInfo)7278 ArkUINativeModuleValue CommonBridge::SetKeyBoardShortCut(ArkUIRuntimeCallInfo* runtimeCallInfo)
7279 {
7280     EcmaVM* vm = runtimeCallInfo->GetVM();
7281     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7282     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7283     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7284     Local<JSValueRef> keysArg = runtimeCallInfo->GetCallArgRef(NUM_2);
7285     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7286     if ((!valueArg->IsString(vm) && !valueArg->IsNumber()) || !keysArg->IsArray(vm)) {
7287         GetArkUINodeModifiers()->getCommonModifier()->resetKeyBoardShortCut(nativeNode);
7288         return panda::JSValueRef::Undefined(vm);
7289     }
7290     std::string stringValue;
7291     if (valueArg->IsNumber()) {
7292         OHOS::Ace::FunctionKey functionkey = static_cast<OHOS::Ace::FunctionKey>(valueArg->Int32Value(vm));
7293         stringValue = JSViewAbstract::GetFunctionKeyName(functionkey);
7294     } else {
7295         stringValue = valueArg->ToString(vm)->ToString(vm);
7296     }
7297     Local<panda::ArrayRef> keysArray = static_cast<Local<panda::ArrayRef>>(keysArg);
7298     auto arrLength = keysArray->Length(vm);
7299     if (arrLength > NUM_10) {
7300         arrLength = NUM_10;
7301     }
7302     std::vector<OHOS::Ace::ModifierKey> keysVector(arrLength);
7303     for (uint32_t i = 0; i < arrLength; i++) {
7304         Local<JSValueRef> objValue = keysArray->GetValueAt(vm, keysArg, i);
7305         keysVector.emplace_back(static_cast<OHOS::Ace::ModifierKey>(objValue->Int32Value(vm)));
7306     }
7307     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
7308     if (runtimeCallInfo->GetArgsNumber() == NUM_4) {
7309         Local<JSValueRef> actionArg = runtimeCallInfo->GetCallArgRef(NUM_3);
7310         auto obj = actionArg->ToObject(vm);
7311         auto containerId = Container::CurrentId();
7312         panda::Local<panda::FunctionRef> func = obj;
7313         auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
7314         auto onActionFunc = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
7315                                 node = AceType::WeakClaim(frameNode), containerId]() {
7316             panda::LocalScope pandaScope(vm);
7317             panda::TryCatch trycatch(vm);
7318             ContainerScope scope(containerId);
7319             auto function = func.Lock();
7320             CHECK_NULL_VOID(!function.IsEmpty());
7321             CHECK_NULL_VOID(function->IsFunction(vm));
7322             PipelineContext::SetCallBackNode(node);
7323             function->Call(vm, function.ToLocal(), nullptr, 0);
7324         };
7325         ViewAbstractModelNG::SetKeyboardShortcut(frameNode, stringValue, keysVector, std::move(onActionFunc));
7326         return panda::JSValueRef::Undefined(vm);
7327     }
7328     ViewAbstractModelNG::SetKeyboardShortcut(frameNode, stringValue, keysVector, nullptr);
7329     return panda::JSValueRef::Undefined(vm);
7330 }
7331 
ResetKeyBoardShortCut(ArkUIRuntimeCallInfo * runtimeCallInfo)7332 ArkUINativeModuleValue CommonBridge::ResetKeyBoardShortCut(ArkUIRuntimeCallInfo* runtimeCallInfo)
7333 {
7334     EcmaVM* vm = runtimeCallInfo->GetVM();
7335     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7336     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
7337     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7338     GetArkUINodeModifiers()->getCommonModifier()->resetKeyBoardShortCut(nativeNode);
7339     return panda::JSValueRef::Undefined(vm);
7340 }
7341 
CreateResourceWrapper()7342 RefPtr<ResourceWrapper> CreateResourceWrapper()
7343 {
7344     RefPtr<ResourceAdapter> resourceAdapter = nullptr;
7345     RefPtr<ThemeConstants> themeConstants = nullptr;
7346     if (SystemProperties::GetResourceDecoupling()) {
7347         resourceAdapter = ResourceManager::GetInstance().GetResourceAdapter(Container::CurrentIdSafely());
7348         if (!resourceAdapter) {
7349             return nullptr;
7350         }
7351     } else {
7352         themeConstants = JSViewAbstract::GetThemeConstants();
7353         if (!themeConstants) {
7354             return nullptr;
7355         }
7356     }
7357     auto resourceWrapper = AceType::MakeRefPtr<ResourceWrapper>(themeConstants, resourceAdapter);
7358     return resourceWrapper;
7359 }
7360 
ParseLightPosition(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,ArkUISizeType & dimPosX,ArkUISizeType & dimPosY,ArkUISizeType & dimPosZ,std::vector<RefPtr<ResourceObject>> & vectorResObj)7361 bool ParseLightPosition(ArkUIRuntimeCallInfo *runtimeCallInfo, EcmaVM* vm, ArkUISizeType& dimPosX,
7362     ArkUISizeType& dimPosY, ArkUISizeType& dimPosZ, std::vector<RefPtr<ResourceObject>>& vectorResObj)
7363 {
7364     Local<JSValueRef> positionXArg = runtimeCallInfo->GetCallArgRef(NUM_1);
7365     Local<JSValueRef> positionYArg = runtimeCallInfo->GetCallArgRef(NUM_2);
7366     Local<JSValueRef> positionZArg = runtimeCallInfo->GetCallArgRef(NUM_3);
7367     CalcDimension dimPositionX;
7368     CalcDimension dimPositionY;
7369     CalcDimension dimPositionZ;
7370     RefPtr<ResourceObject> xResObj;
7371     RefPtr<ResourceObject> yResObj;
7372     RefPtr<ResourceObject> zResObj;
7373     bool xSuccess = ArkTSUtils::ParseJsDimensionVp(vm, positionXArg, dimPositionX, xResObj, false);
7374     bool ySuccess = ArkTSUtils::ParseJsDimensionVp(vm, positionYArg, dimPositionY, yResObj, false);
7375     bool zSuccess = ArkTSUtils::ParseJsDimensionVp(vm, positionZArg, dimPositionZ, zResObj, false);
7376     if (!(xSuccess && ySuccess && zSuccess)) {
7377         return false;
7378     }
7379     if (xResObj) {
7380         vectorResObj.emplace_back(xResObj);
7381     } else {
7382         vectorResObj.emplace_back(nullptr);
7383     }
7384     if (yResObj) {
7385         vectorResObj.emplace_back(yResObj);
7386     } else {
7387         vectorResObj.emplace_back(nullptr);
7388     }
7389     if (zResObj) {
7390         vectorResObj.emplace_back(zResObj);
7391     } else {
7392         vectorResObj.emplace_back(nullptr);
7393     }
7394     dimPosX.value = dimPositionX.Value();
7395     dimPosX.unit = static_cast<int8_t>(dimPositionX.Unit());
7396     dimPosY.value = dimPositionY.Value();
7397     dimPosY.unit = static_cast<int8_t>(dimPositionY.Unit());
7398     dimPosZ.value = dimPositionZ.Value();
7399     dimPosZ.unit = static_cast<int8_t>(dimPositionZ.Unit());
7400     return true;
7401 }
7402 
ParseLightSource(ArkUIRuntimeCallInfo * runtimeCallInfo,EcmaVM * vm,ArkUINodeHandle nativeNode)7403 void ParseLightSource(ArkUIRuntimeCallInfo *runtimeCallInfo, EcmaVM* vm, ArkUINodeHandle nativeNode)
7404 {
7405     struct ArkUISizeType dimPosX = { 0.0, 0 };
7406     struct ArkUISizeType dimPosY = { 0.0, 0 };
7407     struct ArkUISizeType dimPosZ = { 0.0, 0 };
7408     std::vector<RefPtr<ResourceObject>> vectorResObj;
7409     bool success  = ParseLightPosition(runtimeCallInfo, vm, dimPosX, dimPosY, dimPosZ, vectorResObj);
7410     if (success) {
7411         auto resRawPtr = static_cast<void*>(&vectorResObj);
7412         GetArkUINodeModifiers()->getCommonModifier()->setPointLightPosition(
7413             nativeNode, &dimPosX, &dimPosY, &dimPosZ, resRawPtr);
7414     } else {
7415         GetArkUINodeModifiers()->getCommonModifier()->resetPointLightPosition(nativeNode);
7416     }
7417 
7418     Local<JSValueRef> intensityArg = runtimeCallInfo->GetCallArgRef(NUM_4);
7419     if (intensityArg->IsNumber()) {
7420         auto intensityValue = static_cast<ArkUI_Float32>((intensityArg->ToNumber(vm)->Value()));
7421         GetArkUINodeModifiers()->getCommonModifier()->setPointLightIntensity(nativeNode, intensityValue);
7422     } else {
7423         GetArkUINodeModifiers()->getCommonModifier()->resetPointLightIntensity(nativeNode);
7424     }
7425 
7426     Local<JSValueRef> colorArg = runtimeCallInfo->GetCallArgRef(NUM_5);
7427     Color colorValue;
7428     RefPtr<ResourceObject> colorResObj;
7429     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
7430     if (ArkTSUtils::ParseJsColorAlpha(vm, colorArg, colorValue, colorResObj, nodeInfo)) {
7431         auto colorRawPtr = AceType::RawPtr(colorResObj);
7432         GetArkUINodeModifiers()->getCommonModifier()->setPointLightColor(nativeNode, colorValue.GetValue(), colorRawPtr);
7433     } else {
7434         GetArkUINodeModifiers()->getCommonModifier()->resetPointLightColor(nativeNode);
7435     }
7436 }
7437 
SetPointLightStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)7438 ArkUINativeModuleValue CommonBridge::SetPointLightStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
7439 {
7440     EcmaVM* vm = runtimeCallInfo->GetVM();
7441 #ifdef POINT_LIGHT_ENABLE
7442     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7443     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
7444     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7445 
7446     ParseLightSource(runtimeCallInfo, vm, nativeNode);
7447 
7448     auto resourceWrapper = CreateResourceWrapper();
7449     Local<JSValueRef> illuminatedArg = runtimeCallInfo->GetCallArgRef(NUM_6);
7450     if (illuminatedArg->IsNumber() || !resourceWrapper) {
7451         auto illuminatedValue = static_cast<ArkUI_Uint32>(illuminatedArg->ToNumber(vm)->Value());
7452         Dimension illuminatedBorderWidth = resourceWrapper->GetDimensionByName(ILLUMINATED_BORDER_WIDTH_SYS_RES_NAME);
7453         struct ArkUISizeType illuminatedBorderWidthValue = { 0.0, 0 };
7454         illuminatedBorderWidthValue.value = illuminatedBorderWidth.Value();
7455         illuminatedBorderWidthValue.unit = static_cast<int8_t>(illuminatedBorderWidth.Unit());
7456         GetArkUINodeModifiers()->getCommonModifier()->setPointLightIlluminated(
7457             nativeNode, illuminatedValue, &illuminatedBorderWidthValue);
7458     } else {
7459         GetArkUINodeModifiers()->getCommonModifier()->resetPointLightIlluminated(nativeNode);
7460     }
7461 
7462     Local<JSValueRef> bloomArg = runtimeCallInfo->GetCallArgRef(NUM_7);
7463     if (bloomArg->IsNumber() || !resourceWrapper) {
7464         auto bloomValue = static_cast<ArkUI_Float32>(bloomArg->ToNumber(vm)->Value());
7465         double bloomRadius = resourceWrapper->GetDoubleByName(BLOOM_RADIUS_SYS_RES_NAME);
7466         Color bloomColor = resourceWrapper->GetColorByName(BLOOM_COLOR_SYS_RES_NAME);
7467         GetArkUINodeModifiers()->getCommonModifier()->setPointLightBloom(nativeNode, bloomValue,
7468             static_cast<ArkUI_Float32>(bloomRadius), static_cast<ArkUI_Uint32>(bloomColor.GetValue()));
7469     } else {
7470         GetArkUINodeModifiers()->getCommonModifier()->resetPointLightBloom(nativeNode);
7471     }
7472 #endif
7473     return panda::JSValueRef::Undefined(vm);
7474 }
7475 
ResetPointLightStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)7476 ArkUINativeModuleValue CommonBridge::ResetPointLightStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
7477 {
7478     EcmaVM *vm = runtimeCallInfo->GetVM();
7479 #ifdef POINT_LIGHT_ENABLE
7480     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7481     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
7482     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7483     GetArkUINodeModifiers()->getCommonModifier()->resetPointLightPosition(nativeNode);
7484     GetArkUINodeModifiers()->getCommonModifier()->resetPointLightIntensity(nativeNode);
7485     GetArkUINodeModifiers()->getCommonModifier()->resetPointLightColor(nativeNode);
7486     GetArkUINodeModifiers()->getCommonModifier()->resetPointLightIlluminated(nativeNode);
7487     GetArkUINodeModifiers()->getCommonModifier()->resetPointLightBloom(nativeNode);
7488 #endif
7489     return panda::JSValueRef::Undefined(vm);
7490 }
7491 
SetClipWithEdge(ArkUIRuntimeCallInfo * runtimeCallInfo)7492 ArkUINativeModuleValue CommonBridge::SetClipWithEdge(ArkUIRuntimeCallInfo *runtimeCallInfo)
7493 {
7494     EcmaVM *vm = runtimeCallInfo->GetVM();
7495     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7496     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
7497     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7498     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
7499 
7500     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
7501     if (info[NUM_1]->IsUndefined()) {
7502         ViewAbstract::SetClipEdge(frameNode, true);
7503         return panda::JSValueRef::Undefined(vm);
7504     }
7505     if (info[NUM_1]->IsObject()) {
7506         Framework::JSShapeAbstract *clipShape =
7507             Framework::JSRef<Framework::JSObject>::Cast(info[NUM_1])->Unwrap<Framework::JSShapeAbstract>();
7508         if (clipShape == nullptr) {
7509             return panda::JSValueRef::Undefined(vm);
7510         }
7511         ViewAbstract::SetClipShape(frameNode, clipShape->GetBasicShape());
7512     } else if (info[NUM_1]->IsBoolean()) {
7513         ViewAbstract::SetClipEdge(frameNode, info[NUM_1]->ToBoolean());
7514     }
7515     return panda::JSValueRef::Undefined(vm);
7516 }
7517 
ResetClipWithEdge(ArkUIRuntimeCallInfo * runtimeCallInfo)7518 ArkUINativeModuleValue CommonBridge::ResetClipWithEdge(ArkUIRuntimeCallInfo *runtimeCallInfo)
7519 {
7520     EcmaVM *vm = runtimeCallInfo->GetVM();
7521     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
7522     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
7523     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7524     auto *frameNode = reinterpret_cast<FrameNode *>(nativeNode);
7525     ViewAbstract::SetClipEdge(frameNode, true);
7526     return panda::JSValueRef::Undefined(vm);
7527 }
7528 
GetFrameNode(ArkUIRuntimeCallInfo * runtimeCallInfo)7529 FrameNode* CommonBridge::GetFrameNode(ArkUIRuntimeCallInfo* runtimeCallInfo)
7530 {
7531     EcmaVM* vm = runtimeCallInfo->GetVM();
7532     CHECK_NULL_RETURN(vm, nullptr);
7533     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
7534     CHECK_NULL_RETURN(!firstArg.IsNull() && firstArg->IsNativePointer(vm), nullptr);
7535     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
7536     CHECK_NULL_RETURN(nativeNode, nullptr);
7537     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
7538     return frameNode;
7539 }
7540 
CreateChangeValueInfoObj(EcmaVM * vm,const ChangeValueInfo & changeValueInfo)7541 Local<panda::ObjectRef> CommonBridge::CreateChangeValueInfoObj(EcmaVM* vm, const ChangeValueInfo& changeValueInfo)
7542 {
7543     const char* previewTextKeys[] = { "value", "offset" };
7544     Local<JSValueRef> previewTextValues[] = {
7545         panda::StringRef::NewFromUtf16(vm, changeValueInfo.previewText.value.c_str()),
7546         panda::NumberRef::New(vm, changeValueInfo.previewText.offset) };
7547     auto previewTextObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(previewTextKeys),
7548         previewTextKeys, previewTextValues);
7549 
7550     const char* rangeKeys[] = { "start", "end" };
7551     Local<JSValueRef> rangeBeforeValues[] = {
7552         panda::NumberRef::New(vm, changeValueInfo.rangeBefore.start),
7553         panda::NumberRef::New(vm, changeValueInfo.rangeBefore.end) };
7554     auto rangeBeforeObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(rangeKeys),
7555         rangeKeys, rangeBeforeValues);
7556     Local<JSValueRef> rangeAfterValues[] = {
7557         panda::NumberRef::New(vm, changeValueInfo.rangeAfter.start),
7558         panda::NumberRef::New(vm, changeValueInfo.rangeAfter.end) };
7559     auto rangeAfterObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(rangeKeys),
7560         rangeKeys, rangeAfterValues);
7561     Local<JSValueRef> oldPreviewTextValues[] = {
7562         panda::StringRef::NewFromUtf16(vm, changeValueInfo.oldPreviewText.value.c_str()),
7563         panda::NumberRef::New(vm, changeValueInfo.oldPreviewText.offset) };
7564     auto oldPreviewTextObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(previewTextKeys),
7565         previewTextKeys, oldPreviewTextValues);
7566 
7567     const char* optionsKeys[] = { "rangeBefore", "rangeAfter", "oldContent", "oldPreviewText" };
7568     Local<JSValueRef> optionsValues[] = { rangeBeforeObj, rangeAfterObj,
7569         panda::StringRef::NewFromUtf16(vm, changeValueInfo.oldContent.c_str()), oldPreviewTextObj };
7570     auto optionsObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(optionsKeys),
7571         optionsKeys, optionsValues);
7572 
7573     const char* changeValueInfoKeys[] = { "content", "previewText", "options" };
7574     Local<JSValueRef> changeValueInfoValues[] = { panda::StringRef::NewFromUtf16(vm, changeValueInfo.value.c_str()),
7575         previewTextObj, optionsObj };
7576     auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(changeValueInfoKeys),
7577         changeValueInfoKeys, changeValueInfoValues);
7578     return eventObject;
7579 }
7580 
CreateGestureInfo(EcmaVM * vm,const RefPtr<NG::GestureInfo> & gestureInfo)7581 Local<panda::ObjectRef> CommonBridge::CreateGestureInfo(EcmaVM* vm, const RefPtr<NG::GestureInfo>& gestureInfo)
7582 {
7583     if (gestureInfo->GetTag().has_value()) {
7584         const char* keys[] = { "tag", "type", "isSystemGesture" };
7585         Local<JSValueRef> values[] = { panda::StringRef::NewFromUtf8(vm, gestureInfo->GetTag().value().c_str()),
7586             panda::NumberRef::New(vm, static_cast<int32_t>(gestureInfo->GetType())),
7587             panda::BooleanRef::New(vm, gestureInfo->IsSystemGesture()) };
7588         return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7589     }
7590     const char* keys[] = { "type", "isSystemGesture" };
7591     Local<JSValueRef> values[] = { panda::NumberRef::New(vm, static_cast<int32_t>(gestureInfo->GetType())),
7592         panda::BooleanRef::New(vm, gestureInfo->IsSystemGesture()) };
7593     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7594 }
7595 
CreateGestureEventInfo(EcmaVM * vm,GestureTypeName typeName,const std::shared_ptr<BaseGestureEvent> & info)7596 Local<panda::ObjectRef> CommonBridge::CreateGestureEventInfo(
7597     EcmaVM* vm, GestureTypeName typeName, const std::shared_ptr<BaseGestureEvent>& info)
7598 {
7599     auto obj = SetUniqueAttributes(vm, typeName, info);
7600     SetCommonAttributes(obj, vm, info);
7601     auto fingerArr = panda::ArrayRef::New(vm);
7602     const std::list<FingerInfo>& fingerList = info->GetFingerList();
7603     std::list<FingerInfo> notTouchFingerList;
7604     int32_t maxFingerId = -1;
7605     for (const FingerInfo& fingerInfo : fingerList) {
7606         auto element = CreateFingerInfo(vm, fingerInfo);
7607         if (fingerInfo.sourceType_ == SourceType::TOUCH && fingerInfo.sourceTool_ == SourceTool::FINGER) {
7608             fingerArr->SetValueAt(vm, fingerArr, fingerInfo.fingerId_, element);
7609             if (fingerInfo.fingerId_ > maxFingerId) {
7610                 maxFingerId = fingerInfo.fingerId_;
7611             }
7612         } else {
7613             notTouchFingerList.emplace_back(fingerInfo);
7614         }
7615     }
7616     auto idx = maxFingerId + 1;
7617     for (const FingerInfo& fingerInfo : notTouchFingerList) {
7618         auto element = CreateFingerInfo(vm, fingerInfo);
7619         fingerArr->SetValueAt(vm, fingerArr, idx++, element);
7620     }
7621     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "fingerList"), fingerArr);
7622     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "target"), CreateEventTargetObject(vm, info));
7623     CreateFingerInfosInfo(vm, info, obj);
7624     obj->SetNativePointerFieldCount(vm, 1);
7625     obj->SetNativePointerField(vm, 0, static_cast<void*>(info.get()));
7626     return obj;
7627 }
7628 
SetCommonAttributes(Local<panda::ObjectRef> & obj,EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info)7629 void CommonBridge::SetCommonAttributes(
7630     Local<panda::ObjectRef>& obj, EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info)
7631 {
7632     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "timestamp"),
7633         panda::NumberRef::New(vm, static_cast<double>(info->GetTimeStamp().time_since_epoch().count())));
7634     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "source"),
7635         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetSourceDevice())));
7636     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "pressure"), panda::NumberRef::New(vm, info->GetForce()));
7637     if (info->GetTiltX().has_value()) {
7638         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltX"), panda::NumberRef::New(vm, info->GetTiltX().value()));
7639     }
7640     if (info->GetTiltY().has_value()) {
7641         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltY"), panda::NumberRef::New(vm, info->GetTiltY().value()));
7642     }
7643     if (info->GetRollAngle().has_value()) {
7644         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"),
7645             panda::NumberRef::New(vm, info->GetRollAngle().value()));
7646     }
7647     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "sourceTool"),
7648         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetSourceTool())));
7649     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "deviceId"),
7650         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetDeviceId())));
7651     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"),
7652         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetTargetDisplayId())));
7653     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisVertical"), panda::NumberRef::New(vm, info->GetVerticalAxis()));
7654     obj->Set(
7655         vm, panda::StringRef::NewFromUtf8(vm, "axisHorizontal"), panda::NumberRef::New(vm, info->GetHorizontalAxis()));
7656     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "getModifierKeyState"),
7657         panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState));
7658 }
7659 
CreateGestureEventInfo(EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info)7660 Local<panda::ObjectRef> CommonBridge::CreateGestureEventInfo(EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info)
7661 {
7662     auto obj = panda::ObjectRef::New(vm);
7663     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "timestamp"),
7664         panda::NumberRef::New(vm, static_cast<double>(info->GetTimeStamp().time_since_epoch().count())));
7665     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "source"),
7666         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetSourceDevice())));
7667     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "pressure"), panda::NumberRef::New(vm, info->GetForce()));
7668     if (info->GetTiltX().has_value()) {
7669         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltX"), panda::NumberRef::New(vm, info->GetTiltX().value()));
7670     }
7671     if (info->GetTiltY().has_value()) {
7672         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltY"), panda::NumberRef::New(vm, info->GetTiltY().value()));
7673     }
7674     if (info->GetRollAngle().has_value()) {
7675         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"),
7676             panda::NumberRef::New(vm, info->GetRollAngle().value()));
7677     }
7678     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "sourceTool"),
7679         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetSourceTool())));
7680     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "deviceId"),
7681         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetDeviceId())));
7682     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"),
7683         panda::NumberRef::New(vm, static_cast<int32_t>(info->GetTargetDisplayId())));
7684     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisVertical"), panda::NumberRef::New(vm, info->GetVerticalAxis()));
7685     obj->Set(
7686         vm, panda::StringRef::NewFromUtf8(vm, "axisHorizontal"), panda::NumberRef::New(vm, info->GetHorizontalAxis()));
7687     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "getModifierKeyState"),
7688         panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState));
7689 
7690     auto fingerArr = panda::ArrayRef::New(vm);
7691     const std::list<FingerInfo>& fingerList = info->GetFingerList();
7692     std::list<FingerInfo> notTouchFingerList;
7693     int32_t maxFingerId = -1;
7694     for (const FingerInfo& fingerInfo : fingerList) {
7695         auto element = CreateFingerInfo(vm, fingerInfo);
7696         if (fingerInfo.sourceType_ == SourceType::TOUCH && fingerInfo.sourceTool_ == SourceTool::FINGER) {
7697             fingerArr->SetValueAt(vm, fingerArr, fingerInfo.fingerId_, element);
7698             if (fingerInfo.fingerId_ > maxFingerId) {
7699                 maxFingerId = fingerInfo.fingerId_;
7700             }
7701         } else {
7702             notTouchFingerList.emplace_back(fingerInfo);
7703         }
7704     }
7705     auto idx = maxFingerId + 1;
7706     for (const FingerInfo& fingerInfo : notTouchFingerList) {
7707         auto element = CreateFingerInfo(vm, fingerInfo);
7708         fingerArr->SetValueAt(vm, fingerArr, idx++, element);
7709     }
7710     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "fingerList"), fingerArr);
7711     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "target"), CreateEventTargetObject(vm, info));
7712     CreateFingerInfosInfo(vm, info, obj);
7713     obj->SetNativePointerFieldCount(vm, 1);
7714     obj->SetNativePointerField(vm, 0, static_cast<void*>(info.get()));
7715     return obj;
7716 }
7717 
CreateFingerInfosInfo(EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info,Local<panda::ObjectRef> & obj)7718 Local<panda::ObjectRef> CommonBridge::CreateFingerInfosInfo(
7719     EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info, Local<panda::ObjectRef>& obj)
7720 {
7721     auto fingerArr = panda::ArrayRef::New(vm);
7722     const std::list<FingerInfo>& fingerList = info->GetFingerList();
7723     std::list<FingerInfo> notTouchFingerList;
7724     std::vector<Local<panda::ObjectRef>> validFingers;
7725     for (const FingerInfo& fingerInfo : fingerList) {
7726         auto element = CreateFingerInfo(vm, fingerInfo);
7727         if (fingerInfo.sourceType_ == SourceType::TOUCH && fingerInfo.sourceTool_ == SourceTool::FINGER) {
7728             validFingers.emplace_back(element);
7729         } else {
7730             notTouchFingerList.emplace_back(fingerInfo);
7731         }
7732     }
7733     for (size_t i = 0; i < validFingers.size(); ++i) {
7734         fingerArr->SetValueAt(vm, fingerArr, i, validFingers[i]);
7735     }
7736     auto idx = validFingers.size();
7737     for (const FingerInfo& fingerInfo : notTouchFingerList) {
7738         auto element = CreateFingerInfo(vm, fingerInfo);
7739         fingerArr->SetValueAt(vm, fingerArr, idx++, element);
7740     }
7741     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "fingerInfos"), fingerArr);
7742     return obj;
7743 }
7744 
SetUniqueAttributes(EcmaVM * vm,GestureTypeName typeName,const std::shared_ptr<BaseGestureEvent> & info)7745 Local<panda::ObjectRef> CommonBridge::SetUniqueAttributes(
7746     EcmaVM* vm, GestureTypeName typeName, const std::shared_ptr<BaseGestureEvent>& info)
7747 {
7748     double density = PipelineBase::GetCurrentDensity();
7749     switch (typeName) {
7750         case OHOS::Ace::GestureTypeName::TAP_GESTURE: {
7751             const char* keys[] = { "tapLocation" };
7752             Local<JSValueRef> values[] = { CreateTapGestureLocationInfo(vm,info) };
7753             return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7754         }
7755         case OHOS::Ace::GestureTypeName::LONG_PRESS_GESTURE: {
7756             auto* longPressGestureEvent = TypeInfoHelper::DynamicCast<LongPressGestureEvent>(info.get());
7757             if (longPressGestureEvent) {
7758                 const char* keys[] = { "repeat" };
7759                 Local<JSValueRef> values[] = { panda::BooleanRef::New(vm, longPressGestureEvent->GetRepeat()) };
7760                 return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7761             }
7762             return panda::ObjectRef::New(vm);
7763         }
7764         case OHOS::Ace::GestureTypeName::PAN_GESTURE: {
7765             auto* panGestureEvent = TypeInfoHelper::DynamicCast<PanGestureEvent>(info.get());
7766             if (panGestureEvent) {
7767                 const char* keys[] = { "offsetX", "offsetY", "velocityX", "velocityY", "velocity" };
7768                 Local<JSValueRef> values[] = { panda::NumberRef::New(vm, panGestureEvent->GetOffsetX() / density),
7769                     panda::NumberRef::New(vm, panGestureEvent->GetOffsetY() / density),
7770                     panda::NumberRef::New(vm, panGestureEvent->GetVelocity().GetVelocityX() / density),
7771                     panda::NumberRef::New(vm, panGestureEvent->GetVelocity().GetVelocityY() / density),
7772                     panda::NumberRef::New(vm, panGestureEvent->GetVelocity().GetVelocityValue() / density) };
7773                 return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7774             }
7775             return panda::ObjectRef::New(vm);
7776         }
7777         case OHOS::Ace::GestureTypeName::PINCH_GESTURE: {
7778             auto* pinchGestureEvent = TypeInfoHelper::DynamicCast<PinchGestureEvent>(info.get());
7779             if (pinchGestureEvent) {
7780                 const char* keys[] = { "scale", "pinchCenterX", "pinchCenterY" };
7781                 Local<JSValueRef> values[] = { panda::NumberRef::New(vm, pinchGestureEvent->GetScale()),
7782                     panda::NumberRef::New(vm, pinchGestureEvent->GetPinchCenter().GetX() / density),
7783                     panda::NumberRef::New(vm, pinchGestureEvent->GetPinchCenter().GetY() / density) };
7784                 return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7785             }
7786             return panda::ObjectRef::New(vm);
7787         }
7788         case OHOS::Ace::GestureTypeName::ROTATION_GESTURE: {
7789             auto* rotationGestureEvent = TypeInfoHelper::DynamicCast<RotationGestureEvent>(info.get());
7790             if (rotationGestureEvent) {
7791                 const char* keys[] = { "angle" };
7792                 Local<JSValueRef> values[] = { panda::NumberRef::New(vm, rotationGestureEvent->GetAngle()) };
7793                 return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7794             }
7795             return panda::ObjectRef::New(vm);
7796         }
7797         case OHOS::Ace::GestureTypeName::SWIPE_GESTURE: {
7798             auto* swipeGestureEvent = TypeInfoHelper::DynamicCast<SwipeGestureEvent>(info.get());
7799             if (swipeGestureEvent) {
7800                 const char* keys[] = { "angle", "speed" };
7801                 Local<JSValueRef> values[] = { panda::NumberRef::New(vm, swipeGestureEvent->GetAngle()),
7802                     panda::NumberRef::New(vm, swipeGestureEvent->GetSpeed()) };
7803                 return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7804             }
7805             return panda::ObjectRef::New(vm);
7806         }
7807         default:
7808             return panda::ObjectRef::New(vm);
7809     }
7810 }
7811 
CreateRecognizerObject(EcmaVM * vm,const RefPtr<NG::NGGestureRecognizer> & target)7812 Local<panda::ObjectRef> CommonBridge::CreateRecognizerObject(EcmaVM* vm, const RefPtr<NG::NGGestureRecognizer>& target)
7813 {
7814     auto panRecognizer = AceType::DynamicCast<NG::PanRecognizer>(target);
7815     if (panRecognizer) {
7816         JSRef<JSObject> recognizerObj = JSClass<JSPanRecognizer>::NewInstance();
7817         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSPanRecognizer>());
7818         currentRecognizer->Update(panRecognizer);
7819         return recognizerObj->GetLocalHandle();
7820     }
7821     auto pinchRecognizer = AceType::DynamicCast<NG::PinchRecognizer>(target);
7822     if (pinchRecognizer) {
7823         JSRef<JSObject> recognizerObj = JSClass<JSPinchRecognizer>::NewInstance();
7824         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSPinchRecognizer>());
7825         currentRecognizer->Update(pinchRecognizer);
7826         return recognizerObj->GetLocalHandle();
7827     }
7828     auto tapRecognizer = AceType::DynamicCast<NG::ClickRecognizer>(target);
7829     if (tapRecognizer) {
7830         JSRef<JSObject> recognizerObj = JSClass<JSTapRecognizer>::NewInstance();
7831         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSTapRecognizer>());
7832         currentRecognizer->Update(tapRecognizer);
7833         return recognizerObj->GetLocalHandle();
7834     }
7835     auto longPressRecognizer = AceType::DynamicCast<NG::LongPressRecognizer>(target);
7836     if (longPressRecognizer) {
7837         JSRef<JSObject> recognizerObj = JSClass<JSLongPressRecognizer>::NewInstance();
7838         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSLongPressRecognizer>());
7839         currentRecognizer->Update(longPressRecognizer);
7840         return recognizerObj->GetLocalHandle();
7841     }
7842     auto rotationRecognizer = AceType::DynamicCast<NG::RotationRecognizer>(target);
7843     if (rotationRecognizer) {
7844         JSRef<JSObject> recognizerObj = JSClass<JSRotationRecognizer>::NewInstance();
7845         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSRotationRecognizer>());
7846         currentRecognizer->Update(rotationRecognizer);
7847         return recognizerObj->GetLocalHandle();
7848     }
7849     auto swipeRecognizer = AceType::DynamicCast<NG::SwipeRecognizer>(target);
7850     if (swipeRecognizer) {
7851         JSRef<JSObject> recognizerObj = JSClass<JSSwipeRecognizer>::NewInstance();
7852         auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSSwipeRecognizer>());
7853         currentRecognizer->Update(swipeRecognizer);
7854         return recognizerObj->GetLocalHandle();
7855     }
7856     JSRef<JSObject> recognizerObj = JSClass<JSGestureRecognizer>::NewInstance();
7857     auto currentRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSGestureRecognizer>());
7858     currentRecognizer->Update(target);
7859     return recognizerObj->GetLocalHandle();
7860 }
7861 
CreateTapGestureInfo(EcmaVM * vm,GestureEvent & info)7862 Local<panda::ObjectRef> CommonBridge::CreateTapGestureInfo(EcmaVM* vm, GestureEvent& info)
7863 {
7864     if (info.GetFingerList().empty()) {
7865         return panda::ObjectRef::New(vm);
7866     }
7867     auto fingerInfo = info.GetFingerList().back();
7868     const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_;
7869     const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_;
7870     const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_;
7871     const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_;
7872     const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY",
7873                            "globalDisplayX", "globalDisplayY"};
7874     Local<JSValueRef> values[] = {
7875         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX())),
7876         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())),
7877         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())),
7878         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())),
7879         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())),
7880         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())),
7881         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())),
7882         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())),
7883     };
7884     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7885 }
7886 
CreateTouchRecognizersObject(EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info,const RefPtr<NG::NGGestureRecognizer> & target)7887 Local<panda::ArrayRef> CommonBridge::CreateTouchRecognizersObject(
7888     EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info, const RefPtr<NG::NGGestureRecognizer>& target)
7889 {
7890     auto touchRecognizers = panda::ArrayRef::New(vm);
7891     auto frameNode = target->GetAttachedNode().Upgrade();
7892     CHECK_NULL_RETURN(frameNode, touchRecognizers);
7893     auto pipeline = frameNode->GetContext();
7894     CHECK_NULL_RETURN(pipeline, touchRecognizers);
7895     auto eventManager = pipeline->GetEventManager();
7896     CHECK_NULL_RETURN(eventManager, touchRecognizers);
7897     auto& touchTestResult = eventManager->touchTestResults_;
7898     TouchRecognizerMap touchRecognizerMap;
7899     const auto& fingerList = info->GetFingerList();
7900     for (const auto& finger : fingerList) {
7901         auto& touchTargetList = touchTestResult[finger.fingerId_];
7902         CollectTouchEventTarget(touchRecognizerMap, touchTargetList, AceType::RawPtr(frameNode), finger.fingerId_);
7903     }
7904     uint32_t touchRecognizersIdx = 0;
7905     for (auto& [item, fingerIds] : touchRecognizerMap) {
7906         JSRef<JSObject> recognizerObj = JSClass<JSTouchRecognizer>::NewInstance();
7907         auto jsRecognizer = Referenced::Claim(recognizerObj->Unwrap<JSTouchRecognizer>());
7908         if (jsRecognizer) {
7909             jsRecognizer->SetTouchData(item, fingerIds);
7910         }
7911         touchRecognizers->SetValueAt(vm, touchRecognizers, touchRecognizersIdx++, recognizerObj->GetLocalHandle());
7912     }
7913     return touchRecognizers;
7914 }
7915 
CreateTouchRecognizerMap(const std::shared_ptr<BaseGestureEvent> & info,const RefPtr<NG::NGGestureRecognizer> & current)7916 TouchRecognizerMap CommonBridge::CreateTouchRecognizerMap(
7917     const std::shared_ptr<BaseGestureEvent>& info, const RefPtr<NG::NGGestureRecognizer>& current)
7918 {
7919     TouchRecognizerMap touchRecognizerMap;
7920     auto frameNode = current->GetAttachedNode().Upgrade();
7921     CHECK_NULL_RETURN(frameNode, touchRecognizerMap);
7922     auto pipeline = frameNode->GetContext();
7923     CHECK_NULL_RETURN(pipeline, touchRecognizerMap);
7924     auto eventManager = pipeline->GetEventManager();
7925     CHECK_NULL_RETURN(eventManager, touchRecognizerMap);
7926     auto& touchTestResult = eventManager->touchTestResults_;
7927     const auto& fingerList = info->GetFingerList();
7928     for (const auto& finger : fingerList) {
7929         auto& touchTargetList = touchTestResult[finger.fingerId_];
7930         CollectTouchEventTarget(touchRecognizerMap, touchTargetList, AceType::RawPtr(frameNode), finger.fingerId_);
7931     }
7932     return touchRecognizerMap;
7933 }
7934 
CollectTouchEventTarget(TouchRecognizerMap & dict,std::list<RefPtr<TouchEventTarget>> & targets,NG::FrameNode * frameNode,int32_t fingerId)7935 void CommonBridge::CollectTouchEventTarget(
7936     TouchRecognizerMap& dict, std::list<RefPtr<TouchEventTarget>>& targets, NG::FrameNode* frameNode, int32_t fingerId)
7937 {
7938     for (auto& target : targets) {
7939         if (AceType::DynamicCast<NG::NGGestureRecognizer>(target)) {
7940             continue;
7941         }
7942         auto weakTarget = WeakPtr<TouchEventTarget>(target);
7943         if (dict.find(weakTarget) != dict.end() && dict[weakTarget].count(fingerId) > 0) {
7944             continue;
7945         }
7946         auto targetNode = target->GetAttachedNode().Upgrade();
7947         if (targetNode && targetNode == frameNode) {
7948             dict[weakTarget].insert(fingerId);
7949             return;
7950         }
7951         while (targetNode) {
7952             if (targetNode == frameNode) {
7953                 dict[weakTarget].insert(fingerId);
7954                 break;
7955             }
7956             targetNode = targetNode->GetParentFrameNode();
7957         }
7958     }
7959 }
7960 
CreateFingerInfo(EcmaVM * vm,const FingerInfo & fingerInfo)7961 Local<panda::ObjectRef> CommonBridge::CreateFingerInfo(EcmaVM* vm, const FingerInfo& fingerInfo)
7962 {
7963     const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_;
7964     const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_;
7965     const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_;
7966     const OHOS::Ace::Offset& globalDisplayLocation  = fingerInfo.globalDisplayLocation_;
7967     double density = PipelineBase::GetCurrentDensity();
7968     const char* keys[] = { "id", "globalX", "globalY", "localX", "localY", "displayX", "displayY",
7969                            "globalDisplayX", "globalDisplayY", "hand" };
7970     Local<JSValueRef> values[] = { panda::NumberRef::New(vm, fingerInfo.fingerId_),
7971         panda::NumberRef::New(vm, globalLocation.GetX() / density),
7972         panda::NumberRef::New(vm, globalLocation.GetY() / density),
7973         panda::NumberRef::New(vm, localLocation.GetX() / density),
7974         panda::NumberRef::New(vm, localLocation.GetY() / density),
7975         panda::NumberRef::New(vm, screenLocation.GetX() / density),
7976         panda::NumberRef::New(vm, screenLocation.GetY() / density),
7977         panda::NumberRef::New(vm, globalDisplayLocation.GetX() / density),
7978         panda::NumberRef::New(vm, globalDisplayLocation.GetY() / density),
7979         panda::NumberRef::New(vm, fingerInfo.operatingHand_) };
7980         return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
7981 }
7982 
CreateEventTargetObject(EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info)7983 Local<panda::ObjectRef> CommonBridge::CreateEventTargetObject(EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info)
7984 {
7985     const auto& localOffset = info->GetTarget().area.GetOffset();
7986     const auto& origin = info->GetTarget().origin;
7987     const char* keysOfOffset[] = { "x", "y" };
7988     Local<JSValueRef> valuesOfOffset[] = { panda::NumberRef::New(vm, localOffset.GetX().ConvertToVp()),
7989         panda::NumberRef::New(vm, localOffset.GetY().ConvertToVp()) };
7990     auto offset = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keysOfOffset), keysOfOffset, valuesOfOffset);
7991 
7992     const char* keysOfGlobalOffset[] = { "x", "y" };
7993     Local<JSValueRef> valuesOfGlobalOffset[] = { panda::NumberRef::New(
7994         vm, (origin.GetX() + localOffset.GetX()).ConvertToVp()),
7995         panda::NumberRef::New(vm, (origin.GetY() + localOffset.GetY()).ConvertToVp()) };
7996     auto globalOffset = panda::ObjectRef::NewWithNamedProperties(
7997         vm, ArraySize(keysOfGlobalOffset), keysOfGlobalOffset, valuesOfGlobalOffset);
7998     const char* keysOfArea[] = { "position", "globalPosition", "width", "height" };
7999     Local<JSValueRef> valuesOfArea[] = { offset, globalOffset,
8000         panda::NumberRef::New(vm, info->GetTarget().area.GetWidth().ConvertToVp()),
8001         panda::NumberRef::New(vm, info->GetTarget().area.GetHeight().ConvertToVp()) };
8002     auto area = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keysOfArea), keysOfArea, valuesOfArea);
8003     auto target = panda::ObjectRef::New(vm);
8004     target->Set(vm, panda::StringRef::NewFromUtf8(vm, "area"), area);
8005     if (info->GetTarget().id.empty()) {
8006         target->Set(vm, panda::StringRef::NewFromUtf8(vm, "id"), panda::JSValueRef().Undefined(vm));
8007     } else {
8008         target->Set(vm, panda::StringRef::NewFromUtf8(vm, "id"),
8009             panda::StringRef::NewFromUtf8(vm, info->GetTarget().id.c_str()));
8010     }
8011     return target;
8012 }
8013 
CreateAreaObject(EcmaVM * vm,const RectF & rect,const OffsetF & origin)8014 Local<panda::ObjectRef> CommonBridge::CreateAreaObject(EcmaVM* vm, const RectF& rect, const OffsetF& origin)
8015 {
8016     double density = PipelineBase::GetCurrentDensity();
8017     auto localOffset = rect.GetOffset();
8018     const char* keysOfOffset[] = { "x", "y" };
8019     Local<JSValueRef> valuesOfOffset[] = { panda::NumberRef::New(vm, localOffset.GetX() / density),
8020         panda::NumberRef::New(vm, localOffset.GetY() / density) };
8021     auto offset = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keysOfOffset), keysOfOffset, valuesOfOffset);
8022     const char* keysOfGlobalOffset[] = { "x", "y" };
8023     Local<JSValueRef> valuesOfGlobalOffset[] = { panda::NumberRef::New(
8024         vm, (localOffset.GetX() + origin.GetX()) / density),
8025         panda::NumberRef::New(vm, (localOffset.GetY() + origin.GetY()) / density) };
8026     auto globalOffset = panda::ObjectRef::NewWithNamedProperties(
8027         vm, ArraySize(keysOfGlobalOffset), keysOfGlobalOffset, valuesOfGlobalOffset);
8028 
8029     const char* keysOfArea[] = { "pos", "position", "globalPos", "globalPosition", "width", "height" };
8030     Local<JSValueRef> valuesOfArea[] = { offset, offset, globalOffset, globalOffset,
8031         panda::NumberRef::New(vm, rect.Width() / density), panda::NumberRef::New(vm, rect.Height() / density) };
8032     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keysOfArea), keysOfArea, valuesOfArea);
8033 }
8034 
GetGestureCommonValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & priority,int32_t & mask)8035 void CommonBridge::GetGestureCommonValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& priority, int32_t& mask)
8036 {
8037     EcmaVM* vm = runtimeCallInfo->GetVM();
8038     CHECK_NULL_VOID(vm);
8039     Local<JSValueRef> priorityArg = runtimeCallInfo->GetCallArgRef(NUM_1);
8040     if (!priorityArg.IsNull() && !priorityArg->IsUndefined()) {
8041         priority = static_cast<int32_t>(priorityArg->ToNumber(vm)->Value());
8042     }
8043     Local<JSValueRef> maskArg = runtimeCallInfo->GetCallArgRef(NUM_2);
8044     if (!maskArg.IsNull() && !maskArg->IsUndefined()) {
8045         mask = static_cast<int32_t>(maskArg->ToNumber(vm)->Value());
8046     }
8047 }
8048 
SetGestureTag(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t argNumber,ArkUIGesture * gesture)8049 void CommonBridge::SetGestureTag(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber, ArkUIGesture* gesture)
8050 {
8051     EcmaVM* vm = runtimeCallInfo->GetVM();
8052     CHECK_NULL_VOID(vm);
8053     Local<JSValueRef> gestureTagArg = runtimeCallInfo->GetCallArgRef(argNumber);
8054     if (!gestureTagArg.IsNull() && !gestureTagArg->IsUndefined()) {
8055         auto gesturePtr = Referenced::Claim(reinterpret_cast<Gesture*>(gesture));
8056         gesturePtr->SetTag(gestureTagArg->ToString(vm)->ToString(vm));
8057     }
8058 }
8059 
SetGestureDistanceMap(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t argNumber,ArkUIGesture * gesture)8060 void CommonBridge::SetGestureDistanceMap(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber,
8061     ArkUIGesture* gesture)
8062 {
8063     EcmaVM* vm = runtimeCallInfo->GetVM();
8064     CHECK_NULL_VOID(vm);
8065     Local<JSValueRef> gestureDistanceMap = runtimeCallInfo->GetCallArgRef(argNumber);
8066     if (!gestureDistanceMap.IsNull() && !gestureDistanceMap->IsUndefined() && gestureDistanceMap->IsMap(vm)) {
8067         Local<panda::MapRef> distanceMapRef(gestureDistanceMap);
8068         int32_t distanceMapSize = distanceMapRef->GetSize(vm);
8069         PanDistanceMapDimension distanceMap = { { SourceTool::UNKNOWN, DEFAULT_PAN_DISTANCE },
8070             { SourceTool::PEN, DEFAULT_PEN_PAN_DISTANCE } };
8071         for (int32_t i = 0; i < distanceMapSize; i++) {
8072             SourceTool sourceTool = static_cast<SourceTool>(distanceMapRef->GetKey(vm, i)->ToNumber(vm)->Value());
8073             double distance = static_cast<double>(distanceMapRef->GetValue(vm, i)->ToNumber(vm)->Value());
8074             if (sourceTool >= SourceTool::UNKNOWN &&
8075                 sourceTool <= SourceTool::JOYSTICK && GreatOrEqual(distance, 0.0)) {
8076                 distanceMap[sourceTool] = Dimension(distance, DimensionUnit::VP);
8077             }
8078         }
8079         auto gesturePtr = Referenced::Claim(reinterpret_cast<PanGesture*>(gesture));
8080         gesturePtr->SetDistanceMap(distanceMap);
8081     }
8082 }
8083 
SetGestureAllowedTypes(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t argNumber,ArkUIGesture * gesture)8084 void CommonBridge::SetGestureAllowedTypes(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber,
8085     ArkUIGesture* gesture)
8086 {
8087     EcmaVM* vm = runtimeCallInfo->GetVM();
8088     CHECK_NULL_VOID(vm);
8089     Local<JSValueRef> typesArg = runtimeCallInfo->GetCallArgRef(argNumber);
8090     if (typesArg.IsNull() || typesArg->IsUndefined() || !typesArg->IsArray(vm)) {
8091         return;
8092     }
8093     auto typesArr = panda::Local<panda::ArrayRef>(typesArg);
8094     auto typesLength = typesArr->Length(vm);
8095     std::set<SourceTool> allowedTypes{};
8096     for (size_t i = 0; i < typesLength; ++i) {
8097         auto type = panda::ArrayRef::GetValueAt(vm, typesArr, i);
8098         if (type->IsNumber()) {
8099             allowedTypes.insert(static_cast<SourceTool>(type->Int32Value(vm)));
8100         }
8101     }
8102     if (allowedTypes.empty()) {
8103         return;
8104     }
8105     auto gesturePtr = Referenced::Claim(reinterpret_cast<Gesture*>(gesture));
8106     gesturePtr->SetAllowedTypes(allowedTypes);
8107 }
8108 
GetTapGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,int32_t & count,double & distanceThreshold,bool & limitFingerCount,uint32_t argNumber)8109 void CommonBridge::GetTapGestureValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers,
8110     int32_t& count, double& distanceThreshold, bool& limitFingerCount, uint32_t argNumber)
8111 {
8112     EcmaVM* vm = runtimeCallInfo->GetVM();
8113     CHECK_NULL_VOID(vm);
8114     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8115     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8116         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8117         fingers = (fingersValue < DEFAULT_TAP_FINGER || fingersValue > DEFAULT_MAX_FINGERS) ? DEFAULT_TAP_FINGER
8118                                                                                             : fingersValue;
8119     }
8120     Local<JSValueRef> countArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8121     if (!countArg.IsNull() && !countArg->IsUndefined()) {
8122         auto countValue = static_cast<int32_t>(countArg->ToNumber(vm)->Value());
8123         count = countValue < DEFAULT_TAP_COUNT ? DEFAULT_TAP_COUNT : countValue;
8124     }
8125     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 2); // 2: get the third arg
8126     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8127         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8128     }
8129 }
8130 
GetLongPressGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,bool & repeat,int32_t & duration,bool & limitFingerCount,uint32_t argNumber)8131 void CommonBridge::GetLongPressGestureValue(
8132     ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers, bool& repeat, int32_t& duration,
8133     bool& limitFingerCount, uint32_t argNumber)
8134 {
8135     EcmaVM* vm = runtimeCallInfo->GetVM();
8136     CHECK_NULL_VOID(vm);
8137     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8138     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8139         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8140         fingers = (fingersValue < DEFAULT_LONG_PRESS_FINGER || fingersValue > DEFAULT_MAX_FINGERS)
8141                       ? DEFAULT_LONG_PRESS_FINGER
8142                       : fingersValue;
8143     }
8144     Local<JSValueRef> repeatArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8145     if (!repeatArg.IsNull() && !repeatArg->IsUndefined()) {
8146         repeat = repeatArg->ToBoolean(vm)->Value();
8147     }
8148     Local<JSValueRef> durationArg = runtimeCallInfo->GetCallArgRef(argNumber + NUM_2);
8149     if (!durationArg.IsNull() && !durationArg->IsUndefined()) {
8150         auto durationValue = static_cast<int32_t>(durationArg->ToNumber(vm)->Value());
8151         duration = durationValue <= 0 ? DEFAULT_LONG_PRESS_DURATION : durationValue;
8152     }
8153     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 3); // 3: get the fourth arg
8154     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8155         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8156     }
8157 }
8158 
GetPanGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,int32_t & direction,PanDistanceMapDimension & distanceMap,bool & limitFingerCount,uint32_t argNumber)8159 void CommonBridge::GetPanGestureValue(
8160     ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers, int32_t& direction, PanDistanceMapDimension& distanceMap,
8161     bool& limitFingerCount, uint32_t argNumber)
8162 {
8163     EcmaVM* vm = runtimeCallInfo->GetVM();
8164     CHECK_NULL_VOID(vm);
8165     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8166     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8167         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8168         fingers = (fingersValue < DEFAULT_PAN_FINGER || fingersValue > DEFAULT_MAX_FINGERS) ? DEFAULT_PAN_FINGER
8169                                                                                             : fingersValue;
8170     }
8171     Local<JSValueRef> directionArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8172     if (!directionArg.IsNull() && !directionArg->IsUndefined()) {
8173         direction = static_cast<int32_t>(directionArg->ToNumber(vm)->Value());
8174     }
8175     Local<JSValueRef> distanceArg = runtimeCallInfo->GetCallArgRef(argNumber + 2);
8176     if (!distanceArg.IsNull() && !distanceArg->IsUndefined()) {
8177         auto distanceValue = static_cast<double>(distanceArg->ToNumber(vm)->Value());
8178         if (distanceValue >= 0.0f) {
8179             distanceMap[SourceTool::UNKNOWN] = OHOS::Ace::Dimension(distanceValue, DimensionUnit::PX);
8180         } else {
8181             distanceMap[SourceTool::PEN] = DEFAULT_PEN_PAN_DISTANCE;
8182         }
8183     } else {
8184         distanceMap[SourceTool::PEN] = DEFAULT_PEN_PAN_DISTANCE;
8185     }
8186     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 3); // 3: get the fourth arg
8187     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8188         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8189     }
8190 }
8191 
GetSwipeGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,int32_t & direction,double & speed,bool & limitFingerCount,uint32_t argNumber)8192 void CommonBridge::GetSwipeGestureValue(
8193     ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers, int32_t& direction, double& speed,
8194     bool& limitFingerCount, uint32_t argNumber)
8195 {
8196     EcmaVM* vm = runtimeCallInfo->GetVM();
8197     CHECK_NULL_VOID(vm);
8198     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8199     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8200         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8201         fingers = (fingersValue < DEFAULT_SLIDE_FINGER || fingersValue > DEFAULT_MAX_FINGERS) ? DEFAULT_SLIDE_FINGER
8202                                                                                               : fingersValue;
8203     }
8204     Local<JSValueRef> directionArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8205     if (!directionArg.IsNull() && !directionArg->IsUndefined()) {
8206         direction = static_cast<int32_t>(directionArg->ToNumber(vm)->Value());
8207     }
8208     Local<JSValueRef> speedArg = runtimeCallInfo->GetCallArgRef(argNumber + 2);
8209     if (!speedArg.IsNull() && !speedArg->IsUndefined()) {
8210         auto speedValue = static_cast<double>(speedArg->ToNumber(vm)->Value());
8211         speed = LessOrEqual(speedValue, 0.0) ? DEFAULT_SLIDE_SPEED : speedValue;
8212     }
8213     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 3); // 3: get the fourth arg
8214     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8215         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8216     }
8217 }
8218 
GetPinchGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,double & distance,bool & limitFingerCount,uint32_t argNumber)8219 void CommonBridge::GetPinchGestureValue(
8220     ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers, double& distance,
8221     bool& limitFingerCount, uint32_t argNumber)
8222 {
8223     EcmaVM* vm = runtimeCallInfo->GetVM();
8224     CHECK_NULL_VOID(vm);
8225     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8226     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8227         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8228         fingers = (fingersValue < DEFAULT_PINCH_FINGER || fingersValue > DEFAULT_MAX_PINCH_FINGER)
8229                       ? DEFAULT_PINCH_FINGER
8230                       : fingersValue;
8231     }
8232     Local<JSValueRef> distanceArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8233     if (!distanceArg.IsNull() && !distanceArg->IsUndefined()) {
8234         auto distanceValue = static_cast<double>(distanceArg->ToNumber(vm)->Value());
8235         distance = distanceValue <= 0.0 ? DEFAULT_PINCH_DISTANCE : distanceValue;
8236     }
8237     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 2); // 2: get the third arg
8238     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8239         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8240     }
8241 }
8242 
GetRotationGestureValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & fingers,double & angle,bool & limitFingerCount,uint32_t argNumber)8243 void CommonBridge::GetRotationGestureValue(
8244     ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers, double& angle,
8245     bool& limitFingerCount, uint32_t argNumber)
8246 {
8247     EcmaVM* vm = runtimeCallInfo->GetVM();
8248     CHECK_NULL_VOID(vm);
8249     Local<JSValueRef> fingersArg = runtimeCallInfo->GetCallArgRef(argNumber);
8250     if (!fingersArg.IsNull() && !fingersArg->IsUndefined()) {
8251         auto fingersValue = static_cast<int32_t>(fingersArg->ToNumber(vm)->Value());
8252         fingers = (fingersValue < DEFAULT_ROTATION_FINGER || fingersValue > DEFAULT_MAX_ROTATION_FINGER)
8253                       ? DEFAULT_ROTATION_FINGER
8254                       : fingersValue;
8255     }
8256     Local<JSValueRef> angleArg = runtimeCallInfo->GetCallArgRef(argNumber + 1);
8257     if (!angleArg.IsNull() && !angleArg->IsUndefined()) {
8258         auto angleValue = static_cast<double>(angleArg->ToNumber(vm)->Value());
8259         angle = (angleValue <= 0 || angleValue > DEFAULT_MAX_ROTATION_ANGLE) ? DEFAULT_ROTATION_ANGLE : angleValue;
8260     }
8261     Local<JSValueRef> limitFingerCountArg = runtimeCallInfo->GetCallArgRef(argNumber + 2); // 2: get the third arg
8262     if (!limitFingerCountArg.IsNull() && !limitFingerCountArg->IsUndefined()) {
8263         limitFingerCount = limitFingerCountArg->ToBoolean(vm)->Value();
8264     }
8265 }
8266 
GetGestureModeValue(ArkUIRuntimeCallInfo * runtimeCallInfo,int32_t & mode,uint32_t argNumber)8267 void CommonBridge::GetGestureModeValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& mode, uint32_t argNumber)
8268 {
8269     EcmaVM* vm = runtimeCallInfo->GetVM();
8270     CHECK_NULL_VOID(vm);
8271     Local<JSValueRef> modeArg = runtimeCallInfo->GetCallArgRef(argNumber);
8272     if (!modeArg.IsNull() && !modeArg->IsUndefined()) {
8273         mode = static_cast<int32_t>(modeArg->ToNumber(vm)->Value());
8274     }
8275 }
8276 
SetOnGestureEvent(ArkUIRuntimeCallInfo * runtimeCallInfo,const GestureEventAction & action,uint32_t argNumber,ArkUIGesture * gesture)8277 void CommonBridge::SetOnGestureEvent(
8278     ArkUIRuntimeCallInfo* runtimeCallInfo, const GestureEventAction& action, uint32_t argNumber, ArkUIGesture* gesture)
8279 {
8280     EcmaVM* vm = runtimeCallInfo->GetVM();
8281     CHECK_NULL_VOID(vm);
8282     Local<JSValueRef> eventArg = runtimeCallInfo->GetCallArgRef(argNumber);
8283     if (eventArg.IsNull() || eventArg->IsUndefined() || !eventArg->IsFunction(vm)) {
8284         return;
8285     }
8286     auto obj = eventArg->ToObject(vm);
8287     auto containerId = Container::CurrentId();
8288     panda::Local<panda::FunctionRef> func = obj;
8289     auto* frameNode = GetFrameNode(runtimeCallInfo);
8290     bool isWeak = frameNode == nullptr ? false : FrameNodeBridge::IsCustomFrameNode(frameNode);
8291 
8292     if (action == Ace::GestureEventAction::CANCEL) {
8293         auto onActionCancelFunc = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), isWeak),
8294             containerId](GestureEvent& info) {
8295             panda::LocalScope pandaScope(vm);
8296             panda::TryCatch trycatch(vm);
8297             ContainerScope scope(containerId);
8298             auto function = func.Lock();
8299             if (!function.IsEmpty() && function->IsFunction(vm)) {
8300                 auto obj = CreateCommonGestureEventInfo(vm, info);
8301                 panda::Local<panda::JSValueRef> params[1] = { obj };
8302                 function->Call(vm, function.ToLocal(), params, 1);
8303             }
8304         };
8305         auto gesturePtr = Referenced::Claim(reinterpret_cast<Gesture*>(gesture));
8306         gesturePtr->SetOnActionCancelId(onActionCancelFunc);
8307         return;
8308     }
8309     auto event = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), isWeak), containerId](GestureEvent& info) {
8310         panda::LocalScope pandaScope(vm);
8311         panda::TryCatch trycatch(vm);
8312         ContainerScope scope(containerId);
8313         auto function = func.Lock();
8314         if (!function.IsEmpty() && function->IsFunction(vm)) {
8315             auto obj = CreateCommonGestureEventInfo(vm, info);
8316             panda::Local<panda::JSValueRef> params[1] = { obj };
8317             function->Call(vm, function.ToLocal(), params, 1);
8318         }
8319     };
8320     auto gesturePtr = Referenced::Claim(reinterpret_cast<Gesture*>(gesture));
8321     switch (action) {
8322         case Ace::GestureEventAction::ACTION:
8323             gesturePtr->SetOnActionId(event);
8324             break;
8325         case Ace::GestureEventAction::START:
8326             gesturePtr->SetOnActionStartId(event);
8327             break;
8328         case Ace::GestureEventAction::UPDATE:
8329             gesturePtr->SetOnActionUpdateId(event);
8330             break;
8331         case Ace::GestureEventAction::END:
8332             gesturePtr->SetOnActionEndId(event);
8333             break;
8334         default:
8335             break;
8336     }
8337 }
8338 
CreateCommonGestureEventInfo(EcmaVM * vm,GestureEvent & info)8339 Local<panda::ObjectRef> CommonBridge::CreateCommonGestureEventInfo(EcmaVM* vm, GestureEvent& info)
8340 {
8341     double density = PipelineBase::GetCurrentDensity();
8342     const char* keys[] = { "repeat", "offsetX", "offsetY", "scale", "angle", "speed", "timestamp", "pinchCenterX",
8343         "pinchCenterY", "source", "pressure", "sourceTool", "velocityX", "velocityY", "velocity",
8344         "deviceId", "getModifierKeyState" };
8345     Local<JSValueRef> values[] = { panda::BooleanRef::New(vm, info.GetRepeat()),
8346         panda::NumberRef::New(vm, info.GetOffsetX() / density), panda::NumberRef::New(vm, info.GetOffsetY() / density),
8347         panda::NumberRef::New(vm, info.GetScale()), panda::NumberRef::New(vm, info.GetAngle()),
8348         panda::NumberRef::New(vm, info.GetSpeed()),
8349         panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
8350         panda::NumberRef::New(vm, info.GetPinchCenter().GetX() / density),
8351         panda::NumberRef::New(vm, info.GetPinchCenter().GetY() / density),
8352         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetSourceDevice())),
8353         panda::NumberRef::New(vm, info.GetForce()),
8354         panda::NumberRef::New(vm, static_cast<int32_t>(static_cast<int32_t>(info.GetSourceTool()))),
8355         panda::NumberRef::New(vm, info.GetVelocity().GetVelocityX() / density),
8356         panda::NumberRef::New(vm, info.GetVelocity().GetVelocityY() / density),
8357         panda::NumberRef::New(vm, info.GetVelocity().GetVelocityValue() / density),
8358         panda::NumberRef::New(vm, info.GetDeviceId()),
8359         panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState) };
8360     auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
8361     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltX"),
8362         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltX().value_or(0.0f))));
8363     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltY"),
8364         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltY().value_or(0.0f))));
8365     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"),
8366         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetRollAngle().value_or(0.0f))));
8367     auto fingerArr = CreateFingerListArray(vm, info);
8368     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "fingerList"), fingerArr);
8369     auto fingerInfoArr = CreateFingerInfosArray(vm, info);
8370     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "fingerInfos"), fingerInfoArr);
8371     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "target"), FrameNodeBridge::CreateEventTargetObject(vm, info));
8372     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisVertical"), panda::NumberRef::New(vm, info.GetVerticalAxis()));
8373     obj->Set(
8374         vm, panda::StringRef::NewFromUtf8(vm, "axisHorizontal"), panda::NumberRef::New(vm, info.GetHorizontalAxis()));
8375     obj->Set(
8376         vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"), panda::NumberRef::New(vm, info.GetTargetDisplayId()));
8377     obj->SetNativePointerFieldCount(vm, 1);
8378     obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
8379     obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"),
8380         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTargetDisplayId())));
8381     if (info.GetGestureTypeName() == GestureTypeName::TAP_GESTURE && !info.GetFingerList().empty()) {
8382         auto tapGuestureInfo = CreateTapGestureInfo(vm, info);
8383         obj->Set(
8384             vm, panda::StringRef::NewFromUtf8(vm, "tapLocation"), tapGuestureInfo);
8385     }
8386     return obj;
8387 }
8388 
CreateFingerListArray(EcmaVM * vm,GestureEvent & info)8389 Local<panda::ArrayRef> CommonBridge::CreateFingerListArray(EcmaVM* vm, GestureEvent& info)
8390 {
8391     auto fingerArr = panda::ArrayRef::New(vm);
8392     const std::list<FingerInfo>& fingerList = info.GetFingerList();
8393     std::list<FingerInfo> notTouchFingerList;
8394     int32_t maxFingerId = -1;
8395     for (const FingerInfo& fingerInfo : fingerList) {
8396         auto element = CreateFingerInfo(vm, fingerInfo);
8397         if (fingerInfo.sourceType_ == SourceType::TOUCH && fingerInfo.sourceTool_ == SourceTool::FINGER) {
8398             fingerArr->SetValueAt(vm, fingerArr, fingerInfo.fingerId_, element);
8399             if (fingerInfo.fingerId_ > maxFingerId) {
8400                 maxFingerId = fingerInfo.fingerId_;
8401             }
8402         } else {
8403             notTouchFingerList.emplace_back(fingerInfo);
8404         }
8405     }
8406     auto idx = maxFingerId + 1;
8407     for (const FingerInfo& fingerInfo : notTouchFingerList) {
8408         auto element = CreateFingerInfo(vm, fingerInfo);
8409         fingerArr->SetValueAt(vm, fingerArr, idx++, element);
8410     }
8411     return fingerArr;
8412 }
8413 
CreateFingerInfosArray(EcmaVM * vm,GestureEvent & info)8414 Local<panda::ArrayRef> CommonBridge::CreateFingerInfosArray(EcmaVM* vm, GestureEvent& info)
8415 {
8416     auto fingerArr = panda::ArrayRef::New(vm);
8417     const std::list<FingerInfo>& fingerList = info.GetFingerList();
8418     std::list<FingerInfo> notTouchFingerList;
8419     std::vector<Local<panda::ObjectRef>> validFingers;
8420     for (const FingerInfo& fingerInfo : fingerList) {
8421         auto element = CreateFingerInfo(vm, fingerInfo);
8422         if (fingerInfo.sourceType_ == SourceType::TOUCH && fingerInfo.sourceTool_ == SourceTool::FINGER) {
8423             validFingers.emplace_back(element);
8424         } else {
8425             notTouchFingerList.emplace_back(fingerInfo);
8426         }
8427     }
8428     for (size_t i = 0; i < validFingers.size(); ++i) {
8429         fingerArr->SetValueAt(vm, fingerArr, i, validFingers[i]);
8430     }
8431     auto idx = validFingers.size();
8432     for (const FingerInfo& fingerInfo : notTouchFingerList) {
8433         auto element = CreateFingerInfo(vm, fingerInfo);
8434         fingerArr->SetValueAt(vm, fingerArr, idx++, element);
8435     }
8436     return fingerArr;
8437 }
8438 
GetGestureGroup(ArkUIRuntimeCallInfo * runtimeCallInfo,uint32_t argNumber)8439 ArkUIGesture* CommonBridge::GetGestureGroup(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber)
8440 {
8441     EcmaVM* vm = runtimeCallInfo->GetVM();
8442     CHECK_NULL_RETURN(vm, nullptr);
8443     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(argNumber);
8444     CHECK_NULL_RETURN(!firstArg.IsNull(), nullptr);
8445     auto* group = reinterpret_cast<ArkUIGesture*>(firstArg->ToNativePointer(vm)->Value());
8446     return group;
8447 }
8448 
SetOnClick(ArkUIRuntimeCallInfo * runtimeCallInfo)8449 ArkUINativeModuleValue CommonBridge::SetOnClick(ArkUIRuntimeCallInfo* runtimeCallInfo)
8450 {
8451     EcmaVM* vm = runtimeCallInfo->GetVM();
8452     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8453     auto* frameNode = GetFrameNode(runtimeCallInfo);
8454     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8455     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8456     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8457     auto obj = secondeArg->ToObject(vm);
8458     auto containerId = Container::CurrentId();
8459     panda::Local<panda::FunctionRef> func = obj;
8460     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8461     auto onClick = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8462                        node = AceType::WeakClaim(frameNode), containerId](GestureEvent& info) {
8463         panda::LocalScope pandaScope(vm);
8464         panda::TryCatch trycatch(vm);
8465         ContainerScope scope(containerId);
8466         auto function = func.Lock();
8467         CHECK_NULL_VOID(!function.IsEmpty());
8468         CHECK_NULL_VOID(function->IsFunction(vm));
8469         PipelineContext::SetCallBackNode(node);
8470         auto obj = FrameNodeBridge::CreateGestureEventInfo(vm, info);
8471         panda::Local<panda::JSValueRef> params[1] = { obj };
8472         function->Call(vm, function.ToLocal(), params, 1);
8473     };
8474     // The click event of the text component requires special integration.
8475     // If the onClick callback function is modified,
8476     // the SetOnClick function in the arkts_native_text_bridge.cpp file must also be updated accordingly.
8477     if (frameNode->GetTag() == V2::SPAN_ETS_TAG) {
8478         SpanModelNG::SetOnClick(frameNode, std::move(onClick));
8479     } else {
8480         NG::ViewAbstract::SetOnClick(frameNode, std::move(onClick));
8481     }
8482     return panda::JSValueRef::Undefined(vm);
8483 }
8484 
ResetOnClick(ArkUIRuntimeCallInfo * runtimeCallInfo)8485 ArkUINativeModuleValue CommonBridge::ResetOnClick(ArkUIRuntimeCallInfo* runtimeCallInfo)
8486 {
8487     EcmaVM* vm = runtimeCallInfo->GetVM();
8488     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8489     auto* frameNode = GetFrameNode(runtimeCallInfo);
8490     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8491     ViewAbstract::DisableOnClick(frameNode);
8492     return panda::JSValueRef::Undefined(vm);
8493 }
8494 
SetOnDragStart(ArkUIRuntimeCallInfo * runtimeCallInfo)8495 ArkUINativeModuleValue CommonBridge::SetOnDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
8496 {
8497     EcmaVM* vm = runtimeCallInfo->GetVM();
8498     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8499     auto* frameNode = GetFrameNode(runtimeCallInfo);
8500     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8501     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8502     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8503     auto jsVal = info[1];
8504     if (!JSViewAbstract::CheckJSCallbackInfo("OnDragStart", jsVal, checkList)) {
8505         return panda::JSValueRef::Undefined(vm);
8506     }
8507     RefPtr<JsDragFunction> jsOnDragStartFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8508     auto onDragStart = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragStartFunc),
8509                            node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8510                            const RefPtr<OHOS::Ace::DragEvent>& info,
8511                            const std::string& extraParams) -> NG::DragDropBaseInfo {
8512         NG::DragDropBaseInfo dragDropInfo;
8513         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx, dragDropInfo);
8514         PipelineContext::SetCallBackNode(node);
8515         auto ret = func->Execute(info, extraParams);
8516         if (!ret->IsObject()) {
8517             return dragDropInfo;
8518         }
8519         auto builderObj = JSRef<JSObject>::Cast(ret);
8520 #if defined(PIXEL_MAP_SUPPORTED)
8521         auto pixmap = builderObj->GetProperty("pixelMap");
8522         dragDropInfo.pixelMap = CreatePixelMapFromNapiValue(pixmap);
8523 #endif
8524         auto extraInfo = builderObj->GetProperty("extraInfo");
8525         JSViewAbstract::ParseJsString(extraInfo, dragDropInfo.extraInfo);
8526         return dragDropInfo;
8527     };
8528     ViewAbstractModelNG::SetOnDragStart(frameNode, std::move(onDragStart));
8529     return panda::JSValueRef::Undefined(vm);
8530 }
8531 
ResetOnDragStart(ArkUIRuntimeCallInfo * runtimeCallInfo)8532 ArkUINativeModuleValue CommonBridge::ResetOnDragStart(ArkUIRuntimeCallInfo* runtimeCallInfo)
8533 {
8534     EcmaVM* vm = runtimeCallInfo->GetVM();
8535     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8536     auto* frameNode = GetFrameNode(runtimeCallInfo);
8537     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8538     ViewAbstract::DisableOnDragStart(frameNode);
8539     return panda::JSValueRef::Undefined(vm);
8540 }
8541 
SetOnDragEnter(ArkUIRuntimeCallInfo * runtimeCallInfo)8542 ArkUINativeModuleValue CommonBridge::SetOnDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo)
8543 {
8544     EcmaVM* vm = runtimeCallInfo->GetVM();
8545     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8546     auto* frameNode = GetFrameNode(runtimeCallInfo);
8547     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8548     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8549     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8550     auto jsVal = info[1];
8551     if (!JSViewAbstract::CheckJSCallbackInfo("OnDragEnter", jsVal, checkList)) {
8552         return panda::JSValueRef::Undefined(vm);
8553     }
8554     RefPtr<JsDragFunction> jsOnDragEnterFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8555     auto onDragEnter = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragEnterFunc),
8556                            node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8557                            const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
8558         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8559         ACE_SCORING_EVENT("onDragEnter");
8560         PipelineContext::SetCallBackNode(node);
8561         func->Execute(info, extraParams);
8562     };
8563     NG::ViewAbstract::SetOnDragEnter(frameNode, std::move(onDragEnter));
8564     return panda::JSValueRef::Undefined(vm);
8565 }
8566 
ResetOnDragEnter(ArkUIRuntimeCallInfo * runtimeCallInfo)8567 ArkUINativeModuleValue CommonBridge::ResetOnDragEnter(ArkUIRuntimeCallInfo* runtimeCallInfo)
8568 {
8569     EcmaVM* vm = runtimeCallInfo->GetVM();
8570     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8571     auto* frameNode = GetFrameNode(runtimeCallInfo);
8572     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8573     ViewAbstract::DisableOnDragEnter(frameNode);
8574     return panda::JSValueRef::Undefined(vm);
8575 }
8576 
SetOnDragSpringLoading(ArkUIRuntimeCallInfo * runtimeCallInfo)8577 ArkUINativeModuleValue CommonBridge::SetOnDragSpringLoading(ArkUIRuntimeCallInfo* runtimeCallInfo)
8578 {
8579     EcmaVM* vm = runtimeCallInfo->GetVM();
8580     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8581     auto* frameNode = GetFrameNode(runtimeCallInfo);
8582     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8583     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8584     if (info.Length() > SIZE_OF_ONE) {
8585         static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8586         auto jsVal = info[NUM_1];
8587         if (!JSViewAbstract::CheckJSCallbackInfo("JsOnDragSpringLoading", jsVal, checkList)) {
8588             return panda::JSValueRef::Undefined(vm);
8589         }
8590         NG::OnDragDropSpringLoadingFunc onDragSpringLoading = nullptr;
8591         if (jsVal->IsFunction()) {
8592             RefPtr<JsDragFunction> jsOnDragSpringLoadingFunc =
8593                 AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8594             onDragSpringLoading = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragSpringLoadingFunc),
8595                                       node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8596                                       const RefPtr<DragSpringLoadingContext>& info) {
8597                 JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8598                 ACE_SCORING_EVENT("JsOnDragSpringLoading");
8599                 PipelineContext::SetCallBackNode(node);
8600                 func->DragSpringLoadingExecute(info);
8601             };
8602         }
8603         NG::ViewAbstract::SetOnDragSpringLoading(frameNode, std::move(onDragSpringLoading));
8604     }
8605     if (info.Length() == SIZE_OF_THREE && info[NUM_2]->IsObject()) {
8606         auto dragSpringLoadingConfiguration = AceType::MakeRefPtr<NG::DragSpringLoadingConfiguration>();
8607         JSViewAbstract::ParseDragSpringLoadingConfiguration(info[NUM_2], dragSpringLoadingConfiguration);
8608         NG::ViewAbstract::SetOnDragSpringLoadingConfiguration(frameNode, std::move(dragSpringLoadingConfiguration));
8609     }
8610 
8611     return panda::JSValueRef::Undefined(vm);
8612 }
8613 
ResetOnDragSpringLoading(ArkUIRuntimeCallInfo * runtimeCallInfo)8614 ArkUINativeModuleValue CommonBridge::ResetOnDragSpringLoading(ArkUIRuntimeCallInfo* runtimeCallInfo)
8615 {
8616     EcmaVM* vm = runtimeCallInfo->GetVM();
8617     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8618     auto* frameNode = GetFrameNode(runtimeCallInfo);
8619     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8620     ViewAbstract::DisableOnDragSpringLoading(frameNode);
8621     return panda::JSValueRef::Undefined(vm);
8622 }
8623 
SetOnDragMove(ArkUIRuntimeCallInfo * runtimeCallInfo)8624 ArkUINativeModuleValue CommonBridge::SetOnDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
8625 {
8626     EcmaVM* vm = runtimeCallInfo->GetVM();
8627     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8628     auto* frameNode = GetFrameNode(runtimeCallInfo);
8629     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8630     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8631     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8632     auto jsVal = info[1];
8633     if (!JSViewAbstract::CheckJSCallbackInfo("OnDragMove", jsVal, checkList)) {
8634         return panda::JSValueRef::Undefined(vm);
8635     }
8636     RefPtr<JsDragFunction> jsOnDragMoveFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8637     auto onDragMove = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragMoveFunc),
8638                           node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8639                           const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
8640         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8641         ACE_SCORING_EVENT("onDragMove");
8642         PipelineContext::SetCallBackNode(node);
8643         func->Execute(info, extraParams);
8644     };
8645     NG::ViewAbstract::SetOnDragMove(frameNode, std::move(onDragMove));
8646     return panda::JSValueRef::Undefined(vm);
8647 }
8648 
ResetOnDragMove(ArkUIRuntimeCallInfo * runtimeCallInfo)8649 ArkUINativeModuleValue CommonBridge::ResetOnDragMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
8650 {
8651     EcmaVM* vm = runtimeCallInfo->GetVM();
8652     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8653     auto* frameNode = GetFrameNode(runtimeCallInfo);
8654     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8655     ViewAbstract::DisableOnDragMove(frameNode);
8656     return panda::JSValueRef::Undefined(vm);
8657 }
8658 
SetOnDragLeave(ArkUIRuntimeCallInfo * runtimeCallInfo)8659 ArkUINativeModuleValue CommonBridge::SetOnDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo)
8660 {
8661     EcmaVM* vm = runtimeCallInfo->GetVM();
8662     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8663     auto* frameNode = GetFrameNode(runtimeCallInfo);
8664     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8665     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8666     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8667     auto jsVal = info[1];
8668     if (!JSViewAbstract::CheckJSCallbackInfo("OnDragLeave", jsVal, checkList)) {
8669         return panda::JSValueRef::Undefined(vm);
8670     }
8671     RefPtr<JsDragFunction> jsOnDragLeaveFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8672     auto onDragLeave = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragLeaveFunc),
8673                            node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8674                            const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
8675         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8676         ACE_SCORING_EVENT("onDragLeave");
8677         PipelineContext::SetCallBackNode(node);
8678         func->Execute(info, extraParams);
8679     };
8680     NG::ViewAbstract::SetOnDragLeave(frameNode, std::move(onDragLeave));
8681     return panda::JSValueRef::Undefined(vm);
8682 }
8683 
ResetOnDragLeave(ArkUIRuntimeCallInfo * runtimeCallInfo)8684 ArkUINativeModuleValue CommonBridge::ResetOnDragLeave(ArkUIRuntimeCallInfo* runtimeCallInfo)
8685 {
8686     EcmaVM* vm = runtimeCallInfo->GetVM();
8687     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8688     auto* frameNode = GetFrameNode(runtimeCallInfo);
8689     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8690     ViewAbstract::DisableOnDragLeave(frameNode);
8691     return panda::JSValueRef::Undefined(vm);
8692 }
8693 
SetOnDrop(ArkUIRuntimeCallInfo * runtimeCallInfo)8694 ArkUINativeModuleValue CommonBridge::SetOnDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
8695 {
8696     EcmaVM* vm = runtimeCallInfo->GetVM();
8697     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8698     auto* frameNode = GetFrameNode(runtimeCallInfo);
8699     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8700     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8701     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8702     auto jsVal = info[1];
8703     if (!JSViewAbstract::CheckJSCallbackInfo("OnDrop", jsVal, checkList)) {
8704         return panda::JSValueRef::Undefined(vm);
8705     }
8706     RefPtr<JsDragFunction> jsOnDropFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8707     auto onDrop = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDropFunc),
8708                       node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8709                       const RefPtr<OHOS::Ace::DragEvent>& info, const std::string& extraParams) {
8710         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8711         ACE_SCORING_EVENT("onDrop");
8712         PipelineContext::SetCallBackNode(node);
8713         func->Execute(info, extraParams);
8714     };
8715     NG::ViewAbstract::SetOnDrop(frameNode, std::move(onDrop));
8716 
8717     bool disableDataPrefetch = false;
8718     if (info[NUM_2]->IsBoolean()) {
8719         disableDataPrefetch = info[NUM_2]->ToBoolean();
8720     }
8721     NG::ViewAbstract::SetDisableDataPrefetch(frameNode, disableDataPrefetch);
8722     return panda::JSValueRef::Undefined(vm);
8723 }
8724 
ResetOnDrop(ArkUIRuntimeCallInfo * runtimeCallInfo)8725 ArkUINativeModuleValue CommonBridge::ResetOnDrop(ArkUIRuntimeCallInfo* runtimeCallInfo)
8726 {
8727     EcmaVM* vm = runtimeCallInfo->GetVM();
8728     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8729     auto* frameNode = GetFrameNode(runtimeCallInfo);
8730     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8731     ViewAbstract::DisableOnDrop(frameNode);
8732     return panda::JSValueRef::Undefined(vm);
8733 }
8734 
SetOnDragEnd(ArkUIRuntimeCallInfo * runtimeCallInfo)8735 ArkUINativeModuleValue CommonBridge::SetOnDragEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
8736 {
8737     EcmaVM* vm = runtimeCallInfo->GetVM();
8738     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8739     auto* frameNode = GetFrameNode(runtimeCallInfo);
8740     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8741     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
8742     static std::vector<JSCallbackInfoType> checkList { JSCallbackInfoType::FUNCTION };
8743     auto jsVal = info[1];
8744     if (!JSViewAbstract::CheckJSCallbackInfo("OnDragEnd", jsVal, checkList)) {
8745         return panda::JSValueRef::Undefined(vm);
8746     }
8747     RefPtr<JsDragFunction> jsOnDragEndFunc = AceType::MakeRefPtr<JsDragFunction>(JSRef<JSFunc>::Cast(jsVal));
8748     auto onDragEnd = [execCtx = info.GetExecutionContext(), func = std::move(jsOnDragEndFunc),
8749                          node = AceType::WeakClaim<NG::FrameNode>(frameNode)](
8750                          const RefPtr<OHOS::Ace::DragEvent>& info) {
8751         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
8752         ACE_SCORING_EVENT("onDragEnd");
8753         auto extraParams = JsonUtil::Create(true);
8754         PipelineContext::SetCallBackNode(node);
8755         func->Execute(info, extraParams->ToString());
8756     };
8757     NG::ViewAbstract::SetOnDragEnd(frameNode, std::move(onDragEnd));
8758     return panda::JSValueRef::Undefined(vm);
8759 }
8760 
ResetOnDragEnd(ArkUIRuntimeCallInfo * runtimeCallInfo)8761 ArkUINativeModuleValue CommonBridge::ResetOnDragEnd(ArkUIRuntimeCallInfo* runtimeCallInfo)
8762 {
8763     EcmaVM* vm = runtimeCallInfo->GetVM();
8764     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8765     auto* frameNode = GetFrameNode(runtimeCallInfo);
8766     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8767     ViewAbstract::DisableOnDragEnd(frameNode);
8768     return panda::JSValueRef::Undefined(vm);
8769 }
8770 
SetOnTouch(ArkUIRuntimeCallInfo * runtimeCallInfo)8771 ArkUINativeModuleValue CommonBridge::SetOnTouch(ArkUIRuntimeCallInfo* runtimeCallInfo)
8772 {
8773     EcmaVM* vm = runtimeCallInfo->GetVM();
8774     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8775     auto* frameNode = GetFrameNode(runtimeCallInfo);
8776     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8777     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8778     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8779     auto obj = secondeArg->ToObject(vm);
8780     auto containerId = Container::CurrentId();
8781     panda::Local<panda::FunctionRef> func = obj;
8782     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8783     auto onTouch = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8784                        node = AceType::WeakClaim(frameNode), containerId](TouchEventInfo& info) {
8785         panda::LocalScope pandaScope(vm);
8786         panda::TryCatch trycatch(vm);
8787         ContainerScope scope(containerId);
8788         auto function = func.Lock();
8789         CHECK_NULL_VOID(!function.IsEmpty());
8790         CHECK_NULL_VOID(function->IsFunction(vm));
8791         PipelineContext::SetCallBackNode(node);
8792         auto eventObj = FrameNodeBridge::CreateTouchEventInfo(vm, info);
8793         panda::Local<panda::JSValueRef> params[1] = { eventObj };
8794         function->Call(vm, function.ToLocal(), params, 1);
8795     };
8796     NG::ViewAbstract::SetOnTouch(frameNode, std::move(onTouch));
8797     return panda::JSValueRef::Undefined(vm);
8798 }
8799 
ResetOnTouch(ArkUIRuntimeCallInfo * runtimeCallInfo)8800 ArkUINativeModuleValue CommonBridge::ResetOnTouch(ArkUIRuntimeCallInfo* runtimeCallInfo)
8801 {
8802     EcmaVM* vm = runtimeCallInfo->GetVM();
8803     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8804     auto* frameNode = GetFrameNode(runtimeCallInfo);
8805     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8806     ViewAbstract::DisableOnTouch(frameNode);
8807     return panda::JSValueRef::Undefined(vm);
8808 }
8809 
SetChainMode(ArkUIRuntimeCallInfo * runtimeCallInfo)8810 ArkUINativeModuleValue CommonBridge::SetChainMode(ArkUIRuntimeCallInfo* runtimeCallInfo)
8811 {
8812     EcmaVM* vm = runtimeCallInfo->GetVM();
8813     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8814     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
8815     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
8816     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
8817     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
8818     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
8819     int32_t direction = 0;
8820     int32_t style = 0;
8821     if (!secondArg.IsNull() && !secondArg->IsUndefined()) {
8822         direction = static_cast<int32_t>(secondArg->ToNumber(vm)->Value());
8823     }
8824     if (!thirdArg.IsNull() && !thirdArg->IsUndefined()) {
8825         style = static_cast<int32_t>(thirdArg->ToNumber(vm)->Value());
8826     }
8827     GetArkUINodeModifiers()->getCommonModifier()->setChainStyle(nativeNode, direction, style);
8828     return panda::JSValueRef::Undefined(vm);
8829 }
8830 
ResetChainMode(ArkUIRuntimeCallInfo * runtimeCallInfo)8831 ArkUINativeModuleValue CommonBridge::ResetChainMode(ArkUIRuntimeCallInfo* runtimeCallInfo)
8832 {
8833     EcmaVM* vm = runtimeCallInfo->GetVM();
8834     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8835     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
8836     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
8837     GetArkUINodeModifiers()->getCommonModifier()->resetChainStyle(nativeNode);
8838     return panda::JSValueRef::Undefined(vm);
8839 }
SetOnAppear(ArkUIRuntimeCallInfo * runtimeCallInfo)8840 ArkUINativeModuleValue CommonBridge::SetOnAppear(ArkUIRuntimeCallInfo* runtimeCallInfo)
8841 {
8842     EcmaVM* vm = runtimeCallInfo->GetVM();
8843     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8844     auto* frameNode = GetFrameNode(runtimeCallInfo);
8845     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8846     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8847     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8848     auto obj = secondeArg->ToObject(vm);
8849     auto containerId = Container::CurrentId();
8850     panda::Local<panda::FunctionRef> func = obj;
8851     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8852     auto onAppear = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8853                         node = AceType::WeakClaim(frameNode), containerId]() {
8854         panda::LocalScope pandaScope(vm);
8855         panda::TryCatch trycatch(vm);
8856         ContainerScope scope(containerId);
8857         auto function = func.Lock();
8858         CHECK_NULL_VOID(!function.IsEmpty());
8859         CHECK_NULL_VOID(function->IsFunction(vm));
8860         PipelineContext::SetCallBackNode(node);
8861         function->Call(vm, function.ToLocal(), nullptr, 0);
8862     };
8863     NG::ViewAbstract::SetOnAppear(frameNode, std::move(onAppear));
8864     return panda::JSValueRef::Undefined(vm);
8865 }
8866 
ResetOnAppear(ArkUIRuntimeCallInfo * runtimeCallInfo)8867 ArkUINativeModuleValue CommonBridge::ResetOnAppear(ArkUIRuntimeCallInfo* runtimeCallInfo)
8868 {
8869     EcmaVM* vm = runtimeCallInfo->GetVM();
8870     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8871     auto* frameNode = GetFrameNode(runtimeCallInfo);
8872     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8873     ViewAbstract::DisableOnAppear(frameNode);
8874     return panda::JSValueRef::Undefined(vm);
8875 }
8876 
SetOnDisappear(ArkUIRuntimeCallInfo * runtimeCallInfo)8877 ArkUINativeModuleValue CommonBridge::SetOnDisappear(ArkUIRuntimeCallInfo* runtimeCallInfo)
8878 {
8879     EcmaVM* vm = runtimeCallInfo->GetVM();
8880     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8881     auto* frameNode = GetFrameNode(runtimeCallInfo);
8882     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8883     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8884     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8885     auto obj = secondeArg->ToObject(vm);
8886     auto containerId = Container::CurrentId();
8887     panda::Local<panda::FunctionRef> func = obj;
8888     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8889     auto onDisappear = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8890                            node = AceType::WeakClaim(frameNode), containerId]() {
8891         panda::LocalScope pandaScope(vm);
8892         panda::TryCatch trycatch(vm);
8893         ContainerScope scope(containerId);
8894         auto function = func.Lock();
8895         CHECK_NULL_VOID(!function.IsEmpty());
8896         CHECK_NULL_VOID(function->IsFunction(vm));
8897         PipelineContext::SetCallBackNode(node);
8898         function->Call(vm, function.ToLocal(), nullptr, 0);
8899     };
8900     NG::ViewAbstract::SetOnDisappear(frameNode, std::move(onDisappear));
8901     return panda::JSValueRef::Undefined(vm);
8902 }
8903 
ResetOnDisappear(ArkUIRuntimeCallInfo * runtimeCallInfo)8904 ArkUINativeModuleValue CommonBridge::ResetOnDisappear(ArkUIRuntimeCallInfo* runtimeCallInfo)
8905 {
8906     EcmaVM* vm = runtimeCallInfo->GetVM();
8907     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8908     auto* frameNode = GetFrameNode(runtimeCallInfo);
8909     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8910     ViewAbstract::DisableOnDisappear(frameNode);
8911     return panda::JSValueRef::Undefined(vm);
8912 }
8913 
SetOnAttach(ArkUIRuntimeCallInfo * runtimeCallInfo)8914 ArkUINativeModuleValue CommonBridge::SetOnAttach(ArkUIRuntimeCallInfo* runtimeCallInfo)
8915 {
8916     EcmaVM* vm = runtimeCallInfo->GetVM();
8917     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8918     auto* frameNode = GetFrameNode(runtimeCallInfo);
8919     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8920     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8921     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8922     auto obj = secondeArg->ToObject(vm);
8923     auto containerId = Container::CurrentId();
8924     panda::Local<panda::FunctionRef> func = obj;
8925     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8926     auto onAttach = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8927                         node = AceType::WeakClaim(frameNode), containerId]() {
8928         panda::LocalScope pandaScope(vm);
8929         panda::TryCatch trycatch(vm);
8930         ContainerScope scope(containerId);
8931         auto function = func.Lock();
8932         CHECK_NULL_VOID(!function.IsEmpty());
8933         CHECK_NULL_VOID(function->IsFunction(vm));
8934         PipelineContext::SetCallBackNode(node);
8935         function->Call(vm, function.ToLocal(), nullptr, 0);
8936     };
8937     NG::ViewAbstract::SetOnAttach(frameNode, std::move(onAttach));
8938     return panda::JSValueRef::Undefined(vm);
8939 }
8940 
ResetOnAttach(ArkUIRuntimeCallInfo * runtimeCallInfo)8941 ArkUINativeModuleValue CommonBridge::ResetOnAttach(ArkUIRuntimeCallInfo* runtimeCallInfo)
8942 {
8943     EcmaVM* vm = runtimeCallInfo->GetVM();
8944     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8945     auto* frameNode = GetFrameNode(runtimeCallInfo);
8946     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8947     ViewAbstract::DisableOnAttach(frameNode);
8948     return panda::JSValueRef::Undefined(vm);
8949 }
8950 
SetOnDetach(ArkUIRuntimeCallInfo * runtimeCallInfo)8951 ArkUINativeModuleValue CommonBridge::SetOnDetach(ArkUIRuntimeCallInfo* runtimeCallInfo)
8952 {
8953     EcmaVM* vm = runtimeCallInfo->GetVM();
8954     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8955     auto* frameNode = GetFrameNode(runtimeCallInfo);
8956     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8957     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8958     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8959     auto obj = secondeArg->ToObject(vm);
8960     auto containerId = Container::CurrentId();
8961     panda::Local<panda::FunctionRef> func = obj;
8962     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
8963     auto onDetach = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
8964                         node = AceType::WeakClaim(frameNode), containerId]() {
8965         panda::LocalScope pandaScope(vm);
8966         panda::TryCatch trycatch(vm);
8967         ContainerScope scope(containerId);
8968         auto function = func.Lock();
8969         CHECK_NULL_VOID(!function.IsEmpty());
8970         CHECK_NULL_VOID(function->IsFunction(vm));
8971         PipelineContext::SetCallBackNode(node);
8972         function->Call(vm, function.ToLocal(), nullptr, 0);
8973     };
8974     NG::ViewAbstract::SetOnDetach(frameNode, std::move(onDetach));
8975     return panda::JSValueRef::Undefined(vm);
8976 }
8977 
ResetOnDetach(ArkUIRuntimeCallInfo * runtimeCallInfo)8978 ArkUINativeModuleValue CommonBridge::ResetOnDetach(ArkUIRuntimeCallInfo* runtimeCallInfo)
8979 {
8980     EcmaVM* vm = runtimeCallInfo->GetVM();
8981     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
8982     auto* frameNode = GetFrameNode(runtimeCallInfo);
8983     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8984     ViewAbstract::DisableOnDetach(frameNode);
8985     return panda::JSValueRef::Undefined(vm);
8986 }
8987 
SetOnKeyEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)8988 ArkUINativeModuleValue CommonBridge::SetOnKeyEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
8989 {
8990     EcmaVM* vm = runtimeCallInfo->GetVM();
8991     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
8992     auto* frameNode = GetFrameNode(runtimeCallInfo);
8993     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
8994     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
8995     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
8996     auto obj = secondeArg->ToObject(vm);
8997     auto containerId = Container::CurrentId();
8998     panda::Local<panda::FunctionRef> func = obj;
8999     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9000     auto onKeyEvent = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9001                           node = AceType::WeakClaim(frameNode), containerId](KeyEventInfo& info) -> bool {
9002         panda::LocalScope pandaScope(vm);
9003         panda::TryCatch trycatch(vm);
9004         ContainerScope scope(containerId);
9005         auto function = func.Lock();
9006         CHECK_NULL_RETURN(!function.IsEmpty(), false);
9007         CHECK_NULL_RETURN(function->IsFunction(vm), false);
9008         PipelineContext::SetCallBackNode(node);
9009         const char* keys[] = { "type", "keyCode", "keyText", "keySource", "deviceId", "metaKey", "unicode", "timestamp",
9010             "stopPropagation", "getModifierKeyState", "intentionCode", "isNumLockOn", "isCapsLockOn",
9011             "isScrollLockOn" };
9012         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyType())),
9013             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyCode())),
9014             panda::StringRef::NewFromUtf8(vm, info.GetKeyText().c_str()),
9015             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeySource())),
9016             panda::NumberRef::New(vm, info.GetDeviceId()), panda::NumberRef::New(vm, info.GetMetaKey()),
9017             panda::NumberRef::New(vm, info.GetUnicode()),
9018             panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
9019             panda::FunctionRef::New(vm, Framework::JsStopPropagation),
9020             panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
9021             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyIntention())),
9022             panda::BooleanRef::New(vm, info.GetNumLock()),
9023             panda::BooleanRef::New(vm, info.GetCapsLock()),
9024             panda::BooleanRef::New(vm, info.GetScrollLock()) };
9025         auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
9026         obj->SetNativePointerFieldCount(vm, 1);
9027         obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
9028         panda::Local<panda::JSValueRef> params[] = { obj };
9029         auto ret = function->Call(vm, function.ToLocal(), params, 1);
9030         if (ret->IsBoolean()) {
9031             return ret->ToBoolean(vm)->Value();
9032         }
9033         return false;
9034     };
9035     NG::ViewAbstract::SetOnKeyEvent(frameNode, std::move(onKeyEvent));
9036     return panda::JSValueRef::Undefined(vm);
9037 }
9038 
ResetOnKeyEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)9039 ArkUINativeModuleValue CommonBridge::ResetOnKeyEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
9040 {
9041     EcmaVM* vm = runtimeCallInfo->GetVM();
9042     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9043     auto* frameNode = GetFrameNode(runtimeCallInfo);
9044     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9045     ViewAbstract::DisableOnKeyEvent(frameNode);
9046     return panda::JSValueRef::Undefined(vm);
9047 }
9048 
SetOnKeyPreIme(ArkUIRuntimeCallInfo * runtimeCallInfo)9049 ArkUINativeModuleValue CommonBridge::SetOnKeyPreIme(ArkUIRuntimeCallInfo* runtimeCallInfo)
9050 {
9051     EcmaVM* vm = runtimeCallInfo->GetVM();
9052     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9053     auto* frameNode = GetFrameNode(runtimeCallInfo);
9054     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9055     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9056     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9057     auto obj = secondeArg->ToObject(vm);
9058     auto containerId = Container::CurrentId();
9059     panda::Local<panda::FunctionRef> func = obj;
9060     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9061     auto onPreImeEvent = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9062                              node = AceType::WeakClaim(frameNode), containerId](KeyEventInfo& info) -> bool {
9063         panda::LocalScope pandaScope(vm);
9064         panda::TryCatch trycatch(vm);
9065         ContainerScope scope(containerId);
9066         auto function = func.Lock();
9067         CHECK_NULL_RETURN(!function.IsEmpty(), false);
9068         CHECK_NULL_RETURN(function->IsFunction(vm), false);
9069         PipelineContext::SetCallBackNode(node);
9070         const char* keys[] = { "type", "keyCode", "keyText", "keySource", "deviceId", "metaKey", "unicode",
9071             "timestamp", "stopPropagation", "getModifierKeyState", "intentionCode", "isNumLockOn", "isCapsLockOn",
9072             "isScrollLockOn" };
9073         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyType())),
9074             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyCode())),
9075             panda::StringRef::NewFromUtf8(vm, info.GetKeyText().c_str()),
9076             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeySource())),
9077             panda::NumberRef::New(vm, info.GetDeviceId()), panda::NumberRef::New(vm, info.GetMetaKey()),
9078             panda::NumberRef::New(vm, info.GetUnicode()),
9079             panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
9080             panda::FunctionRef::New(vm, Framework::JsStopPropagation),
9081             panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
9082             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyIntention())),
9083             panda::BooleanRef::New(vm, info.GetNumLock()),
9084             panda::BooleanRef::New(vm, info.GetCapsLock()),
9085             panda::BooleanRef::New(vm, info.GetScrollLock()) };
9086         auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
9087         obj->SetNativePointerFieldCount(vm, 1);
9088         obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
9089         panda::Local<panda::JSValueRef> params[] = { obj };
9090         auto ret = function->Call(vm, function.ToLocal(), params, 1);
9091         if (ret->IsBoolean()) {
9092             return ret->ToBoolean(vm)->Value();
9093         }
9094         return false;
9095     };
9096     NG::ViewAbstractModelNG::SetOnKeyPreIme(frameNode, std::move(onPreImeEvent));
9097     return panda::JSValueRef::Undefined(vm);
9098 }
9099 
ResetOnKeyPreIme(ArkUIRuntimeCallInfo * runtimeCallInfo)9100 ArkUINativeModuleValue CommonBridge::ResetOnKeyPreIme(ArkUIRuntimeCallInfo* runtimeCallInfo)
9101 {
9102     EcmaVM* vm = runtimeCallInfo->GetVM();
9103     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9104     auto* frameNode = GetFrameNode(runtimeCallInfo);
9105     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9106     NG::ViewAbstractModelNG::DisableOnKeyPreIme(frameNode);
9107     return panda::JSValueRef::Undefined(vm);
9108 }
9109 
SetOnKeyEventDispatch(ArkUIRuntimeCallInfo * runtimeCallInfo)9110 ArkUINativeModuleValue CommonBridge::SetOnKeyEventDispatch(ArkUIRuntimeCallInfo* runtimeCallInfo)
9111 {
9112     EcmaVM* vm = runtimeCallInfo->GetVM();
9113     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9114     auto* frameNode = GetFrameNode(runtimeCallInfo);
9115     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9116     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9117     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9118     auto obj = secondeArg->ToObject(vm);
9119     auto containerId = Container::CurrentId();
9120     panda::Local<panda::FunctionRef> func = obj;
9121     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9122     auto onKeyEventDispatch = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9123                                   node = AceType::WeakClaim(frameNode), containerId](KeyEventInfo& info) -> bool {
9124         panda::LocalScope pandaScope(vm);
9125         panda::TryCatch trycatch(vm);
9126         ContainerScope scope(containerId);
9127         auto function = func.Lock();
9128         CHECK_NULL_RETURN(!function.IsEmpty(), false);
9129         CHECK_NULL_RETURN(function->IsFunction(vm), false);
9130         PipelineContext::SetCallBackNode(node);
9131         const char* keys[] = { "type", "keyCode", "keyText", "keySource", "deviceId", "metaKey", "unicode", "timestamp",
9132             "stopPropagation", "getModifierKeyState", "intentionCode", "isNumLockOn", "isCapsLockOn",
9133             "isScrollLockOn" };
9134         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyType())),
9135             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyCode())),
9136             panda::StringRef::NewFromUtf8(vm, info.GetKeyText().c_str()),
9137             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeySource())),
9138             panda::NumberRef::New(vm, info.GetDeviceId()), panda::NumberRef::New(vm, info.GetMetaKey()),
9139             panda::NumberRef::New(vm, info.GetUnicode()),
9140             panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
9141             panda::FunctionRef::New(vm, Framework::JsStopPropagation),
9142             panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
9143             panda::NumberRef::New(vm, static_cast<int32_t>(info.GetKeyIntention())),
9144             panda::BooleanRef::New(vm, info.GetNumLock()),
9145             panda::BooleanRef::New(vm, info.GetCapsLock()),
9146             panda::BooleanRef::New(vm, info.GetScrollLock()) };
9147         auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
9148         obj->SetNativePointerFieldCount(vm, 1);
9149         obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
9150         panda::Local<panda::JSValueRef> params[] = { obj };
9151         auto ret = function->Call(vm, function.ToLocal(), params, 1);
9152         if (ret->IsBoolean()) {
9153             return ret->ToBoolean(vm)->Value();
9154         }
9155         return false;
9156     };
9157     NG::ViewAbstract::SetOnKeyEventDispatch(frameNode, std::move(onKeyEventDispatch));
9158     return panda::JSValueRef::Undefined(vm);
9159 }
9160 
ResetOnKeyEventDispatch(ArkUIRuntimeCallInfo * runtimeCallInfo)9161 ArkUINativeModuleValue CommonBridge::ResetOnKeyEventDispatch(ArkUIRuntimeCallInfo* runtimeCallInfo)
9162 {
9163     EcmaVM* vm = runtimeCallInfo->GetVM();
9164     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9165     auto* frameNode = GetFrameNode(runtimeCallInfo);
9166     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9167     NG::ViewAbstract::DisableOnKeyEventDispatch(frameNode);
9168     return panda::JSValueRef::Undefined(vm);
9169 }
9170 
SetOnFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)9171 ArkUINativeModuleValue CommonBridge::SetOnFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
9172 {
9173     EcmaVM* vm = runtimeCallInfo->GetVM();
9174     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9175     auto* frameNode = GetFrameNode(runtimeCallInfo);
9176     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9177     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9178     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9179     auto obj = secondeArg->ToObject(vm);
9180     auto containerId = Container::CurrentId();
9181     panda::Local<panda::FunctionRef> func = obj;
9182     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9183     auto onFocus = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9184                        node = AceType::WeakClaim(frameNode), containerId]() {
9185         panda::LocalScope pandaScope(vm);
9186         panda::TryCatch trycatch(vm);
9187         ContainerScope scope(containerId);
9188         auto function = func.Lock();
9189         CHECK_NULL_VOID(!function.IsEmpty());
9190         CHECK_NULL_VOID(function->IsFunction(vm));
9191         PipelineContext::SetCallBackNode(node);
9192         function->Call(vm, function.ToLocal(), nullptr, 0);
9193     };
9194     NG::ViewAbstract::SetOnFocus(frameNode, std::move(onFocus));
9195     return panda::JSValueRef::Undefined(vm);
9196 }
9197 
ResetOnFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)9198 ArkUINativeModuleValue CommonBridge::ResetOnFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
9199 {
9200     EcmaVM* vm = runtimeCallInfo->GetVM();
9201     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9202     auto* frameNode = GetFrameNode(runtimeCallInfo);
9203     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9204     ViewAbstract::DisableOnFocus(frameNode);
9205     return panda::JSValueRef::Undefined(vm);
9206 }
9207 
SetOnBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)9208 ArkUINativeModuleValue CommonBridge::SetOnBlur(ArkUIRuntimeCallInfo* runtimeCallInfo)
9209 {
9210     EcmaVM* vm = runtimeCallInfo->GetVM();
9211     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9212     auto* frameNode = GetFrameNode(runtimeCallInfo);
9213     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9214     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9215     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9216     auto obj = secondeArg->ToObject(vm);
9217     auto containerId = Container::CurrentId();
9218     panda::Local<panda::FunctionRef> func = obj;
9219     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9220     auto onBlur = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag), node = AceType::WeakClaim(frameNode),
9221                       containerId]() {
9222         panda::LocalScope pandaScope(vm);
9223         panda::TryCatch trycatch(vm);
9224         ContainerScope scope(containerId);
9225         auto function = func.Lock();
9226         CHECK_NULL_VOID(!function.IsEmpty());
9227         CHECK_NULL_VOID(function->IsFunction(vm));
9228         PipelineContext::SetCallBackNode(node);
9229         function->Call(vm, function.ToLocal(), nullptr, 0);
9230     };
9231     NG::ViewAbstract::SetOnBlur(frameNode, std::move(onBlur));
9232     return panda::JSValueRef::Undefined(vm);
9233 }
9234 
ResetOnBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)9235 ArkUINativeModuleValue CommonBridge::ResetOnBlur(ArkUIRuntimeCallInfo* runtimeCallInfo)
9236 {
9237     EcmaVM* vm = runtimeCallInfo->GetVM();
9238     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9239     auto* frameNode = GetFrameNode(runtimeCallInfo);
9240     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9241     ViewAbstract::DisableOnBlur(frameNode);
9242     return panda::JSValueRef::Undefined(vm);
9243 }
9244 
CreateHoverInfo(EcmaVM * vm,const HoverInfo & hoverInfo)9245 Local<panda::ObjectRef> CommonBridge::CreateHoverInfo(EcmaVM* vm, const HoverInfo& hoverInfo)
9246 {
9247     const char* keys[] = { "stopPropagation", "getModifierKeyState", "timestamp", "source", "target", "deviceId",
9248         "targetDisplayId", "displayX", "displayY", "windowX", "windowY", "x", "y", "globalDisplayX", "globalDisplayY",
9249         "sourceTool" };
9250     double density = PipelineBase::GetCurrentDensity();
9251     const Offset& globalOffset = hoverInfo.GetGlobalLocation();
9252     const Offset& localOffset = hoverInfo.GetLocalLocation();
9253     const Offset& screenOffset = hoverInfo.GetScreenLocation();
9254     const Offset& globalDisplayOffset = hoverInfo.GetGlobalDisplayLocation();
9255     Local<JSValueRef> values[] = { panda::FunctionRef::New(vm, Framework::JsStopPropagation),
9256         panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
9257         panda::NumberRef::New(vm, static_cast<double>(hoverInfo.GetTimeStamp().time_since_epoch().count())),
9258         panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetSourceDevice())),
9259         FrameNodeBridge::CreateEventTargetObject(vm, hoverInfo), panda::NumberRef::New(vm, hoverInfo.GetDeviceId()),
9260         panda::NumberRef::New(vm, hoverInfo.GetTargetDisplayId()),
9261         panda::NumberRef::New(vm, density != 0 ? screenOffset.GetX() / density : 0),
9262         panda::NumberRef::New(vm, density != 0 ? screenOffset.GetY() / density : 0),
9263         panda::NumberRef::New(vm, density != 0 ? globalOffset.GetX() / density : 0),
9264         panda::NumberRef::New(vm, density != 0 ? globalOffset.GetY() / density : 0),
9265         panda::NumberRef::New(vm, density != 0 ? localOffset.GetX() / density : 0),
9266         panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0),
9267         panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetX() / density : 0),
9268         panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetY() / density : 0),
9269         panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetSourceTool())) };
9270     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
9271 }
9272 
SetOnHover(ArkUIRuntimeCallInfo * runtimeCallInfo)9273 ArkUINativeModuleValue CommonBridge::SetOnHover(ArkUIRuntimeCallInfo* runtimeCallInfo)
9274 {
9275     EcmaVM* vm = runtimeCallInfo->GetVM();
9276     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9277     auto* frameNode = GetFrameNode(runtimeCallInfo);
9278     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9279     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9280     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9281     auto obj = secondeArg->ToObject(vm);
9282     auto containerId = Container::CurrentId();
9283     panda::Local<panda::FunctionRef> func = obj;
9284     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9285     auto onHover = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9286                        node = AceType::WeakClaim(frameNode), containerId](bool isHover, HoverInfo& hoverInfo) {
9287         panda::LocalScope pandaScope(vm);
9288         panda::TryCatch trycatch(vm);
9289         ContainerScope scope(containerId);
9290         auto function = func.Lock();
9291         CHECK_NULL_VOID(!function.IsEmpty());
9292         CHECK_NULL_VOID(function->IsFunction(vm));
9293         PipelineContext::SetCallBackNode(node);
9294         auto isHoverParam = panda::BooleanRef::New(vm, isHover);
9295         auto obj = CreateHoverInfo(vm, hoverInfo);
9296         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltX"),
9297             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetTiltX().value_or(0.0f))));
9298         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltY"),
9299             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetTiltY().value_or(0.0f))));
9300         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"),
9301             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetRollAngle().value_or(0.0f))));
9302         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisVertical"), panda::NumberRef::New(vm, 0.0f));
9303         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisHorizontal"), panda::NumberRef::New(vm, 0.0f));
9304         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "pressure"), panda::NumberRef::New(vm, 0.0f));
9305         obj->SetNativePointerFieldCount(vm, 1);
9306         obj->SetNativePointerField(vm, 0, static_cast<void*>(&hoverInfo));
9307         panda::Local<panda::JSValueRef> params[] = { isHoverParam, obj };
9308         function->Call(vm, function.ToLocal(), params, ArraySize(params));
9309     };
9310     NG::ViewAbstract::SetOnHover(frameNode, std::move(onHover));
9311     return panda::JSValueRef::Undefined(vm);
9312 }
9313 
ResetOnHover(ArkUIRuntimeCallInfo * runtimeCallInfo)9314 ArkUINativeModuleValue CommonBridge::ResetOnHover(ArkUIRuntimeCallInfo* runtimeCallInfo)
9315 {
9316     EcmaVM* vm = runtimeCallInfo->GetVM();
9317     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9318     auto* frameNode = GetFrameNode(runtimeCallInfo);
9319     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9320     ViewAbstract::DisableOnHover(frameNode);
9321     return panda::JSValueRef::Undefined(vm);
9322 }
9323 
SetOnHoverMove(ArkUIRuntimeCallInfo * runtimeCallInfo)9324 ArkUINativeModuleValue CommonBridge::SetOnHoverMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
9325 {
9326     EcmaVM* vm = runtimeCallInfo->GetVM();
9327     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9328     auto* frameNode = GetFrameNode(runtimeCallInfo);
9329     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9330     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9331     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9332     auto obj = secondeArg->ToObject(vm);
9333     auto containerId = Container::CurrentId();
9334     panda::Local<panda::FunctionRef> func = obj;
9335     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9336     auto onHoverMove = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9337                            node = AceType::WeakClaim(frameNode), containerId](HoverInfo& hoverInfo) {
9338         panda::LocalScope pandaScope(vm);
9339         panda::TryCatch trycatch(vm);
9340         ContainerScope scope(containerId);
9341         auto function = func.Lock();
9342         CHECK_NULL_VOID(!function.IsEmpty());
9343         CHECK_NULL_VOID(function->IsFunction(vm));
9344         PipelineContext::SetCallBackNode(node);
9345         auto obj = CreateHoverInfo(vm, hoverInfo);
9346         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltX"),
9347             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetTiltX().value_or(0.0f))));
9348         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "tiltY"),
9349             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetTiltY().value_or(0.0f))));
9350         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"),
9351             panda::NumberRef::New(vm, static_cast<int32_t>(hoverInfo.GetRollAngle().value_or(0.0f))));
9352         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisVertical"), panda::NumberRef::New(vm, 0.0f));
9353         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "axisHorizontal"), panda::NumberRef::New(vm, 0.0f));
9354         obj->Set(vm, panda::StringRef::NewFromUtf8(vm, "pressure"), panda::NumberRef::New(vm, 0.0f));
9355         obj->SetNativePointerFieldCount(vm, 1);
9356         obj->SetNativePointerField(vm, 0, static_cast<void*>(&hoverInfo));
9357         panda::Local<panda::JSValueRef> params[] = { obj };
9358         function->Call(vm, function.ToLocal(), params, ArraySize(params));
9359     };
9360     NG::ViewAbstract::SetOnHoverMove(frameNode, std::move(onHoverMove));
9361     return panda::JSValueRef::Undefined(vm);
9362 }
9363 
ResetOnHoverMove(ArkUIRuntimeCallInfo * runtimeCallInfo)9364 ArkUINativeModuleValue CommonBridge::ResetOnHoverMove(ArkUIRuntimeCallInfo* runtimeCallInfo)
9365 {
9366     EcmaVM* vm = runtimeCallInfo->GetVM();
9367     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9368     auto* frameNode = GetFrameNode(runtimeCallInfo);
9369     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9370     ViewAbstract::DisableOnHoverMove(frameNode);
9371     return panda::JSValueRef::Undefined(vm);
9372 }
9373 
SetOnMouse(ArkUIRuntimeCallInfo * runtimeCallInfo)9374 ArkUINativeModuleValue CommonBridge::SetOnMouse(ArkUIRuntimeCallInfo* runtimeCallInfo)
9375 {
9376     EcmaVM* vm = runtimeCallInfo->GetVM();
9377     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9378     auto* frameNode = GetFrameNode(runtimeCallInfo);
9379     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9380     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9381     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9382     auto obj = secondeArg->ToObject(vm);
9383     auto containerId = Container::CurrentId();
9384     panda::Local<panda::FunctionRef> func = obj;
9385     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9386     auto onMouse = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9387                        node = AceType::WeakClaim(frameNode), containerId](MouseInfo& info) {
9388         panda::LocalScope pandaScope(vm);
9389         panda::TryCatch trycatch(vm);
9390         ContainerScope scope(containerId);
9391         auto function = func.Lock();
9392         CHECK_NULL_VOID(!function.IsEmpty());
9393         CHECK_NULL_VOID(function->IsFunction(vm));
9394         PipelineContext::SetCallBackNode(node);
9395         auto obj = FrameNodeBridge::CreateMouseInfo(vm, info);
9396         panda::Local<panda::JSValueRef> params[1] = { obj };
9397         function->Call(vm, function.ToLocal(), params, 1);
9398     };
9399     NG::ViewAbstract::SetOnMouse(frameNode, std::move(onMouse));
9400     return panda::JSValueRef::Undefined(vm);
9401 }
9402 
ResetOnMouse(ArkUIRuntimeCallInfo * runtimeCallInfo)9403 ArkUINativeModuleValue CommonBridge::ResetOnMouse(ArkUIRuntimeCallInfo* runtimeCallInfo)
9404 {
9405     EcmaVM* vm = runtimeCallInfo->GetVM();
9406     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9407     auto* frameNode = GetFrameNode(runtimeCallInfo);
9408     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9409     ViewAbstract::DisableOnMouse(frameNode);
9410     return panda::JSValueRef::Undefined(vm);
9411 }
9412 
SetOnSizeChange(ArkUIRuntimeCallInfo * runtimeCallInfo)9413 ArkUINativeModuleValue CommonBridge::SetOnSizeChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
9414 {
9415     EcmaVM* vm = runtimeCallInfo->GetVM();
9416     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9417     auto* frameNode = GetFrameNode(runtimeCallInfo);
9418     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9419     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9420     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9421     auto obj = secondeArg->ToObject(vm);
9422     auto containerId = Container::CurrentId();
9423     panda::Local<panda::FunctionRef> func = obj;
9424     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9425     auto onSizeChange = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9426                             node = AceType::WeakClaim(frameNode),
9427                             containerId](const NG::RectF& oldRect, const NG::RectF& rect) {
9428         panda::LocalScope pandaScope(vm);
9429         panda::TryCatch trycatch(vm);
9430         ContainerScope scope(containerId);
9431         auto function = func.Lock();
9432         CHECK_NULL_VOID(!function.IsEmpty());
9433         CHECK_NULL_VOID(function->IsFunction(vm));
9434         PipelineContext::SetCallBackNode(node);
9435         double density = PipelineBase::GetCurrentDensity();
9436         const char* keys[] = { "width", "height" };
9437         Local<JSValueRef> oldValues[] = { panda::NumberRef::New(vm, oldRect.Width() / density),
9438             panda::NumberRef::New(vm, oldRect.Height() / density) };
9439         auto oldSize = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, oldValues);
9440         Local<JSValueRef> newValues[] = { panda::NumberRef::New(vm, rect.Width() / density),
9441             panda::NumberRef::New(vm, rect.Height() / density) };
9442         auto newSize = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, newValues);
9443         panda::Local<panda::JSValueRef> params[2] = { oldSize, newSize };
9444         function->Call(vm, function.ToLocal(), params, 2);
9445     };
9446     NG::ViewAbstract::SetOnSizeChanged(frameNode, std::move(onSizeChange));
9447     return panda::JSValueRef::Undefined(vm);
9448 }
9449 
ResetOnSizeChange(ArkUIRuntimeCallInfo * runtimeCallInfo)9450 ArkUINativeModuleValue CommonBridge::ResetOnSizeChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
9451 {
9452     EcmaVM* vm = runtimeCallInfo->GetVM();
9453     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9454     auto* frameNode = GetFrameNode(runtimeCallInfo);
9455     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9456     ViewAbstract::SetOnSizeChanged(frameNode, nullptr);
9457     return panda::JSValueRef::Undefined(vm);
9458 }
9459 
SetOnAreaChange(ArkUIRuntimeCallInfo * runtimeCallInfo)9460 ArkUINativeModuleValue CommonBridge::SetOnAreaChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
9461 {
9462     EcmaVM* vm = runtimeCallInfo->GetVM();
9463     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9464     auto* frameNode = GetFrameNode(runtimeCallInfo);
9465     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9466     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9467     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9468     auto obj = secondeArg->ToObject(vm);
9469     auto containerId = Container::CurrentId();
9470     panda::Local<panda::FunctionRef> func = obj;
9471     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9472     auto onAreaChange = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9473                             node = AceType::WeakClaim(frameNode), containerId](
9474                             const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) {
9475         panda::LocalScope pandaScope(vm);
9476         panda::TryCatch trycatch(vm);
9477         ContainerScope scope(containerId);
9478         auto function = func.Lock();
9479         CHECK_NULL_VOID(!function.IsEmpty());
9480         CHECK_NULL_VOID(function->IsFunction(vm));
9481         PipelineContext::SetCallBackNode(node);
9482         auto oldArea = CreateAreaObject(vm, oldRect, oldOrigin);
9483         auto area = CreateAreaObject(vm, rect, origin);
9484         panda::Local<panda::JSValueRef> params[2] = { oldArea, area };
9485         function->Call(vm, function.ToLocal(), params, 2);
9486     };
9487     NG::ViewAbstract::SetOnAreaChanged(frameNode, std::move(onAreaChange));
9488     return panda::JSValueRef::Undefined(vm);
9489 }
9490 
ResetOnAreaChange(ArkUIRuntimeCallInfo * runtimeCallInfo)9491 ArkUINativeModuleValue CommonBridge::ResetOnAreaChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
9492 {
9493     EcmaVM* vm = runtimeCallInfo->GetVM();
9494     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9495     auto* frameNode = GetFrameNode(runtimeCallInfo);
9496     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9497     ViewAbstract::DisableOnAreaChange(frameNode);
9498     return panda::JSValueRef::Undefined(vm);
9499 }
9500 
SetOnGestureJudgeBegin(ArkUIRuntimeCallInfo * runtimeCallInfo)9501 ArkUINativeModuleValue CommonBridge::SetOnGestureJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
9502 {
9503     EcmaVM* vm = runtimeCallInfo->GetVM();
9504     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9505     auto* frameNode = GetFrameNode(runtimeCallInfo);
9506     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9507     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9508     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9509     auto obj = secondeArg->ToObject(vm);
9510     auto containerId = Container::CurrentId();
9511     panda::Local<panda::FunctionRef> func = obj;
9512     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9513     auto onGestureJudgeBegin = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9514                                    node = AceType::WeakClaim(frameNode),
9515                                    containerId](const RefPtr<GestureInfo>& gestureInfo,
9516                                    const std::shared_ptr<BaseGestureEvent>& info) -> GestureJudgeResult {
9517         panda::LocalScope pandaScope(vm);
9518         panda::TryCatch trycatch(vm);
9519         ContainerScope scope(containerId);
9520         auto function = func.Lock();
9521         CHECK_NULL_RETURN(!function.IsEmpty(), GestureJudgeResult::CONTINUE);
9522         CHECK_NULL_RETURN(function->IsFunction(vm), GestureJudgeResult::CONTINUE);
9523         PipelineContext::SetCallBackNode(node);
9524         auto gestureInfoObj = CreateGestureInfo(vm, gestureInfo);
9525         auto gestureEventObj = CreateGestureEventInfo(vm, gestureInfo->GetType(), info);
9526         panda::Local<panda::JSValueRef> params[2] = { gestureInfoObj, gestureEventObj };
9527         auto returnValue = GestureJudgeResult::CONTINUE;
9528         auto value = function->Call(vm, function.ToLocal(), params, 2);
9529         if (value->IsNumber()) {
9530             returnValue = static_cast<GestureJudgeResult>(value->ToNumber(vm)->Value());
9531         }
9532         return returnValue;
9533     };
9534     NG::ViewAbstract::SetOnGestureJudgeBegin(frameNode, std::move(onGestureJudgeBegin));
9535     return panda::JSValueRef::Undefined(vm);
9536 }
9537 
CreateTapGestureLocationInfo(EcmaVM * vm,const std::shared_ptr<BaseGestureEvent> & info)9538 Local<panda::ObjectRef> CommonBridge::CreateTapGestureLocationInfo(
9539     EcmaVM* vm, const std::shared_ptr<BaseGestureEvent>& info)
9540 {
9541     const std::list<FingerInfo>& fingerList = info->GetFingerList();
9542     if (fingerList.empty()) {
9543         return panda::ObjectRef::New(vm);
9544     }
9545     auto fingerInfo = info->GetFingerList().back();
9546     const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_;
9547     const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_;
9548     const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_;
9549     const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_;
9550     double density = PipelineBase::GetCurrentDensity();
9551     const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY",
9552                            "globalDisplayX", "globalDisplayY"};
9553     density = density != 0 ? density : 1;
9554     Local<JSValueRef> values[] = {
9555         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX())),
9556         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())),
9557         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())),
9558         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())),
9559         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())),
9560         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())),
9561         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())),
9562         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())),
9563     };
9564     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
9565 }
9566 
ResetOnGestureJudgeBegin(ArkUIRuntimeCallInfo * runtimeCallInfo)9567 ArkUINativeModuleValue CommonBridge::ResetOnGestureJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
9568 {
9569     EcmaVM* vm = runtimeCallInfo->GetVM();
9570     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9571     auto* frameNode = GetFrameNode(runtimeCallInfo);
9572     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9573     ViewAbstract::SetOnGestureJudgeBegin(frameNode, nullptr);
9574     return panda::JSValueRef::Undefined(vm);
9575 }
9576 
SetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo * runtimeCallInfo)9577 ArkUINativeModuleValue CommonBridge::SetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
9578 {
9579     EcmaVM* vm = runtimeCallInfo->GetVM();
9580     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9581     auto* frameNode = GetFrameNode(runtimeCallInfo);
9582     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9583     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9584     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9585     auto obj = secondeArg->ToObject(vm);
9586     auto containerId = Container::CurrentId();
9587     panda::Local<panda::FunctionRef> func = obj;
9588     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9589     auto onGestureRecognizerJudgeBegin =
9590         [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag), node = AceType::WeakClaim(frameNode),
9591             containerId](const std::shared_ptr<BaseGestureEvent>& info, const RefPtr<NGGestureRecognizer>& current,
9592             const std::list<RefPtr<NGGestureRecognizer>>& others) -> GestureJudgeResult {
9593         panda::LocalScope pandaScope(vm);
9594         panda::TryCatch trycatch(vm);
9595         ContainerScope scope(containerId);
9596         auto function = func.Lock();
9597         CHECK_NULL_RETURN(!function.IsEmpty(), GestureJudgeResult::CONTINUE);
9598         CHECK_NULL_RETURN(function->IsFunction(vm), GestureJudgeResult::CONTINUE);
9599         PipelineContext::SetCallBackNode(node);
9600         auto gestureInfo = current->GetGestureInfo();
9601         CHECK_NULL_RETURN(gestureInfo, GestureJudgeResult::CONTINUE);
9602         auto gestureEventObj = CreateGestureEventInfo(vm, gestureInfo->GetType(), info);
9603         auto currentObj = CreateRecognizerObject(vm, current);
9604         auto othersArr = panda::ArrayRef::New(vm);
9605         uint32_t othersIdx = 0;
9606         for (const auto& item : others) {
9607             auto othersObj = CreateRecognizerObject(vm, item);
9608             othersArr->SetValueAt(vm, othersArr, othersIdx++, othersObj);
9609         }
9610         auto touchRecognizers = CreateTouchRecognizersObject(vm, info, current);
9611         panda::Local<panda::JSValueRef> params[4] = { gestureEventObj, currentObj, othersArr, touchRecognizers };
9612         auto returnValue = GestureJudgeResult::CONTINUE;
9613         auto value = function->Call(vm, function.ToLocal(), params, 4);
9614         if (value->IsNumber()) {
9615             returnValue = static_cast<GestureJudgeResult>(value->ToNumber(vm)->Value());
9616         }
9617         return returnValue;
9618     };
9619     NG::ViewAbstract::SetOnGestureRecognizerJudgeBegin(frameNode, std::move(onGestureRecognizerJudgeBegin));
9620     return panda::JSValueRef::Undefined(vm);
9621 }
9622 
ResetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo * runtimeCallInfo)9623 ArkUINativeModuleValue CommonBridge::ResetOnGestureRecognizerJudgeBegin(ArkUIRuntimeCallInfo* runtimeCallInfo)
9624 {
9625     EcmaVM* vm = runtimeCallInfo->GetVM();
9626     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9627     auto* frameNode = GetFrameNode(runtimeCallInfo);
9628     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9629     ViewAbstract::SetOnGestureRecognizerJudgeBegin(frameNode, nullptr);
9630     return panda::JSValueRef::Undefined(vm);
9631 }
9632 
SetOnTouchTestDone(ArkUIRuntimeCallInfo * runtimeCallInfo)9633 ArkUINativeModuleValue CommonBridge::SetOnTouchTestDone(ArkUIRuntimeCallInfo* runtimeCallInfo)
9634 {
9635     EcmaVM* vm = runtimeCallInfo->GetVM();
9636     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9637     auto* frameNode = GetFrameNode(runtimeCallInfo);
9638     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9639     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9640     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9641     auto obj = secondeArg->ToObject(vm);
9642     auto containerId = Container::CurrentId();
9643     panda::Local<panda::FunctionRef> func = obj;
9644     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9645     auto onTouchTestDone = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
9646                                node = AceType::WeakClaim(frameNode),
9647                                containerId](const std::shared_ptr<BaseGestureEvent>& info,
9648                                const std::list<RefPtr<NGGestureRecognizer>>& others) -> void {
9649         panda::LocalScope pandaScope(vm);
9650         panda::TryCatch trycatch(vm);
9651         ContainerScope scope(containerId);
9652         auto function = func.Lock();
9653         CHECK_NULL_VOID(!function.IsEmpty());
9654         CHECK_NULL_VOID(function->IsFunction(vm));
9655         PipelineContext::SetCallBackNode(node);
9656         auto gestureEventObj = CreateGestureEventInfo(vm, info);
9657         auto othersArr = panda::ArrayRef::New(vm);
9658         uint32_t othersIdx = 0;
9659         for (const auto& item : others) {
9660             auto othersObj = CreateRecognizerObject(vm, item);
9661             othersArr->SetValueAt(vm, othersArr, othersIdx++, othersObj);
9662         }
9663         panda::Local<panda::JSValueRef> params[2] = { gestureEventObj, othersArr };
9664         function->Call(vm, function.ToLocal(), params, 2);
9665     };
9666     NG::ViewAbstract::SetOnTouchTestDone(frameNode, std::move(onTouchTestDone));
9667     return panda::JSValueRef::Undefined(vm);
9668 }
9669 
ResetOnTouchTestDone(ArkUIRuntimeCallInfo * runtimeCallInfo)9670 ArkUINativeModuleValue CommonBridge::ResetOnTouchTestDone(ArkUIRuntimeCallInfo* runtimeCallInfo)
9671 {
9672     EcmaVM* vm = runtimeCallInfo->GetVM();
9673     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9674     auto* frameNode = GetFrameNode(runtimeCallInfo);
9675     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9676     ViewAbstract::SetOnTouchTestDone(frameNode, nullptr);
9677     return panda::JSValueRef::Undefined(vm);
9678 }
9679 
SetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo * runtimeCallInfo)9680 ArkUINativeModuleValue CommonBridge::SetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo)
9681 {
9682     EcmaVM* vm = runtimeCallInfo->GetVM();
9683     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9684     auto* frameNode = GetFrameNode(runtimeCallInfo);
9685     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9686     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
9687     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
9688     auto obj = secondeArg->ToObject(vm);
9689     auto containerId = Container::CurrentId();
9690     panda::Local<panda::FunctionRef> func = obj;
9691     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
9692     auto shouldBuiltInRecognizerParallelWithFunc =
9693         [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag), node = AceType::WeakClaim(frameNode),
9694             containerId](const RefPtr<NG::NGGestureRecognizer>& current,
9695             const std::vector<RefPtr<NG::NGGestureRecognizer>>& others) -> RefPtr<NG::NGGestureRecognizer> {
9696         panda::LocalScope pandaScope(vm);
9697         panda::TryCatch trycatch(vm);
9698         ContainerScope scope(containerId);
9699         auto function = func.Lock();
9700         CHECK_NULL_RETURN(!function.IsEmpty(), nullptr);
9701         CHECK_NULL_RETURN(function->IsFunction(vm), nullptr);
9702         PipelineContext::SetCallBackNode(node);
9703         auto currentObj = CreateRecognizerObject(vm, current);
9704         auto othersArr = panda::ArrayRef::New(vm);
9705         uint32_t othersIdx = 0;
9706         for (const auto& item : others) {
9707             auto othersObj = CreateRecognizerObject(vm, item);
9708             othersArr->SetValueAt(vm, othersArr, othersIdx++, othersObj);
9709         }
9710         panda::Local<panda::JSValueRef> params[2] = { currentObj, othersArr };
9711         auto value = function->Call(vm, function.ToLocal(), params, 2);
9712         if (!value->IsObject(vm)) {
9713             return nullptr;
9714         }
9715         RefPtr<NG::NGGestureRecognizer> returnValue = nullptr;
9716         auto valueObj = value->ToObject(vm);
9717         valueObj->Freeze(vm);
9718         auto jsObj = JSRef<JSObject>(JSObject(valueObj));
9719         returnValue = Referenced::Claim(jsObj->Unwrap<JSGestureRecognizer>())->GetRecognizer().Upgrade();
9720         return returnValue;
9721     };
9722     NG::ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
9723         frameNode, std::move(shouldBuiltInRecognizerParallelWithFunc));
9724     return panda::JSValueRef::Undefined(vm);
9725 }
9726 
ResetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo * runtimeCallInfo)9727 ArkUINativeModuleValue CommonBridge::ResetShouldBuiltInRecognizerParallelWith(ArkUIRuntimeCallInfo* runtimeCallInfo)
9728 {
9729     EcmaVM* vm = runtimeCallInfo->GetVM();
9730     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
9731     auto* frameNode = GetFrameNode(runtimeCallInfo);
9732     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
9733     ViewAbstract::SetShouldBuiltInRecognizerParallelWith(frameNode, nullptr);
9734     return panda::JSValueRef::Undefined(vm);
9735 }
9736 
AddTapGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9737 ArkUINativeModuleValue CommonBridge::AddTapGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9738 {
9739     EcmaVM* vm = runtimeCallInfo->GetVM();
9740     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9741     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9742     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9743     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9744     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9745     int32_t priority = 0;
9746     int32_t mask = 0;
9747     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9748     int32_t fingers = DEFAULT_TAP_FINGER;
9749     int32_t count = DEFAULT_TAP_COUNT;
9750     double distanceThreshold = DEFAULT_TAP_DISTANCE;
9751     bool limitFingerCount = false;
9752     GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, limitFingerCount, NUM_5);
9753     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->
9754         createTapGestureWithDistanceThreshold(count, fingers, distanceThreshold, limitFingerCount, nullptr);
9755     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9756     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9757     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_8, gesture);
9758     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9759         nativeNode, gesture, priority, mask);
9760     return panda::JSValueRef::Undefined(vm);
9761 }
9762 
AddLongPressGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9763 ArkUINativeModuleValue CommonBridge::AddLongPressGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9764 {
9765     EcmaVM* vm = runtimeCallInfo->GetVM();
9766     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9767     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9768     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9769     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9770     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9771     int32_t priority = 0;
9772     int32_t mask = 0;
9773     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9774     int32_t fingers = DEFAULT_LONG_PRESS_FINGER;
9775     bool repeat = false;
9776     int32_t duration = DEFAULT_LONG_PRESS_DURATION;
9777     bool limitFingerCount = false;
9778     GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, limitFingerCount, NUM_5);
9779     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createLongPressGesture(
9780         fingers, repeat, duration, limitFingerCount, nullptr);
9781     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9782     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9783     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_9, gesture);
9784     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_10, gesture);
9785     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_11, gesture);
9786     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9787         nativeNode, gesture, priority, mask);
9788     return panda::JSValueRef::Undefined(vm);
9789 }
9790 
AddPanGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9791 ArkUINativeModuleValue CommonBridge::AddPanGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9792 {
9793     EcmaVM* vm = runtimeCallInfo->GetVM();
9794     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9795     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9796     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9797     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9798     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9799     int32_t priority = 0;
9800     int32_t mask = 0;
9801     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9802     int32_t fingers = DEFAULT_PAN_FINGER;
9803     int32_t direction = PanDirection::ALL;
9804     PanDistanceMapDimension distanceMap = { { SourceTool::UNKNOWN, DEFAULT_PAN_DISTANCE } };
9805     bool limitFingerCount = false;
9806     GetPanGestureValue(runtimeCallInfo, fingers, direction, distanceMap, limitFingerCount, NUM_5);
9807     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPanGesture(
9808         fingers, direction, distanceMap[SourceTool::UNKNOWN].ConvertToPx(), limitFingerCount, nullptr);
9809     SetGestureDistanceMap(runtimeCallInfo, NUM_9, gesture);
9810     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9811     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9812     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_10, gesture);
9813     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_11, gesture);
9814     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_12, gesture);
9815     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_13, gesture);
9816     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9817         nativeNode, gesture, priority, mask);
9818     return panda::JSValueRef::Undefined(vm);
9819 }
9820 
AddSwipeGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9821 ArkUINativeModuleValue CommonBridge::AddSwipeGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9822 {
9823     EcmaVM* vm = runtimeCallInfo->GetVM();
9824     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9825     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9826     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9827     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9828     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9829     int32_t priority = 0;
9830     int32_t mask = 0;
9831     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9832     int32_t fingers = DEFAULT_SLIDE_FINGER;
9833     int32_t direction = SwipeDirection::ALL;
9834     double speed = DEFAULT_SLIDE_SPEED;
9835     bool limitFingerCount = false;
9836     GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, limitFingerCount, NUM_5);
9837     auto* gesture =
9838         GetArkUINodeModifiers()->getGestureModifier()-> createSwipeGestureByModifier(
9839             fingers, direction, speed, limitFingerCount);
9840     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9841     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9842     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_9, gesture);
9843     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9844         nativeNode, gesture, priority, mask);
9845     return panda::JSValueRef::Undefined(vm);
9846 }
9847 
AddPinchGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9848 ArkUINativeModuleValue CommonBridge::AddPinchGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9849 {
9850     EcmaVM* vm = runtimeCallInfo->GetVM();
9851     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9852     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9853     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9854     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9855     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9856     int32_t priority = 0;
9857     int32_t mask = 0;
9858     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9859     int32_t fingers = DEFAULT_PINCH_FINGER;
9860     double distance = DEFAULT_PINCH_DISTANCE;
9861     bool limitFingerCount = false;
9862     GetPinchGestureValue(runtimeCallInfo, fingers, distance, limitFingerCount, NUM_5);
9863     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPinchGesture(
9864         fingers, distance, limitFingerCount, nullptr);
9865     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9866     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9867     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_8, gesture);
9868     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_9, gesture);
9869     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_10, gesture);
9870     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_11, gesture);
9871     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9872         nativeNode, gesture, priority, mask);
9873     return panda::JSValueRef::Undefined(vm);
9874 }
9875 
AddRotationGesture(ArkUIRuntimeCallInfo * runtimeCallInfo)9876 ArkUINativeModuleValue CommonBridge::AddRotationGesture(ArkUIRuntimeCallInfo* runtimeCallInfo)
9877 {
9878     EcmaVM* vm = runtimeCallInfo->GetVM();
9879     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9880     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
9881     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
9882     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
9883     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
9884     int32_t priority = 0;
9885     int32_t mask = 0;
9886     GetGestureCommonValue(runtimeCallInfo, priority, mask);
9887     int32_t fingers = DEFAULT_ROTATION_FINGER;
9888     double angle = DEFAULT_ROTATION_ANGLE;
9889     bool limitFingerCount = false;
9890     GetRotationGestureValue(runtimeCallInfo, fingers, angle, limitFingerCount, NUM_5);
9891     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createRotationGesture(
9892         fingers, angle, limitFingerCount, nullptr);
9893     SetGestureTag(runtimeCallInfo, NUM_3, gesture);
9894     SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
9895     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_8, gesture);
9896     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_9, gesture);
9897     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_10, gesture);
9898     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_11, gesture);
9899     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
9900         nativeNode, gesture, priority, mask);
9901     return panda::JSValueRef::Undefined(vm);
9902 }
9903 
AddGestureGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9904 ArkUINativeModuleValue CommonBridge::AddGestureGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
9905 {
9906     EcmaVM* vm = runtimeCallInfo->GetVM();
9907     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9908     int32_t mode = 0;
9909     GetGestureModeValue(runtimeCallInfo, mode, NUM_3);
9910     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createGestureGroup(mode);
9911     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
9912     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_2, gesture);
9913     return panda::NativePointerRef::New(vm, gesture);
9914 }
9915 
AddTapGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9916 ArkUINativeModuleValue CommonBridge::AddTapGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
9917 {
9918     EcmaVM* vm = runtimeCallInfo->GetVM();
9919     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9920     int32_t fingers = DEFAULT_TAP_FINGER;
9921     int32_t count = DEFAULT_TAP_COUNT;
9922     double distanceThreshold = DEFAULT_TAP_DISTANCE;
9923     bool limitFingerCount = false;
9924     GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, limitFingerCount, NUM_3);
9925     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->
9926         createTapGestureWithDistanceThreshold(count, fingers, distanceThreshold, limitFingerCount, nullptr);
9927     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
9928     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
9929     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_6, gesture);
9930     auto* group = GetGestureGroup(runtimeCallInfo, NUM_7);
9931     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
9932     return panda::JSValueRef::Undefined(vm);
9933 }
9934 
AddLongPressGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9935 ArkUINativeModuleValue CommonBridge::AddLongPressGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
9936 {
9937     EcmaVM* vm = runtimeCallInfo->GetVM();
9938     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9939     int32_t fingers = DEFAULT_LONG_PRESS_FINGER;
9940     bool repeat = false;
9941     int32_t duration = DEFAULT_LONG_PRESS_DURATION;
9942     bool limitFingerCount = false;
9943     GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, limitFingerCount, NUM_3);
9944     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createLongPressGesture(
9945         fingers, repeat, duration, limitFingerCount, nullptr);
9946     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
9947     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
9948     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_7, gesture);
9949     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
9950     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
9951     auto* group = GetGestureGroup(runtimeCallInfo, NUM_10);
9952     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
9953     return panda::JSValueRef::Undefined(vm);
9954 }
9955 
AddPanGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9956 ArkUINativeModuleValue CommonBridge::AddPanGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
9957 {
9958     EcmaVM* vm = runtimeCallInfo->GetVM();
9959     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9960     int32_t fingers = DEFAULT_PAN_FINGER;
9961     int32_t direction = PanDirection::ALL;
9962     PanDistanceMapDimension distanceMap = { { SourceTool::UNKNOWN, DEFAULT_PAN_DISTANCE } };
9963     bool limitFingerCount = false;
9964     GetPanGestureValue(runtimeCallInfo, fingers, direction, distanceMap, limitFingerCount, NUM_3);
9965     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPanGesture(
9966         fingers, direction, distanceMap[SourceTool::UNKNOWN].ConvertToPx(), limitFingerCount, nullptr);
9967     SetGestureDistanceMap(runtimeCallInfo, NUM_7, gesture);
9968     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
9969     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
9970     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_8, gesture);
9971     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_9, gesture);
9972     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_10, gesture);
9973     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_11, gesture);
9974     auto* group = GetGestureGroup(runtimeCallInfo, NUM_12);
9975     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
9976     return panda::JSValueRef::Undefined(vm);
9977 }
9978 
AddSwipeGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9979 ArkUINativeModuleValue CommonBridge::AddSwipeGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
9980 {
9981     EcmaVM* vm = runtimeCallInfo->GetVM();
9982     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
9983     int32_t fingers = DEFAULT_SLIDE_FINGER;
9984     int32_t direction = SwipeDirection::ALL;
9985     double speed = DEFAULT_SLIDE_SPEED;
9986     bool limitFingerCount = false;
9987     GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, limitFingerCount, NUM_3);
9988     auto* gesture =
9989         GetArkUINodeModifiers()->getGestureModifier()->createSwipeGestureByModifier(
9990             fingers, direction, speed, limitFingerCount);
9991     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
9992     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
9993     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_7, gesture);
9994     auto* group = GetGestureGroup(runtimeCallInfo, NUM_8);
9995     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
9996     return panda::JSValueRef::Undefined(vm);
9997 }
9998 
AddPinchGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)9999 ArkUINativeModuleValue CommonBridge::AddPinchGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
10000 {
10001     EcmaVM* vm = runtimeCallInfo->GetVM();
10002     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10003     int32_t fingers = DEFAULT_PINCH_FINGER;
10004     double distance = DEFAULT_PINCH_DISTANCE;
10005     bool limitFingerCount = false;
10006     GetPinchGestureValue(runtimeCallInfo, fingers, distance, limitFingerCount, NUM_3);
10007     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPinchGesture(
10008         fingers, distance, limitFingerCount, nullptr);
10009     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
10010     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
10011     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_6, gesture);
10012     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_7, gesture);
10013     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
10014     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
10015     auto* group = GetGestureGroup(runtimeCallInfo, NUM_10);
10016     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
10017     return panda::JSValueRef::Undefined(vm);
10018 }
10019 
AddRotationGestureToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)10020 ArkUINativeModuleValue CommonBridge::AddRotationGestureToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
10021 {
10022     EcmaVM* vm = runtimeCallInfo->GetVM();
10023     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10024     int32_t fingers = DEFAULT_ROTATION_FINGER;
10025     double angle = DEFAULT_ROTATION_ANGLE;
10026     bool limitFingerCount = false;
10027     GetRotationGestureValue(runtimeCallInfo, fingers, angle, limitFingerCount, NUM_3);
10028     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createRotationGesture(
10029         fingers, angle, limitFingerCount, nullptr);
10030     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
10031     SetGestureAllowedTypes(runtimeCallInfo, NUM_2, gesture);
10032     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_6, gesture);
10033     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_7, gesture);
10034     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
10035     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
10036     auto* group = GetGestureGroup(runtimeCallInfo, NUM_10);
10037     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
10038     return panda::JSValueRef::Undefined(vm);
10039 }
10040 
AddGestureGroupToGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)10041 ArkUINativeModuleValue CommonBridge::AddGestureGroupToGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
10042 {
10043     EcmaVM* vm = runtimeCallInfo->GetVM();
10044     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10045     int32_t mode = 2;
10046     GetGestureModeValue(runtimeCallInfo, mode, NUM_3);
10047     auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createGestureGroup(mode);
10048     SetGestureTag(runtimeCallInfo, NUM_1, gesture);
10049     SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_2, gesture);
10050     auto* group = GetGestureGroup(runtimeCallInfo, NUM_4);
10051     GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
10052     return panda::NativePointerRef::New(vm, gesture);
10053 }
10054 
AttachGestureGroup(ArkUIRuntimeCallInfo * runtimeCallInfo)10055 ArkUINativeModuleValue CommonBridge::AttachGestureGroup(ArkUIRuntimeCallInfo* runtimeCallInfo)
10056 {
10057     EcmaVM* vm = runtimeCallInfo->GetVM();
10058     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10059     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10060     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10061     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10062     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10063     int32_t priority = 0;
10064     int32_t mask = 0;
10065     GetGestureCommonValue(runtimeCallInfo, priority, mask);
10066     auto* group = GetGestureGroup(runtimeCallInfo, NUM_3);
10067     GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
10068         nativeNode, group, priority, mask);
10069     return panda::JSValueRef::Undefined(vm);
10070 }
10071 
RemoveGestureByTag(ArkUIRuntimeCallInfo * runtimeCallInfo)10072 ArkUINativeModuleValue CommonBridge::RemoveGestureByTag(ArkUIRuntimeCallInfo* runtimeCallInfo)
10073 {
10074     EcmaVM* vm = runtimeCallInfo->GetVM();
10075     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10076     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10077     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10078     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10079     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10080     Local<JSValueRef> gestureTagArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10081     if (!gestureTagArg.IsNull() && !gestureTagArg->IsUndefined()) {
10082         auto tag = gestureTagArg->ToString(vm)->ToString(vm);
10083         GetArkUINodeModifiers()->getGestureModifier()->removeGestureFromNodeByTag(nativeNode, tag.c_str());
10084     }
10085     return panda::JSValueRef::Undefined(vm);
10086 }
10087 
ClearGestures(ArkUIRuntimeCallInfo * runtimeCallInfo)10088 ArkUINativeModuleValue CommonBridge::ClearGestures(ArkUIRuntimeCallInfo* runtimeCallInfo)
10089 {
10090     EcmaVM* vm = runtimeCallInfo->GetVM();
10091     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10092     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10093     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10094     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10095     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10096     GetArkUINodeModifiers()->getGestureModifier()->clearGestures(nativeNode);
10097     return panda::JSValueRef::Undefined(vm);
10098 }
10099 
GetWindowName(ArkUIRuntimeCallInfo * runtimeCallInfo)10100 ArkUINativeModuleValue CommonBridge::GetWindowName(ArkUIRuntimeCallInfo* runtimeCallInfo)
10101 {
10102     EcmaVM* vm = runtimeCallInfo->GetVM();
10103     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10104     auto context = PipelineBase::GetCurrentContext();
10105     CHECK_NULL_RETURN(context, panda::JSValueRef::Undefined(vm));
10106     auto window = context->GetWindow();
10107     CHECK_NULL_RETURN(window, panda::JSValueRef::Undefined(vm));
10108     std::string windowName = window->GetWindowName();
10109     return panda::StringRef::NewFromUtf8(vm, windowName.c_str());
10110 }
10111 
GetWindowWidthBreakpoint(ArkUIRuntimeCallInfo * runtimeCallInfo)10112 ArkUINativeModuleValue CommonBridge::GetWindowWidthBreakpoint(ArkUIRuntimeCallInfo* runtimeCallInfo)
10113 {
10114     EcmaVM* vm = runtimeCallInfo->GetVM();
10115     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10116     auto container = Container::Current();
10117     CHECK_NULL_RETURN(container, panda::JSValueRef::Undefined(vm));
10118     auto window = container->GetWindow();
10119     CHECK_NULL_RETURN(window, panda::JSValueRef::Undefined(vm));
10120 
10121     WidthLayoutBreakPoint layoutBreakpoints = SystemProperties::GetWidthLayoutBreakpoints();
10122     WidthBreakpoint breakpoint = window->GetWidthBreakpoint(layoutBreakpoints);
10123 
10124     return panda::IntegerRef::NewFromUnsigned(vm, static_cast<uint32_t>(breakpoint));
10125 }
10126 
GetWindowHeightBreakpoint(ArkUIRuntimeCallInfo * runtimeCallInfo)10127 ArkUINativeModuleValue CommonBridge::GetWindowHeightBreakpoint(ArkUIRuntimeCallInfo* runtimeCallInfo)
10128 {
10129     EcmaVM* vm = runtimeCallInfo->GetVM();
10130     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10131     auto container = Container::Current();
10132     CHECK_NULL_RETURN(container, panda::JSValueRef::Undefined(vm));
10133     auto window = container->GetWindow();
10134     CHECK_NULL_RETURN(window, panda::JSValueRef::Undefined(vm));
10135 
10136     HeightLayoutBreakPoint layoutBreakpoints = SystemProperties::GetHeightLayoutBreakpoints();
10137     HeightBreakpoint breakpoint = window->GetHeightBreakpoint(layoutBreakpoints);
10138 
10139     return panda::IntegerRef::NewFromUnsigned(vm, static_cast<uint32_t>(breakpoint));
10140 }
10141 
FreezeUINodeById(ArkUIRuntimeCallInfo * runtimeCallInfo)10142 ArkUINativeModuleValue CommonBridge::FreezeUINodeById(ArkUIRuntimeCallInfo* runtimeCallInfo)
10143 {
10144     EcmaVM* vm = runtimeCallInfo->GetVM();
10145     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10146     Local<JSValueRef> idArg = runtimeCallInfo->GetCallArgRef(0);
10147     Local<JSValueRef> isFreezeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10148     if (!idArg->IsString(vm)) {
10149         return panda::JSValueRef::Undefined(vm);
10150     }
10151     std::string id = idArg->ToString(vm)->ToString(vm);
10152     bool isFreeze = false;
10153     if (isFreezeArg->IsBoolean()) {
10154         isFreeze = isFreezeArg->ToBoolean(vm)->Value();
10155         GetArkUINodeModifiers()->getCommonModifier()->freezeUINodeById(id.c_str(), isFreeze);
10156     } else {
10157         GetArkUINodeModifiers()->getCommonModifier()->freezeUINodeById(id.c_str(), false);
10158     }
10159     return panda::JSValueRef::Undefined(vm);
10160 }
10161 
FreezeUINodeByUniqueId(ArkUIRuntimeCallInfo * runtimeCallInfo)10162 ArkUINativeModuleValue CommonBridge::FreezeUINodeByUniqueId(ArkUIRuntimeCallInfo* runtimeCallInfo)
10163 {
10164     EcmaVM* vm = runtimeCallInfo->GetVM();
10165     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10166     Local<JSValueRef> uniqueIdArg = runtimeCallInfo->GetCallArgRef(0);
10167     Local<JSValueRef> isFreezeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10168     if (!uniqueIdArg->IsNumber()) {
10169         return panda::JSValueRef::Undefined(vm);
10170     }
10171     int32_t uniqueId = uniqueIdArg->IntegerValue(vm);
10172     bool isFreeze = false;
10173     if (isFreezeArg->IsBoolean()) {
10174         isFreeze = isFreezeArg->ToBoolean(vm)->Value();
10175         GetArkUINodeModifiers()->getCommonModifier()->freezeUINodeByUniqueId(uniqueId, isFreeze);
10176     } else {
10177         GetArkUINodeModifiers()->getCommonModifier()->freezeUINodeByUniqueId(uniqueId, false);
10178     }
10179     return panda::JSValueRef::Undefined(vm);
10180 }
10181 
SetSystemBarEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)10182 ArkUINativeModuleValue CommonBridge::SetSystemBarEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
10183 {
10184     EcmaVM* vm = runtimeCallInfo->GetVM();
10185     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10186     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10187     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10188     auto* nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10189     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10190     Local<JSValueRef> enableArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10191     if (enableArg->IsBoolean()) {
10192         auto enable = enableArg->ToBoolean(vm);
10193         GetArkUINodeModifiers()->getCommonModifier()->setSystemBarEffect(nativeNode, enable->Value());
10194     }
10195     return panda::JSValueRef::Undefined(vm);
10196 }
10197 
PostFrameCallback(ArkUIRuntimeCallInfo * runtimeCallInfo)10198 ArkUINativeModuleValue CommonBridge::PostFrameCallback(ArkUIRuntimeCallInfo* runtimeCallInfo)
10199 {
10200     EcmaVM* vm = runtimeCallInfo->GetVM();
10201     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10202 
10203     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0); // frameCallback
10204     if (firstArg->IsNull() || firstArg->IsUndefined() || !firstArg->IsObject(vm)) {
10205         return panda::JSValueRef::Undefined(vm);
10206     }
10207     auto frameCallback = firstArg->ToObject(vm);
10208 
10209     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
10210     int64_t delayMillis = 0;
10211     if (secondArg->IsNumber()) {
10212         delayMillis = secondArg->IntegerValue(vm);
10213     }
10214 
10215     if (frameCallback->IsNull() || frameCallback->IsUndefined() || !frameCallback->IsObject(vm)) {
10216         return panda::JSValueRef::Undefined(vm);
10217     }
10218 
10219     FrameCallbackFunc onFrameCallbackFunc = nullptr;
10220     FrameCallbackFuncFromCAPI onIdleCallbackFunc = nullptr;
10221 
10222     if (frameCallback->Get(vm, "onFrame")->IsFunction(vm)) {
10223         onFrameCallbackFunc = [vm, frameCallbackObj =
10224             panda::CopyableGlobal(vm, frameCallback)](int64_t nanoTimestamp) -> void {
10225             LocalScope scope(vm);
10226             Local<FunctionRef> onFrameFunc = frameCallbackObj->Get(vm, "onFrame");
10227 
10228             auto nanoTimestampRef = NumberRef::New(vm, nanoTimestamp);
10229             Local<JSValueRef> params[] = { nanoTimestampRef };
10230             onFrameFunc->Call(vm, frameCallbackObj.ToLocal(), params, 1);
10231         };
10232     }
10233 
10234     if (frameCallback->Get(vm, "onIdle")->IsFunction(vm)) {
10235         onIdleCallbackFunc = [vm, frameCallbackObj =
10236             panda::CopyableGlobal(vm, frameCallback)](int64_t nanoTimestamp, int32_t frameCount) -> void {
10237             LocalScope scope(vm);
10238             Local<FunctionRef> onIdleFunc = frameCallbackObj->Get(vm, "onIdle");
10239 
10240             auto nanoTimestampRef = NumberRef::New(vm, nanoTimestamp);
10241             Local<JSValueRef> params[] = { nanoTimestampRef };
10242             onIdleFunc->Call(vm, frameCallbackObj.ToLocal(), params, 1);
10243         };
10244     }
10245 
10246     if (onFrameCallbackFunc == nullptr && onIdleCallbackFunc == nullptr) {
10247         return panda::JSValueRef::Undefined(vm);
10248     }
10249 
10250     auto context = PipelineContext::GetCurrentContext();
10251     CHECK_NULL_RETURN(context, panda::JSValueRef::Undefined(vm));
10252     context->AddFrameCallback(std::move(onFrameCallbackFunc), std::move(onIdleCallbackFunc), delayMillis);
10253     return panda::JSValueRef::Undefined(vm);
10254 }
10255 
ResetFocusScopeId(ArkUIRuntimeCallInfo * runtimeCallInfo)10256 ArkUINativeModuleValue CommonBridge::ResetFocusScopeId(ArkUIRuntimeCallInfo* runtimeCallInfo)
10257 {
10258     EcmaVM* vm = runtimeCallInfo->GetVM();
10259     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10260     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10261     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10262     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10263     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10264     GetArkUINodeModifiers()->getCommonModifier()->resetFocusScopeId(nativeNode);
10265     return panda::JSValueRef::Undefined(vm);
10266 }
10267 
SetFocusScopeId(ArkUIRuntimeCallInfo * runtimeCallInfo)10268 ArkUINativeModuleValue CommonBridge::SetFocusScopeId(ArkUIRuntimeCallInfo* runtimeCallInfo)
10269 {
10270     EcmaVM* vm = runtimeCallInfo->GetVM();
10271     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10272     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10273     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10274     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10275     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10276     Local<JSValueRef> idArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10277     Local<JSValueRef> isGroupArg = runtimeCallInfo->GetCallArgRef(NUM_2);
10278     Local<JSValueRef> arrowKeyStepOutArg = runtimeCallInfo->GetCallArgRef(NUM_3);
10279     if (!idArg->IsString(vm)) {
10280         return panda::JSValueRef::Undefined(vm);
10281     }
10282     auto id = idArg->ToString(vm)->ToString(vm);
10283     bool isGroup = false;
10284     if (isGroupArg->IsBoolean()) {
10285         isGroup = isGroupArg->ToBoolean(vm)->Value();
10286     }
10287     bool arrowKeyStepOut = true;
10288     if (arrowKeyStepOutArg->IsBoolean()) {
10289         arrowKeyStepOut = arrowKeyStepOutArg->ToBoolean(vm)->Value();
10290     }
10291     GetArkUINodeModifiers()->getCommonModifier()->setFocusScopeId(nativeNode, id.c_str(), isGroup, arrowKeyStepOut);
10292     return panda::JSValueRef::Undefined(vm);
10293 }
10294 
ResetFocusScopePriority(ArkUIRuntimeCallInfo * runtimeCallInfo)10295 ArkUINativeModuleValue CommonBridge::ResetFocusScopePriority(ArkUIRuntimeCallInfo* runtimeCallInfo)
10296 {
10297     EcmaVM* vm = runtimeCallInfo->GetVM();
10298     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10299     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10300     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10301     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10302     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10303     GetArkUINodeModifiers()->getCommonModifier()->resetFocusScopePriority(nativeNode);
10304     return panda::JSValueRef::Undefined(vm);
10305 }
10306 
SetFocusScopePriority(ArkUIRuntimeCallInfo * runtimeCallInfo)10307 ArkUINativeModuleValue CommonBridge::SetFocusScopePriority(ArkUIRuntimeCallInfo* runtimeCallInfo)
10308 {
10309     EcmaVM* vm = runtimeCallInfo->GetVM();
10310     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10311     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10312     CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm));
10313     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10314     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10315     Local<JSValueRef> scopeIdArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10316     Local<JSValueRef> priorityArg = runtimeCallInfo->GetCallArgRef(NUM_2);
10317     if (!scopeIdArg->IsString(vm)) {
10318         return panda::JSValueRef::Undefined(vm);
10319     }
10320     auto scopeId = scopeIdArg->ToString(vm)->ToString(vm);
10321     int32_t priority = 0;
10322     if (priorityArg->IsNumber()) {
10323         priority = priorityArg->Int32Value(vm);
10324     }
10325     GetArkUINodeModifiers()->getCommonModifier()->setFocusScopePriority(nativeNode, scopeId.c_str(), priority);
10326     return panda::JSValueRef::Undefined(vm);
10327 }
SetPixelRound(ArkUIRuntimeCallInfo * runtimeCallInfo)10328 ArkUINativeModuleValue CommonBridge::SetPixelRound(ArkUIRuntimeCallInfo* runtimeCallInfo)
10329 {
10330     EcmaVM* vm = runtimeCallInfo->GetVM();
10331     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10332     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10333     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10334     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10335     auto startArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10336     auto topArg = runtimeCallInfo->GetCallArgRef(NUM_2);
10337     auto endArg = runtimeCallInfo->GetCallArgRef(NUM_3);
10338     auto bottomArg = runtimeCallInfo->GetCallArgRef(NUM_4);
10339     if (startArg->IsUndefined() && topArg->IsUndefined() && endArg->IsUndefined() && bottomArg->IsUndefined()) {
10340         GetArkUINodeModifiers()->getCommonModifier()->resetPixelRound(nativeNode);
10341         return panda::JSValueRef::Undefined(vm);
10342     }
10343     int32_t values[] = { -1, -1, -1, -1 };
10344     if (startArg->IsInt()) {
10345         values[NUM_0] = startArg->Int32Value(vm);
10346     }
10347     if (topArg->IsInt()) {
10348         values[NUM_1] = topArg->Int32Value(vm);
10349     }
10350     if (endArg->IsInt()) {
10351         values[NUM_2] = endArg->Int32Value(vm);
10352     }
10353     if (bottomArg->IsInt()) {
10354         values[NUM_3] = bottomArg->Int32Value(vm);
10355     }
10356     GetArkUINodeModifiers()->getCommonModifier()->setPixelRound(
10357         nativeNode, values, (sizeof(values) / sizeof(values[NUM_0])));
10358     return panda::JSValueRef::Undefined(vm);
10359 }
10360 
ResetPixelRound(ArkUIRuntimeCallInfo * runtimeCallInfo)10361 ArkUINativeModuleValue CommonBridge::ResetPixelRound(ArkUIRuntimeCallInfo* runtimeCallInfo)
10362 {
10363     EcmaVM* vm = runtimeCallInfo->GetVM();
10364     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10365     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10366     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10367     GetArkUINodeModifiers()->getCommonModifier()->resetPixelRound(nativeNode);
10368     return panda::JSValueRef::Undefined(vm);
10369 }
10370 
GreatOrEqualAPITargetVersion(ArkUIRuntimeCallInfo * runtimeCallInfo)10371 ArkUINativeModuleValue CommonBridge::GreatOrEqualAPITargetVersion(ArkUIRuntimeCallInfo* runtimeCallInfo)
10372 {
10373     EcmaVM* vm = runtimeCallInfo->GetVM();
10374     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10375 
10376     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10377     if (firstArg->IsNull() || firstArg->IsUndefined() || !firstArg->IsNumber()) {
10378         return panda::BooleanRef::New(vm, false);
10379     }
10380     int32_t apiTargetVersion = firstArg->Int32Value(vm);
10381     auto platformVersion = static_cast<PlatformVersion>(apiTargetVersion);
10382     return panda::BooleanRef::New(vm, Container::GreatOrEqualAPITargetVersion(platformVersion));
10383 }
10384 
LessThanAPITargetVersion(ArkUIRuntimeCallInfo * runtimeCallInfo)10385 ArkUINativeModuleValue CommonBridge::LessThanAPITargetVersion(ArkUIRuntimeCallInfo* runtimeCallInfo)
10386 {
10387     EcmaVM* vm = runtimeCallInfo->GetVM();
10388     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10389 
10390     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10391     if (firstArg->IsNull() || firstArg->IsUndefined() || !firstArg->IsNumber()) {
10392         return panda::BooleanRef::New(vm, false);
10393     }
10394     int32_t apiTargetVersion = firstArg->Int32Value(vm);
10395     auto platformVersion = static_cast<PlatformVersion>(apiTargetVersion);
10396     return panda::BooleanRef::New(vm, Container::LessThanAPITargetVersion(platformVersion));
10397 }
10398 
GetApiTargetVersion(ArkUIRuntimeCallInfo * runtimeCallInfo)10399 ArkUINativeModuleValue CommonBridge::GetApiTargetVersion(ArkUIRuntimeCallInfo* runtimeCallInfo)
10400 {
10401     EcmaVM* vm = runtimeCallInfo->GetVM();
10402     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10403 
10404     auto container = Container::CurrentSafely();
10405     CHECK_NULL_RETURN(container, panda::JSValueRef::Undefined(vm));
10406     int32_t apiTargetVersion = container->GetApiTargetVersion();
10407     return panda::NumberRef::New(vm, apiTargetVersion);
10408 }
10409 
SetFocusBox(ArkUIRuntimeCallInfo * runtimeCallInfo)10410 ArkUINativeModuleValue CommonBridge::SetFocusBox(ArkUIRuntimeCallInfo* runtimeCallInfo)
10411 {
10412     EcmaVM* vm = runtimeCallInfo->GetVM();
10413     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10414     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10415     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10416     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10417     auto marginArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10418     auto widthArg = runtimeCallInfo->GetCallArgRef(NUM_2);
10419     auto colorArg = runtimeCallInfo->GetCallArgRef(NUM_3);
10420     ArkUI_Uint32 hasValue = 0;
10421     CalcDimension margin;
10422     std::vector<RefPtr<ResourceObject>> focusBoxResObjs;
10423     RefPtr<ResourceObject> resObjMargin;
10424     if (!marginArg->IsUndefined() && !marginArg->IsNull()) {
10425         if (ArkTSUtils::ParseJsDimensionFpNG(vm, marginArg, margin, resObjMargin, false)) {
10426             hasValue = 1;
10427         } else if (ArkTSUtils::ParseJsLengthMetrics(vm, marginArg, margin, resObjMargin)) {
10428             hasValue = 1;
10429         }
10430     }
10431     focusBoxResObjs.push_back(resObjMargin);
10432     hasValue = hasValue << 1;
10433     CalcDimension width;
10434     RefPtr<ResourceObject> resObjWidth;
10435     if (!widthArg->IsUndefined() && !widthArg->IsNull()) {
10436         if (ArkTSUtils::ParseJsDimensionFpNG(vm, widthArg, width, resObjWidth, false) && GreatOrEqual(width.Value(), 0.0f)) {
10437             hasValue += 1;
10438         } else if (ArkTSUtils::ParseJsLengthMetrics(vm, widthArg, width, resObjWidth) && GreatOrEqual(width.Value(), 0.0f)) {
10439             hasValue += 1;
10440         }
10441     }
10442     focusBoxResObjs.push_back(resObjWidth);
10443     hasValue = hasValue << 1;
10444     Color strokeColor;
10445     RefPtr<ResourceObject> resObjColor;
10446     if (!colorArg->IsUndefined() && !colorArg->IsNull() &&
10447         ArkTSUtils::ParseColorMetricsToColor(vm, colorArg, strokeColor, resObjColor)) {
10448         hasValue += 1;
10449         auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
10450         ArkTSUtils::CompleteResourceObjectFromColor(resObjColor, strokeColor, true, nodeInfo);
10451     }
10452     focusBoxResObjs.push_back(resObjColor);
10453     GetArkUINodeModifiers()->getCommonModifier()->setFocusBoxStyle(nativeNode, margin.Value(),
10454         static_cast<int>(margin.Unit()), width.Value(), static_cast<int>(width.Unit()), strokeColor.GetValue(),
10455         hasValue, static_cast<void*>(&focusBoxResObjs));
10456     return panda::JSValueRef::Undefined(vm);
10457 }
10458 
ResetFocusBox(ArkUIRuntimeCallInfo * runtimeCallInfo)10459 ArkUINativeModuleValue CommonBridge::ResetFocusBox(ArkUIRuntimeCallInfo* runtimeCallInfo)
10460 {
10461     EcmaVM* vm = runtimeCallInfo->GetVM();
10462     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10463     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10464     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10465     GetArkUINodeModifiers()->getCommonModifier()->resetFocusBoxStyle(nativeNode);
10466     return panda::JSValueRef::Undefined(vm);
10467 }
10468 
SetNextFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)10469 ArkUINativeModuleValue CommonBridge::SetNextFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
10470 {
10471     EcmaVM* vm = runtimeCallInfo->GetVM();
10472     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10473     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10474     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10475     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10476     ArkUI_Uint32 hasValue = 0;
10477     std::string nextFocusArray[NUM_6];
10478     auto forward = runtimeCallInfo->GetCallArgRef(NUM_1);
10479     auto backward = runtimeCallInfo->GetCallArgRef(NUM_2);
10480     auto up = runtimeCallInfo->GetCallArgRef(NUM_3);
10481     auto down = runtimeCallInfo->GetCallArgRef(NUM_4);
10482     auto left = runtimeCallInfo->GetCallArgRef(NUM_5);
10483     auto right = runtimeCallInfo->GetCallArgRef(NUM_6);
10484     if (forward->IsString(vm)) {
10485         nextFocusArray[NUM_0] = forward->ToString(vm)->ToString(vm);
10486         hasValue = 1;
10487     }
10488     hasValue = hasValue << 1;
10489     if (backward->IsString(vm)) {
10490         nextFocusArray[NUM_1] = backward->ToString(vm)->ToString(vm);
10491         hasValue += 1;
10492     }
10493     hasValue = hasValue << 1;
10494     if (up->IsString(vm)) {
10495         nextFocusArray[NUM_2] = up->ToString(vm)->ToString(vm);
10496         hasValue += 1;
10497     }
10498     hasValue = hasValue << 1;
10499     if (down->IsString(vm)) {
10500         nextFocusArray[NUM_3] = down->ToString(vm)->ToString(vm);
10501         hasValue += 1;
10502     }
10503     hasValue = hasValue << 1;
10504     if (left->IsString(vm)) {
10505         nextFocusArray[NUM_4] = left->ToString(vm)->ToString(vm);
10506         hasValue += 1;
10507     }
10508     hasValue = hasValue << 1;
10509     if (right->IsString(vm)) {
10510         nextFocusArray[NUM_5] = right->ToString(vm)->ToString(vm);
10511         hasValue += 1;
10512     }
10513     GetArkUINodeModifiers()->getCommonModifier()->setNextFocus(nativeNode,
10514         nextFocusArray[NUM_0].c_str(), nextFocusArray[NUM_1].c_str(),
10515         nextFocusArray[NUM_2].c_str(), nextFocusArray[NUM_3].c_str(),
10516         nextFocusArray[NUM_4].c_str(), nextFocusArray[NUM_5].c_str(), hasValue);
10517     return panda::JSValueRef::Undefined(vm);
10518 }
10519 
ResetNextFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)10520 ArkUINativeModuleValue CommonBridge::ResetNextFocus(ArkUIRuntimeCallInfo* runtimeCallInfo)
10521 {
10522     EcmaVM* vm = runtimeCallInfo->GetVM();
10523     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10524     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
10525     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
10526     GetArkUINodeModifiers()->getCommonModifier()->resetNextFocus(nativeNode);
10527     return panda::JSValueRef::Undefined(vm);
10528 }
10529 
CreateFocusAxisEventInfo(EcmaVM * vm,NG::FocusAxisEventInfo & info)10530 Local<panda::ObjectRef> CommonBridge::CreateFocusAxisEventInfo(EcmaVM* vm, NG::FocusAxisEventInfo& info)
10531 {
10532     auto axisMap = panda::MapRef::New(vm);
10533     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_X)),
10534         panda::NumberRef::New(vm, info.GetAbsXValue()));
10535     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_Y)),
10536         panda::NumberRef::New(vm, info.GetAbsYValue()));
10537     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_Z)),
10538         panda::NumberRef::New(vm, info.GetAbsZValue()));
10539     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_RZ)),
10540         panda::NumberRef::New(vm, info.GetAbsRzValue()));
10541     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_GAS)),
10542         panda::NumberRef::New(vm, info.GetAbsGasValue()));
10543     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_BRAKE)),
10544         panda::NumberRef::New(vm, info.GetAbsBrakeValue()));
10545     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_HAT0X)),
10546         panda::NumberRef::New(vm, info.GetAbsHat0XValue()));
10547     axisMap->Set(vm, panda::NumberRef::New(vm, static_cast<int>(NG::AxisModel::ABS_HAT0Y)),
10548         panda::NumberRef::New(vm, info.GetAbsHat0YValue()));
10549     const char* keys[] = { "axisMap", "target", "timestamp", "source", "pressure", "tiltX", "tiltY", "sourceTool",
10550         "deviceId", "getModifierKeyState", "stopPropagation", "targetDisplayId" };
10551     Local<JSValueRef> values[] = { axisMap, FrameNodeBridge::CreateEventTargetObject(vm, info),
10552         panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
10553         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetSourceDevice())),
10554         panda::NumberRef::New(vm, info.GetForce()),
10555         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltX().value_or(0.0f))),
10556         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltY().value_or(0.0f))),
10557         panda::NumberRef::New(vm, static_cast<int32_t>(static_cast<int32_t>(info.GetSourceTool()))),
10558         panda::NumberRef::New(vm, info.GetDeviceId()), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
10559         panda::FunctionRef::New(vm, Framework::JsStopPropagation),
10560         panda::NumberRef::New(vm, (info.GetTargetDisplayId()))};
10561     auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
10562     obj->SetNativePointerFieldCount(vm, 1);
10563     obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
10564     return obj;
10565 }
10566 
SetOnFocusAxisEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)10567 ArkUINativeModuleValue CommonBridge::SetOnFocusAxisEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
10568 {
10569     EcmaVM* vm = runtimeCallInfo->GetVM();
10570     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10571     auto* frameNode = GetFrameNode(runtimeCallInfo);
10572     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10573     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
10574     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
10575     auto obj = secondeArg->ToObject(vm);
10576     auto containerId = Container::CurrentId();
10577     panda::Local<panda::FunctionRef> func = obj;
10578     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
10579     auto onFocusAxisEvent = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
10580                                 node = AceType::WeakClaim(frameNode), containerId](FocusAxisEventInfo& info) {
10581         panda::LocalScope pandaScope(vm);
10582         panda::TryCatch trycatch(vm);
10583         ContainerScope scope(containerId);
10584         auto function = func.Lock();
10585         CHECK_NULL_VOID(!function.IsEmpty());
10586         CHECK_NULL_VOID(function->IsFunction(vm));
10587         PipelineContext::SetCallBackNode(node);
10588         auto obj = CreateFocusAxisEventInfo(vm, info);
10589         panda::Local<panda::JSValueRef> params[] = { obj };
10590         function->Call(vm, function.ToLocal(), params, 1);
10591     };
10592     NG::ViewAbstract::SetOnFocusAxisEvent(frameNode, std::move(onFocusAxisEvent));
10593     return panda::JSValueRef::Undefined(vm);
10594 }
10595 
ResetOnFocusAxisEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)10596 ArkUINativeModuleValue CommonBridge::ResetOnFocusAxisEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
10597 {
10598     EcmaVM* vm = runtimeCallInfo->GetVM();
10599     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10600     auto* frameNode = GetFrameNode(runtimeCallInfo);
10601     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10602     ViewAbstract::DisableOnFocusAxisEvent(frameNode);
10603     return panda::JSValueRef::Undefined(vm);
10604 }
10605 
RegisterFrameNodeDestructorCallback(ArkUIRuntimeCallInfo * runtimeCallInfo)10606 ArkUINativeModuleValue CommonBridge::RegisterFrameNodeDestructorCallback(ArkUIRuntimeCallInfo* runtimeCallInfo)
10607 {
10608     EcmaVM* vm = runtimeCallInfo->GetVM();
10609     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10610     auto* frameNode = GetFrameNode(runtimeCallInfo);
10611     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10612     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
10613     if (secondeArg->IsNull() || secondeArg->IsUndefined()) {
10614         frameNode->SetFrameNodeDestructorCallback(nullptr);
10615         return panda::JSValueRef::Undefined(vm);
10616     }
10617     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
10618     auto obj = secondeArg->ToObject(vm);
10619     auto containerId = Container::CurrentId();
10620     CHECK_NULL_RETURN(containerId != -1, panda::JSValueRef::Undefined(vm));
10621     panda::Local<panda::FunctionRef> func = obj;
10622     auto frameNodeDestructorCallback = [vm, func = JsWeak(panda::CopyableGlobal(vm, func)),
10623                                            node = AceType::WeakClaim(frameNode), containerId](int32_t frameNodeId) {
10624         panda::LocalScope pandaScope(vm);
10625         panda::TryCatch trycatch(vm);
10626         ContainerScope scope(containerId);
10627         auto function = func.Lock();
10628         CHECK_NULL_VOID(!function.IsEmpty());
10629         CHECK_NULL_VOID(function->IsFunction(vm));
10630         PipelineContext::SetCallBackNode(node);
10631         auto frameNodeIdParam = panda::NumberRef::New(vm, frameNodeId);
10632         panda::Local<panda::JSValueRef> params[] = { frameNodeIdParam };
10633         function->Call(vm, function.ToLocal(), params, 1);
10634     };
10635     frameNode->SetFrameNodeDestructorCallback(std::move(frameNodeDestructorCallback));
10636     return panda::JSValueRef::Undefined(vm);
10637 }
10638 
CreateAxisEventInfo(EcmaVM * vm,AxisInfo & info)10639 Local<panda::ObjectRef> CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& info)
10640 {
10641     const Offset& globalOffset = info.GetGlobalLocation();
10642     const Offset& localOffset = info.GetLocalLocation();
10643     const Offset& screenOffset = info.GetScreenLocation();
10644     const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation();
10645     double density = PipelineBase::GetCurrentDensity();
10646     const char* keys[] = { "action", "displayX", "displayY", "windowX", "windowY", "x", "y", "scrollStep",
10647         "propagation", "getHorizontalAxisValue", "getVerticalAxisValue", "target", "timestamp", "source", "pressure",
10648         "tiltX", "tiltY", "sourceTool", "deviceId", "getModifierKeyState", "axisVertical", "axisHorizontal",
10649         "globalDisplayX", "globalDisplayY", "targetDisplayId" };
10650     Local<JSValueRef> values[] = { panda::NumberRef::New(vm, static_cast<int32_t>(info.GetAction())),
10651         panda::NumberRef::New(vm, screenOffset.GetX() / density),
10652         panda::NumberRef::New(vm, screenOffset.GetY() / density),
10653         panda::NumberRef::New(vm, globalOffset.GetX() / density),
10654         panda::NumberRef::New(vm, globalOffset.GetY() / density),
10655         panda::NumberRef::New(vm, localOffset.GetX() / density),
10656         panda::NumberRef::New(vm, localOffset.GetY() / density), panda::NumberRef::New(vm, info.GetScrollStep()),
10657         panda::FunctionRef::New(vm, Framework::JsPropagation),
10658         panda::FunctionRef::New(vm, ArkTSUtils::JsGetHorizontalAxisValue),
10659         panda::FunctionRef::New(vm, ArkTSUtils::JsGetVerticalAxisValue),
10660         FrameNodeBridge::CreateEventTargetObject(vm, info),
10661         panda::NumberRef::New(vm, static_cast<double>(info.GetTimeStamp().time_since_epoch().count())),
10662         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetSourceDevice())),
10663         panda::NumberRef::New(vm, info.GetForce()),
10664         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltX().value_or(0.0f))),
10665         panda::NumberRef::New(vm, static_cast<int32_t>(info.GetTiltY().value_or(0.0f))),
10666         panda::NumberRef::New(vm, static_cast<int32_t>(static_cast<int32_t>(info.GetSourceTool()))),
10667         panda::NumberRef::New(vm, info.GetDeviceId()),
10668         panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState),
10669         panda::NumberRef::New(vm, info.GetVerticalAxis()),
10670         panda::NumberRef::New(vm, info.GetHorizontalAxis()),
10671         panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density),
10672         panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density),
10673         panda::NumberRef::New(vm, info.GetTargetDisplayId()) };
10674     auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
10675     obj->SetNativePointerFieldCount(vm, 1);
10676     obj->SetNativePointerField(vm, 0, static_cast<void*>(&info));
10677     return obj;
10678 }
10679 
SetOnAxisEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)10680 ArkUINativeModuleValue CommonBridge::SetOnAxisEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
10681 {
10682     EcmaVM* vm = runtimeCallInfo->GetVM();
10683     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10684     auto* frameNode = GetFrameNode(runtimeCallInfo);
10685     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10686     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(1);
10687     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
10688     auto obj = secondeArg->ToObject(vm);
10689     auto containerId = Container::CurrentId();
10690     panda::Local<panda::FunctionRef> func = obj;
10691     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
10692     auto onAxisEvent = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
10693                            node = AceType::WeakClaim(frameNode), containerId](AxisInfo& info) {
10694         panda::LocalScope pandaScope(vm);
10695         panda::TryCatch trycatch(vm);
10696         ContainerScope scope(containerId);
10697         auto function = func.Lock();
10698         CHECK_NULL_VOID(!function.IsEmpty());
10699         CHECK_NULL_VOID(function->IsFunction(vm));
10700         PipelineContext::SetCallBackNode(node);
10701         auto obj = CreateAxisEventInfo(vm, info);
10702         panda::Local<panda::JSValueRef> params[] = { obj };
10703         function->Call(vm, function.ToLocal(), params, 1);
10704     };
10705     NG::ViewAbstract::SetOnAxisEvent(frameNode, std::move(onAxisEvent));
10706     return panda::JSValueRef::Undefined(vm);
10707 }
10708 
ResetOnAxisEvent(ArkUIRuntimeCallInfo * runtimeCallInfo)10709 ArkUINativeModuleValue CommonBridge::ResetOnAxisEvent(ArkUIRuntimeCallInfo* runtimeCallInfo)
10710 {
10711     EcmaVM* vm = runtimeCallInfo->GetVM();
10712     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10713     auto* frameNode = GetFrameNode(runtimeCallInfo);
10714     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10715     ViewAbstract::DisableOnAxisEvent(frameNode);
10716     return panda::JSValueRef::Undefined(vm);
10717 }
10718 
SetVisualEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)10719 ArkUINativeModuleValue CommonBridge::SetVisualEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
10720 {
10721     EcmaVM* vm = runtimeCallInfo->GetVM();
10722     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10723     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10724     Local<JSValueRef> visualEffectArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10725     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10726     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10727     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10728     auto nodeModifiers = GetArkUINodeModifiers();
10729     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10730     if (visualEffectArg->IsNull() || visualEffectArg->IsUndefined()) {
10731         nodeModifiers->getCommonModifier()->resetVisualEffect(nativeNode);
10732         return panda::JSValueRef::Undefined(vm);
10733     }
10734     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
10735     auto jsVal = info[NUM_1];
10736     auto visualEffect = Framework::UnwrapNapiValue(jsVal);
10737     nodeModifiers->getCommonModifier()->setVisualEffect(nativeNode, visualEffect);
10738     return panda::JSValueRef::Undefined(vm);
10739 }
10740 
ResetVisualEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)10741 ArkUINativeModuleValue CommonBridge::ResetVisualEffect(ArkUIRuntimeCallInfo* runtimeCallInfo)
10742 {
10743     EcmaVM* vm = runtimeCallInfo->GetVM();
10744     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10745     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10746     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10747     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10748     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10749     auto nodeModifiers = GetArkUINodeModifiers();
10750     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10751     nodeModifiers->getCommonModifier()->resetVisualEffect(nativeNode);
10752     return panda::JSValueRef::Undefined(vm);
10753 }
10754 
SetBackgroundFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10755 ArkUINativeModuleValue CommonBridge::SetBackgroundFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10756 {
10757     EcmaVM* vm = runtimeCallInfo->GetVM();
10758     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10759     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10760     Local<JSValueRef> backgroundFilterArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10761     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10762     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10763     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10764     auto nodeModifiers = GetArkUINodeModifiers();
10765     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10766     if (backgroundFilterArg->IsNull() || backgroundFilterArg->IsUndefined()) {
10767         nodeModifiers->getCommonModifier()->resetBackgroundFilter(nativeNode);
10768         return panda::JSValueRef::Undefined(vm);
10769     }
10770     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
10771     auto jsVal = info[NUM_1];
10772     auto backgroundFilter = Framework::UnwrapNapiValue(jsVal);
10773     nodeModifiers->getCommonModifier()->setBackgroundFilter(nativeNode, backgroundFilter);
10774     return panda::JSValueRef::Undefined(vm);
10775 }
10776 
ResetBackgroundFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10777 ArkUINativeModuleValue CommonBridge::ResetBackgroundFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10778 {
10779     EcmaVM* vm = runtimeCallInfo->GetVM();
10780     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10781     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10782     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10783     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10784     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10785     auto nodeModifiers = GetArkUINodeModifiers();
10786     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10787     nodeModifiers->getCommonModifier()->resetBackgroundFilter(nativeNode);
10788     return panda::JSValueRef::Undefined(vm);
10789 }
10790 
SetForegroundFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10791 ArkUINativeModuleValue CommonBridge::SetForegroundFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10792 {
10793     EcmaVM* vm = runtimeCallInfo->GetVM();
10794     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10795     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10796     Local<JSValueRef> foregroundFilterArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10797     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10798     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10799     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10800     auto nodeModifiers = GetArkUINodeModifiers();
10801     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10802     if (foregroundFilterArg->IsNull() || foregroundFilterArg->IsUndefined()) {
10803         nodeModifiers->getCommonModifier()->resetForegroundFilter(nativeNode);
10804         return panda::JSValueRef::Undefined(vm);
10805     }
10806     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
10807     auto jsVal = info[NUM_1];
10808     auto foregroundFilter = Framework::UnwrapNapiValue(jsVal);
10809     nodeModifiers->getCommonModifier()->setForegroundFilter(nativeNode, foregroundFilter);
10810     return panda::JSValueRef::Undefined(vm);
10811 }
10812 
ResetForegroundFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10813 ArkUINativeModuleValue CommonBridge::ResetForegroundFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10814 {
10815     EcmaVM* vm = runtimeCallInfo->GetVM();
10816     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10817     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10818     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10819     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10820     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10821     auto nodeModifiers = GetArkUINodeModifiers();
10822     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10823     nodeModifiers->getCommonModifier()->resetForegroundFilter(nativeNode);
10824     return panda::JSValueRef::Undefined(vm);
10825 }
10826 
SetCompositingFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10827 ArkUINativeModuleValue CommonBridge::SetCompositingFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10828 {
10829     EcmaVM* vm = runtimeCallInfo->GetVM();
10830     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10831     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10832     Local<JSValueRef> compositingFilterArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10833     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10834     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10835     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10836     auto nodeModifiers = GetArkUINodeModifiers();
10837     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10838     if (compositingFilterArg->IsNull() || compositingFilterArg->IsUndefined()) {
10839         nodeModifiers->getCommonModifier()->resetCompositingFilter(nativeNode);
10840         return panda::JSValueRef::Undefined(vm);
10841     }
10842     Framework::JsiCallbackInfo info = Framework::JsiCallbackInfo(runtimeCallInfo);
10843     auto jsVal = info[NUM_1];
10844     auto compositingFilter = Framework::UnwrapNapiValue(jsVal);
10845     nodeModifiers->getCommonModifier()->setCompositingFilter(nativeNode, compositingFilter);
10846     return panda::JSValueRef::Undefined(vm);
10847 }
10848 
ResetCompositingFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)10849 ArkUINativeModuleValue CommonBridge::ResetCompositingFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
10850 {
10851     EcmaVM* vm = runtimeCallInfo->GetVM();
10852     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10853     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10854     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10855     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10856     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10857     auto nodeModifiers = GetArkUINodeModifiers();
10858     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10859     nodeModifiers->getCommonModifier()->resetCompositingFilter(nativeNode);
10860     return panda::JSValueRef::Undefined(vm);
10861 }
10862 
SetFreeze(ArkUIRuntimeCallInfo * runtimeCallInfo)10863 ArkUINativeModuleValue CommonBridge::SetFreeze(ArkUIRuntimeCallInfo* runtimeCallInfo)
10864 {
10865     EcmaVM* vm = runtimeCallInfo->GetVM();
10866     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10867     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10868     Local<JSValueRef> freezeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10869     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10870     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10871     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10872     auto nodeModifiers = GetArkUINodeModifiers();
10873     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10874     if (freezeArg->IsBoolean()) {
10875         bool freeze = freezeArg->ToBoolean(vm)->Value();
10876         nodeModifiers->getCommonModifier()->setFreeze(nativeNode, freeze);
10877         return panda::JSValueRef::Undefined(vm);
10878     }
10879     nodeModifiers->getCommonModifier()->resetFreeze(nativeNode);
10880     return panda::JSValueRef::Undefined(vm);
10881 }
10882 
ResetFreeze(ArkUIRuntimeCallInfo * runtimeCallInfo)10883 ArkUINativeModuleValue CommonBridge::ResetFreeze(ArkUIRuntimeCallInfo* runtimeCallInfo)
10884 {
10885     EcmaVM* vm = runtimeCallInfo->GetVM();
10886     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
10887     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
10888     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
10889     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
10890     CHECK_NULL_RETURN(nativeNode, panda::JSValueRef::Undefined(vm));
10891     auto nodeModifiers = GetArkUINodeModifiers();
10892     CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm));
10893     nodeModifiers->getCommonModifier()->resetFreeze(nativeNode);
10894     return panda::JSValueRef::Undefined(vm);
10895 }
10896 
SetOnPreDrag(ArkUIRuntimeCallInfo * runtimeCallInfo)10897 ArkUINativeModuleValue CommonBridge::SetOnPreDrag(ArkUIRuntimeCallInfo* runtimeCallInfo)
10898 {
10899     EcmaVM* vm = runtimeCallInfo->GetVM();
10900     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10901     auto* frameNode = GetFrameNode(runtimeCallInfo);
10902     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10903     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
10904     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
10905     auto obj = secondeArg->ToObject(vm);
10906     auto containerId = Container::CurrentId();
10907     panda::Local<panda::FunctionRef> func = obj;
10908     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
10909     auto onPreDrag = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
10910                          node = AceType::WeakClaim(frameNode), containerId](const PreDragStatus& preDragStatus) {
10911         panda::LocalScope pandaScope(vm);
10912         panda::TryCatch trycatch(vm);
10913         ContainerScope scope(containerId);
10914         auto function = func.Lock();
10915         CHECK_EQUAL_VOID(function.IsEmpty(), true);
10916         CHECK_EQUAL_VOID(function->IsFunction(vm), false);
10917         PipelineContext::SetCallBackNode(node);
10918         auto preDragStatusParam = panda::NumberRef::New(vm, static_cast<int32_t>(preDragStatus));
10919         panda::Local<panda::JSValueRef> params[] = { preDragStatusParam };
10920         function->Call(vm, function.ToLocal(), params, NUM_1);
10921     };
10922     NG::ViewAbstract::SetOnPreDrag(frameNode, std::move(onPreDrag));
10923     return panda::JSValueRef::Undefined(vm);
10924 }
10925 
ResetOnPreDrag(ArkUIRuntimeCallInfo * runtimeCallInfo)10926 ArkUINativeModuleValue CommonBridge::ResetOnPreDrag(ArkUIRuntimeCallInfo* runtimeCallInfo)
10927 {
10928     EcmaVM* vm = runtimeCallInfo->GetVM();
10929     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10930     auto* frameNode = GetFrameNode(runtimeCallInfo);
10931     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10932     ViewAbstract::DisableOnPreDrag(frameNode);
10933     return panda::JSValueRef::Undefined(vm);
10934 }
10935 
SetOnVisibleAreaChange(ArkUIRuntimeCallInfo * runtimeCallInfo)10936 ArkUINativeModuleValue CommonBridge::SetOnVisibleAreaChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
10937 {
10938     EcmaVM* vm = runtimeCallInfo->GetVM();
10939     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10940     auto* frameNode = GetFrameNode(runtimeCallInfo);
10941     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10942     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
10943     JsiRef<JsiValue> secondArg =
10944         JsiRef<JsiValue>::FastMake(runtimeCallInfo->GetVM(), runtimeCallInfo->GetCallArgRef(NUM_1));
10945     CHECK_NULL_RETURN(secondArg->IsArray(), panda::JSValueRef::Undefined(vm));
10946     auto ratioArray = JSRef<JSArray>::Cast(secondArg);
10947     size_t size = ratioArray->Length();
10948     std::vector<double> ratioList;
10949     for (size_t i = 0; i < size; i++) {
10950         double ratio = 0.0;
10951         JSViewAbstract::ParseJsDouble(ratioArray->GetValueAt(i), ratio);
10952         if (LessOrEqual(ratio, VISIBLE_RATIO_MIN)) {
10953             ratio = VISIBLE_RATIO_MIN;
10954         }
10955 
10956         if (GreatOrEqual(ratio, VISIBLE_RATIO_MAX)) {
10957             ratio = VISIBLE_RATIO_MAX;
10958         }
10959         ratioList.push_back(ratio);
10960     }
10961     CHECK_NULL_RETURN(thirdArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
10962     auto event = thirdArg->ToObject(vm);
10963     auto containerId = Container::CurrentId();
10964     panda::Local<panda::FunctionRef> func = event;
10965     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
10966     auto onVisibleAreaChange = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
10967                                    node = AceType::WeakClaim(frameNode),
10968                                    containerId](bool isVisible, double visibleRatio) {
10969         panda::LocalScope pandaScope(vm);
10970         panda::TryCatch trycatch(vm);
10971         ContainerScope scope(containerId);
10972         auto function = func.Lock();
10973         CHECK_EQUAL_VOID(function.IsEmpty(), true);
10974         CHECK_EQUAL_VOID(function->IsFunction(vm), false);
10975         PipelineContext::SetCallBackNode(node);
10976         auto isVisibles = panda::BooleanRef::New(vm, isVisible);
10977         auto visibleRatios = panda::NumberRef::New(vm, visibleRatio);
10978         panda::Local<panda::JSValueRef> params[NUM_2] = { isVisibles, visibleRatios };
10979         function->Call(vm, function.ToLocal(), params, NUM_2);
10980     };
10981     NG::ViewAbstract::SetOnVisibleChange(frameNode, std::move(onVisibleAreaChange), ratioList);
10982     return panda::JSValueRef::Undefined(vm);
10983 }
10984 
ResetOnVisibleAreaChange(ArkUIRuntimeCallInfo * runtimeCallInfo)10985 ArkUINativeModuleValue CommonBridge::ResetOnVisibleAreaChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
10986 {
10987     EcmaVM* vm = runtimeCallInfo->GetVM();
10988     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
10989     auto* frameNode = GetFrameNode(runtimeCallInfo);
10990     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
10991     ViewAbstract::ResetVisibleChange(frameNode);
10992     return panda::JSValueRef::Undefined(vm);
10993 }
10994 
ConvertHitTestMode(EcmaVM * vm,HitTestMode mode)10995 panda::Local<panda::JSValueRef> ConvertHitTestMode(EcmaVM* vm, HitTestMode mode)
10996 {
10997     switch (mode) {
10998         case HitTestMode::HTMDEFAULT:
10999             return panda::StringRef::NewFromUtf8(vm, "default");
11000         case HitTestMode::HTMBLOCK:
11001             return panda::StringRef::NewFromUtf8(vm, "block");
11002         case HitTestMode::HTMTRANSPARENT:
11003             return panda::StringRef::NewFromUtf8(vm, "transparent");
11004         case HitTestMode::HTMNONE:
11005             return panda::StringRef::NewFromUtf8(vm, "none");
11006         case HitTestMode::HTMTRANSPARENT_SELF:
11007             return panda::StringRef::NewFromUtf8(vm, "transparent_self");
11008         default:
11009             return panda::StringRef::NewFromUtf8(vm, "unknown");
11010     }
11011 }
11012 
SetOnTouchIntercept(ArkUIRuntimeCallInfo * runtimeCallInfo)11013 ArkUINativeModuleValue CommonBridge::SetOnTouchIntercept(ArkUIRuntimeCallInfo* runtimeCallInfo)
11014 {
11015     EcmaVM* vm = runtimeCallInfo->GetVM();
11016     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
11017     auto* frameNode = GetFrameNode(runtimeCallInfo);
11018     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
11019     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
11020     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
11021     auto obj = secondeArg->ToObject(vm);
11022     auto containerId = Container::CurrentId();
11023     panda::Local<panda::FunctionRef> func = obj;
11024     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
11025     auto onTouchIntercept = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
11026                                 node = AceType::WeakClaim(frameNode),
11027                                 containerId](TouchEventInfo& info) -> NG::HitTestMode {
11028         panda::LocalScope pandaScope(vm);
11029         panda::TryCatch trycatch(vm);
11030         ContainerScope scope(containerId);
11031         auto function = func.Lock();
11032         CHECK_EQUAL_RETURN(function.IsEmpty(), true, HitTestMode::HTMDEFAULT);
11033         CHECK_EQUAL_RETURN(function->IsFunction(vm), false, HitTestMode::HTMDEFAULT);
11034         PipelineContext::SetCallBackNode(node);
11035         auto touchEventObj = FrameNodeBridge::CreateTouchEventInfo(vm, info);
11036         HitTestMode hitTestMode = NG::HitTestMode::HTMDEFAULT;
11037         auto hitTestModeValue = ConvertHitTestMode(vm, hitTestMode);
11038         panda::Local<panda::JSValueRef> params[NUM_2] = { touchEventObj, hitTestModeValue };
11039         auto value = function->Call(vm, function.ToLocal(), params, NUM_2);
11040         if (value->IsNumber()) {
11041             return static_cast<NG::HitTestMode>(value->ToNumber(vm)->Value());
11042         }
11043         return hitTestMode;
11044     };
11045     NG::ViewAbstract::SetOnTouchIntercept(frameNode, std::move(onTouchIntercept));
11046     return panda::JSValueRef::Undefined(vm);
11047 }
11048 
ResetOnTouchIntercept(ArkUIRuntimeCallInfo * runtimeCallInfo)11049 ArkUINativeModuleValue CommonBridge::ResetOnTouchIntercept(ArkUIRuntimeCallInfo* runtimeCallInfo)
11050 {
11051     EcmaVM* vm = runtimeCallInfo->GetVM();
11052     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
11053     auto* frameNode = GetFrameNode(runtimeCallInfo);
11054     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
11055     ViewAbstract::SetOnTouchIntercept(frameNode, nullptr);
11056     return panda::JSValueRef::Undefined(vm);
11057 }
11058 
CreateTouchTestInfo(EcmaVM * vm,const NG::TouchTestInfo & info)11059 Local<panda::ObjectRef> CommonBridge::CreateTouchTestInfo(EcmaVM *vm, const NG::TouchTestInfo &info)
11060 {
11061     const char *keys[] = {"windowX", "windowY", "parentX", "parentY", "x", "y", "rect", "id"};
11062     Local<JSValueRef> values[] = {
11063         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.windowPoint.GetX())),
11064         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.windowPoint.GetY())),
11065         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.currentCmpPoint.GetX())),
11066         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.currentCmpPoint.GetY())),
11067         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.subCmpPoint.GetX())),
11068         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(info.subCmpPoint.GetY())),
11069         CreateRectangle(vm, info.subRect),
11070         panda::StringRef::NewFromUtf8(vm, info.id.c_str())};
11071     auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
11072     return obj;
11073 }
11074 
CreateRectangle(EcmaVM * vm,const NG::RectF & rect)11075 Local<panda::ObjectRef> CommonBridge::CreateRectangle(EcmaVM *vm, const NG::RectF &rect)
11076 {
11077     const char *rectKeys[] = {"x", "y", "width", "height"};
11078     Local<JSValueRef> rectValues[] = {panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(rect.GetX())),
11079         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(rect.GetY())),
11080         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(rect.Width())),
11081         panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(rect.Height()))};
11082 
11083     return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(rectKeys), rectKeys, rectValues);
11084 }
11085 
SetOnChildTouchTest(ArkUIRuntimeCallInfo * runtimeCallInfo)11086 ArkUINativeModuleValue CommonBridge::SetOnChildTouchTest(ArkUIRuntimeCallInfo* runtimeCallInfo)
11087 {
11088     EcmaVM* vm = runtimeCallInfo->GetVM();
11089     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
11090     auto* frameNode = GetFrameNode(runtimeCallInfo);
11091     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
11092     Local<JSValueRef> secondeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
11093     CHECK_NULL_RETURN(secondeArg->IsFunction(vm), panda::JSValueRef::Undefined(vm));
11094     auto containerId = Container::CurrentId();
11095     panda::Local<panda::FunctionRef> func = secondeArg->ToObject(vm);
11096     auto flag = FrameNodeBridge::IsCustomFrameNode(frameNode);
11097     auto onChildTouchTest = [vm, func = JSFuncObjRef(panda::CopyableGlobal(vm, func), flag),
11098                                 node = AceType::WeakClaim(frameNode),
11099                                 containerId](const std::vector<TouchTestInfo>& touchTestInfo) -> TouchResult {
11100         panda::LocalScope pandaScope(vm);
11101         panda::TryCatch trycatch(vm);
11102         ContainerScope scope(containerId);
11103         PipelineContext::SetCallBackNode(node);
11104         auto touchEventArr = panda::ArrayRef::New(vm);
11105         for (size_t i = 0; i < touchTestInfo.size(); i++) {
11106             auto touchEventObj = CreateTouchTestInfo(vm, touchTestInfo[i]);
11107             touchEventArr->SetValueAt(vm, touchEventArr, i, touchEventObj);
11108         }
11109         NG::TouchResult returnValue;
11110         returnValue.strategy = TouchTestStrategy::DEFAULT;
11111         returnValue.id = "";
11112         auto function = func.Lock();
11113         CHECK_EQUAL_RETURN(function.IsEmpty(), true, returnValue);
11114         CHECK_EQUAL_RETURN(function->IsFunction(vm), false, returnValue);
11115         panda::Local<panda::JSValueRef> params[] = { touchEventArr };
11116         auto value = function->Call(vm, function.ToLocal(), params, NUM_1);
11117         if (!value->IsObject(vm)) {
11118             return returnValue;
11119         }
11120         auto retObj = value->ToObject(vm);
11121         auto strategy = retObj->Get(vm, panda::StringRef::NewFromUtf8(vm, "strategy"));
11122         if (!strategy->IsNumber()) {
11123             return returnValue;
11124         }
11125         auto id = retObj->Get(vm, panda::StringRef::NewFromUtf8(vm, "id"));
11126         if (!id->IsString(vm)) {
11127             return returnValue;
11128         }
11129         returnValue.strategy = static_cast<NG::TouchTestStrategy>(strategy->ToNumber(vm)->Value());
11130         returnValue.id = id->ToString(vm)->ToString(vm);
11131         return returnValue;
11132     };
11133     ViewAbstract::SetOnTouchTestFunc(frameNode, std::move(onChildTouchTest));
11134     return panda::JSValueRef::Undefined(vm);
11135 }
11136 
ResetOnChildTouchTest(ArkUIRuntimeCallInfo * runtimeCallInfo)11137 ArkUINativeModuleValue CommonBridge::ResetOnChildTouchTest(ArkUIRuntimeCallInfo* runtimeCallInfo)
11138 {
11139     EcmaVM* vm = runtimeCallInfo->GetVM();
11140     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
11141     auto* frameNode = GetFrameNode(runtimeCallInfo);
11142     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
11143     ViewAbstract::SetOnTouchTestFunc(frameNode, nullptr);
11144     return panda::JSValueRef::Undefined(vm);
11145 }
11146 } // namespace OHOS::Ace::NG
11147