• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_BRIDGE_JS_FRONTEND_ENGINE_QUICKJS_SCROLL_VIEW_BRIDGE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_JS_FRONTEND_ENGINE_QUICKJS_SCROLL_VIEW_BRIDGE_H
18 
19 #include "frameworks/bridge/common/dom/dom_node.h"
20 #include "frameworks/bridge/js_frontend/engine/quickjs/qjs_engine.h"
21 #include "frameworks/bridge/js_frontend/engine/quickjs/qjs_utils.h"
22 
23 namespace OHOS::Ace::Framework {
24 
25 class ComponentApiBridge : virtual public AceType {
26     DECLARE_ACE_TYPE(ComponentApiBridge, AceType)
27 
28 public:
29     static JSValue JsGetScrollOffset(JSContext* ctx, NodeId nodeId);
30     static JSValue JsGetBoundingRect(JSContext* ctx, NodeId nodeId);
31     static JSValue JsGetInspector(JSContext* ctx, NodeId nodeId);
32     static void JsScrollTo(JSContext* ctx, const std::string& args, NodeId nodeId);
33     static JSValue JsCreateObserver(JSContext* ctx, const std::string& args, NodeId nodeId);
34 
35     static JSValue JsObserverOn(JSContext* ctx, JSValueConst value, int32_t argc, JSValueConst* argv);
36     static JSValue JsObserverOff(JSContext* ctx, JSValueConst value, int32_t argc, JSValueConst* argv);
37 };
38 
39 class QJSVisibleListenerCallback : virtual public AceType {
40     DECLARE_ACE_TYPE(QJSVisibleListenerCallback, AceType)
41 
42 public:
43     QJSVisibleListenerCallback(JSContext* ctx, JSValue callback, NodeId nodeId);
44 
45     ~QJSVisibleListenerCallback() override;
46 
GetJsObject()47     JSValue GetJsObject()
48     {
49         return listenCallback_;
50     }
51 
GetContext()52     JSContext* GetContext() const
53     {
54         return ctx_;
55     }
56 
GetNodeId()57     NodeId GetNodeId() const
58     {
59         return nodeId_;
60     }
61 
62 private:
63     JSContext* ctx_ = nullptr;
64     JSValue listenCallback_;
65     NodeId nodeId_ = -1;
66 };
67 
68 } // namespace OHOS::Ace::Framework
69 
70 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_JS_FRONTEND_ENGINE_QUICKJS_SCROLL_VIEW_BRIDGE_H
71