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 resourcePath; 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 SetBackgroundTransparent(bool backgroundTransparent) = 0; 57 virtual bool GetBackgroundTransparent() const = 0; 58 virtual void CreateContent() = 0; 59 virtual void DestroyContent() = 0; 60 61 virtual void UpdateViewportConfig( 62 const SizeF& size, float density, int32_t orientation, AnimationOption animationOpt, 63 const OffsetF& offset) = 0; 64 65 virtual void TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) = 0; 66 virtual bool TransferKeyEvent(const KeyEvent& event) = 0; 67 virtual void TransferFocusState(bool isFocus) = 0; 68 virtual void TransferFocusActiveEvent(bool isFocus) = 0; 69 70 virtual void SearchElementInfoByAccessibilityId(int64_t elementId, int32_t mode, int64_t baseParent, 71 std::list<Accessibility::AccessibilityElementInfo>& output) = 0; 72 virtual void SearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent, 73 std::list<Accessibility::AccessibilityElementInfo>& output) = 0; 74 virtual void FindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent, 75 Accessibility::AccessibilityElementInfo& output) = 0; 76 virtual void FocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent, 77 Accessibility::AccessibilityElementInfo& output) = 0; 78 virtual bool NotifyExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments, 79 int32_t action, int64_t offset) = 0; 80 virtual void TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, 81 int64_t timeMs) = 0; 82 virtual void TransferAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) = 0; 83 virtual void TransferAccessibilityChildTreeDeregister() = 0; 84 virtual void TransferAccessibilityDumpChildInfo( 85 const std::vector<std::string>& params, std::vector<std::string>& info) = 0; SetUIContentType(UIContentType uIContentType)86 virtual void SetUIContentType(UIContentType uIContentType) {}; IsRestrictedWorkerThread()87 virtual bool IsRestrictedWorkerThread() { return false; } CheckDCMaxConstraintInWorker(void * worker)88 virtual bool CheckDCMaxConstraintInWorker(void *worker) { return false; } CheckWorkerMaxConstraint(void * worker)89 virtual bool CheckWorkerMaxConstraint(void *worker) { return true; } 90 virtual void UpdateParentOffsetToWindow(const OffsetF& offset) = 0; OnAccessibilityParentRectInfoUpdate()91 virtual void OnAccessibilityParentRectInfoUpdate() {} 92 Dump(RendererDumpInfo & rendererDumpInfo)93 virtual void Dump(RendererDumpInfo &rendererDumpInfo) {} NotifyUieDump(const std::vector<std::string> & params,std::vector<std::string> & info)94 virtual void NotifyUieDump(const std::vector<std::string>& params, std::vector<std::string>& info) {} 95 NotifyForeground()96 virtual void NotifyForeground() {}; NotifyBackground()97 virtual void NotifyBackground() {}; 98 99 private: 100 ACE_DISALLOW_COPY_AND_MOVE(DynamicComponentRenderer); 101 }; 102 } // namespace OHOS::Ace::NG 103 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DYNAMIC_COMPONENT_RENDERER_H 104