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