1 /*
2  * Copyright (c) 2024 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 "ohos_nweb/bridge/ark_web_native_embed_touch_event_wrapper.h"
17 
18 #include "ohos_nweb/bridge/ark_web_gesture_event_result_wrapper.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
ArkWebNativeEmbedTouchEventWrapper(ArkWebRefPtr<ArkWebNativeEmbedTouchEvent> ark_web_native_embed_touch_event)24 ArkWebNativeEmbedTouchEventWrapper::ArkWebNativeEmbedTouchEventWrapper(
25     ArkWebRefPtr<ArkWebNativeEmbedTouchEvent> ark_web_native_embed_touch_event)
26     : ark_web_native_embed_touch_event_(ark_web_native_embed_touch_event)
27 {}
28 
GetX()29 float ArkWebNativeEmbedTouchEventWrapper::GetX()
30 {
31     return ark_web_native_embed_touch_event_->GetX();
32 }
33 
GetY()34 float ArkWebNativeEmbedTouchEventWrapper::GetY()
35 {
36     return ark_web_native_embed_touch_event_->GetY();
37 }
38 
GetId()39 int32_t ArkWebNativeEmbedTouchEventWrapper::GetId()
40 {
41     return ark_web_native_embed_touch_event_->GetId();
42 }
43 
GetType()44 ArkWebTouchType ArkWebNativeEmbedTouchEventWrapper::GetType()
45 {
46     return static_cast<ArkWebTouchType>(ark_web_native_embed_touch_event_->GetType());
47 }
48 
GetOffsetX()49 float ArkWebNativeEmbedTouchEventWrapper::GetOffsetX()
50 {
51     return ark_web_native_embed_touch_event_->GetOffsetX();
52 }
53 
GetOffsetY()54 float ArkWebNativeEmbedTouchEventWrapper::GetOffsetY()
55 {
56     return ark_web_native_embed_touch_event_->GetOffsetY();
57 }
58 
GetScreenX()59 float ArkWebNativeEmbedTouchEventWrapper::GetScreenX()
60 {
61     return ark_web_native_embed_touch_event_->GetScreenX();
62 }
63 
GetScreenY()64 float ArkWebNativeEmbedTouchEventWrapper::GetScreenY()
65 {
66     return ark_web_native_embed_touch_event_->GetScreenY();
67 }
68 
GetEmbedId()69 std::string ArkWebNativeEmbedTouchEventWrapper::GetEmbedId()
70 {
71     ArkWebString stEmbedId = ark_web_native_embed_touch_event_->GetEmbedId();
72 
73     std::string objEmbedId = ArkWebStringStructToClass(stEmbedId);
74     ArkWebStringStructRelease(stEmbedId);
75     return objEmbedId;
76 }
77 
GetResult()78 std::shared_ptr<OHOS::NWeb::NWebGestureEventResult> ArkWebNativeEmbedTouchEventWrapper::GetResult()
79 {
80     ArkWebRefPtr<ArkWebGestureEventResult> result = ark_web_native_embed_touch_event_->GetResult();
81     if (CHECK_REF_PTR_IS_NULL(result)) {
82         return nullptr;
83     }
84 
85     return std::make_shared<ArkWebGestureEventResultWrapper>(result);
86 }
87 
88 } // namespace OHOS::ArkWeb
89