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_quick_menu_params_impl.h"
17 
18 #include "ohos_nweb/bridge/ark_web_touch_handle_state_impl.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
24 using ArkWebTouchHandleType = OHOS::NWeb::NWebTouchHandleState::TouchHandleType;
25 
ArkWebQuickMenuParamsImpl(std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> nweb_quick_menu_params)26 ArkWebQuickMenuParamsImpl::ArkWebQuickMenuParamsImpl(
27     std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> nweb_quick_menu_params)
28     : nweb_quick_menu_params_(nweb_quick_menu_params)
29 {}
30 
GetXCoord()31 int32_t ArkWebQuickMenuParamsImpl::GetXCoord()
32 {
33     return nweb_quick_menu_params_->GetXCoord();
34 }
35 
GetYCoord()36 int32_t ArkWebQuickMenuParamsImpl::GetYCoord()
37 {
38     return nweb_quick_menu_params_->GetYCoord();
39 }
40 
GetWidth()41 int32_t ArkWebQuickMenuParamsImpl::GetWidth()
42 {
43     return nweb_quick_menu_params_->GetWidth();
44 }
45 
GetHeight()46 int32_t ArkWebQuickMenuParamsImpl::GetHeight()
47 {
48     return nweb_quick_menu_params_->GetHeight();
49 }
50 
GetEditStateFlags()51 int32_t ArkWebQuickMenuParamsImpl::GetEditStateFlags()
52 {
53     return nweb_quick_menu_params_->GetEditStateFlags();
54 }
55 
GetSelectX()56 int32_t ArkWebQuickMenuParamsImpl::GetSelectX()
57 {
58     return nweb_quick_menu_params_->GetSelectX();
59 }
60 
GetSelectY()61 int32_t ArkWebQuickMenuParamsImpl::GetSelectY()
62 {
63     return nweb_quick_menu_params_->GetSelectY();
64 }
65 
GetSelectWidth()66 int32_t ArkWebQuickMenuParamsImpl::GetSelectWidth()
67 {
68     return nweb_quick_menu_params_->GetSelectWidth();
69 }
70 
GetSelectXHeight()71 int32_t ArkWebQuickMenuParamsImpl::GetSelectXHeight()
72 {
73     return nweb_quick_menu_params_->GetSelectXHeight();
74 }
75 
GetTouchHandleState(int type)76 ArkWebRefPtr<ArkWebTouchHandleState> ArkWebQuickMenuParamsImpl::GetTouchHandleState(int type)
77 {
78     std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> nweb_touch_handle_state =
79         nweb_quick_menu_params_->GetTouchHandleState(static_cast<ArkWebTouchHandleType>(type));
80     if (CHECK_SHARED_PTR_IS_NULL(nweb_touch_handle_state)) {
81         return nullptr;
82     }
83 
84     return new ArkWebTouchHandleStateImpl(nweb_touch_handle_state);
85 }
86 
GetIsLongPressActived()87 bool ArkWebQuickMenuParamsImpl::GetIsLongPressActived()
88 {
89     return nweb_quick_menu_params_->GetIsLongPressActived();
90 }
91 } // namespace OHOS::ArkWeb
92