• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BASE_NODE_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BASE_NODE_H
18 
19 #include "base/geometry/ng/size_t.h"
20 #include "base/memory/ace_type.h"
21 #include "base/utils/utils.h"
22 #include "bridge/declarative_frontend/engine/functions/js_function.h"
23 #include "bridge/declarative_frontend/engine/js_types.h"
24 #include "core/components_ng/base/ui_node.h"
25 #include "core/components_ng/base/view_stack_processor.h"
26 #include "frameworks/bridge/declarative_frontend/engine/bindings_defines.h"
27 
28 namespace OHOS::Ace::Framework {
29 class JSBaseNode : public AceType {
30     DECLARE_ACE_TYPE(JSBaseNode, AceType)
31 public:
32     JSBaseNode() = default;
JSBaseNode(const NG::OptionalSizeF & size,NodeRenderType renderType,std::string surfaceId)33     JSBaseNode(const NG::OptionalSizeF& size, NodeRenderType renderType, std::string surfaceId)
34         : size_(size), renderType_(renderType), surfaceId_(std::move(surfaceId))
35     {}
36     ~JSBaseNode() override = default;
37 
38     static void JSBind(BindingTarget globalObj);
39     static void ConstructorCallback(const JSCallbackInfo& info);
40     static void DestructorCallback(JSBaseNode* node);
41     void FinishUpdateFunc(const JSCallbackInfo& info);
42     void Create(const JSCallbackInfo& info);
43     void BuildNode(const JSCallbackInfo& info);
44     void PostTouchEvent(const JSCallbackInfo& info);
45     void CreateRenderNode(const JSCallbackInfo& info);
46     void UpdateStart(const JSCallbackInfo& info);
47     void UpdateEnd(const JSCallbackInfo& info);
Dispose(const JSCallbackInfo & info)48     void Dispose(const JSCallbackInfo& info)
49     {
50         viewNode_.Reset();
51     }
52 
GetViewNode()53     RefPtr<NG::UINode> GetViewNode() const
54     {
55         return viewNode_;
56     }
57 
58 protected:
59     RefPtr<NG::UINode> viewNode_;
60 
61 private:
62     NG::OptionalSizeF size_;
63     NodeRenderType renderType_ = NodeRenderType::RENDER_TYPE_DISPLAY;
64     std::string surfaceId_;
65     std::unique_ptr<NG::ScopedViewStackProcessor> scopedViewStackProcessor_;
66 };
67 } // namespace OHOS::Ace::Framework
68 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BASE_NODE_H
69