• 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 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 #include "core/accessibility/accessibility_manager.h"
21 
22 namespace OHOS {
23 namespace Ace {
24 /**
25  * @class FormRendererDelegate
26  * FormRendererDelegate interface is used to form renderer delegate.
27  */
28 class ACE_EXPORT FormRendererDelegateImpl : public FormRendererDelegateStub {
29 public:
30     FormRendererDelegateImpl() = default;
31     ~FormRendererDelegateImpl() override = default;
32     /**
33      * @brief OnSurfaceCreate.
34      * @param surfaceNode The surfaceNode.
35      * @param formJsInfo The formJsInfo.
36      * @param want The want.
37      */
38     int32_t OnSurfaceCreate(const std::shared_ptr<Rosen::RSSurfaceNode>& surfaceNode,
39         const OHOS::AppExecFwk::FormJsInfo& formJsInfo, const AAFwk::Want& want) override;
40     /**
41      * @brief OnActionEvent.
42      * @param action The action.
43      */
44     int32_t OnActionEvent(const std::string& action) override;
45     /**
46      * @brief OnError.
47      * @param code The code.
48      * @param msg The msg.
49      */
50     int32_t OnError(const std::string& code, const std::string& msg) override;
51     /**
52      * @brief OnSurfaceChange.
53      * @param width
54      * @param height
55      */
56     int32_t OnSurfaceChange(float width, float height, float borderWidth = 0.0) override;
57     /**
58      * @brief OnSurfaceDetach.
59      * @param surfaceId The surfaceNode ID.
60      */
61     int32_t OnSurfaceDetach(uint64_t surfaceId) override;
62 
63     int32_t OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos) override;
64 
65     int32_t OnGetRectRelativeToWindow(AccessibilityParentRectInfo& parentRectInfo) override;
66 
67     int32_t OnCheckManagerDelegate(bool &checkFlag) override;
68 
69     void SetSurfaceCreateEventHandler(std::function<void(const std::shared_ptr<Rosen::RSSurfaceNode>&,
70             const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>&& listener);
71     void SetActionEventHandler(std::function<void(const std::string&)>&& listener);
72     void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& listener);
73     void SetSurfaceChangeEventHandler(std::function<void(float width, float height, float borderWidth)>&& listener);
74     void SetSurfaceDetachEventHandler(std::function<void()>&& listener);
75     void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& listener);
76     void SetGetRectRelativeToWindowHandler(std::function<void(AccessibilityParentRectInfo& parentRectInfo)>&& listener);
77     void SetCheckManagerDelegate(std::function<void(bool&)>&& listener);
78 private:
79     std::function<void(
80         const std::shared_ptr<Rosen::RSSurfaceNode>&, const OHOS::AppExecFwk::FormJsInfo&, const AAFwk::Want&)>
81         surfaceCreateEventHandler_;
82     std::function<void(const std::string&)> actionEventHandler_;
83     std::function<void(const std::string&, const std::string&)> errorEventHandler_;
84     std::function<void(float width, float height, float borderWidth)> surfaceChangeEventHandler_;
85     std::function<void()> surfaceDetachEventHandler_;
86     std::function<void(const std::vector<std::string>&)> formLinkInfoUpdateHandler_;
87     std::function<void(AccessibilityParentRectInfo& parentRectInfo)> getRectRelativeToWindowHandler_;
88     std::function<void(bool&)> checkManagerDelegate_;
89 };
90 } // namespace Ace
91 } // namespace OHOS
92 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_DELEGATE_IMPL_H
93