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 FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DISPATCHER_IMPL_H 17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DISPATCHER_IMPL_H 18 19 #include "form_renderer_dispatcher_stub.h" 20 21 #include "base/utils/macros.h" 22 #include "ui_content.h" 23 #include "event_handler.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class EventHandler; 28 } 29 namespace Rosen { 30 class RSUIContext; 31 } 32 namespace Ace { 33 class FormRenderer; 34 /** 35 * @class FormRendererDispatcher 36 * FormRendererDispatcher interface is used to form renderer dispatcher. 37 */ 38 class ACE_EXPORT FormRendererDispatcherImpl : public FormRendererDispatcherStub { 39 public: 40 FormRendererDispatcherImpl(const std::shared_ptr<UIContent> uiContent, 41 const std::shared_ptr<FormRenderer> formRenderer, 42 std::weak_ptr<OHOS::AppExecFwk::EventHandler> eventHandler); 43 ~FormRendererDispatcherImpl() override = default; 44 /** 45 * @brief Dispatcher pointer event. 46 * @param pointerEvent The pointer event info. 47 */ 48 void DispatchPointerEvent( 49 const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, 50 SerializedGesture& serializedGesture) override; 51 /** 52 * @brief Set AllowUpdate. 53 * @param allowUpdate The allowUpdate. 54 */ 55 void SetAllowUpdate(bool allowUpdate) override; 56 bool IsAllowUpdate(); 57 void SetVisible(bool isVisible); 58 bool IsVisible(); 59 void SetMultiInstanceEnabled(bool isMultiInstanceEnabled) override; 60 61 void DispatchSurfaceChangeEvent(float width, float height, uint32_t reason = 0, 62 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, float borderWidth = 0.0) override; 63 void SetObscured(bool isObscured) override; 64 void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) override; 65 void OnAccessibilityChildTreeDeregister() override; 66 void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override; 67 void OnAccessibilityTransferHoverEvent(float pointX, float pointY, int32_t sourceType, 68 int32_t eventType, int64_t timeMs) override; 69 void OnNotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override; 70 private: 71 std::weak_ptr<UIContent> uiContent_; 72 std::weak_ptr<FormRenderer> formRenderer_; 73 std::weak_ptr<OHOS::AppExecFwk::EventHandler> eventHandler_; 74 bool allowUpdate_ = true; 75 bool isVisible_ = true; 76 bool isMultiInstanceEnabled_ = false; 77 static std::recursive_mutex globalLock_; 78 void HandleSurfaceChangeEvent(const std::shared_ptr<UIContent>& uiContent, float width, float height, 79 uint32_t reason, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction, float borderWidth); 80 std::shared_ptr<Rosen::RSUIContext> GetRSUIContext(const std::shared_ptr<UIContent>& uiContent); 81 }; 82 } // namespace Ace 83 } // namespace OHOS 84 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DISPATCHER_IMPL_H 85