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