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 "frameworks/bridge/declarative_frontend/engine/functions/js_common_gesture_function.h"
17
18 namespace OHOS::Ace::Framework {
19
GetTapLocation(const FingerInfo & fingerInfo)20 JSRef<JSObject> JsCommonGestureFunction::GetTapLocation(const FingerInfo& fingerInfo)
21 {
22 JSRef<JSObjTemplate> objectTemplate = JSRef<JSObjTemplate>::New();
23 JSRef<JSObject> tapLocation = objectTemplate->NewInstance();
24 const OHOS::Ace::Offset& localOffset = fingerInfo.localLocation_;
25 const OHOS::Ace::Offset& globalOffset = fingerInfo.globalLocation_;
26 const OHOS::Ace::Offset& screenOffset = fingerInfo.screenLocation_;
27 tapLocation->SetProperty<double>("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX()));
28 tapLocation->SetProperty<double>("windowY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY()));
29 tapLocation->SetProperty<double>("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX()));
30 tapLocation->SetProperty<double>("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY()));
31 tapLocation->SetProperty<double>("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX()));
32 tapLocation->SetProperty<double>("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY()));
33
34 return tapLocation;
35 }
36
37 } // namespace OHOS::Ace::Framework
38