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_DELEGATE_IMPL_H 17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H 18 19 #include "form_renderer_delegate_stub.h" 20 21 namespace OHOS { 22 namespace Ace { 23 /** 24 * @class FormRendererDelegate 25 * FormRendererDelegate interface is used to form renderer delegate. 26 */ 27 class ACE_EXPORT FormRendererDelegateImpl : public FormRendererDelegateStub { 28 public: 29 FormRendererDelegateImpl() = default; 30 ~FormRendererDelegateImpl() override = default; 31 /** 32 * @brief OnSurfaceCreate. 33 * @param surfaceNode The surfaceNode. 34 * @param formJsInfo The formJsInfo. 35 * @param want The want. 36 */ 37 int32_t OnSurfaceCreate( 38 const std::shared_ptr<Rosen::RSSurfaceNode>& surfaceNode, 39 const OHOS::AppExecFwk::FormJsInfo& formJsInfo, 40 const AAFwk::Want& want) override; 41 /** 42 * @brief OnActionEvent. 43 * @param action The action. 44 */ 45 int32_t OnActionEvent(const std::string& action) override; 46 /** 47 * @brief OnError. 48 * @param code The code. 49 * @param msg The msg. 50 */ 51 int32_t OnError(const std::string& code, const std::string& msg) override; 52 /** 53 * @brief OnSurfaceChange. 54 * @param width 55 * @param height 56 */ 57 int32_t OnSurfaceChange(float width, float height) override; 58 59 void SetSurfaceCreateEventHandler(std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&, 60 const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>&& listener); 61 void SetActionEventHandler(std::function<void(const std::string&)>&& listener); 62 void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& listener); 63 void SetSurfaceChangeEventHandler(std::function<void(float width, float height)>&& listener); 64 65 private: 66 std::function<void( 67 const std::shared_ptr<Rosen::RSSurfaceNode>&, const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)> 68 surfaceCreateEventHandler_; 69 std::function<void(const std::string&)> actionEventHandler_; 70 std::function<void(const std::string&, const std::string&)> errorEventHandler_; 71 std::function<void(float width, float height)> surfaceChangeEventHandler_; 72 }; 73 } // namespace Ace 74 } // namespace OHOS 75 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H 76