• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_mouse_event_wrapper.h"
17 
18 #include "ohos_nweb/bridge/ark_web_mouse_event_result_wrapper.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
ArkWebNativeEmbedMouseEventWrapper(ArkWebRefPtr<ArkWebNativeEmbedMouseEvent> ark_web_native_embed_mouse_event)24 ArkWebNativeEmbedMouseEventWrapper::ArkWebNativeEmbedMouseEventWrapper(
25     ArkWebRefPtr<ArkWebNativeEmbedMouseEvent> ark_web_native_embed_mouse_event)
26     : ark_web_native_embed_mouse_event_(ark_web_native_embed_mouse_event)
27 {}
28 
GetX()29 float ArkWebNativeEmbedMouseEventWrapper::GetX()
30 {
31     return ark_web_native_embed_mouse_event_->GetX();
32 }
33 
GetY()34 float ArkWebNativeEmbedMouseEventWrapper::GetY()
35 {
36     return ark_web_native_embed_mouse_event_->GetY();
37 }
38 
IsHitNativeArea()39 bool ArkWebNativeEmbedMouseEventWrapper::IsHitNativeArea()
40 {
41     return ark_web_native_embed_mouse_event_->IsHitNativeArea();
42 }
43 
GetType()44 ArkWebMouseType ArkWebNativeEmbedMouseEventWrapper::GetType()
45 {
46     return static_cast<ArkWebMouseType>(ark_web_native_embed_mouse_event_->GetType());
47 }
48 
GetButton()49 ArkWebMouseButton ArkWebNativeEmbedMouseEventWrapper::GetButton()
50 {
51     return static_cast<ArkWebMouseButton>(ark_web_native_embed_mouse_event_->GetButton());
52 }
53 
GetOffsetX()54 float ArkWebNativeEmbedMouseEventWrapper::GetOffsetX()
55 {
56     return ark_web_native_embed_mouse_event_->GetOffsetX();
57 }
58 
GetOffsetY()59 float ArkWebNativeEmbedMouseEventWrapper::GetOffsetY()
60 {
61     return ark_web_native_embed_mouse_event_->GetOffsetY();
62 }
63 
GetScreenX()64 float ArkWebNativeEmbedMouseEventWrapper::GetScreenX()
65 {
66     return ark_web_native_embed_mouse_event_->GetScreenX();
67 }
68 
GetScreenY()69 float ArkWebNativeEmbedMouseEventWrapper::GetScreenY()
70 {
71     return ark_web_native_embed_mouse_event_->GetScreenY();
72 }
73 
GetEmbedId()74 std::string ArkWebNativeEmbedMouseEventWrapper::GetEmbedId()
75 {
76     ArkWebString stEmbedId = ark_web_native_embed_mouse_event_->GetEmbedId();
77 
78     std::string objEmbedId = ArkWebStringStructToClass(stEmbedId);
79     ArkWebStringStructRelease(stEmbedId);
80     return objEmbedId;
81 }
82 
GetResult()83 std::shared_ptr<OHOS::NWeb::NWebMouseEventResult> ArkWebNativeEmbedMouseEventWrapper::GetResult()
84 {
85     ArkWebRefPtr<ArkWebMouseEventResult> result = ark_web_native_embed_mouse_event_->GetResult();
86     if (CHECK_REF_PTR_IS_NULL(result)) {
87         return nullptr;
88     }
89 
90     return std::make_shared<ArkWebMouseEventResultWrapper>(result);
91 }
92 
93 } // namespace OHOS::ArkWeb
94