1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_area_bridge.h"
16 
17 #include "bridge/common/utils/utils.h"
18 #include "bridge/declarative_frontend/engine/jsi/jsi_types.h"
19 #include "bridge/declarative_frontend/jsview/js_text_editable_controller.h"
20 #include "bridge/declarative_frontend/jsview/js_view_abstract.h"
21 #include "core/components/common/layout/constants.h"
22 #include "core/components/common/properties/text_style.h"
23 #include "core/components/text_field/textfield_theme.h"
24 #include "core/components_ng/pattern/text_field/text_field_model.h"
25 #include "core/components_ng/pattern/text_field/text_field_model_ng.h"
26 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
27 #include "frameworks/bridge/declarative_frontend/jsview/js_textfield.h"
28 
29 namespace OHOS::Ace::NG {
30 constexpr int NUM_0 = 0;
31 constexpr int NUM_1 = 1;
32 constexpr int NUM_2 = 2;
33 constexpr int NUM_3 = 3;
34 constexpr int NUM_4 = 4;
35 constexpr int NUM_5 = 5;
36 constexpr int NUM_6 = 6;
37 constexpr int NUM_9 = 9;
38 constexpr int NUM_13 = 13;
39 constexpr int SIZE_OF_FOUR = 4;
40 constexpr int PARAM_ARR_LENGTH_1 = 1;
41 constexpr int PARAM_ARR_LENGTH_2 = 2;
42 constexpr uint32_t KEY_BOARD_FOCUS_DEFAULT = 1;
43 constexpr uint32_t ILLEGAL_VALUE = 0;
44 constexpr int32_t DEFAULT_MODE = -1;
45 constexpr uint32_t COLOR_ALPHA_VALUE = 0xFF000000;
46 const int32_t MINI_VALID_VALUE = 1;
47 const int32_t MAX_VALID_VALUE = 100;
48 constexpr int16_t DEFAULT_ALPHA = 255;
49 constexpr double DEFAULT_OPACITY = 0.2;
50 constexpr uint32_t DEFAULT_OVERFLOW = 4;
51 const std::vector<TextOverflow> TEXT_OVERFLOWS = { TextOverflow::NONE, TextOverflow::CLIP, TextOverflow::ELLIPSIS,
52     TextOverflow::MARQUEE, TextOverflow::DEFAULT };
53 const std::string DEFAULT_FONT_WEIGHT = "400";
54 const std::vector<OHOS::Ace::TextAlign> TEXT_ALIGNS = { OHOS::Ace::TextAlign::START, OHOS::Ace::TextAlign::CENTER,
55     OHOS::Ace::TextAlign::END, OHOS::Ace::TextAlign::JUSTIFY };
56 const std::vector<OHOS::Ace::FontStyle> FONT_STYLES = { OHOS::Ace::FontStyle::NORMAL, OHOS::Ace::FontStyle::ITALIC };
57 constexpr TextDecorationStyle DEFAULT_DECORATION_STYLE = TextDecorationStyle::SOLID;
58 const std::vector<TextHeightAdaptivePolicy> HEIGHT_ADAPTIVE_POLICY = { TextHeightAdaptivePolicy::MAX_LINES_FIRST,
59     TextHeightAdaptivePolicy::MIN_FONT_SIZE_FIRST, TextHeightAdaptivePolicy::LAYOUT_CONSTRAINT_FIRST };
60 
SetStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)61 ArkUINativeModuleValue TextAreaBridge::SetStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
62 {
63     EcmaVM *vm = runtimeCallInfo->GetVM();
64     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
65     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
66     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
67     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
68     if (secondArg->IsString(vm)) {
69         auto str = secondArg->ToString(vm)->ToString(vm);
70         if (str == "Inline") {
71             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaStyle(nativeNode,
72                 static_cast<int32_t>(InputStyle::INLINE));
73         } else {
74             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaStyle(nativeNode,
75                 static_cast<int32_t>(InputStyle::DEFAULT));
76         }
77     } else {
78         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaStyle(nativeNode);
79     }
80     return panda::JSValueRef::Undefined(vm);
81 }
82 
ResetStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)83 ArkUINativeModuleValue TextAreaBridge::ResetStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
84 {
85     EcmaVM *vm = runtimeCallInfo->GetVM();
86     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
87     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
88     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
89     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaStyle(nativeNode);
90     return panda::JSValueRef::Undefined(vm);
91 }
92 
SetSelectionMenuHidden(ArkUIRuntimeCallInfo * runtimeCallInfo)93 ArkUINativeModuleValue TextAreaBridge::SetSelectionMenuHidden(ArkUIRuntimeCallInfo *runtimeCallInfo)
94 {
95     EcmaVM *vm = runtimeCallInfo->GetVM();
96     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
97     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
98     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
99     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
100     uint32_t contextMenuHidden = 0;
101     if (secondArg->IsBoolean()) {
102         contextMenuHidden = static_cast<uint32_t>(secondArg->ToBoolean(vm)->Value());
103     }
104     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaSelectionMenuHidden(nativeNode, contextMenuHidden);
105     return panda::JSValueRef::Undefined(vm);
106 }
107 
ResetSelectionMenuHidden(ArkUIRuntimeCallInfo * runtimeCallInfo)108 ArkUINativeModuleValue TextAreaBridge::ResetSelectionMenuHidden(ArkUIRuntimeCallInfo *runtimeCallInfo)
109 {
110     EcmaVM *vm = runtimeCallInfo->GetVM();
111     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
112     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
113     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
114     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaSelectionMenuHidden(nativeNode);
115     return panda::JSValueRef::Undefined(vm);
116 }
117 
SetMaxLines(ArkUIRuntimeCallInfo * runtimeCallInfo)118 ArkUINativeModuleValue TextAreaBridge::SetMaxLines(ArkUIRuntimeCallInfo *runtimeCallInfo)
119 {
120     EcmaVM *vm = runtimeCallInfo->GetVM();
121     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
122     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
123     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
124     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
125     if (secondArg->IsNumber() && secondArg->Int32Value(vm) > 0) {
126         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaMaxLines(nativeNode, secondArg->Uint32Value(vm));
127     } else {
128         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMaxLines(nativeNode);
129     }
130     return panda::JSValueRef::Undefined(vm);
131 }
132 
ResetMaxLines(ArkUIRuntimeCallInfo * runtimeCallInfo)133 ArkUINativeModuleValue TextAreaBridge::ResetMaxLines(ArkUIRuntimeCallInfo *runtimeCallInfo)
134 {
135     EcmaVM *vm = runtimeCallInfo->GetVM();
136     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
137     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
138     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
139     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMaxLines(nativeNode);
140     return panda::JSValueRef::Undefined(vm);
141 }
142 
SetCopyOption(ArkUIRuntimeCallInfo * runtimeCallInfo)143 ArkUINativeModuleValue TextAreaBridge::SetCopyOption(ArkUIRuntimeCallInfo *runtimeCallInfo)
144 {
145     EcmaVM *vm = runtimeCallInfo->GetVM();
146     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
147     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
148     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
149     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
150     int32_t copyOptions = static_cast<int32_t>(OHOS::Ace::CopyOptions::None);
151     int32_t copyOptionsDistributed = static_cast<int32_t>(OHOS::Ace::CopyOptions::Distributed);
152     if (secondArg->IsNumber() && secondArg->Int32Value(vm) >= copyOptions &&
153         secondArg->Int32Value(vm) <= copyOptionsDistributed) {
154         copyOptions = secondArg->Int32Value(vm);
155         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaCopyOption(nativeNode, copyOptions);
156     } else {
157         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaCopyOption(nativeNode);
158     }
159     return panda::JSValueRef::Undefined(vm);
160 }
161 
ResetCopyOption(ArkUIRuntimeCallInfo * runtimeCallInfo)162 ArkUINativeModuleValue TextAreaBridge::ResetCopyOption(ArkUIRuntimeCallInfo *runtimeCallInfo)
163 {
164     EcmaVM *vm = runtimeCallInfo->GetVM();
165     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
166     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
167     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
168     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaCopyOption(nativeNode);
169     return panda::JSValueRef::Undefined(vm);
170 }
171 
SetPlaceholderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)172 ArkUINativeModuleValue TextAreaBridge::SetPlaceholderColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
173 {
174     EcmaVM *vm = runtimeCallInfo->GetVM();
175     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
176     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
177     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
178     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
179     Color color;
180     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
181         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaPlaceholderColor(nativeNode);
182     } else {
183         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaPlaceholderColor(nativeNode, color.GetValue());
184     }
185     return panda::JSValueRef::Undefined(vm);
186 }
187 
ResetPlaceholderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)188 ArkUINativeModuleValue TextAreaBridge::ResetPlaceholderColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
189 {
190     EcmaVM *vm = runtimeCallInfo->GetVM();
191     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
192     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
193     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
194     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaPlaceholderColor(nativeNode);
195     return panda::JSValueRef::Undefined(vm);
196 }
197 
SetTextAreaTextAlign(ArkUIRuntimeCallInfo * runtimeCallInfo)198 ArkUINativeModuleValue TextAreaBridge::SetTextAreaTextAlign(ArkUIRuntimeCallInfo *runtimeCallInfo)
199 {
200     EcmaVM *vm = runtimeCallInfo->GetVM();
201     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
202     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
203     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
204     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
205     if (secondArg->IsNumber()) {
206         int32_t value = secondArg->Int32Value(vm);
207         if (value >= 0 && value < static_cast<int32_t>(TEXT_ALIGNS.size())) {
208             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaTextAlign(nativeNode, value);
209         } else {
210             return panda::JSValueRef::Undefined(vm);
211         }
212     } else {
213         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaTextAlign(nativeNode);
214     }
215     return panda::JSValueRef::Undefined(vm);
216 }
217 
ResetTextAreaTextAlign(ArkUIRuntimeCallInfo * runtimeCallInfo)218 ArkUINativeModuleValue TextAreaBridge::ResetTextAreaTextAlign(ArkUIRuntimeCallInfo *runtimeCallInfo)
219 {
220     EcmaVM *vm = runtimeCallInfo->GetVM();
221     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
222     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
223     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
224     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaTextAlign(nativeNode);
225     return panda::JSValueRef::Undefined(vm);
226 }
227 
SetPlaceholderFont(ArkUIRuntimeCallInfo * runtimeCallInfo)228 ArkUINativeModuleValue TextAreaBridge::SetPlaceholderFont(ArkUIRuntimeCallInfo *runtimeCallInfo)
229 {
230     EcmaVM *vm = runtimeCallInfo->GetVM();
231     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
232     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
233     Local<JSValueRef> fontSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
234     Local<JSValueRef> fontWeightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
235     Local<JSValueRef> fontFamilyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
236     Local<JSValueRef> fontStyleArg = runtimeCallInfo->GetCallArgRef(NUM_4);
237     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
238     struct ArkUIResourceLength fontSize = { 0.0, -1, nullptr };
239     CalcDimension size;
240     std::string calcStr;
241     if (ArkTSUtils::ParseJsDimensionNG(vm, fontSizeArg, size, DimensionUnit::FP, false)) {
242         if (size.Unit() == DimensionUnit::CALC) {
243             fontSize.unit = static_cast<int32_t>(DimensionUnit::CALC);
244             calcStr = size.CalcValue();
245             fontSize.string = calcStr.c_str();
246         } else {
247             fontSize.value = size.Value();
248             fontSize.unit = static_cast<int32_t>(size.Unit());
249             fontSize.string = calcStr.c_str();
250         }
251     }
252     std::string fontWeight;
253     if (!fontWeightArg->IsNull()) {
254         if (fontWeightArg->IsNumber()) {
255             fontWeight = std::to_string(fontWeightArg->Int32Value(vm));
256         } else if (fontWeightArg->IsString(vm)) {
257             fontWeight = fontWeightArg->ToString(vm)->ToString(vm);
258         }
259     }
260     std::vector<std::string> fontFamilies;
261     std::string family;
262     if (ArkTSUtils::ParseJsFontFamilies(vm, fontFamilyArg, fontFamilies)) {
263         for (uint32_t i = 0; i < fontFamilies.size(); i++) {
264             family += fontFamilies.at(i);
265             family += ',';
266         }
267         family.pop_back();
268     }
269     int32_t style = -1;
270     if (fontStyleArg->IsNumber()) {
271         style = fontStyleArg->Int32Value(vm);
272         if (style <= 0 || style > static_cast<int32_t>(FONT_STYLES.size())) {
273             style = -1;
274         }
275     }
276     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaPlaceholderFont(nativeNode, &fontSize,
277         fontWeight.c_str(), family.c_str(), style);
278     return panda::JSValueRef::Undefined(vm);
279 }
280 
ResetPlaceholderFont(ArkUIRuntimeCallInfo * runtimeCallInfo)281 ArkUINativeModuleValue TextAreaBridge::ResetPlaceholderFont(ArkUIRuntimeCallInfo *runtimeCallInfo)
282 {
283     EcmaVM *vm = runtimeCallInfo->GetVM();
284     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
285     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
286     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
287     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaPlaceholderFont(nativeNode);
288     return panda::JSValueRef::Undefined(vm);
289 }
290 
SetBarState(ArkUIRuntimeCallInfo * runtimeCallInfo)291 ArkUINativeModuleValue TextAreaBridge::SetBarState(ArkUIRuntimeCallInfo *runtimeCallInfo)
292 {
293     EcmaVM *vm = runtimeCallInfo->GetVM();
294     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
295     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
296     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
297     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
298     if (secondArg->IsNumber()) {
299         uint32_t barStateValue = secondArg->Uint32Value(vm);
300         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBarState(nativeNode, barStateValue);
301     } else {
302         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBarState(nativeNode);
303     }
304     return panda::JSValueRef::Undefined(vm);
305 }
306 
ResetBarState(ArkUIRuntimeCallInfo * runtimeCallInfo)307 ArkUINativeModuleValue TextAreaBridge::ResetBarState(ArkUIRuntimeCallInfo *runtimeCallInfo)
308 {
309     EcmaVM *vm = runtimeCallInfo->GetVM();
310     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
311     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
312     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
313     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBarState(nativeNode);
314     return panda::JSValueRef::Undefined(vm);
315 }
316 
SetEnableKeyboardOnFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)317 ArkUINativeModuleValue TextAreaBridge::SetEnableKeyboardOnFocus(ArkUIRuntimeCallInfo *runtimeCallInfo)
318 {
319     EcmaVM *vm = runtimeCallInfo->GetVM();
320     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
321     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
322     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
323     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
324     uint32_t keyboardOnFocusValue = KEY_BOARD_FOCUS_DEFAULT;
325     if (secondArg->IsBoolean()) {
326         keyboardOnFocusValue = static_cast<uint32_t>(secondArg->ToBoolean(vm)->Value());
327     }
328     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaEnableKeyboardOnFocus(nativeNode, keyboardOnFocusValue);
329     return panda::JSValueRef::Undefined(vm);
330 }
331 
ResetEnableKeyboardOnFocus(ArkUIRuntimeCallInfo * runtimeCallInfo)332 ArkUINativeModuleValue TextAreaBridge::ResetEnableKeyboardOnFocus(ArkUIRuntimeCallInfo *runtimeCallInfo)
333 {
334     EcmaVM *vm = runtimeCallInfo->GetVM();
335     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
336     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
337     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
338     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnableKeyboardOnFocus(nativeNode);
339     return panda::JSValueRef::Undefined(vm);
340 }
341 
SetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)342 ArkUINativeModuleValue TextAreaBridge::SetFontFamily(ArkUIRuntimeCallInfo *runtimeCallInfo)
343 {
344     EcmaVM *vm = runtimeCallInfo->GetVM();
345     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
346     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
347     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
348     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
349     std::vector<std::string> fontFamilies;
350     if (!ArkTSUtils::ParseJsFontFamilies(vm, secondArg, fontFamilies)) {
351         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontFamily(nativeNode);
352         return panda::JSValueRef::Undefined(vm);
353     }
354     std::string families;
355     for (uint32_t i = 0; i < fontFamilies.size(); i++) {
356         families += fontFamilies.at(i);
357         families += ',';
358     }
359     families.pop_back();
360     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontFamily(nativeNode, families.c_str());
361     return panda::JSValueRef::Undefined(vm);
362 }
363 
ResetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)364 ArkUINativeModuleValue TextAreaBridge::ResetFontFamily(ArkUIRuntimeCallInfo *runtimeCallInfo)
365 {
366     EcmaVM *vm = runtimeCallInfo->GetVM();
367     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
368     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
369     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
370     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontFamily(nativeNode);
371     return panda::JSValueRef::Undefined(vm);
372 }
373 
SetShowCounter(ArkUIRuntimeCallInfo * runtimeCallInfo)374 ArkUINativeModuleValue TextAreaBridge::SetShowCounter(ArkUIRuntimeCallInfo *runtimeCallInfo)
375 {
376     EcmaVM *vm = runtimeCallInfo->GetVM();
377     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
378     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
379     Local<JSValueRef> showCounterArg = runtimeCallInfo->GetCallArgRef(NUM_1);
380     Local<JSValueRef> highlightBorderArg = runtimeCallInfo->GetCallArgRef(NUM_2);
381     Local<JSValueRef> thresholdArg = runtimeCallInfo->GetCallArgRef(NUM_3);
382     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
383     auto showCounter = false;
384     if (showCounterArg->IsBoolean()) {
385         showCounter = showCounterArg->BooleaValue(vm);
386     }
387     auto highlightBorder = true;
388     if (highlightBorderArg->IsBoolean()) {
389         highlightBorder = highlightBorderArg->BooleaValue(vm);
390     }
391     auto thresholdValue = static_cast<int32_t>(DEFAULT_MODE);
392     if (thresholdArg->IsNumber()) {
393         thresholdValue = thresholdArg->Int32Value(vm);
394         if (thresholdValue < MINI_VALID_VALUE || thresholdValue > MAX_VALID_VALUE) {
395             thresholdValue = static_cast<int32_t>(ILLEGAL_VALUE);
396             showCounter = false;
397         }
398     }
399     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaShowCounterOptions(
400         nativeNode, showCounter, thresholdValue, highlightBorder);
401     return panda::JSValueRef::Undefined(vm);
402 }
403 
ResetShowCounter(ArkUIRuntimeCallInfo * runtimeCallInfo)404 ArkUINativeModuleValue TextAreaBridge::ResetShowCounter(ArkUIRuntimeCallInfo *runtimeCallInfo)
405 {
406     EcmaVM *vm = runtimeCallInfo->GetVM();
407     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
408     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
409     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
410     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaShowCounter(nativeNode);
411     return panda::JSValueRef::Undefined(vm);
412 }
413 
SetCaretColor(ArkUIRuntimeCallInfo * runtimeCallInfo)414 ArkUINativeModuleValue TextAreaBridge::SetCaretColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
415 {
416     EcmaVM *vm = runtimeCallInfo->GetVM();
417     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
418     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
419     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
420     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
421     Color color;
422     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
423         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaCaretColor(nativeNode);
424     } else {
425         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaCaretColor(nativeNode, color.GetValue());
426     }
427     return panda::JSValueRef::Undefined(vm);
428 }
429 
ResetCaretColor(ArkUIRuntimeCallInfo * runtimeCallInfo)430 ArkUINativeModuleValue TextAreaBridge::ResetCaretColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
431 {
432     EcmaVM *vm = runtimeCallInfo->GetVM();
433     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
434     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
435     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
436     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaCaretColor(nativeNode);
437     return panda::JSValueRef::Undefined(vm);
438 }
439 
SetMaxLength(ArkUIRuntimeCallInfo * runtimeCallInfo)440 ArkUINativeModuleValue TextAreaBridge::SetMaxLength(ArkUIRuntimeCallInfo *runtimeCallInfo)
441 {
442     EcmaVM *vm = runtimeCallInfo->GetVM();
443     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
444     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
445     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
446     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
447     if (!secondArg->IsNumber()) {
448         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMaxLength(nativeNode);
449     } else {
450         int32_t maxLength = secondArg->Int32Value(vm);
451         if (std::isinf(static_cast<float>(secondArg->ToNumber(vm)->Value()))) {
452             maxLength = INT32_MAX; // Infinity
453         }
454         if (maxLength >= 0) {
455             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaMaxLength(nativeNode, maxLength);
456         } else {
457             GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMaxLength(nativeNode);
458         }
459     }
460     return panda::JSValueRef::Undefined(vm);
461 }
462 
ResetMaxLength(ArkUIRuntimeCallInfo * runtimeCallInfo)463 ArkUINativeModuleValue TextAreaBridge::ResetMaxLength(ArkUIRuntimeCallInfo *runtimeCallInfo)
464 {
465     EcmaVM *vm = runtimeCallInfo->GetVM();
466     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
467     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
468     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
469     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMaxLength(nativeNode);
470     return panda::JSValueRef::Undefined(vm);
471 }
472 
SetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)473 ArkUINativeModuleValue TextAreaBridge::SetFontColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
474 {
475     EcmaVM *vm = runtimeCallInfo->GetVM();
476     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
477     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
478     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
479     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
480     Color color;
481     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
482         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontColor(nativeNode);
483     } else {
484         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontColor(nativeNode, color.GetValue());
485     }
486     return panda::JSValueRef::Undefined(vm);
487 }
488 
ResetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)489 ArkUINativeModuleValue TextAreaBridge::ResetFontColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
490 {
491     EcmaVM *vm = runtimeCallInfo->GetVM();
492     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
493     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
494     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
495     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontColor(nativeNode);
496     return panda::JSValueRef::Undefined(vm);
497 }
498 
SetFontStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)499 ArkUINativeModuleValue TextAreaBridge::SetFontStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
500 {
501     EcmaVM *vm = runtimeCallInfo->GetVM();
502     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
503     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
504     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
505     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
506     if (secondArg->IsNumber()) {
507         int32_t fontStyle = secondArg->Int32Value(vm);
508         if (fontStyle >= 0 && fontStyle < static_cast<int32_t>(FONT_STYLES.size())) {
509             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontStyle(nativeNode,
510                 static_cast<uint32_t>(fontStyle));
511         } else {
512             return panda::JSValueRef::Undefined(vm);
513         }
514     } else {
515         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontStyle(nativeNode);
516     }
517     return panda::JSValueRef::Undefined(vm);
518 }
519 
ResetFontStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)520 ArkUINativeModuleValue TextAreaBridge::ResetFontStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
521 {
522     EcmaVM *vm = runtimeCallInfo->GetVM();
523     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
524     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
525     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
526     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontStyle(nativeNode);
527     return panda::JSValueRef::Undefined(vm);
528 }
529 
SetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)530 ArkUINativeModuleValue TextAreaBridge::SetFontWeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
531 {
532     EcmaVM *vm = runtimeCallInfo->GetVM();
533     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
534     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
535     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
536     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
537     std::string fontWeight = DEFAULT_FONT_WEIGHT;
538     if (!secondArg->IsNull()) {
539         if (secondArg->IsNumber()) {
540             fontWeight = std::to_string(secondArg->Int32Value(vm));
541         } else if (secondArg->IsString(vm)) {
542             fontWeight = secondArg->ToString(vm)->ToString(vm);
543         }
544     }
545     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontWeightStr(nativeNode, fontWeight.c_str());
546     return panda::JSValueRef::Undefined(vm);
547 }
548 
ResetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)549 ArkUINativeModuleValue TextAreaBridge::ResetFontWeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
550 {
551     EcmaVM *vm = runtimeCallInfo->GetVM();
552     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
553     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
554     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
555     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontWeight(nativeNode);
556     return panda::JSValueRef::Undefined(vm);
557 }
558 
SetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)559 ArkUINativeModuleValue TextAreaBridge::SetFontSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
560 {
561     EcmaVM *vm = runtimeCallInfo->GetVM();
562     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
563     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
564     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
565     Local<JSValueRef> jsValue = runtimeCallInfo->GetCallArgRef(NUM_1);
566     struct ArkUIResourceLength fontSize = { 0.0, 0, nullptr };
567     CalcDimension size;
568     std::string calcStr;
569     if (jsValue->IsUndefined() || !ArkTSUtils::ParseJsDimensionNG(vm, jsValue, size, DimensionUnit::FP, false)) {
570         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontSize(nativeNode);
571     } else {
572         if (size.Unit() == DimensionUnit::CALC) {
573             fontSize.unit = static_cast<int32_t>(DimensionUnit::CALC);
574             calcStr = size.CalcValue();
575             fontSize.string = calcStr.c_str();
576             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontSize(nativeNode, &fontSize);
577         } else {
578             fontSize.value = size.Value();
579             fontSize.unit = static_cast<int32_t>(size.Unit());
580             fontSize.string = calcStr.c_str();
581             GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontSize(nativeNode, &fontSize);
582         }
583     }
584     return panda::JSValueRef::Undefined(vm);
585 }
586 
ResetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)587 ArkUINativeModuleValue TextAreaBridge::ResetFontSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
588 {
589     EcmaVM *vm = runtimeCallInfo->GetVM();
590     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
591     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
592     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
593     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontSize(nativeNode);
594     return panda::JSValueRef::Undefined(vm);
595 }
596 
SetFontFeature(ArkUIRuntimeCallInfo * runtimeCallInfo)597 ArkUINativeModuleValue TextAreaBridge::SetFontFeature(ArkUIRuntimeCallInfo* runtimeCallInfo)
598 {
599     EcmaVM* vm = runtimeCallInfo->GetVM();
600     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
601     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
602     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
603     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
604     if (secondArg->IsString(vm)) {
605         auto value = secondArg->ToString(vm)->ToString(vm);
606         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaFontFeature(nativeNode, value.c_str());
607     } else {
608         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontFeature(nativeNode);
609     }
610     return panda::JSValueRef::Undefined(vm);
611 }
612 
ResetFontFeature(ArkUIRuntimeCallInfo * runtimeCallInfo)613 ArkUINativeModuleValue TextAreaBridge::ResetFontFeature(ArkUIRuntimeCallInfo* runtimeCallInfo)
614 {
615     EcmaVM* vm = runtimeCallInfo->GetVM();
616     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
617     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
618     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
619     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaFontFeature(nativeNode);
620     return panda::JSValueRef::Undefined(vm);
621 }
622 
SetDecoration(ArkUIRuntimeCallInfo * runtimeCallInfo)623 ArkUINativeModuleValue TextAreaBridge::SetDecoration(ArkUIRuntimeCallInfo* runtimeCallInfo)
624 {
625     EcmaVM* vm = runtimeCallInfo->GetVM();
626     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
627     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
628     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
629     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
630     Local<JSValueRef> fourthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
631     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
632     auto container = Container::Current();
633     CHECK_NULL_RETURN(container, panda::JSValueRef::Undefined(vm));
634     auto pipelineContext = container->GetPipelineContext();
635     CHECK_NULL_RETURN(pipelineContext, panda::JSValueRef::Undefined(vm));
636     auto themeManager = pipelineContext->GetThemeManager();
637     CHECK_NULL_RETURN(themeManager, panda::JSValueRef::Undefined(vm));
638     auto theme = themeManager->GetTheme<TextFieldTheme>();
639     CHECK_NULL_RETURN(theme, panda::JSValueRef::Undefined(vm));
640     Color color = theme->GetTextStyle().GetTextDecorationColor();
641     int32_t textAreaDecoration = static_cast<int32_t>(theme->GetTextStyle().GetTextDecoration());
642     if (secondArg->IsInt()) {
643         textAreaDecoration = secondArg->Int32Value(vm);
644     }
645     ArkTSUtils::ParseJsColorAlpha(vm, thirdArg, color, Color::BLACK);
646     int32_t textDecorationStyle = static_cast<int32_t>(DEFAULT_DECORATION_STYLE);
647     if (fourthArg->IsInt()) {
648         textDecorationStyle = fourthArg->Int32Value(vm);
649     }
650     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaDecoration(
651         nativeNode, textAreaDecoration, color.GetValue(), textDecorationStyle);
652     return panda::JSValueRef::Undefined(vm);
653 }
654 
ResetDecoration(ArkUIRuntimeCallInfo * runtimeCallInfo)655 ArkUINativeModuleValue TextAreaBridge::ResetDecoration(ArkUIRuntimeCallInfo* runtimeCallInfo)
656 {
657     EcmaVM* vm = runtimeCallInfo->GetVM();
658     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
659     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
660     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
661     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaDecoration(nativeNode);
662     return panda::JSValueRef::Undefined(vm);
663 }
664 
SetLetterSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)665 ArkUINativeModuleValue TextAreaBridge::SetLetterSpacing(ArkUIRuntimeCallInfo* runtimeCallInfo)
666 {
667     EcmaVM* vm = runtimeCallInfo->GetVM();
668     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
669     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
670     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
671     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
672     CalcDimension value;
673     if (!ArkTSUtils::ParseJsDimensionNG(vm, valueArg, value, DimensionUnit::FP, false)) {
674         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLetterSpacing(nativeNode);
675     } else {
676         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaLetterSpacing(
677             nativeNode, value.Value(), static_cast<int>(value.Unit()));
678     }
679     return panda::JSValueRef::Undefined(vm);
680 }
SetMinFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)681 ArkUINativeModuleValue TextAreaBridge::SetMinFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
682 {
683     EcmaVM* vm = runtimeCallInfo->GetVM();
684     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
685     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
686     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
687     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
688     CalcDimension value;
689     auto pipelineContext = PipelineBase::GetCurrentContext();
690     CHECK_NULL_RETURN(pipelineContext, panda::NativePointerRef::New(vm, nullptr));
691     auto theme = pipelineContext->GetTheme<TextFieldTheme>();
692     CHECK_NULL_RETURN(theme, panda::NativePointerRef::New(vm, nullptr));
693     if (!ArkTSUtils::ParseJsDimensionNG(vm, valueArg, value, DimensionUnit::FP, false)) {
694         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaAdaptMinFontSize(nativeNode);
695     } else {
696         if (value.IsNegative()) {
697             value = theme->GetTextStyle().GetAdaptMinFontSize();
698         }
699         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaAdaptMinFontSize(
700             nativeNode, value.Value(), static_cast<int32_t>(value.Unit()));
701     }
702     return panda::JSValueRef::Undefined(vm);
703 }
704 
ResetLetterSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)705 ArkUINativeModuleValue TextAreaBridge::ResetLetterSpacing(ArkUIRuntimeCallInfo* runtimeCallInfo)
706 {
707     EcmaVM* vm = runtimeCallInfo->GetVM();
708     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
709     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
710     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
711     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLetterSpacing(nativeNode);
712     return panda::JSValueRef::Undefined(vm);
713 }
714 
SetLineHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)715 ArkUINativeModuleValue TextAreaBridge::SetLineHeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
716 {
717     EcmaVM* vm = runtimeCallInfo->GetVM();
718     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
719     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
720     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
721     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
722     CalcDimension value;
723     if (!ArkTSUtils::ParseJsDimensionNG(vm, valueArg, value, DimensionUnit::FP, true)) {
724         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineHeight(nativeNode);
725     } else {
726         if (value.IsNegative()) {
727             value.Reset();
728         }
729         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaLineHeight(
730             nativeNode, value.Value(), static_cast<int>(value.Unit()));
731     }
732     return panda::JSValueRef::Undefined(vm);
733 }
ResetMinFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)734 ArkUINativeModuleValue TextAreaBridge::ResetMinFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
735 {
736     EcmaVM* vm = runtimeCallInfo->GetVM();
737     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
738     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
739     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
740     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaAdaptMinFontSize(nativeNode);
741     return panda::JSValueRef::Undefined(vm);
742 }
743 
SetMaxFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)744 ArkUINativeModuleValue TextAreaBridge::SetMaxFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
745 {
746     EcmaVM* vm = runtimeCallInfo->GetVM();
747     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
748     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
749     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
750     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
751     CalcDimension value;
752     auto pipelineContext = PipelineBase::GetCurrentContext();
753     CHECK_NULL_RETURN(pipelineContext, panda::NativePointerRef::New(vm, nullptr));
754     auto theme = pipelineContext->GetTheme<TextFieldTheme>();
755     CHECK_NULL_RETURN(theme, panda::NativePointerRef::New(vm, nullptr));
756     if (!ArkTSUtils::ParseJsDimensionNG(vm, valueArg, value, DimensionUnit::FP, false)) {
757         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaAdaptMaxFontSize(nativeNode);
758     } else {
759         if (value.IsNegative()) {
760             value = theme->GetTextStyle().GetAdaptMaxFontSize();
761         }
762         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaAdaptMaxFontSize(
763             nativeNode, value.Value(), static_cast<int32_t>(value.Unit()));
764     }
765     return panda::JSValueRef::Undefined(vm);
766 }
767 
ResetLineHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)768 ArkUINativeModuleValue TextAreaBridge::ResetLineHeight(ArkUIRuntimeCallInfo* runtimeCallInfo)
769 {
770     EcmaVM* vm = runtimeCallInfo->GetVM();
771     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
772     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
773     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
774     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineHeight(nativeNode);
775     return panda::JSValueRef::Undefined(vm);
776 }
777 
SetWordBreak(ArkUIRuntimeCallInfo * runtimeCallInfo)778 ArkUINativeModuleValue TextAreaBridge::SetWordBreak(ArkUIRuntimeCallInfo* runtimeCallInfo)
779 {
780     EcmaVM* vm = runtimeCallInfo->GetVM();
781     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
782     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
783     Local<JSValueRef> workBreakArg = runtimeCallInfo->GetCallArgRef(NUM_1);
784     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
785     if (workBreakArg->IsNull() || workBreakArg->IsUndefined() || !workBreakArg->IsNumber()) {
786         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaWordBreak(nativeNode);
787         return panda::JSValueRef::Undefined(vm);
788     }
789     uint32_t wordBreak = workBreakArg->Uint32Value(vm);
790     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaWordBreak(nativeNode, wordBreak);
791     return panda::JSValueRef::Undefined(vm);
792 }
793 
ResetWordBreak(ArkUIRuntimeCallInfo * runtimeCallInfo)794 ArkUINativeModuleValue TextAreaBridge::ResetWordBreak(ArkUIRuntimeCallInfo* runtimeCallInfo)
795 {
796     EcmaVM* vm = runtimeCallInfo->GetVM();
797     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
798     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
799     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
800     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaWordBreak(nativeNode);
801     return panda::JSValueRef::Undefined(vm);
802 }
803 
SetLineBreakStrategy(ArkUIRuntimeCallInfo * runtimeCallInfo)804 ArkUINativeModuleValue TextAreaBridge::SetLineBreakStrategy(ArkUIRuntimeCallInfo* runtimeCallInfo)
805 {
806     EcmaVM* vm = runtimeCallInfo->GetVM();
807     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
808     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
809     Local<JSValueRef> lineBreakStrategyArg = runtimeCallInfo->GetCallArgRef(NUM_1);
810     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
811     if (lineBreakStrategyArg->IsNull() || lineBreakStrategyArg->IsUndefined() || !lineBreakStrategyArg->IsNumber()) {
812         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineBreakStrategy(nativeNode);
813         return panda::JSValueRef::Undefined(vm);
814     }
815     uint32_t lineBreakStrategy = lineBreakStrategyArg->Uint32Value(vm);
816     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaLineBreakStrategy(nativeNode, lineBreakStrategy);
817     return panda::JSValueRef::Undefined(vm);
818 }
819 
ResetLineBreakStrategy(ArkUIRuntimeCallInfo * runtimeCallInfo)820 ArkUINativeModuleValue TextAreaBridge::ResetLineBreakStrategy(ArkUIRuntimeCallInfo* runtimeCallInfo)
821 {
822     EcmaVM* vm = runtimeCallInfo->GetVM();
823     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
824     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
825     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
826     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineBreakStrategy(nativeNode);
827     return panda::JSValueRef::Undefined(vm);
828 }
829 
ResetMaxFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)830 ArkUINativeModuleValue TextAreaBridge::ResetMaxFontSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
831 {
832     EcmaVM* vm = runtimeCallInfo->GetVM();
833     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
834     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
835     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
836     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaAdaptMaxFontSize(nativeNode);
837     return panda::JSValueRef::Undefined(vm);
838 }
839 
SetHeightAdaptivePolicy(ArkUIRuntimeCallInfo * runtimeCallInfo)840 ArkUINativeModuleValue TextAreaBridge::SetHeightAdaptivePolicy(ArkUIRuntimeCallInfo* runtimeCallInfo)
841 {
842     EcmaVM* vm = runtimeCallInfo->GetVM();
843     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
844     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
845     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
846     Local<JSValueRef> valueArg = runtimeCallInfo->GetCallArgRef(NUM_1);
847     int32_t value = valueArg->ToNumber(vm)->Value();
848     if (value < 0 || value >= static_cast<int32_t>(HEIGHT_ADAPTIVE_POLICY.size())) {
849         value = 0;
850     }
851     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaHeightAdaptivePolicy(nativeNode, value);
852     return panda::JSValueRef::Undefined(vm);
853 }
854 
ResetHeightAdaptivePolicy(ArkUIRuntimeCallInfo * runtimeCallInfo)855 ArkUINativeModuleValue TextAreaBridge::ResetHeightAdaptivePolicy(ArkUIRuntimeCallInfo* runtimeCallInfo)
856 {
857     EcmaVM* vm = runtimeCallInfo->GetVM();
858     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
859     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
860     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
861     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaHeightAdaptivePolicy(nativeNode);
862     return panda::JSValueRef::Undefined(vm);
863 }
SetSelectedBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)864 ArkUINativeModuleValue TextAreaBridge::SetSelectedBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
865 {
866     EcmaVM* vm = runtimeCallInfo->GetVM();
867     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
868     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
869     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
870     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
871     Color color;
872     if (ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
873         if (color.GetAlpha() == DEFAULT_ALPHA) {
874             color = color.ChangeOpacity(DEFAULT_OPACITY);
875         }
876         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaSelectedBackgroundColor(
877             nativeNode, color.GetValue());
878     } else {
879         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaSelectedBackgroundColor(nativeNode);
880     }
881     return panda::JSValueRef::Undefined(vm);
882 }
883 
ResetSelectedBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)884 ArkUINativeModuleValue TextAreaBridge::ResetSelectedBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
885 {
886     EcmaVM* vm = runtimeCallInfo->GetVM();
887     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
888     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
889     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
890     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaSelectedBackgroundColor(nativeNode);
891     return panda::JSValueRef::Undefined(vm);
892 }
893 
SetCaretStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)894 ArkUINativeModuleValue TextAreaBridge::SetCaretStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
895 {
896     EcmaVM *vm = runtimeCallInfo->GetVM();
897     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
898     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
899     Local<JSValueRef> caretWidthArg = runtimeCallInfo->GetCallArgRef(NUM_1);
900     Local<JSValueRef> caretColorArg = runtimeCallInfo->GetCallArgRef(NUM_2);
901     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
902 
903     auto textFieldTheme = ArkTSUtils::GetTheme<TextFieldTheme>();
904     CHECK_NULL_RETURN(textFieldTheme, panda::JSValueRef::Undefined(vm));
905     CalcDimension caretWidth = textFieldTheme->GetCursorWidth();
906     if (!ArkTSUtils::ParseJsDimensionVpNG(vm, caretWidthArg, caretWidth, false) ||
907             LessNotEqual(caretWidth.Value(), 0.0)) {
908         caretWidth = textFieldTheme->GetCursorWidth();
909     }
910     Color color;
911     uint32_t caretColor;
912     if (!caretColorArg->IsUndefined()) {
913         if (ArkTSUtils::ParseJsColorAlpha(vm, caretColorArg, color)) {
914             caretColor = color.GetValue();
915         } else {
916             caretColor = textFieldTheme->GetCursorColor().GetValue();
917         }
918     } else {
919         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaCaret(
920             nativeNode, caretWidth.Value(), static_cast<int8_t>(caretWidth.Unit()));
921         return panda::JSValueRef::Undefined(vm);
922     }
923     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaCaretStyle(
924         nativeNode, caretWidth.Value(), static_cast<int8_t>(caretWidth.Unit()), caretColor);
925     return panda::JSValueRef::Undefined(vm);
926 }
927 
ResetCaretStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)928 ArkUINativeModuleValue TextAreaBridge::ResetCaretStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
929 {
930     EcmaVM *vm = runtimeCallInfo->GetVM();
931     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
932     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
933     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
934     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaCaretStyle(nativeNode);
935     return panda::JSValueRef::Undefined(vm);
936 }
937 
SetTextOverflow(ArkUIRuntimeCallInfo * runtimeCallInfo)938 ArkUINativeModuleValue TextAreaBridge::SetTextOverflow(ArkUIRuntimeCallInfo* runtimeCallInfo)
939 {
940     EcmaVM* vm = runtimeCallInfo->GetVM();
941     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
942     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
943     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
944     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
945     int32_t value;
946     if (secondArg->IsUndefined()) {
947         value = DEFAULT_OVERFLOW;
948     } else if (secondArg->IsNumber()) {
949         value = secondArg->Int32Value(vm);
950     } else {
951         value = DEFAULT_OVERFLOW;
952     }
953     if (value < 0 || value >= static_cast<int32_t>(TEXT_OVERFLOWS.size())) {
954         value = DEFAULT_OVERFLOW;
955     }
956     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaTextOverflow(nativeNode, value);
957     return panda::JSValueRef::Undefined(vm);
958 }
959 
ResetTextOverflow(ArkUIRuntimeCallInfo * runtimeCallInfo)960 ArkUINativeModuleValue TextAreaBridge::ResetTextOverflow(ArkUIRuntimeCallInfo* runtimeCallInfo)
961 {
962     EcmaVM* vm = runtimeCallInfo->GetVM();
963     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
964     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
965     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
966     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaTextOverflow(nativeNode);
967     return panda::JSValueRef::Undefined(vm);
968 }
969 
SetTextIndent(ArkUIRuntimeCallInfo * runtimeCallInfo)970 ArkUINativeModuleValue TextAreaBridge::SetTextIndent(ArkUIRuntimeCallInfo* runtimeCallInfo)
971 {
972     EcmaVM* vm = runtimeCallInfo->GetVM();
973     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
974     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
975     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
976     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
977     CalcDimension indent;
978     if (!ArkTSUtils::ParseJsDimensionNG(vm, secondArg, indent, DimensionUnit::VP, true)) {
979         indent.Reset();
980     }
981 
982     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaTextIndent(
983         nativeNode, indent.Value(), static_cast<int8_t>(indent.Unit()));
984     return panda::JSValueRef::Undefined(vm);
985 }
986 
ResetTextIndent(ArkUIRuntimeCallInfo * runtimeCallInfo)987 ArkUINativeModuleValue TextAreaBridge::ResetTextIndent(ArkUIRuntimeCallInfo* runtimeCallInfo)
988 {
989     EcmaVM* vm = runtimeCallInfo->GetVM();
990     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
991     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
992     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
993     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaTextIndent(nativeNode);
994     return panda::JSValueRef::Undefined(vm);
995 }
996 
SetLineSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)997 ArkUINativeModuleValue TextAreaBridge::SetLineSpacing(ArkUIRuntimeCallInfo* runtimeCallInfo)
998 {
999     EcmaVM* vm = runtimeCallInfo->GetVM();
1000     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1001     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1002     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1003     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1004     CalcDimension value;
1005     if (!ArkTSUtils::ParseJsLengthMetrics(vm, secondArg, value)) {
1006         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineSpacing(nativeNode);
1007     } else {
1008         if (value.IsNegative()) {
1009             value.Reset();
1010         }
1011         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaLineSpacing(
1012             nativeNode, value.Value(), static_cast<int>(value.Unit()));
1013     }
1014     return panda::JSValueRef::Undefined(vm);
1015 }
1016 
ResetLineSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)1017 ArkUINativeModuleValue TextAreaBridge::ResetLineSpacing(ArkUIRuntimeCallInfo* runtimeCallInfo)
1018 {
1019     EcmaVM* vm = runtimeCallInfo->GetVM();
1020     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1021     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1022     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1023     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaLineSpacing(nativeNode);
1024     return panda::JSValueRef::Undefined(vm);
1025 }
1026 
SetOnChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1027 ArkUINativeModuleValue TextAreaBridge::SetOnChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1028 {
1029     EcmaVM *vm = runtimeCallInfo->GetVM();
1030     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1031     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1032     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1033     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1034     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1035     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1036     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1037         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnChange(nativeNode);
1038         return panda::JSValueRef::Undefined(vm);
1039     }
1040     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1041     std::function<void(const std::string&, PreviewText&)> callback = [vm, frameNode,
1042         func = panda::CopyableGlobal(vm, func)](const std::string& changeValue, PreviewText& previewText) {
1043         panda::LocalScope pandaScope(vm);
1044         panda::TryCatch trycatch(vm);
1045         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1046         const char* keys[] = { "offset", "value" };
1047         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, previewText.offset),
1048             panda::StringRef::NewFromUtf8(vm, previewText.value.c_str()) };
1049         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1050         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_2] = {
1051             panda::StringRef::NewFromUtf8(vm, changeValue.c_str()), eventObject };
1052         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_2);
1053     };
1054     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnChange(
1055         nativeNode, reinterpret_cast<void*>(&callback));
1056     return panda::JSValueRef::Undefined(vm);
1057 }
1058 
ResetOnChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1059 ArkUINativeModuleValue TextAreaBridge::ResetOnChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1060 {
1061     EcmaVM* vm = runtimeCallInfo->GetVM();
1062     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1063     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1064     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1065     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnChange(nativeNode);
1066     return panda::JSValueRef::Undefined(vm);
1067 }
1068 
SetEnterKeyType(ArkUIRuntimeCallInfo * runtimeCallInfo)1069 ArkUINativeModuleValue TextAreaBridge::SetEnterKeyType(ArkUIRuntimeCallInfo *runtimeCallInfo)
1070 {
1071     EcmaVM *vm = runtimeCallInfo->GetVM();
1072     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1073     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1074     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1075     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1076 
1077     if (secondArg->IsNumber()) {
1078         int32_t value = secondArg->Int32Value(vm);
1079         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaEnterKeyType(nativeNode, value);
1080     } else {
1081         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnterKeyType(nativeNode);
1082     }
1083     return panda::JSValueRef::Undefined(vm);
1084 }
1085 
ResetEnterKeyType(ArkUIRuntimeCallInfo * runtimeCallInfo)1086 ArkUINativeModuleValue TextAreaBridge::ResetEnterKeyType(ArkUIRuntimeCallInfo *runtimeCallInfo)
1087 {
1088     EcmaVM *vm = runtimeCallInfo->GetVM();
1089     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1090     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1091     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1092     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnterKeyType(nativeNode);
1093     return panda::JSValueRef::Undefined(vm);
1094 }
1095 
SetInputFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)1096 ArkUINativeModuleValue TextAreaBridge::SetInputFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
1097 {
1098     EcmaVM *vm = runtimeCallInfo->GetVM();
1099     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1100     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1101     Local<JSValueRef> inputFilterArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1102     Local<JSValueRef> errorCallbackArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1103     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1104     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1105     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1106     if (inputFilterArg->IsUndefined() || inputFilterArg->IsNull() || !inputFilterArg->IsString(vm)) {
1107         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaInputFilter(nativeNode);
1108         return panda::JSValueRef::Undefined(vm);
1109     }
1110     std::string inputFilter = inputFilterArg->ToString(vm)->ToString(vm);
1111     if (errorCallbackArg->IsUndefined() || errorCallbackArg->IsNull() ||
1112         !errorCallbackArg->IsFunction(vm)) {
1113         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaInputFilter(
1114             nativeNode, inputFilter.c_str(), nullptr);
1115     } else {
1116         panda::Local<panda::FunctionRef> func = errorCallbackArg->ToObject(vm);
1117         std::function<void(const std::string&)> callback = [vm, frameNode,
1118             func = panda::CopyableGlobal(vm, func)](const std::string& info) {
1119             panda::LocalScope pandaScope(vm);
1120             panda::TryCatch trycatch(vm);
1121             PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1122             panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = {
1123                 panda::StringRef::NewFromUtf8(vm, info.c_str()) };
1124             func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1125         };
1126         GetArkUINodeModifiers()->getTextAreaModifier()->
1127             setTextAreaInputFilter(nativeNode, inputFilter.c_str(), reinterpret_cast<void*>(&callback));
1128     }
1129     return panda::JSValueRef::Undefined(vm);
1130 }
1131 
ResetInputFilter(ArkUIRuntimeCallInfo * runtimeCallInfo)1132 ArkUINativeModuleValue TextAreaBridge::ResetInputFilter(ArkUIRuntimeCallInfo* runtimeCallInfo)
1133 {
1134     EcmaVM* vm = runtimeCallInfo->GetVM();
1135     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1136     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1137     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1138     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaInputFilter(nativeNode);
1139     return panda::JSValueRef::Undefined(vm);
1140 }
1141 
SetOnTextSelectionChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1142 ArkUINativeModuleValue TextAreaBridge::SetOnTextSelectionChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1143 {
1144     EcmaVM *vm = runtimeCallInfo->GetVM();
1145     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1146     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1147     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1148     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1149     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1150     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1151     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1152         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnTextSelectionChange(nativeNode);
1153         return panda::JSValueRef::Undefined(vm);
1154     }
1155     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1156     std::function<void(int32_t, int32_t)> callback = [vm, frameNode,
1157         func = panda::CopyableGlobal(vm, func)](int32_t selectionStart, int selectionEnd) {
1158         panda::LocalScope pandaScope(vm);
1159         panda::TryCatch trycatch(vm);
1160         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1161         panda::Local<panda::NumberRef> startParam = panda::NumberRef::New(vm, selectionStart);
1162         panda::Local<panda::NumberRef> endParam = panda::NumberRef::New(vm, selectionEnd);
1163         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_2] = { startParam, endParam };
1164         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_2);
1165     };
1166     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnTextSelectionChange(
1167         nativeNode, reinterpret_cast<void*>(&callback));
1168     return panda::JSValueRef::Undefined(vm);
1169 }
1170 
ResetOnTextSelectionChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1171 ArkUINativeModuleValue TextAreaBridge::ResetOnTextSelectionChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1172 {
1173     EcmaVM* vm = runtimeCallInfo->GetVM();
1174     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1175     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1176     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1177     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnTextSelectionChange(nativeNode);
1178     return panda::JSValueRef::Undefined(vm);
1179 }
1180 
SetOnContentScroll(ArkUIRuntimeCallInfo * runtimeCallInfo)1181 ArkUINativeModuleValue TextAreaBridge::SetOnContentScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
1182 {
1183     EcmaVM *vm = runtimeCallInfo->GetVM();
1184     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1185     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1186     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1187     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1188     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1189     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1190     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1191         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnContentScroll(nativeNode);
1192         return panda::JSValueRef::Undefined(vm);
1193     }
1194     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1195     std::function<void(float, float)> callback = [vm, frameNode,
1196         func = panda::CopyableGlobal(vm, func)](float totalOffsetX, float totalOffsetY) {
1197         panda::LocalScope pandaScope(vm);
1198         panda::TryCatch trycatch(vm);
1199         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1200         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_2] = {
1201             panda::NumberRef::New(vm, totalOffsetX), panda::NumberRef::New(vm, totalOffsetY) };
1202         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_2);
1203     };
1204     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnContentScroll(
1205         nativeNode, reinterpret_cast<void*>(&callback));
1206     return panda::JSValueRef::Undefined(vm);
1207 }
1208 
ResetOnContentScroll(ArkUIRuntimeCallInfo * runtimeCallInfo)1209 ArkUINativeModuleValue TextAreaBridge::ResetOnContentScroll(ArkUIRuntimeCallInfo* runtimeCallInfo)
1210 {
1211     EcmaVM* vm = runtimeCallInfo->GetVM();
1212     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1213     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1214     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1215     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnContentScroll(nativeNode);
1216     return panda::JSValueRef::Undefined(vm);
1217 }
1218 
SetOnEditChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1219 ArkUINativeModuleValue TextAreaBridge::SetOnEditChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1220 {
1221     EcmaVM *vm = runtimeCallInfo->GetVM();
1222     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1223     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1224     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1225     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1226     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1227     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1228     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1229         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnEditChange(nativeNode);
1230         return panda::JSValueRef::Undefined(vm);
1231     }
1232     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1233     std::function<void(bool)> callback = [vm, frameNode,
1234         func = panda::CopyableGlobal(vm, func)](bool isInEditStatus) {
1235         panda::LocalScope pandaScope(vm);
1236         panda::TryCatch trycatch(vm);
1237         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1238         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = {
1239             panda::BooleanRef::New(vm, isInEditStatus) };
1240         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1241     };
1242     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnEditChange(
1243         nativeNode, reinterpret_cast<void*>(&callback));
1244     return panda::JSValueRef::Undefined(vm);
1245 }
1246 
ResetOnEditChange(ArkUIRuntimeCallInfo * runtimeCallInfo)1247 ArkUINativeModuleValue TextAreaBridge::ResetOnEditChange(ArkUIRuntimeCallInfo* runtimeCallInfo)
1248 {
1249     EcmaVM* vm = runtimeCallInfo->GetVM();
1250     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1251     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1252     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1253     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnEditChange(nativeNode);
1254     return panda::JSValueRef::Undefined(vm);
1255 }
1256 
SetOnCopy(ArkUIRuntimeCallInfo * runtimeCallInfo)1257 ArkUINativeModuleValue TextAreaBridge::SetOnCopy(ArkUIRuntimeCallInfo* runtimeCallInfo)
1258 {
1259     EcmaVM *vm = runtimeCallInfo->GetVM();
1260     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1261     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1262     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1263     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1264     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1265     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1266     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1267         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnCopy(nativeNode);
1268         return panda::JSValueRef::Undefined(vm);
1269     }
1270     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1271     std::function<void(const std::string&)> callback = [vm, frameNode,
1272         func = panda::CopyableGlobal(vm, func)](const std::string& copyStr) {
1273         panda::LocalScope pandaScope(vm);
1274         panda::TryCatch trycatch(vm);
1275         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1276         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = {
1277             panda::StringRef::NewFromUtf8(vm, copyStr.c_str()) };
1278         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1279     };
1280     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnCopy(nativeNode, reinterpret_cast<void*>(&callback));
1281     return panda::JSValueRef::Undefined(vm);
1282 }
1283 
ResetOnCopy(ArkUIRuntimeCallInfo * runtimeCallInfo)1284 ArkUINativeModuleValue TextAreaBridge::ResetOnCopy(ArkUIRuntimeCallInfo* runtimeCallInfo)
1285 {
1286     EcmaVM* vm = runtimeCallInfo->GetVM();
1287     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1288     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1289     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1290     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnCopy(nativeNode);
1291     return panda::JSValueRef::Undefined(vm);
1292 }
1293 
SetOnCut(ArkUIRuntimeCallInfo * runtimeCallInfo)1294 ArkUINativeModuleValue TextAreaBridge::SetOnCut(ArkUIRuntimeCallInfo* runtimeCallInfo)
1295 {
1296     EcmaVM *vm = runtimeCallInfo->GetVM();
1297     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1298     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1299     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1300     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1301     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1302     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1303     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1304         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnCut(nativeNode);
1305         return panda::JSValueRef::Undefined(vm);
1306     }
1307     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1308     std::function<void(const std::string&)> callback = [vm, frameNode,
1309         func = panda::CopyableGlobal(vm, func)](const std::string& cutStr) {
1310         panda::LocalScope pandaScope(vm);
1311         panda::TryCatch trycatch(vm);
1312         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1313         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = {
1314             panda::StringRef::NewFromUtf8(vm, cutStr.c_str()) };
1315         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1316     };
1317     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnCut(nativeNode, reinterpret_cast<void*>(&callback));
1318     return panda::JSValueRef::Undefined(vm);
1319 }
1320 
ResetOnCut(ArkUIRuntimeCallInfo * runtimeCallInfo)1321 ArkUINativeModuleValue TextAreaBridge::ResetOnCut(ArkUIRuntimeCallInfo* runtimeCallInfo)
1322 {
1323     EcmaVM* vm = runtimeCallInfo->GetVM();
1324     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1325     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1326     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1327     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnCut(nativeNode);
1328     return panda::JSValueRef::Undefined(vm);
1329 }
1330 
SetOnPaste(ArkUIRuntimeCallInfo * runtimeCallInfo)1331 ArkUINativeModuleValue TextAreaBridge::SetOnPaste(ArkUIRuntimeCallInfo* runtimeCallInfo)
1332 {
1333     EcmaVM *vm = runtimeCallInfo->GetVM();
1334     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1335     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1336     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1337     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1338     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1339     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1340     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1341         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnPaste(nativeNode);
1342         return panda::JSValueRef::Undefined(vm);
1343     }
1344     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1345     std::function<void(const std::string&, NG::TextCommonEvent&)> callback = [vm, frameNode,
1346         func = panda::CopyableGlobal(vm, func)](const std::string& val, NG::TextCommonEvent& info) {
1347         panda::LocalScope pandaScope(vm);
1348         panda::TryCatch trycatch(vm);
1349         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1350         auto eventObject = panda::ObjectRef::New(vm);
1351         eventObject->SetNativePointerFieldCount(vm, 1);
1352         eventObject->Set(vm, panda::StringRef::NewFromUtf8(vm, "preventDefault"),
1353             panda::FunctionRef::New(vm, Framework::JsPreventDefault));
1354         eventObject->SetNativePointerField(vm, 0, static_cast<void*>(&info));
1355         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_2] = {
1356             panda::StringRef::NewFromUtf8(vm, val.c_str()), eventObject };
1357         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_2);
1358     };
1359     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnPaste(
1360         nativeNode, reinterpret_cast<void*>(&callback));
1361     return panda::JSValueRef::Undefined(vm);
1362 }
1363 
ResetOnPaste(ArkUIRuntimeCallInfo * runtimeCallInfo)1364 ArkUINativeModuleValue TextAreaBridge::ResetOnPaste(ArkUIRuntimeCallInfo* runtimeCallInfo)
1365 {
1366     EcmaVM* vm = runtimeCallInfo->GetVM();
1367     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1368     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1369     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1370     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnPaste(nativeNode);
1371     return panda::JSValueRef::Undefined(vm);
1372 }
1373 
SetType(ArkUIRuntimeCallInfo * runtimeCallInfo)1374 ArkUINativeModuleValue TextAreaBridge::SetType(ArkUIRuntimeCallInfo* runtimeCallInfo)
1375 {
1376     EcmaVM *vm = runtimeCallInfo->GetVM();
1377     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1378     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1379     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1380     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1381     if (secondArg->IsNumber()) {
1382         int32_t value = secondArg->Int32Value(vm);
1383         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaType(nativeNode, value);
1384     } else {
1385         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaType(nativeNode);
1386     }
1387     return panda::JSValueRef::Undefined(vm);
1388 }
1389 
ResetType(ArkUIRuntimeCallInfo * runtimeCallInfo)1390 ArkUINativeModuleValue TextAreaBridge::ResetType(ArkUIRuntimeCallInfo* runtimeCallInfo)
1391 {
1392     EcmaVM* vm = runtimeCallInfo->GetVM();
1393     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1394     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1395     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1396     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaType(nativeNode);
1397     return panda::JSValueRef::Undefined(vm);
1398 }
1399 
SetPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)1400 ArkUINativeModuleValue TextAreaBridge::SetPadding(ArkUIRuntimeCallInfo *runtimeCallInfo)
1401 {
1402     EcmaVM *vm = runtimeCallInfo->GetVM();
1403     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1404     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1405     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1406     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1407     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1408     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1409     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1410 
1411     struct ArkUISizeType top = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
1412     struct ArkUISizeType right = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
1413     struct ArkUISizeType bottom = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
1414     struct ArkUISizeType left = { 0.0, static_cast<int8_t>(DimensionUnit::VP) };
1415 
1416     CalcDimension topDimen(0, DimensionUnit::VP);
1417     CalcDimension rightDimen(0, DimensionUnit::VP);
1418     CalcDimension bottomDimen(0, DimensionUnit::VP);
1419     CalcDimension leftDimen(0, DimensionUnit::VP);
1420 
1421     ArkTSUtils::ParsePadding(vm, secondArg, topDimen, top);
1422     ArkTSUtils::ParsePadding(vm, thirdArg, rightDimen, right);
1423     ArkTSUtils::ParsePadding(vm, forthArg, bottomDimen, bottom);
1424     ArkTSUtils::ParsePadding(vm, fifthArg, leftDimen, left);
1425     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaPadding(nativeNode, &top, &right, &bottom, &left);
1426     return panda::JSValueRef::Undefined(vm);
1427 }
1428 
ResetPadding(ArkUIRuntimeCallInfo * runtimeCallInfo)1429 ArkUINativeModuleValue TextAreaBridge::ResetPadding(ArkUIRuntimeCallInfo* runtimeCallInfo)
1430 {
1431     EcmaVM *vm = runtimeCallInfo->GetVM();
1432     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1433     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1434     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1435     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaPadding(nativeNode);
1436     return panda::JSValueRef::Undefined(vm);
1437 }
1438 
SetOnSubmit(ArkUIRuntimeCallInfo * runtimeCallInfo)1439 ArkUINativeModuleValue TextAreaBridge::SetOnSubmit(ArkUIRuntimeCallInfo* runtimeCallInfo)
1440 {
1441     EcmaVM *vm = runtimeCallInfo->GetVM();
1442     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1443     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1444     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1445     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1446     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1447     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1448     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1449         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnSubmitWithEvent(nativeNode);
1450         return panda::JSValueRef::Undefined(vm);
1451     }
1452     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1453     std::function<void(int32_t, NG::TextFieldCommonEvent&)> callback = [vm, frameNode,
1454         func = panda::CopyableGlobal(vm, func)](int32_t key, NG::TextFieldCommonEvent& event) {
1455         panda::LocalScope pandaScope(vm);
1456         panda::TryCatch trycatch(vm);
1457         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1458         const char* keys[] = { "text", "keepEditableState" };
1459         Local<JSValueRef> values[] = { panda::StringRef::NewFromUtf8(vm, event.GetText().c_str()),
1460             panda::FunctionRef::New(vm, Framework::JSTextField::JsKeepEditableState) };
1461         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1462         eventObject->SetNativePointerFieldCount(vm, 1);
1463         eventObject->SetNativePointerField(vm, 0, static_cast<void*>(&event));
1464         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_2] = {
1465             panda::IntegerRef::New(vm, key), eventObject };
1466         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_2);
1467     };
1468     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnSubmitWithEvent(
1469         nativeNode, reinterpret_cast<void*>(&callback));
1470     return panda::JSValueRef::Undefined(vm);
1471 }
1472 
ResetOnSubmit(ArkUIRuntimeCallInfo * runtimeCallInfo)1473 ArkUINativeModuleValue TextAreaBridge::ResetOnSubmit(ArkUIRuntimeCallInfo* runtimeCallInfo)
1474 {
1475     EcmaVM* vm = runtimeCallInfo->GetVM();
1476     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1477     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1478     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1479     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnSubmitWithEvent(nativeNode);
1480     return panda::JSValueRef::Undefined(vm);
1481 }
1482 
SetContentType(ArkUIRuntimeCallInfo * runtimeCallInfo)1483 ArkUINativeModuleValue TextAreaBridge::SetContentType(ArkUIRuntimeCallInfo *runtimeCallInfo)
1484 {
1485     EcmaVM *vm = runtimeCallInfo->GetVM();
1486     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1487     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1488     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1489     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1490 
1491     if (secondArg->IsNumber()) {
1492         uint32_t value = static_cast<uint32_t>(secondArg->Int32Value(vm));
1493         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaContentType(nativeNode, value);
1494     } else {
1495         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaContentType(nativeNode);
1496     }
1497     return panda::JSValueRef::Undefined(vm);
1498 }
1499 
ResetContentType(ArkUIRuntimeCallInfo * runtimeCallInfo)1500 ArkUINativeModuleValue TextAreaBridge::ResetContentType(ArkUIRuntimeCallInfo *runtimeCallInfo)
1501 {
1502     EcmaVM *vm = runtimeCallInfo->GetVM();
1503     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1504     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1505     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1506     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaContentType(nativeNode);
1507     return panda::JSValueRef::Undefined(vm);
1508 }
1509 
SetEnableAutoFill(ArkUIRuntimeCallInfo * runtimeCallInfo)1510 ArkUINativeModuleValue TextAreaBridge::SetEnableAutoFill(ArkUIRuntimeCallInfo *runtimeCallInfo)
1511 {
1512     EcmaVM *vm = runtimeCallInfo->GetVM();
1513     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1514     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1515     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1516     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1517 
1518     if (secondArg->IsBoolean()) {
1519         uint32_t enableAutoFill = static_cast<uint32_t>(secondArg->ToBoolean(vm)->Value());
1520         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaEnableAutoFill(nativeNode, enableAutoFill);
1521     } else {
1522         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnableAutoFill(nativeNode);
1523     }
1524 
1525     return panda::JSValueRef::Undefined(vm);
1526 }
1527 
ResetEnableAutoFill(ArkUIRuntimeCallInfo * runtimeCallInfo)1528 ArkUINativeModuleValue TextAreaBridge::ResetEnableAutoFill(ArkUIRuntimeCallInfo *runtimeCallInfo)
1529 {
1530     EcmaVM *vm = runtimeCallInfo->GetVM();
1531     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1532     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1533     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1534     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnableAutoFill(nativeNode);
1535     return panda::JSValueRef::Undefined(vm);
1536 }
1537 
SetBorder(ArkUIRuntimeCallInfo * runtimeCallInfo)1538 ArkUINativeModuleValue TextAreaBridge::SetBorder(ArkUIRuntimeCallInfo* runtimeCallInfo)
1539 {
1540     EcmaVM *vm = runtimeCallInfo->GetVM();
1541     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1542     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1543     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1544 
1545     std::vector<ArkUI_Float32> options;
1546     // Border Width args start index from 1
1547     ArkTSUtils::ParseOuterBorderWidth(runtimeCallInfo, vm, options);
1548     // Border Radius args start index
1549     ArkTSUtils::ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9);
1550 
1551     std::vector<uint32_t> colorAndStyleOptions;
1552     // Border Color args start index
1553     ArkTSUtils::ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5);
1554     // Border Style args start index
1555     ArkTSUtils::ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13);
1556 
1557     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorder(
1558         nativeNode, options.data(), options.size(), colorAndStyleOptions.data(), colorAndStyleOptions.size());
1559     return panda::JSValueRef::Undefined(vm);
1560 }
1561 
ResetBorder(ArkUIRuntimeCallInfo * runtimeCallInfo)1562 ArkUINativeModuleValue TextAreaBridge::ResetBorder(ArkUIRuntimeCallInfo *runtimeCallInfo)
1563 {
1564     EcmaVM *vm = runtimeCallInfo->GetVM();
1565     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1566     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1567     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1568     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorder(nativeNode);
1569     return panda::JSValueRef::Undefined(vm);
1570 }
1571 
SetBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)1572 ArkUINativeModuleValue TextAreaBridge::SetBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
1573 {
1574     EcmaVM* vm = runtimeCallInfo->GetVM();
1575     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1576     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1577     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1578     Local<JSValueRef> leftArgs = runtimeCallInfo->GetCallArgRef(NUM_1);
1579     Local<JSValueRef> rightArgs = runtimeCallInfo->GetCallArgRef(NUM_2);
1580     Local<JSValueRef> topArgs = runtimeCallInfo->GetCallArgRef(NUM_3);
1581     Local<JSValueRef> bottomArgs = runtimeCallInfo->GetCallArgRef(NUM_4);
1582     if (leftArgs->IsUndefined() && rightArgs->IsUndefined() && topArgs->IsUndefined() && bottomArgs->IsUndefined()) {
1583         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorderWidth(nativeNode);
1584         return panda::JSValueRef::Undefined(vm);
1585     }
1586 
1587     uint32_t size = NUM_4;
1588     ArkUI_Float32 values[size];
1589     int units[size];
1590 
1591     ArkTSUtils::SetBorderWidthArray(vm, leftArgs, values, units, NUM_0);
1592     ArkTSUtils::SetBorderWidthArray(vm, rightArgs, values, units, NUM_1);
1593     ArkTSUtils::SetBorderWidthArray(vm, topArgs, values, units, NUM_2);
1594     ArkTSUtils::SetBorderWidthArray(vm, bottomArgs, values, units, NUM_3);
1595 
1596     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderWidth(nativeNode, values, units, size);
1597     return panda::JSValueRef::Undefined(vm);
1598 }
1599 
ResetBorderWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)1600 ArkUINativeModuleValue TextAreaBridge::ResetBorderWidth(ArkUIRuntimeCallInfo *runtimeCallInfo)
1601 {
1602     EcmaVM *vm = runtimeCallInfo->GetVM();
1603     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1604     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1605     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1606     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorderWidth(nativeNode);
1607     return panda::JSValueRef::Undefined(vm);
1608 }
1609 
SetBorderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1610 ArkUINativeModuleValue TextAreaBridge::SetBorderColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
1611 {
1612     EcmaVM *vm = runtimeCallInfo->GetVM();
1613     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1614     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1615     Local<JSValueRef> leftArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1616     Local<JSValueRef> rightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1617     Local<JSValueRef> topArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1618     Local<JSValueRef> bottomArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1619     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1620 
1621     Color leftColor;
1622     Color rightColor;
1623     Color topColor;
1624     Color bottomColor;
1625 
1626     if (!ArkTSUtils::ParseJsColorAlpha(vm, leftArg, leftColor)) {
1627         leftColor.SetValue(COLOR_ALPHA_VALUE);
1628     }
1629     if (!ArkTSUtils::ParseJsColorAlpha(vm, rightArg, rightColor)) {
1630         rightColor.SetValue(COLOR_ALPHA_VALUE);
1631     }
1632     if (!ArkTSUtils::ParseJsColorAlpha(vm, topArg, topColor)) {
1633         topColor.SetValue(COLOR_ALPHA_VALUE);
1634     }
1635     if (!ArkTSUtils::ParseJsColorAlpha(vm, bottomArg, bottomColor)) {
1636         bottomColor.SetValue(COLOR_ALPHA_VALUE);
1637     }
1638     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderColor(nativeNode, leftColor.GetValue(),
1639         rightColor.GetValue(), topColor.GetValue(), bottomColor.GetValue());
1640     return panda::JSValueRef::Undefined(vm);
1641 }
1642 
ResetBorderColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1643 ArkUINativeModuleValue TextAreaBridge::ResetBorderColor(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()->getTextAreaModifier()->resetTextAreaBorderColor(nativeNode);
1650     return panda::JSValueRef::Undefined(vm);
1651 }
1652 
SetBorderStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)1653 ArkUINativeModuleValue TextAreaBridge::SetBorderStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
1654 {
1655     EcmaVM *vm = runtimeCallInfo->GetVM();
1656     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1657     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1658     auto typeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1659     auto styleArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1660     auto topArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1661     auto rightArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1662     auto bottomArg = runtimeCallInfo->GetCallArgRef(NUM_5);
1663     auto leftArg = runtimeCallInfo->GetCallArgRef(NUM_6);
1664     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1665     if ((!typeArg->IsBoolean()) || (!typeArg->BooleaValue(vm))) {
1666         int32_t styles[] = { static_cast<int32_t>(BorderStyle::SOLID) };
1667         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderStyle(nativeNode, styles,
1668             (sizeof(styles) / sizeof(styles[NUM_0])));
1669         return panda::JSValueRef::Undefined(vm);
1670     }
1671     if (styleArg->IsInt()) {
1672         int32_t styles[] = { styleArg->Int32Value(vm) };
1673         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderStyle(nativeNode, styles,
1674             (sizeof(styles) / sizeof(styles[NUM_0])));
1675         return panda::JSValueRef::Undefined(vm);
1676     }
1677     int32_t styles[] = { -1, -1, -1, -1 };
1678     if (topArg->IsInt()) {
1679         styles[NUM_0] = topArg->Int32Value(vm);
1680     }
1681     if (rightArg->IsInt()) {
1682         styles[NUM_1] = rightArg->Int32Value(vm);
1683     }
1684     if (bottomArg->IsInt()) {
1685         styles[NUM_2] = bottomArg->Int32Value(vm);
1686     }
1687     if (leftArg->IsInt()) {
1688         styles[NUM_3] = leftArg->Int32Value(vm);
1689     }
1690     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderStyle(nativeNode, styles,
1691         (sizeof(styles) / sizeof(styles[NUM_0])));
1692     return panda::JSValueRef::Undefined(vm);
1693 }
1694 
ResetBorderStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)1695 ArkUINativeModuleValue TextAreaBridge::ResetBorderStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
1696 {
1697     EcmaVM *vm = runtimeCallInfo->GetVM();
1698     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1699     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1700     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1701     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorderStyle(nativeNode);
1702     return panda::JSValueRef::Undefined(vm);
1703 }
1704 
SetBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)1705 ArkUINativeModuleValue TextAreaBridge::SetBorderRadius(ArkUIRuntimeCallInfo *runtimeCallInfo)
1706 {
1707     EcmaVM *vm = runtimeCallInfo->GetVM();
1708     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1709     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1710     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1711     Local<JSValueRef> topLeftArgs = runtimeCallInfo->GetCallArgRef(NUM_1);
1712     Local<JSValueRef> topRightArgs = runtimeCallInfo->GetCallArgRef(NUM_2);
1713     Local<JSValueRef> bottomLeftArgs = runtimeCallInfo->GetCallArgRef(NUM_3);
1714     Local<JSValueRef> bottomRightArgs = runtimeCallInfo->GetCallArgRef(NUM_4);
1715     if (topLeftArgs->IsUndefined() && topRightArgs->IsUndefined() && bottomLeftArgs->IsUndefined() &&
1716         bottomRightArgs->IsUndefined()) {
1717         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorderRadius(nativeNode);
1718         return panda::JSValueRef::Undefined(vm);
1719     }
1720 
1721     CalcDimension topLeft;
1722     CalcDimension topRight;
1723     CalcDimension bottomLeft;
1724     CalcDimension bottomRight;
1725 
1726     ArkTSUtils::ParseAllBorder(vm, topLeftArgs, topLeft);
1727     ArkTSUtils::ParseAllBorder(vm, topRightArgs, topRight);
1728     ArkTSUtils::ParseAllBorder(vm, bottomLeftArgs, bottomLeft);
1729     ArkTSUtils::ParseAllBorder(vm, bottomRightArgs, bottomRight);
1730 
1731     uint32_t size = SIZE_OF_FOUR;
1732     ArkUI_Float32 values[size];
1733     int units[size];
1734 
1735     values[NUM_0] = topLeft.Value();
1736     units[NUM_0] = static_cast<int>(topLeft.Unit());
1737     values[NUM_1] = topRight.Value();
1738     units[NUM_1] = static_cast<int>(topRight.Unit());
1739     values[NUM_2] = bottomLeft.Value();
1740     units[NUM_2] = static_cast<int>(bottomLeft.Unit());
1741     values[NUM_3] = bottomRight.Value();
1742     units[NUM_3] = static_cast<int>(bottomRight.Unit());
1743 
1744     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBorderRadius(nativeNode, values, units, SIZE_OF_FOUR);
1745 
1746     return panda::JSValueRef::Undefined(vm);
1747 }
1748 
ResetBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)1749 ArkUINativeModuleValue TextAreaBridge::ResetBorderRadius(ArkUIRuntimeCallInfo *runtimeCallInfo)
1750 {
1751     EcmaVM *vm = runtimeCallInfo->GetVM();
1752     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1753     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1754     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1755     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBorderRadius(nativeNode);
1756     return panda::JSValueRef::Undefined(vm);
1757 }
1758 
SetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1759 ArkUINativeModuleValue TextAreaBridge::SetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
1760 {
1761     EcmaVM *vm = runtimeCallInfo->GetVM();
1762     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1763     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1764     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1765     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1766     Color color;
1767     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
1768         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBackgroundColor(nativeNode);
1769     } else {
1770         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaBackgroundColor(nativeNode, color.GetValue());
1771     }
1772     return panda::JSValueRef::Undefined(vm);
1773 }
1774 
ResetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)1775 ArkUINativeModuleValue TextAreaBridge::ResetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
1776 {
1777     EcmaVM *vm = runtimeCallInfo->GetVM();
1778     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1779     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1780     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1781     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaBackgroundColor(nativeNode);
1782     return panda::JSValueRef::Undefined(vm);
1783 }
1784 
SetMargin(ArkUIRuntimeCallInfo * runtimeCallInfo)1785 ArkUINativeModuleValue TextAreaBridge::SetMargin(ArkUIRuntimeCallInfo *runtimeCallInfo)
1786 {
1787     EcmaVM *vm = runtimeCallInfo->GetVM();
1788     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1789     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1790     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1791     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1792     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
1793     Local<JSValueRef> forthArg = runtimeCallInfo->GetCallArgRef(NUM_3);
1794     Local<JSValueRef> fifthArg = runtimeCallInfo->GetCallArgRef(NUM_4);
1795     ArkUISizeType top = ArkTSUtils::ParseJsToArkUISize(vm, secondArg);
1796     ArkUISizeType right = ArkTSUtils::ParseJsToArkUISize(vm, thirdArg);
1797     ArkUISizeType bottom = ArkTSUtils::ParseJsToArkUISize(vm, forthArg);
1798     ArkUISizeType left = ArkTSUtils::ParseJsToArkUISize(vm, fifthArg);
1799     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaMargin(nativeNode, &top, &right, &bottom, &left);
1800     return panda::JSValueRef::Undefined(vm);
1801 }
1802 
ResetMargin(ArkUIRuntimeCallInfo * runtimeCallInfo)1803 ArkUINativeModuleValue TextAreaBridge::ResetMargin(ArkUIRuntimeCallInfo *runtimeCallInfo)
1804 {
1805     EcmaVM *vm = runtimeCallInfo->GetVM();
1806     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1807     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1808     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1809     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaMargin(nativeNode);
1810     return panda::JSValueRef::Undefined(vm);
1811 }
1812 
SetOnWillInsert(ArkUIRuntimeCallInfo * runtimeCallInfo)1813 ArkUINativeModuleValue TextAreaBridge::SetOnWillInsert(ArkUIRuntimeCallInfo* runtimeCallInfo)
1814 {
1815     EcmaVM *vm = runtimeCallInfo->GetVM();
1816     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1817     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1818     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1819     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1820     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1821     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1822     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1823         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnWillInsert(nativeNode);
1824         return panda::JSValueRef::Undefined(vm);
1825     }
1826     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1827     std::function<bool(const InsertValueInfo&)> callback = [vm, frameNode,
1828         func = panda::CopyableGlobal(vm, func)](const InsertValueInfo& insertValue) -> bool {
1829         panda::LocalScope pandaScope(vm);
1830         panda::TryCatch trycatch(vm);
1831         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1832         const char* keys[] = { "insertOffset", "insertValue" };
1833         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, insertValue.insertOffset),
1834             panda::StringRef::NewFromUtf8(vm, insertValue.insertValue.c_str()) };
1835         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1836         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = { eventObject };
1837         auto ret = func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1838         if (ret->IsBoolean()) {
1839             return ret->ToBoolean(vm)->Value();
1840         }
1841         return true;
1842     };
1843     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnWillInsert(nativeNode,
1844         reinterpret_cast<intptr_t>(&callback));
1845     return panda::JSValueRef::Undefined(vm);
1846 }
1847 
ResetOnWillInsert(ArkUIRuntimeCallInfo * runtimeCallInfo)1848 ArkUINativeModuleValue TextAreaBridge::ResetOnWillInsert(ArkUIRuntimeCallInfo* runtimeCallInfo)
1849 {
1850     EcmaVM* vm = runtimeCallInfo->GetVM();
1851     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1852     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1853     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1854     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnWillInsert(nativeNode);
1855     return panda::JSValueRef::Undefined(vm);
1856 }
1857 
SetOnDidInsert(ArkUIRuntimeCallInfo * runtimeCallInfo)1858 ArkUINativeModuleValue TextAreaBridge::SetOnDidInsert(ArkUIRuntimeCallInfo* runtimeCallInfo)
1859 {
1860     EcmaVM *vm = runtimeCallInfo->GetVM();
1861     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1862     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1863     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1864     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1865     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1866     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1867     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1868         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnDidInsert(nativeNode);
1869         return panda::JSValueRef::Undefined(vm);
1870     }
1871     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1872     std::function<void(const InsertValueInfo&)> callback = [vm, frameNode,
1873         func = panda::CopyableGlobal(vm, func)](const InsertValueInfo& insertValue) {
1874         panda::LocalScope pandaScope(vm);
1875         panda::TryCatch trycatch(vm);
1876         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1877         const char* keys[] = { "insertOffset", "insertValue" };
1878         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, insertValue.insertOffset),
1879             panda::StringRef::NewFromUtf8(vm, insertValue.insertValue.c_str()) };
1880         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1881         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = { eventObject };
1882         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1883     };
1884     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnDidInsert(
1885         nativeNode, reinterpret_cast<intptr_t>(&callback));
1886     return panda::JSValueRef::Undefined(vm);
1887 }
1888 
ResetOnDidInsert(ArkUIRuntimeCallInfo * runtimeCallInfo)1889 ArkUINativeModuleValue TextAreaBridge::ResetOnDidInsert(ArkUIRuntimeCallInfo* runtimeCallInfo)
1890 {
1891     EcmaVM* vm = runtimeCallInfo->GetVM();
1892     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1893     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1894     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1895     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnDidInsert(nativeNode);
1896     return panda::JSValueRef::Undefined(vm);
1897 }
1898 
SetOnWillDelete(ArkUIRuntimeCallInfo * runtimeCallInfo)1899 ArkUINativeModuleValue TextAreaBridge::SetOnWillDelete(ArkUIRuntimeCallInfo* runtimeCallInfo)
1900 {
1901     EcmaVM *vm = runtimeCallInfo->GetVM();
1902     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1903     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1904     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1905     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1906     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1907     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1908     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1909         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnWillDelete(nativeNode);
1910         return panda::JSValueRef::Undefined(vm);
1911     }
1912     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1913     std::function<bool(const DeleteValueInfo&)> callback = [vm, frameNode,
1914         func = panda::CopyableGlobal(vm, func)](const DeleteValueInfo& deleteValue) -> bool {
1915         panda::LocalScope pandaScope(vm);
1916         panda::TryCatch trycatch(vm);
1917         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1918         const char* keys[] = { "deleteOffset", "direction", "deleteValue" };
1919         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, deleteValue.deleteOffset),
1920             panda::NumberRef::New(vm, static_cast<int32_t>(deleteValue.direction)),
1921             panda::StringRef::NewFromUtf8(vm, deleteValue.deleteValue.c_str()) };
1922         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1923         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = { eventObject };
1924         auto ret = func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1925         if (ret->IsBoolean()) {
1926             return ret->ToBoolean(vm)->Value();
1927         }
1928         return true;
1929     };
1930     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnWillDelete(
1931         nativeNode, reinterpret_cast<intptr_t>(&callback));
1932     return panda::JSValueRef::Undefined(vm);
1933 }
1934 
ResetOnWillDelete(ArkUIRuntimeCallInfo * runtimeCallInfo)1935 ArkUINativeModuleValue TextAreaBridge::ResetOnWillDelete(ArkUIRuntimeCallInfo* runtimeCallInfo)
1936 {
1937     EcmaVM* vm = runtimeCallInfo->GetVM();
1938     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1939     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1940     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1941     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnWillDelete(nativeNode);
1942     return panda::JSValueRef::Undefined(vm);
1943 }
1944 
SetOnDidDelete(ArkUIRuntimeCallInfo * runtimeCallInfo)1945 ArkUINativeModuleValue TextAreaBridge::SetOnDidDelete(ArkUIRuntimeCallInfo* runtimeCallInfo)
1946 {
1947     EcmaVM *vm = runtimeCallInfo->GetVM();
1948     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1949     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1950     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(1);
1951     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1952     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1953     CHECK_NULL_RETURN(frameNode, panda::NativePointerRef::New(vm, nullptr));
1954     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1955         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnDidDelete(nativeNode);
1956         return panda::JSValueRef::Undefined(vm);
1957     }
1958     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1959     std::function<void(const DeleteValueInfo&)> callback = [vm, frameNode,
1960         func = panda::CopyableGlobal(vm, func)](const DeleteValueInfo& deleteValue) {
1961         panda::LocalScope pandaScope(vm);
1962         panda::TryCatch trycatch(vm);
1963         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1964         const char* keys[] = { "deleteOffset", "direction", "deleteValue" };
1965         Local<JSValueRef> values[] = { panda::NumberRef::New(vm, deleteValue.deleteOffset),
1966             panda::NumberRef::New(vm, static_cast<int32_t>(deleteValue.direction)),
1967             panda::StringRef::NewFromUtf8(vm, deleteValue.deleteValue.c_str()) };
1968         auto eventObject = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values);
1969         panda::Local<panda::JSValueRef> params[PARAM_ARR_LENGTH_1] = { eventObject };
1970         func->Call(vm, func.ToLocal(), params, PARAM_ARR_LENGTH_1);
1971     };
1972     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaOnDidDelete(
1973         nativeNode, reinterpret_cast<intptr_t>(&callback));
1974     return panda::JSValueRef::Undefined(vm);
1975 }
1976 
ResetOnDidDelete(ArkUIRuntimeCallInfo * runtimeCallInfo)1977 ArkUINativeModuleValue TextAreaBridge::ResetOnDidDelete(ArkUIRuntimeCallInfo* runtimeCallInfo)
1978 {
1979     EcmaVM* vm = runtimeCallInfo->GetVM();
1980     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1981     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1982     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1983     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaOnDidDelete(nativeNode);
1984     return panda::JSValueRef::Undefined(vm);
1985 }
1986 
SetEnablePreviewText(ArkUIRuntimeCallInfo * runtimeCallInfo)1987 ArkUINativeModuleValue TextAreaBridge::SetEnablePreviewText(ArkUIRuntimeCallInfo* runtimeCallInfo)
1988 {
1989     EcmaVM *vm = runtimeCallInfo->GetVM();
1990     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1991     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1992     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
1993     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1994 
1995     if (secondArg->IsBoolean()) {
1996         uint32_t value = static_cast<uint32_t>(secondArg->ToBoolean(vm)->Value());
1997         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaEnablePreviewText(nativeNode, value);
1998     } else {
1999         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnablePreviewText(nativeNode);
2000     }
2001     return panda::JSValueRef::Undefined(vm);
2002 }
2003 
ResetEnablePreviewText(ArkUIRuntimeCallInfo * runtimeCallInfo)2004 ArkUINativeModuleValue TextAreaBridge::ResetEnablePreviewText(ArkUIRuntimeCallInfo* runtimeCallInfo)
2005 {
2006     EcmaVM* vm = runtimeCallInfo->GetVM();
2007     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2008     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
2009     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2010     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnablePreviewText(nativeNode);
2011     return panda::JSValueRef::Undefined(vm);
2012 }
2013 
SetSelectionMenuOptions(ArkUIRuntimeCallInfo * runtimeCallInfo)2014 ArkUINativeModuleValue TextAreaBridge::SetSelectionMenuOptions(ArkUIRuntimeCallInfo* runtimeCallInfo)
2015 {
2016     EcmaVM* vm = runtimeCallInfo->GetVM();
2017     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2018     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2019     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2020     NG::OnCreateMenuCallback onCreateMenuCallback;
2021     NG::OnMenuItemClickCallback onMenuItemClickCallback;
2022     if (!ArkTSUtils::ParseSelectionMenuOptions(runtimeCallInfo, vm, onCreateMenuCallback, onMenuItemClickCallback)) {
2023         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaSelectionMenuOptions(nativeNode);
2024         return panda::JSValueRef::Undefined(vm);
2025     }
2026     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaSelectionMenuOptions(
2027         nativeNode, reinterpret_cast<void*>(&onCreateMenuCallback), reinterpret_cast<void*>(&onMenuItemClickCallback));
2028     return panda::JSValueRef::Undefined(vm);
2029 }
2030 
ResetSelectionMenuOptions(ArkUIRuntimeCallInfo * runtimeCallInfo)2031 ArkUINativeModuleValue TextAreaBridge::ResetSelectionMenuOptions(ArkUIRuntimeCallInfo* runtimeCallInfo)
2032 {
2033     EcmaVM* vm = runtimeCallInfo->GetVM();
2034     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2035     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2036     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2037     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaSelectionMenuOptions(nativeNode);
2038     return panda::JSValueRef::Undefined(vm);
2039 }
2040 
SetWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)2041 ArkUINativeModuleValue TextAreaBridge::SetWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
2042 {
2043     EcmaVM* vm = runtimeCallInfo->GetVM();
2044     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2045     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2046     Local<JSValueRef> widthArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2047     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2048     auto value = widthArg->ToString(vm)->ToString(vm);
2049     if (value.empty()) {
2050         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaWidth(nativeNode);
2051         return panda::JSValueRef::Undefined(vm);
2052     }
2053     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaWidth(
2054         nativeNode, value.c_str());
2055     return panda::JSValueRef::Undefined(vm);
2056 }
2057 
ResetWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)2058 ArkUINativeModuleValue TextAreaBridge::ResetWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
2059 {
2060     EcmaVM* vm = runtimeCallInfo->GetVM();
2061     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2062     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2063     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2064     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaWidth(nativeNode);
2065     return panda::JSValueRef::Undefined(vm);
2066 }
2067 
SetEnableHapticFeedback(ArkUIRuntimeCallInfo * runtimeCallInfo)2068 ArkUINativeModuleValue TextAreaBridge::SetEnableHapticFeedback(ArkUIRuntimeCallInfo* runtimeCallInfo)
2069 {
2070     EcmaVM* vm = runtimeCallInfo->GetVM();
2071     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2072     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2073     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
2074     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2075 
2076     if (secondArg->IsBoolean()) {
2077         uint32_t value = static_cast<uint32_t>(secondArg->ToBoolean(vm)->Value());
2078         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaEnableHapticFeedback(nativeNode, value);
2079     } else {
2080         GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnableHapticFeedback(nativeNode);
2081     }
2082     return panda::JSValueRef::Undefined(vm);
2083 }
2084 
ResetEnableHapticFeedback(ArkUIRuntimeCallInfo * runtimeCallInfo)2085 ArkUINativeModuleValue TextAreaBridge::ResetEnableHapticFeedback(ArkUIRuntimeCallInfo* runtimeCallInfo)
2086 {
2087     EcmaVM* vm = runtimeCallInfo->GetVM();
2088     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2089     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
2090     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
2091     GetArkUINodeModifiers()->getTextAreaModifier()->resetTextAreaEnableHapticFeedback(nativeNode);
2092     return panda::JSValueRef::Undefined(vm);
2093 }
2094 
SetTextAreaInitialize(ArkUIRuntimeCallInfo * runtimeCallInfo)2095 ArkUINativeModuleValue TextAreaBridge::SetTextAreaInitialize(ArkUIRuntimeCallInfo* runtimeCallInfo)
2096 {
2097     EcmaVM* vm = runtimeCallInfo->GetVM();
2098     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
2099     Local<JSValueRef> nodeVal = runtimeCallInfo->GetCallArgRef(NUM_0);
2100     Local<JSValueRef> placeholderVal = runtimeCallInfo->GetCallArgRef(NUM_1);
2101     Local<JSValueRef> textVal = runtimeCallInfo->GetCallArgRef(NUM_2);
2102     Local<JSValueRef> controllerVal = runtimeCallInfo->GetCallArgRef(NUM_3);
2103     auto nativeNode = nodePtr(nodeVal->ToNativePointer(vm)->Value());
2104     std::string placeholder;
2105     if (ArkTSUtils::ParseJsString(vm, placeholderVal, placeholder)) {
2106         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaPlaceholderString(nativeNode, placeholder.c_str());
2107     } else {
2108         GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaPlaceholderString(nativeNode, "");
2109     }
2110     std::string text, value;
2111     auto changeEventVal = Framework::JSRef<Framework::JSVal>::Make();
2112     if (textVal->IsString(vm) && ArkTSUtils::ParseJsString(vm, textVal, text)) {
2113         value = text;
2114     } else {
2115         value = "";
2116     }
2117     GetArkUINodeModifiers()->getTextAreaModifier()->setTextAreaTextString(nativeNode, value.c_str());
2118     auto* frameNode = reinterpret_cast<FrameNode*>(nativeNode);
2119     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
2120     if (!controllerVal->IsUndefined() && !controllerVal->IsNull()) {
2121         auto* jsController = Framework::JSRef<Framework::JSObject>(Framework::JSObject(controllerVal->ToObject(vm)))
2122                                  ->Unwrap<Framework::JSTextEditableController>();
2123         if (jsController) {
2124             auto pointer = TextFieldModelNG::GetJSTextEditableController(frameNode);
2125             auto preController = reinterpret_cast<Framework::JSTextEditableController*>(Referenced::RawPtr(pointer));
2126             if (preController) {
2127                 preController->SetController(nullptr);
2128             }
2129             TextFieldModelNG::SetJSTextEditableController(frameNode, Referenced::Claim((Referenced*)jsController));
2130             auto controller = TextFieldModelNG::GetOrCreateController(frameNode);
2131             jsController->SetController(controller);
2132         }
2133     } else {
2134         auto pointer = TextFieldModelNG::GetJSTextEditableController(frameNode);
2135         auto preController = reinterpret_cast<Framework::JSTextEditableController*>(Referenced::RawPtr(pointer));
2136         if (preController) {
2137             preController->SetController(nullptr);
2138         }
2139         TextFieldModelNG::SetJSTextEditableController(frameNode, nullptr);
2140     }
2141     return panda::JSValueRef::Undefined(vm);
2142 }
2143 } // namespace OHOS::Ace::NG
2144