• 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 
16 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_hyperlink_bridge.h"
17 #include "core/interfaces/native/node/api.h"
18 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
19 
20 namespace OHOS::Ace::NG {
SetColor(ArkUIRuntimeCallInfo * runtimeCallInfo)21 ArkUINativeModuleValue HyperlinkBridge::SetColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
22 {
23     EcmaVM* vm = runtimeCallInfo->GetVM();
24     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
25     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
26     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
27     void* nativeNode = firstArg->ToNativePointer(vm)->Value();
28     Color color;
29     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) {
30         GetArkUIInternalNodeAPI()->GetHyperlinkModifier().ResetHyperlinkColor(nativeNode);
31     } else {
32         GetArkUIInternalNodeAPI()->GetHyperlinkModifier().SetHyperlinkColor(nativeNode, color.GetValue());
33     }
34     return panda::JSValueRef::Undefined(vm);
35 }
36 
ResetColor(ArkUIRuntimeCallInfo * runtimeCallInfo)37 ArkUINativeModuleValue HyperlinkBridge::ResetColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
38 {
39     EcmaVM* vm = runtimeCallInfo->GetVM();
40     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
41     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
42     void* nativeNode = firstArg->ToNativePointer(vm)->Value();
43     GetArkUIInternalNodeAPI()->GetHyperlinkModifier().ResetHyperlinkColor(nativeNode);
44     return panda::JSValueRef::Undefined(vm);
45 }
46 
SetDraggable(ArkUIRuntimeCallInfo * runtimeCallInfo)47 ArkUINativeModuleValue HyperlinkBridge::SetDraggable(ArkUIRuntimeCallInfo* runtimeCallInfo)
48 {
49     EcmaVM* vm = runtimeCallInfo->GetVM();
50     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
51     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
52     Local<JSValueRef> draggableArg = runtimeCallInfo->GetCallArgRef(1);
53     void* nativeNode = nodeArg->ToNativePointer(vm)->Value();
54     if (draggableArg->IsBoolean()) {
55         bool boolValue = draggableArg->ToBoolean(vm)->Value();
56         GetArkUIInternalNodeAPI()->GetHyperlinkModifier().SetHyperlinkDraggable(nativeNode, boolValue);
57     } else {
58         GetArkUIInternalNodeAPI()->GetHyperlinkModifier().ResetHyperlinkDraggable(nativeNode);
59     }
60     return panda::JSValueRef::Undefined(vm);
61 }
62 
ResetDraggable(ArkUIRuntimeCallInfo * runtimeCallInfo)63 ArkUINativeModuleValue HyperlinkBridge::ResetDraggable(ArkUIRuntimeCallInfo* runtimeCallInfo)
64 {
65     EcmaVM* vm = runtimeCallInfo->GetVM();
66     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
67     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
68     void* nativeNode = nodeArg->ToNativePointer(vm)->Value();
69     GetArkUIInternalNodeAPI()->GetHyperlinkModifier().ResetHyperlinkDraggable(nativeNode);
70     return panda::JSValueRef::Undefined(vm);
71 }
72 }