• 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_xcomponent_bridge.h"
16 
17 #include "core/interfaces/native/node/api.h"
18 #include "bridge/declarative_frontend/jsview/models/indexer_model_impl.h"
19 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
20 
21 namespace OHOS::Ace::NG {
22 
SetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)23 ArkUINativeModuleValue XComponentBridge::SetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
24 {
25     EcmaVM *vm = runtimeCallInfo->GetVM();
26     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
27     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
28     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
29     void* nativeNode = firstArg->ToNativePointer(vm)->Value();
30     Color color;
31     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
32         GetArkUIInternalNodeAPI()->GetXComponentModifier().ResetXComponentBackgroundColor(nativeNode);
33     } else {
34         GetArkUIInternalNodeAPI()->GetXComponentModifier().SetXComponentBackgroundColor(nativeNode, color.GetValue());
35     }
36     return panda::JSValueRef::Undefined(vm);
37 }
38 
ResetBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)39 ArkUINativeModuleValue XComponentBridge::ResetBackgroundColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
40 {
41     EcmaVM *vm = runtimeCallInfo->GetVM();
42     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
43     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
44     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
45     GetArkUIInternalNodeAPI()->GetXComponentModifier().ResetXComponentBackgroundColor(nativeNode);
46     return panda::JSValueRef::Undefined(vm);
47 }
48 
SetOpacity(ArkUIRuntimeCallInfo * runtimeCallInfo)49 ArkUINativeModuleValue XComponentBridge::SetOpacity(ArkUIRuntimeCallInfo *runtimeCallInfo)
50 {
51     EcmaVM *vm = runtimeCallInfo->GetVM();
52     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
53     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
54     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
55     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
56     double opacity;
57     if (!ArkTSUtils::ParseJsDouble(vm, secondArg, opacity)) {
58         GetArkUIInternalNodeAPI()->GetXComponentModifier().ResetXComponentOpacity(nativeNode);
59     } else {
60         GetArkUIInternalNodeAPI()->GetXComponentModifier().SetXComponentOpacity(nativeNode, opacity);
61     }
62     return panda::JSValueRef::Undefined(vm);
63 }
64 
ResetOpacity(ArkUIRuntimeCallInfo * runtimeCallInfo)65 ArkUINativeModuleValue XComponentBridge::ResetOpacity(ArkUIRuntimeCallInfo *runtimeCallInfo)
66 {
67     EcmaVM *vm = runtimeCallInfo->GetVM();
68     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
69     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
70     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
71     GetArkUIInternalNodeAPI()->GetXComponentModifier().ResetXComponentOpacity(nativeNode);
72     return panda::JSValueRef::Undefined(vm);
73 }
74 
SetLinearGradientBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)75 ArkUINativeModuleValue XComponentBridge::SetLinearGradientBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
76 {
77     EcmaVM* vm = runtimeCallInfo->GetVM();
78     return panda::JSValueRef::Undefined(vm);
79 }
80 
ResetLinearGradientBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)81 ArkUINativeModuleValue XComponentBridge::ResetLinearGradientBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
82 {
83     EcmaVM* vm = runtimeCallInfo->GetVM();
84     return panda::JSValueRef::Undefined(vm);
85 }
86 
SetPixelStretchEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)87 ArkUINativeModuleValue XComponentBridge::SetPixelStretchEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
88 {
89     EcmaVM* vm = runtimeCallInfo->GetVM();
90     return panda::JSValueRef::Undefined(vm);
91 }
92 
ResetPixelStretchEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)93 ArkUINativeModuleValue XComponentBridge::ResetPixelStretchEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
94 {
95     EcmaVM* vm = runtimeCallInfo->GetVM();
96     return panda::JSValueRef::Undefined(vm);
97 }
98 
SetLightUpEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)99 ArkUINativeModuleValue XComponentBridge::SetLightUpEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
100 {
101     EcmaVM* vm = runtimeCallInfo->GetVM();
102     return panda::JSValueRef::Undefined(vm);
103 }
104 
ResetLightUpEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)105 ArkUINativeModuleValue XComponentBridge::ResetLightUpEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
106 {
107     EcmaVM* vm = runtimeCallInfo->GetVM();
108     return panda::JSValueRef::Undefined(vm);
109 }
110 
SetSphericalEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)111 ArkUINativeModuleValue XComponentBridge::SetSphericalEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
112 {
113     EcmaVM* vm = runtimeCallInfo->GetVM();
114     return panda::JSValueRef::Undefined(vm);
115 }
116 
ResetSphericalEffect(ArkUIRuntimeCallInfo * runtimeCallInfo)117 ArkUINativeModuleValue XComponentBridge::ResetSphericalEffect(ArkUIRuntimeCallInfo *runtimeCallInfo)
118 {
119     EcmaVM* vm = runtimeCallInfo->GetVM();
120     return panda::JSValueRef::Undefined(vm);
121 }
122 
SetColorBlend(ArkUIRuntimeCallInfo * runtimeCallInfo)123 ArkUINativeModuleValue XComponentBridge::SetColorBlend(ArkUIRuntimeCallInfo *runtimeCallInfo)
124 {
125     EcmaVM* vm = runtimeCallInfo->GetVM();
126     return panda::JSValueRef::Undefined(vm);
127 }
128 
ResetColorBlend(ArkUIRuntimeCallInfo * runtimeCallInfo)129 ArkUINativeModuleValue XComponentBridge::ResetColorBlend(ArkUIRuntimeCallInfo *runtimeCallInfo)
130 {
131     EcmaVM* vm = runtimeCallInfo->GetVM();
132     return panda::JSValueRef::Undefined(vm);
133 }
134 
SetHueRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)135 ArkUINativeModuleValue XComponentBridge::SetHueRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
136 {
137     EcmaVM* vm = runtimeCallInfo->GetVM();
138     return panda::JSValueRef::Undefined(vm);
139 }
140 
ResetHueRotate(ArkUIRuntimeCallInfo * runtimeCallInfo)141 ArkUINativeModuleValue XComponentBridge::ResetHueRotate(ArkUIRuntimeCallInfo *runtimeCallInfo)
142 {
143     EcmaVM* vm = runtimeCallInfo->GetVM();
144     return panda::JSValueRef::Undefined(vm);
145 }
146 
SetSepia(ArkUIRuntimeCallInfo * runtimeCallInfo)147 ArkUINativeModuleValue XComponentBridge::SetSepia(ArkUIRuntimeCallInfo *runtimeCallInfo)
148 {
149     EcmaVM* vm = runtimeCallInfo->GetVM();
150     return panda::JSValueRef::Undefined(vm);
151 }
152 
ResetSepia(ArkUIRuntimeCallInfo * runtimeCallInfo)153 ArkUINativeModuleValue XComponentBridge::ResetSepia(ArkUIRuntimeCallInfo *runtimeCallInfo)
154 {
155     EcmaVM* vm = runtimeCallInfo->GetVM();
156     return panda::JSValueRef::Undefined(vm);
157 }
158 
SetInvert(ArkUIRuntimeCallInfo * runtimeCallInfo)159 ArkUINativeModuleValue XComponentBridge::SetInvert(ArkUIRuntimeCallInfo *runtimeCallInfo)
160 {
161     EcmaVM* vm = runtimeCallInfo->GetVM();
162     return panda::JSValueRef::Undefined(vm);
163 }
164 
ResetInvert(ArkUIRuntimeCallInfo * runtimeCallInfo)165 ArkUINativeModuleValue XComponentBridge::ResetInvert(ArkUIRuntimeCallInfo *runtimeCallInfo)
166 {
167     EcmaVM* vm = runtimeCallInfo->GetVM();
168     return panda::JSValueRef::Undefined(vm);
169 }
170 
SetContrast(ArkUIRuntimeCallInfo * runtimeCallInfo)171 ArkUINativeModuleValue XComponentBridge::SetContrast(ArkUIRuntimeCallInfo *runtimeCallInfo)
172 {
173     EcmaVM* vm = runtimeCallInfo->GetVM();
174     return panda::JSValueRef::Undefined(vm);
175 }
176 
ResetContrast(ArkUIRuntimeCallInfo * runtimeCallInfo)177 ArkUINativeModuleValue XComponentBridge::ResetContrast(ArkUIRuntimeCallInfo *runtimeCallInfo)
178 {
179     EcmaVM* vm = runtimeCallInfo->GetVM();
180     return panda::JSValueRef::Undefined(vm);
181 }
182 
SetSaturate(ArkUIRuntimeCallInfo * runtimeCallInfo)183 ArkUINativeModuleValue XComponentBridge::SetSaturate(ArkUIRuntimeCallInfo *runtimeCallInfo)
184 {
185     EcmaVM* vm = runtimeCallInfo->GetVM();
186     return panda::JSValueRef::Undefined(vm);
187 }
188 
ResetSaturate(ArkUIRuntimeCallInfo * runtimeCallInfo)189 ArkUINativeModuleValue XComponentBridge::ResetSaturate(ArkUIRuntimeCallInfo *runtimeCallInfo)
190 {
191     EcmaVM* vm = runtimeCallInfo->GetVM();
192     return panda::JSValueRef::Undefined(vm);
193 }
194 
SetBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)195 ArkUINativeModuleValue XComponentBridge::SetBrightness(ArkUIRuntimeCallInfo *runtimeCallInfo)
196 {
197     EcmaVM* vm = runtimeCallInfo->GetVM();
198     return panda::JSValueRef::Undefined(vm);
199 }
200 
ResetBrightness(ArkUIRuntimeCallInfo * runtimeCallInfo)201 ArkUINativeModuleValue XComponentBridge::ResetBrightness(ArkUIRuntimeCallInfo *runtimeCallInfo)
202 {
203     EcmaVM* vm = runtimeCallInfo->GetVM();
204     return panda::JSValueRef::Undefined(vm);
205 }
206 
SetGrayscale(ArkUIRuntimeCallInfo * runtimeCallInfo)207 ArkUINativeModuleValue XComponentBridge::SetGrayscale(ArkUIRuntimeCallInfo *runtimeCallInfo)
208 {
209     EcmaVM* vm = runtimeCallInfo->GetVM();
210     return panda::JSValueRef::Undefined(vm);
211 }
212 
ResetGrayscale(ArkUIRuntimeCallInfo * runtimeCallInfo)213 ArkUINativeModuleValue XComponentBridge::ResetGrayscale(ArkUIRuntimeCallInfo *runtimeCallInfo)
214 {
215     EcmaVM* vm = runtimeCallInfo->GetVM();
216     return panda::JSValueRef::Undefined(vm);
217 }
218 
SetBackdropBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)219 ArkUINativeModuleValue XComponentBridge::SetBackdropBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
220 {
221     EcmaVM* vm = runtimeCallInfo->GetVM();
222     return panda::JSValueRef::Undefined(vm);
223 }
224 
ResetBackdropBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)225 ArkUINativeModuleValue XComponentBridge::ResetBackdropBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
226 {
227     EcmaVM* vm = runtimeCallInfo->GetVM();
228     return panda::JSValueRef::Undefined(vm);
229 }
230 
SetBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)231 ArkUINativeModuleValue XComponentBridge::SetBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
232 {
233     EcmaVM* vm = runtimeCallInfo->GetVM();
234     return panda::JSValueRef::Undefined(vm);
235 }
236 
ResetBlur(ArkUIRuntimeCallInfo * runtimeCallInfo)237 ArkUINativeModuleValue XComponentBridge::ResetBlur(ArkUIRuntimeCallInfo *runtimeCallInfo)
238 {
239     EcmaVM* vm = runtimeCallInfo->GetVM();
240     return panda::JSValueRef::Undefined(vm);
241 }
242 
SetBackgroundImagePosition(ArkUIRuntimeCallInfo * runtimeCallInfo)243 ArkUINativeModuleValue XComponentBridge::SetBackgroundImagePosition(ArkUIRuntimeCallInfo *runtimeCallInfo)
244 {
245     EcmaVM* vm = runtimeCallInfo->GetVM();
246     return panda::JSValueRef::Undefined(vm);
247 }
248 
ResetBackgroundImagePosition(ArkUIRuntimeCallInfo * runtimeCallInfo)249 ArkUINativeModuleValue XComponentBridge::ResetBackgroundImagePosition(ArkUIRuntimeCallInfo *runtimeCallInfo)
250 {
251     EcmaVM* vm = runtimeCallInfo->GetVM();
252     return panda::JSValueRef::Undefined(vm);
253 }
254 
SetBackgroundImageSize(ArkUIRuntimeCallInfo * runtimeCallInfo)255 ArkUINativeModuleValue XComponentBridge::SetBackgroundImageSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
256 {
257     EcmaVM* vm = runtimeCallInfo->GetVM();
258     return panda::JSValueRef::Undefined(vm);
259 }
260 
ResetBackgroundImageSize(ArkUIRuntimeCallInfo * runtimeCallInfo)261 ArkUINativeModuleValue XComponentBridge::ResetBackgroundImageSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
262 {
263     EcmaVM* vm = runtimeCallInfo->GetVM();
264     return panda::JSValueRef::Undefined(vm);
265 }
266 
SetBackgroundImage(ArkUIRuntimeCallInfo * runtimeCallInfo)267 ArkUINativeModuleValue XComponentBridge::SetBackgroundImage(ArkUIRuntimeCallInfo *runtimeCallInfo)
268 {
269     EcmaVM* vm = runtimeCallInfo->GetVM();
270     return panda::JSValueRef::Undefined(vm);
271 }
272 
ResetBackgroundImage(ArkUIRuntimeCallInfo * runtimeCallInfo)273 ArkUINativeModuleValue XComponentBridge::ResetBackgroundImage(ArkUIRuntimeCallInfo *runtimeCallInfo)
274 {
275     EcmaVM* vm = runtimeCallInfo->GetVM();
276     return panda::JSValueRef::Undefined(vm);
277 }
278 } // namespace OHOS::Ace::NG
279