1 /*
2  * Copyright (c) 2023-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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DYNAMIC_COMPONENT_RENDERER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DYNAMIC_COMPONENT_RENDERER_H
18 
19 #include "interfaces/inner_api/ace/ui_content.h"
20 
21 #include "base/memory/ace_type.h"
22 #include "core/components_ng/base/frame_node.h"
23 
24 namespace OHOS::Ace::NG {
25 struct RendererDumpInfo {
26     int64_t createUiContenTime = 0;
27     int64_t limitedWorkerInitTime = 0;
28     int64_t loadAbcTime = 0;
29 
ReSetRendererDumpInfo30     void ReSet()
31     {
32         createUiContenTime = 0;
33         limitedWorkerInitTime = 0;
34         loadAbcTime = 0;
35     }
36 };
37 
38 struct IsolatedInfo {
39     std::string abcPath;
40     std::string reourcePath;
41     std::string entryPoint;
42     std::vector<std::string> registerComponents;
43 };
44 
45 class DynamicComponentRenderer : public virtual AceType {
46     DECLARE_ACE_TYPE(DynamicComponentRenderer, AceType);
47 
48 public:
49     DynamicComponentRenderer() = default;
50     virtual ~DynamicComponentRenderer() = default;
51 
52     static RefPtr<DynamicComponentRenderer> Create(
53         const RefPtr<FrameNode>& host, void* runtime, const IsolatedInfo& isolatedInfo);
54 
55     virtual void SetAdaptiveSize(bool adaptiveWidth, bool adaptiveHeight) = 0;
56     virtual void CreateContent() = 0;
57     virtual void DestroyContent() = 0;
58 
59     virtual void UpdateViewportConfig(
60         const SizeF& size, float density, int32_t orientation, AnimationOption animationOpt) = 0;
61 
62     virtual void TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) = 0;
63     virtual bool TransferKeyEvent(const KeyEvent& event) = 0;
64     virtual void TransferFocusState(bool isFocus) = 0;
65     virtual void TransferFocusActiveEvent(bool isFocus) = 0;
66 
67     virtual void SearchElementInfoByAccessibilityId(int64_t elementId, int32_t mode, int64_t baseParent,
68         std::list<Accessibility::AccessibilityElementInfo>& output) = 0;
69     virtual void SearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
70         std::list<Accessibility::AccessibilityElementInfo>& output) = 0;
71     virtual void FindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
72         Accessibility::AccessibilityElementInfo& output) = 0;
73     virtual void FocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
74         Accessibility::AccessibilityElementInfo& output) = 0;
75     virtual bool NotifyExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
76         int32_t action, int64_t offset) = 0;
77     virtual void TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
78         int64_t timeMs) = 0;
79 
Dump(RendererDumpInfo & rendererDumpInfo)80     virtual void Dump(RendererDumpInfo &rendererDumpInfo) {}
81 
82 private:
83     ACE_DISALLOW_COPY_AND_MOVE(DynamicComponentRenderer);
84 };
85 } // namespace OHOS::Ace::NG
86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DYNAMIC_COMPONENT_RENDERER_H
87