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 #include "form_renderer_dispatcher_impl.h"
16
17 #include "form_renderer.h"
18 #include "form_renderer_hilog.h"
19
20 namespace OHOS {
21 namespace Ace {
FormRendererDispatcherImpl(const std::shared_ptr<UIContent> uiContent,const std::shared_ptr<FormRenderer> formRenderer)22 FormRendererDispatcherImpl::FormRendererDispatcherImpl(
23 const std::shared_ptr<UIContent> uiContent, const std::shared_ptr<FormRenderer> formRenderer)
24 : uiContent_(uiContent), formRenderer_(formRenderer)
25 {}
26
DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent> & pointerEvent)27 void FormRendererDispatcherImpl::DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent)
28 {
29 auto uiContent = uiContent_.lock();
30 if (!uiContent) {
31 HILOG_ERROR("uiContent is nullptr");
32 return;
33 }
34
35 uiContent->ProcessPointerEvent(pointerEvent);
36 }
37
IsAllowUpdate()38 bool FormRendererDispatcherImpl::IsAllowUpdate()
39 {
40 return allowUpdate_;
41 }
42
SetAllowUpdate(bool allowUpdate)43 void FormRendererDispatcherImpl::SetAllowUpdate(bool allowUpdate)
44 {
45 allowUpdate_ = allowUpdate;
46 }
47
DispatchSurfaceChangeEvent(float width,float height)48 void FormRendererDispatcherImpl::DispatchSurfaceChangeEvent(float width, float height)
49 {
50 auto uiContent = uiContent_.lock();
51 if (!uiContent) {
52 HILOG_ERROR("uiContent is nullptr");
53 return;
54 }
55 uiContent->SetFormWidth(width);
56 uiContent->SetFormHeight(height);
57 uiContent->OnFormSurfaceChange(width, height);
58
59 auto formRenderer = formRenderer_.lock();
60 if (!formRenderer) {
61 HILOG_ERROR("formRenderer is nullptr");
62 return;
63 }
64 formRenderer->OnSurfaceChange(width, height);
65 }
66 } // namespace Ace
67 } // namespace OHOS
68