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_impl.h"
17 
18 #include "ohos_nweb/bridge/ark_web_gesture_event_result_impl.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
ArkWebNativeEmbedTouchEventImpl(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedTouchEvent> nweb_native_embed_touch_event)24 ArkWebNativeEmbedTouchEventImpl::ArkWebNativeEmbedTouchEventImpl(
25     std::shared_ptr<OHOS::NWeb::NWebNativeEmbedTouchEvent> nweb_native_embed_touch_event)
26     : nweb_native_embed_touch_event_(nweb_native_embed_touch_event)
27 {}
28 
GetX()29 float ArkWebNativeEmbedTouchEventImpl::GetX()
30 {
31     return nweb_native_embed_touch_event_->GetX();
32 }
33 
GetY()34 float ArkWebNativeEmbedTouchEventImpl::GetY()
35 {
36     return nweb_native_embed_touch_event_->GetY();
37 }
38 
GetId()39 int32_t ArkWebNativeEmbedTouchEventImpl::GetId()
40 {
41     return nweb_native_embed_touch_event_->GetId();
42 }
43 
GetType()44 size_t ArkWebNativeEmbedTouchEventImpl::GetType()
45 {
46     return static_cast<size_t>(nweb_native_embed_touch_event_->GetType());
47 }
48 
GetOffsetX()49 float ArkWebNativeEmbedTouchEventImpl::GetOffsetX()
50 {
51     return nweb_native_embed_touch_event_->GetOffsetX();
52 }
53 
GetOffsetY()54 float ArkWebNativeEmbedTouchEventImpl::GetOffsetY()
55 {
56     return nweb_native_embed_touch_event_->GetOffsetY();
57 }
58 
GetScreenX()59 float ArkWebNativeEmbedTouchEventImpl::GetScreenX()
60 {
61     return nweb_native_embed_touch_event_->GetScreenX();
62 }
63 
GetScreenY()64 float ArkWebNativeEmbedTouchEventImpl::GetScreenY()
65 {
66     return nweb_native_embed_touch_event_->GetScreenY();
67 }
68 
GetEmbedId()69 ArkWebString ArkWebNativeEmbedTouchEventImpl::GetEmbedId()
70 {
71     return ArkWebStringClassToStruct(nweb_native_embed_touch_event_->GetEmbedId());
72 }
73 
GetResult()74 ArkWebRefPtr<ArkWebGestureEventResult> ArkWebNativeEmbedTouchEventImpl::GetResult()
75 {
76     std::shared_ptr<OHOS::NWeb::NWebGestureEventResult> result = nweb_native_embed_touch_event_->GetResult();
77     if (CHECK_SHARED_PTR_IS_NULL(result)) {
78         return nullptr;
79     }
80     return new ArkWebGestureEventResultImpl(result);
81 }
82 
83 } // namespace OHOS::ArkWeb
84