• 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 #include "form_renderer.h"
17 
18 #include "configuration.h"
19 #include "form_constants.h"
20 #include "form_renderer_hilog.h"
21 #include "event_handler.h"
22 #include "refbase.h"
23 
24 #include "base/utils/utils.h"
25 
26 namespace OHOS {
27 namespace Ace {
28 namespace {
29 constexpr char FORM_RENDERER_ALLOW_UPDATE[] = "allowUpdate";
30 constexpr char FORM_RENDERER_DISPATCHER[] = "ohos.extra.param.key.process_on_form_renderer_dispatcher";
31 constexpr char FORM_RENDERER_PROCESS_ON_ADD_SURFACE[] = "ohos.extra.param.key.process_on_add_surface";
32 constexpr char TRANSPARENT_COLOR[] = "#00FFFFFF";
33 constexpr int32_t DOUBLE = 2;
34 } // namespace
35 
36 using EventHandler = OHOS::AppExecFwk::EventHandler;
37 
FormRenderer(const std::shared_ptr<OHOS::AbilityRuntime::Context> context,const std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime,std::weak_ptr<OHOS::AppExecFwk::EventHandler> eventHandler)38 FormRenderer::FormRenderer(const std::shared_ptr<OHOS::AbilityRuntime::Context> context,
39     const std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime,
40     std::weak_ptr<OHOS::AppExecFwk::EventHandler> eventHandler)
41     : context_(context), runtime_(runtime), eventHandler_(eventHandler)
42 {
43     HILOG_INFO("FormRenderer created.");
44     if (!context_ || !runtime_) {
45         return;
46     }
47     auto& nativeEngine = (static_cast<AbilityRuntime::JsRuntime&>(*runtime_.get())).GetNativeEngine();
48     uiContent_ = UIContent::Create(context_.get(), &nativeEngine, true);
49 }
50 
~FormRenderer()51 FormRenderer::~FormRenderer()
52 {
53     HILOG_DEBUG("called");
54 }
55 
PreInitUIContent(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)56 void FormRenderer::PreInitUIContent(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
57 {
58     HILOG_INFO("InitUIContent width = %{public}f , height = %{public}f, borderWidth = %{public}f. \
59         formJsInfo.formData.size = %{public}zu. formJsInfo.imageDataMap.size = %{public}zu.",
60         width_, height_, borderWidth_,
61         formJsInfo.formData.size(),
62         formJsInfo.imageDataMap.size());
63     SetAllowUpdate(allowUpdate_);
64     uiContent_->SetFormWidth(width_ - borderWidth_ * DOUBLE);
65     uiContent_->SetFormHeight(height_ - borderWidth_ * DOUBLE);
66     lastBorderWidth_ = borderWidth_;
67     uiContent_->SetFontScaleFollowSystem(fontScaleFollowSystem_);
68     uiContent_->UpdateFormSharedImage(formJsInfo.imageDataMap);
69     uiContent_->UpdateFormData(formJsInfo.formData);
70     uiContent_->PreInitializeForm(nullptr, formJsInfo.formSrc, nullptr);
71     backgroundColor_ = want.GetStringParam(OHOS::AppExecFwk::Constants::PARAM_FORM_TRANSPARENCY_KEY);
72     if (!backgroundColor_.empty()) {
73         uiContent_->SetFormBackgroundColor(backgroundColor_);
74     }
75 }
76 
RunFormPageInner(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)77 void FormRenderer::RunFormPageInner(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
78 {
79     if (renderingMode_ == AppExecFwk::Constants::RenderingMode::SINGLE_COLOR) {
80         uiContent_->SetFormRenderingMode(static_cast<int8_t>(renderingMode_));
81     }
82     uiContent_->RunFormPage();
83     backgroundColor_ = want.GetStringParam(OHOS::AppExecFwk::Constants::PARAM_FORM_TRANSPARENCY_KEY);
84     if (!backgroundColor_.empty()) {
85         uiContent_->SetFormBackgroundColor(backgroundColor_);
86     }
87 
88     auto actionEventHandler = [weak = weak_from_this()](const std::string& action) {
89         auto formRenderer = weak.lock();
90         if (formRenderer) {
91             formRenderer->OnActionEvent(action);
92         }
93     };
94     uiContent_->SetActionEventHandler(actionEventHandler);
95 
96     auto errorEventHandler = [weak = weak_from_this()](const std::string& code, const std::string& msg) {
97         auto formRenderer = weak.lock();
98         if (formRenderer) {
99             formRenderer->OnError(code, msg);
100         }
101     };
102     uiContent_->SetErrorEventHandler(errorEventHandler);
103 
104     if (!formJsInfo.isDynamic) {
105         auto formLinkInfoUpdateHandler = [weak = weak_from_this()](const std::vector<std::string>& formLinkInfos) {
106             auto formRenderer = weak.lock();
107             if (formRenderer) {
108                 formRenderer->OnFormLinkInfoUpdate(formLinkInfos);
109             }
110         };
111         uiContent_->SetFormLinkInfoUpdateHandler(formLinkInfoUpdateHandler);
112     }
113 
114     auto rsSurfaceNode = uiContent_->GetFormRootNode();
115     if (rsSurfaceNode == nullptr) {
116         return;
117     }
118     rsSurfaceNode->SetBounds(round(borderWidth_), round(borderWidth_), round(width_ - borderWidth_ * DOUBLE),
119         round(height_ - borderWidth_ * DOUBLE));
120     if (renderingMode_ == AppExecFwk::Constants::RenderingMode::SINGLE_COLOR) {
121         HILOG_INFO("InitUIContent SetFormBackgroundColor #00FFFFFF");
122         uiContent_->SetFormBackgroundColor(TRANSPARENT_COLOR);
123     }
124     HILOG_INFO("ChangeSensitiveNodes: %{public}s", obscurationMode_ ? "true" : "false");
125     uiContent_->ChangeSensitiveNodes(obscurationMode_);
126     uiContent_->Foreground();
127 }
128 
InitUIContent(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)129 void FormRenderer::InitUIContent(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
130 {
131     PreInitUIContent(want, formJsInfo);
132     RunFormPageInner(want, formJsInfo);
133 }
134 
ParseWant(const OHOS::AAFwk::Want & want)135 void FormRenderer::ParseWant(const OHOS::AAFwk::Want& want)
136 {
137     allowUpdate_ = want.GetBoolParam(FORM_RENDERER_ALLOW_UPDATE, true);
138     width_ = want.GetDoubleParam(OHOS::AppExecFwk::Constants::PARAM_FORM_WIDTH_KEY, 0.0f);
139     height_ = want.GetDoubleParam(OHOS::AppExecFwk::Constants::PARAM_FORM_HEIGHT_KEY, 0.0f);
140     proxy_ = want.GetRemoteObject(FORM_RENDERER_PROCESS_ON_ADD_SURFACE);
141     renderingMode_ = (AppExecFwk::Constants::RenderingMode)want.GetIntParam(
142         OHOS::AppExecFwk::Constants::PARAM_FORM_RENDERINGMODE_KEY, 0);
143     borderWidth_ = want.GetFloatParam(OHOS::AppExecFwk::Constants::PARAM_FORM_BORDER_WIDTH_KEY, 0.0f);
144     fontScaleFollowSystem_ = want.GetBoolParam(OHOS::AppExecFwk::Constants::PARAM_FONT_FOLLOW_SYSTEM_KEY, true);
145     obscurationMode_ = want.GetBoolParam(OHOS::AppExecFwk::Constants::PARAM_FORM_OBSCURED_KEY, false);
146 }
147 
AddForm(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)148 void FormRenderer::AddForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
149 {
150     if (uiContent_ == nullptr) {
151         HILOG_ERROR("uiContent is null!");
152         return;
153     }
154     formRendererDispatcherImpl_ = new FormRendererDispatcherImpl(uiContent_, shared_from_this(), eventHandler_);
155     ParseWant(want);
156     InitUIContent(want, formJsInfo);
157     SetRenderDelegate(proxy_);
158     if (want.HasParameter(OHOS::AppExecFwk::Constants::FORM_STATUS_DATA)) {
159         std::string statusData = want.GetStringParam(OHOS::AppExecFwk::Constants::FORM_STATUS_DATA);
160         RecoverForm(statusData);
161     }
162     OnSurfaceCreate(formJsInfo, want.GetBoolParam(
163         OHOS::AppExecFwk::Constants::FORM_IS_RECOVER_FORM_TO_HANDLE_CLICK_EVENT, false));
164 }
165 
PreInitAddForm(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)166 void FormRenderer::PreInitAddForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
167 {
168     if (uiContent_ == nullptr) {
169         HILOG_ERROR("uiContent is null!");
170         return;
171     }
172     formRendererDispatcherImpl_ = new FormRendererDispatcherImpl(uiContent_, shared_from_this(), eventHandler_);
173     ParseWant(want);
174     PreInitUIContent(want, formJsInfo);
175 }
176 
RunFormPage(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)177 void FormRenderer::RunFormPage(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
178 {
179     if (uiContent_ == nullptr) {
180         HILOG_ERROR("uiContent is null!");
181         return;
182     }
183     ParseWant(want);
184     RunFormPageInner(want, formJsInfo);
185     SetRenderDelegate(proxy_);
186     if (want.HasParameter(OHOS::AppExecFwk::Constants::FORM_STATUS_DATA)) {
187         std::string statusData = want.GetStringParam(OHOS::AppExecFwk::Constants::FORM_STATUS_DATA);
188         RecoverForm(statusData);
189     }
190     OnSurfaceCreate(formJsInfo, want.GetBoolParam(
191         OHOS::AppExecFwk::Constants::FORM_IS_RECOVER_FORM_TO_HANDLE_CLICK_EVENT, false));
192 }
193 
ReloadForm(const std::string & url)194 void FormRenderer::ReloadForm(const std::string& url)
195 {
196     if (!uiContent_) {
197         HILOG_ERROR("uiContent_ is null");
198         return;
199     }
200     uiContent_->ReloadForm(url);
201 }
202 
IsAllowUpdate()203 bool FormRenderer::IsAllowUpdate()
204 {
205     if (formRendererDispatcherImpl_ == nullptr) {
206         HILOG_ERROR("formRendererDispatcherImpl is null");
207         return true;
208     }
209 
210     return formRendererDispatcherImpl_->IsAllowUpdate();
211 }
212 
SetAllowUpdate(bool allowUpdate)213 void FormRenderer::SetAllowUpdate(bool allowUpdate)
214 {
215     if (formRendererDispatcherImpl_ == nullptr) {
216         HILOG_ERROR("formRendererDispatcherImpl is null");
217         return;
218     }
219 
220     formRendererDispatcherImpl_->SetAllowUpdate(allowUpdate);
221 }
222 
UpdateForm(const OHOS::AppExecFwk::FormJsInfo & formJsInfo)223 void FormRenderer::UpdateForm(const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
224 {
225     HILOG_INFO("FormRender UpdateForm start.");
226     if (!IsAllowUpdate()) {
227         HILOG_ERROR("Not allow update");
228         return;
229     }
230     if (!uiContent_) {
231         HILOG_ERROR("uiContent_ is null");
232         return;
233     }
234     uiContent_->SetFontScaleFollowSystem(fontScaleFollowSystem_);
235     uiContent_->UpdateFormSharedImage(formJsInfo.imageDataMap);
236     uiContent_->UpdateFormData(formJsInfo.formData);
237     HILOG_INFO("FormRender UpdateForm end. formJsInfo.formData.size = %{public}zu. \
238         formJsInfo.imageDataMap.size = %{public}zu.",
239         formJsInfo.formData.size(),
240         formJsInfo.imageDataMap.size());
241 }
242 
Destroy()243 void FormRenderer::Destroy()
244 {
245     HILOG_INFO("Destroy FormRenderer start.");
246     if (formRendererDelegate_ != nullptr) {
247         auto rsSurfaceNode = uiContent_->GetFormRootNode();
248         if (rsSurfaceNode != nullptr) {
249             HILOG_INFO("Form OnSurfaceRelease!");
250             formRendererDelegate_->OnSurfaceRelease(rsSurfaceNode->GetId());
251         }
252     }
253 
254     if (formRendererDelegate_ != nullptr && formRendererDelegate_->AsObject() != nullptr) {
255         formRendererDelegate_->AsObject()->RemoveDeathRecipient(renderDelegateDeathRecipient_);
256     }
257     renderDelegateDeathRecipient_ = nullptr;
258     formRendererDelegate_ = nullptr;
259     formRendererDispatcherImpl_ = nullptr;
260     if (uiContent_) {
261         uiContent_->Destroy();
262         uiContent_ = nullptr;
263     }
264     context_ = nullptr;
265     runtime_ = nullptr;
266     HILOG_INFO("Destroy FormRenderer finish.");
267 }
268 
OnSurfaceChange(float width,float height,float borderWidth)269 void FormRenderer::OnSurfaceChange(float width, float height, float borderWidth)
270 {
271     if (!formRendererDelegate_) {
272         HILOG_ERROR("form renderer delegate is null!");
273         return;
274     }
275     HILOG_INFO("Form OnSurfaceChange!");
276     formRendererDelegate_->OnSurfaceChange(width, height, borderWidth);
277     width_ = width;
278     height_ = height;
279     borderWidth_ = borderWidth;
280 }
281 
OnSurfaceCreate(const OHOS::AppExecFwk::FormJsInfo & formJsInfo,bool isRecoverFormToHandleClickEvent)282 void FormRenderer::OnSurfaceCreate(const OHOS::AppExecFwk::FormJsInfo& formJsInfo,
283     bool isRecoverFormToHandleClickEvent)
284 {
285     if (!formRendererDispatcherImpl_) {
286         HILOG_ERROR("form renderer dispatcher is null!");
287         return;
288     }
289     if (!formRendererDelegate_) {
290         HILOG_ERROR("form renderer delegate is null!");
291         return;
292     }
293     OHOS::AAFwk::Want newWant;
294     newWant.SetParam(FORM_RENDERER_DISPATCHER, formRendererDispatcherImpl_->AsObject());
295     newWant.SetParam(OHOS::AppExecFwk::Constants::FORM_IS_RECOVER_FORM_TO_HANDLE_CLICK_EVENT,
296         isRecoverFormToHandleClickEvent);
297     auto rsSurfaceNode = uiContent_->GetFormRootNode();
298     HILOG_INFO("Form OnSurfaceCreate!");
299     formRendererDelegate_->OnSurfaceCreate(rsSurfaceNode, formJsInfo, newWant);
300 }
301 
OnSurfaceReuse(const OHOS::AppExecFwk::FormJsInfo & formJsInfo)302 void FormRenderer::OnSurfaceReuse(const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
303 {
304     if (!formRendererDispatcherImpl_) {
305         HILOG_ERROR("form renderer dispatcher is null!");
306         return;
307     }
308     if (!formRendererDelegate_) {
309         HILOG_ERROR("form renderer delegate is null!");
310         return;
311     }
312     auto rsSurfaceNode = uiContent_->GetFormRootNode();
313     if (rsSurfaceNode == nullptr) {
314         HILOG_ERROR("form renderer rsSurfaceNode is null!");
315         return;
316     }
317     OHOS::AAFwk::Want newWant;
318     newWant.SetParam(FORM_RENDERER_DISPATCHER, formRendererDispatcherImpl_->AsObject());
319     HILOG_INFO("Form OnSurfaceReuse.");
320     formRendererDelegate_->OnSurfaceReuse(rsSurfaceNode->GetId(), formJsInfo, newWant);
321     formRendererDelegate_->OnFormLinkInfoUpdate(cachedInfos_);
322 }
323 
OnSurfaceDetach()324 void FormRenderer::OnSurfaceDetach()
325 {
326     if (!formRendererDelegate_) {
327         HILOG_ERROR("form renderer delegate is null!");
328         return;
329     }
330     auto rsSurfaceNode = uiContent_->GetFormRootNode();
331     if (rsSurfaceNode == nullptr) {
332         HILOG_ERROR("form renderer rsSurfaceNode is null!");
333         return;
334     }
335     HILOG_INFO("Form OnSurfaceDetach.");
336     formRendererDelegate_->OnSurfaceDetach(rsSurfaceNode->GetId());
337 }
338 
OnActionEvent(const std::string & action)339 void FormRenderer::OnActionEvent(const std::string& action)
340 {
341     if (!formRendererDelegate_) {
342         HILOG_ERROR("formRendererDelegate is null!");
343         return;
344     }
345 
346     formRendererDelegate_->OnActionEvent(action);
347 }
348 
OnError(const std::string & code,const std::string & msg)349 void FormRenderer::OnError(const std::string& code, const std::string& msg)
350 {
351     if (!formRendererDelegate_) {
352         HILOG_ERROR("formRendererDelegate is null!");
353         return;
354     }
355 
356     formRendererDelegate_->OnError(code, msg);
357 }
358 
OnFormLinkInfoUpdate(const std::vector<std::string> & formLinkInfos)359 void FormRenderer::OnFormLinkInfoUpdate(const std::vector<std::string>& formLinkInfos)
360 {
361     if (!formRendererDelegate_) {
362         HILOG_ERROR("formRendererDelegate is null!");
363         return;
364     }
365     cachedInfos_ = formLinkInfos;
366     formRendererDelegate_->OnFormLinkInfoUpdate(formLinkInfos);
367 }
368 
SetRenderDelegate(const sptr<IRemoteObject> & remoteObj)369 void FormRenderer::SetRenderDelegate(const sptr<IRemoteObject>& remoteObj)
370 {
371     HILOG_INFO("Get renderRemoteObj, add death recipient.");
372     auto renderRemoteObj = iface_cast<IFormRendererDelegate>(remoteObj);
373     if (renderRemoteObj == nullptr) {
374         HILOG_ERROR("renderRemoteObj is nullptr.");
375         return;
376     }
377 
378     formRendererDelegate_ = renderRemoteObj;
379 
380     if (renderDelegateDeathRecipient_ == nullptr) {
381         renderDelegateDeathRecipient_ = new FormRenderDelegateRecipient(
382             [eventHandler = eventHandler_, renderer = weak_from_this()]() {
383                 auto handler = eventHandler.lock();
384                 if (!handler) {
385                     HILOG_ERROR("eventHandler is nullptr");
386                     return;
387                 }
388 
389                 handler->PostTask([weak = renderer]() {
390                     auto formRender = weak.lock();
391                     if (!formRender) {
392                         HILOG_ERROR("formRender is nullptr");
393                         return;
394                     }
395                     formRender->ResetRenderDelegate();
396                 });
397             });
398     }
399     auto renderDelegate = formRendererDelegate_->AsObject();
400     if (renderDelegate == nullptr) {
401         HILOG_ERROR("renderDelegate is nullptr, can not get obj from renderRemoteObj.");
402         return;
403     }
404     renderDelegate->AddDeathRecipient(renderDelegateDeathRecipient_);
405 }
406 
ResetRenderDelegate()407 void FormRenderer::ResetRenderDelegate()
408 {
409     HILOG_INFO("ResetRenderDelegate.");
410     formRendererDelegate_ = nullptr;
411 }
412 
UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration> & config)413 void FormRenderer::UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config)
414 {
415     if (!uiContent_) {
416         HILOG_ERROR("uiContent_ is null");
417         return;
418     }
419 
420     uiContent_->UpdateConfiguration(config);
421 }
422 
OnRemoteDied(const wptr<IRemoteObject> & remote)423 void FormRenderDelegateRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
424 {
425     HILOG_ERROR("Recv FormRenderDelegate death notice");
426     if (remote == nullptr) {
427         HILOG_ERROR("weak remote is null");
428         return;
429     }
430     if (handler_) {
431         handler_();
432     }
433 }
434 
AttachForm(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)435 void FormRenderer::AttachForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
436 {
437     if (uiContent_ == nullptr) {
438         HILOG_ERROR("uiContent is null!");
439         return;
440     }
441     ParseWant(want);
442     OnSurfaceDetach();
443     AttachUIContent(want, formJsInfo);
444     SetRenderDelegate(proxy_);
445     OnSurfaceReuse(formJsInfo);
446 }
447 
AttachUIContent(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::FormJsInfo & formJsInfo)448 void FormRenderer::AttachUIContent(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo)
449 {
450     HILOG_INFO("AttachUIContent width = %{public}f , height = %{public}f, borderWidth_ = %{public}f.",
451         width_, height_, borderWidth_);
452     SetAllowUpdate(allowUpdate_);
453     auto rsSurfaceNode = uiContent_->GetFormRootNode();
454     if (rsSurfaceNode == nullptr) {
455         HILOG_ERROR("rsSurfaceNode is nullptr.");
456         return;
457     }
458     float width = width_ - borderWidth_ * DOUBLE;
459     float height = height_ - borderWidth_ * DOUBLE;
460     if (!NearEqual(width, uiContent_->GetFormWidth()) || !NearEqual(height, uiContent_->GetFormHeight())
461         || !NearEqual(borderWidth_, lastBorderWidth_)) {
462         uiContent_->SetFormWidth(width);
463         uiContent_->SetFormHeight(height);
464         lastBorderWidth_ = borderWidth_;
465         uiContent_->OnFormSurfaceChange(width, height);
466         rsSurfaceNode->SetBounds(borderWidth_, borderWidth_, width, height);
467     }
468     auto backgroundColor = want.GetStringParam(OHOS::AppExecFwk::Constants::PARAM_FORM_TRANSPARENCY_KEY);
469     if (backgroundColor_ != backgroundColor) {
470         backgroundColor_ = backgroundColor;
471         uiContent_->SetFormBackgroundColor(backgroundColor_);
472     }
473     if (renderingMode_ == AppExecFwk::Constants::RenderingMode::SINGLE_COLOR) {
474         HILOG_INFO("AttachUIContent SetFormBackgroundColor #00FFFFFF");
475         uiContent_->SetFormBackgroundColor(TRANSPARENT_COLOR);
476     }
477 
478     uiContent_->Foreground();
479 }
480 
GetRectRelativeToWindow(int32_t & top,int32_t & left) const481 void FormRenderer::GetRectRelativeToWindow(int32_t &top, int32_t &left) const
482 {
483     if (!formRendererDelegate_) {
484         HILOG_ERROR("form renderer delegate is null!");
485         return;
486     }
487     formRendererDelegate_->OnGetRectRelativeToWindow(top, left);
488 }
489 
RecycleForm(std::string & statusData)490 void FormRenderer::RecycleForm(std::string& statusData)
491 {
492     if (uiContent_ == nullptr) {
493         HILOG_ERROR("RecycleForm, uiContent_ is null!");
494         return;
495     }
496     statusData = uiContent_->RecycleForm();
497 }
498 
RecoverForm(const std::string & statusData)499 void FormRenderer::RecoverForm(const std::string& statusData)
500 {
501     if (uiContent_ == nullptr) {
502         HILOG_ERROR("RecoverForm, uiContent_ is null!");
503         return;
504     }
505     uiContent_->RecoverForm(statusData);
506 }
507 
SetVisibleChange(bool isVisible)508 void FormRenderer::SetVisibleChange(bool isVisible)
509 {
510     if (uiContent_ == nullptr) {
511         HILOG_ERROR("SetVisibleChange error, uiContent_ is null!");
512         return;
513     }
514     uiContent_->ProcessFormVisibleChange(isVisible);
515 }
516 } // namespace Ace
517 } // namespace OHOS
518