• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "frameworks/bridge/declarative_frontend/engine/js_types.h"
17 
18 namespace OHOS::Ace::Framework {
19 
20 #ifdef USE_V8_ENGINE
JsStopPropagation(const v8::FunctionCallbackInfo<v8::Value> & info)21 void JsStopPropagation(const v8::FunctionCallbackInfo<v8::Value>& info)
22 {
23     v8::Local<v8::Object> thisObj = info.This();
24     BaseEventInfo* eventInfo = static_cast<BaseEventInfo*>(thisObj->GetAlignedPointerFromInternalField(0));
25     if (eventInfo) {
26         eventInfo->SetStopPropagation(true);
27     }
28 }
29 
30 #elif USE_QUICKJS_ENGINE
31 JSValue JsStopPropagation(JSContext* ctx, JSValueConst new_target, int argc, JSValueConst* arg)
32 {
33     auto eventInfo = static_cast<BaseEventInfo*>(JS_GetOpaque3(new_target));
34     if (eventInfo) {
35         LOGD("JsStopPropagation is trigger");
36         eventInfo->SetStopPropagation(true);
37     }
38     return JS_UNDEFINED;
39 }
40 
41 #elif USE_ARK_ENGINE
42 Local<JSValueRef> JsStopPropagation(panda::JsiRuntimeCallInfo *info)
43 {
44     Local<JSValueRef> thisObj = info->GetThisRef();
45     auto eventInfo = static_cast<BaseEventInfo*>(panda::Local<panda::ObjectRef>(thisObj)->GetNativePointerField(0));
46     if (eventInfo) {
47         LOGD("JsStopPropagation is trigger");
48         eventInfo->SetStopPropagation(true);
49     }
50     return JSValueRef::Undefined(info->GetVM());
51 }
52 #endif
53 
54 } // namespace OHOS::Ace::Framework
55