• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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 "core/components_ng/base/view_abstract.h"
17 #include <cstdint>
18 #include <functional>
19 #include <unordered_map>
20 #include "core/components_ng/pattern/overlay/overlay_manager.h"
21 
22 #include "interfaces/inner_api/ui_session/ui_session_manager.h"
23 
24 #include "base/error/error_code.h"
25 #include "base/subwindow/subwindow.h"
26 #include "base/utils/system_properties.h"
27 #include "base/utils/utils.h"
28 #include "core/common/ace_engine.h"
29 #include "core/common/container.h"
30 #include "core/common/container_scope.h"
31 #include "core/components/common/layout/constants.h"
32 #include "core/components/common/properties/shadow.h"
33 #include "core/components/theme/shadow_theme.h"
34 #include "core/components_ng/base/frame_node.h"
35 #include "core/components_ng/base/view_stack_processor.h"
36 #include "core/components_ng/layout/layout_property.h"
37 #include "core/components_ng/pattern/bubble/bubble_pattern.h"
38 #include "core/components_ng/pattern/bubble/bubble_view.h"
39 #include "core/components_ng/pattern/dialog/dialog_pattern.h"
40 #include "core/components_ng/pattern/menu/menu_view.h"
41 #include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
42 #include "core/components_ng/pattern/overlay/dialog_manager.h"
43 #include "core/components_ng/pattern/stack/stack_pattern.h"
44 
45 namespace OHOS::Ace::NG {
46 
SetWidth(const CalcLength & width)47 void ViewAbstract::SetWidth(const CalcLength& width)
48 {
49     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
50         return;
51     }
52     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
53     CHECK_NULL_VOID(frameNode);
54     auto layoutProperty = frameNode->GetLayoutProperty();
55     CHECK_NULL_VOID(layoutProperty);
56     // get previously user defined ideal height
57     std::optional<CalcLength> height = std::nullopt;
58     auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
59     if (layoutConstraint && layoutConstraint->selfIdealSize) {
60         height = layoutConstraint->selfIdealSize->Height();
61     }
62     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
63 }
64 
SetHeight(const CalcLength & height)65 void ViewAbstract::SetHeight(const CalcLength& height)
66 {
67     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
68         return;
69     }
70     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
71     CHECK_NULL_VOID(frameNode);
72     auto layoutProperty = frameNode->GetLayoutProperty();
73     CHECK_NULL_VOID(layoutProperty);
74     // get previously user defined ideal width
75     std::optional<CalcLength> width = std::nullopt;
76     auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
77     if (layoutConstraint && layoutConstraint->selfIdealSize) {
78         width = layoutConstraint->selfIdealSize->Width();
79     }
80     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
81 }
82 
SetClickEffectLevel(const ClickEffectLevel & level,float scaleValue)83 void ViewAbstract::SetClickEffectLevel(const ClickEffectLevel& level, float scaleValue)
84 {
85     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
86         return;
87     }
88     ClickEffectInfo clickEffectInfo;
89     clickEffectInfo.level = level;
90     clickEffectInfo.scaleNumber = scaleValue;
91     ACE_UPDATE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo);
92 }
93 
ClearWidthOrHeight(bool isWidth)94 void ViewAbstract::ClearWidthOrHeight(bool isWidth)
95 {
96     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
97         return;
98     }
99     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
100     CHECK_NULL_VOID(frameNode);
101     auto layoutProperty = frameNode->GetLayoutProperty();
102     CHECK_NULL_VOID(layoutProperty);
103     layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
104 }
105 
SetMinWidth(const CalcLength & width)106 void ViewAbstract::SetMinWidth(const CalcLength& width)
107 {
108     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
109         return;
110     }
111     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
112     CHECK_NULL_VOID(frameNode);
113     auto layoutProperty = frameNode->GetLayoutProperty();
114     CHECK_NULL_VOID(layoutProperty);
115     layoutProperty->UpdateCalcMinSize(CalcSize(width, std::nullopt));
116 }
117 
SetMinHeight(const CalcLength & height)118 void ViewAbstract::SetMinHeight(const CalcLength& height)
119 {
120     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
121         return;
122     }
123     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
124     CHECK_NULL_VOID(frameNode);
125     auto layoutProperty = frameNode->GetLayoutProperty();
126     CHECK_NULL_VOID(layoutProperty);
127     layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, height));
128 }
129 
ResetMinSize(bool resetWidth)130 void ViewAbstract::ResetMinSize(bool resetWidth)
131 {
132     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
133         return;
134     }
135     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
136     CHECK_NULL_VOID(frameNode);
137     auto layoutProperty = frameNode->GetLayoutProperty();
138     CHECK_NULL_VOID(layoutProperty);
139     layoutProperty->ResetCalcMinSize(resetWidth);
140 }
141 
SetMaxWidth(const CalcLength & width)142 void ViewAbstract::SetMaxWidth(const CalcLength& width)
143 {
144     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
145         return;
146     }
147     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
148     CHECK_NULL_VOID(frameNode);
149     auto layoutProperty = frameNode->GetLayoutProperty();
150     CHECK_NULL_VOID(layoutProperty);
151     layoutProperty->UpdateCalcMaxSize(CalcSize(width, std::nullopt));
152 }
153 
SetMaxHeight(const CalcLength & height)154 void ViewAbstract::SetMaxHeight(const CalcLength& height)
155 {
156     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
157         return;
158     }
159     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
160     CHECK_NULL_VOID(frameNode);
161     auto layoutProperty = frameNode->GetLayoutProperty();
162     CHECK_NULL_VOID(layoutProperty);
163     layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, height));
164 }
165 
ResetMaxSize(bool resetWidth)166 void ViewAbstract::ResetMaxSize(bool resetWidth)
167 {
168     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
169         return;
170     }
171     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
172     CHECK_NULL_VOID(frameNode);
173     auto layoutProperty = frameNode->GetLayoutProperty();
174     CHECK_NULL_VOID(layoutProperty);
175     layoutProperty->ResetCalcMaxSize(resetWidth);
176 }
177 
SetAspectRatio(float ratio)178 void ViewAbstract::SetAspectRatio(float ratio)
179 {
180     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
181         return;
182     }
183     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio);
184 }
185 
ResetAspectRatio()186 void ViewAbstract::ResetAspectRatio()
187 {
188     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
189         return;
190     }
191     ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, AspectRatio);
192 }
193 
SetBackgroundAlign(const Alignment & align)194 void ViewAbstract::SetBackgroundAlign(const Alignment& align)
195 {
196     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
197         return;
198     }
199     ACE_UPDATE_RENDER_CONTEXT(BackgroundAlign, align);
200 }
201 
SetBackgroundColor(const Color & color)202 void ViewAbstract::SetBackgroundColor(const Color& color)
203 {
204     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
205         return;
206     }
207 
208     Color updateColor = color;
209     auto pipeline = PipelineContext::GetCurrentContext();
210     if (pipeline != nullptr) {
211         pipeline->CheckNeedUpdateBackgroundColor(updateColor);
212     }
213 
214     ACE_UPDATE_RENDER_CONTEXT(BackgroundColor, updateColor);
215 }
216 
SetBackgroundColor(FrameNode * frameNode,const Color & color)217 void ViewAbstract::SetBackgroundColor(FrameNode* frameNode, const Color& color)
218 {
219     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundColor, color, frameNode);
220 }
221 
SetBackgroundImage(const ImageSourceInfo & src)222 void ViewAbstract::SetBackgroundImage(const ImageSourceInfo& src)
223 {
224     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
225         return;
226     }
227     auto pipeline = PipelineContext::GetCurrentContext();
228     if (pipeline != nullptr) {
229         bool disableSetImage = pipeline->CheckNeedDisableUpdateBackgroundImage();
230         if (disableSetImage) {
231             return;
232         }
233     }
234     ACE_UPDATE_RENDER_CONTEXT(BackgroundImage, src);
235 }
236 
SetBackgroundImage(FrameNode * frameNode,const ImageSourceInfo & src)237 void ViewAbstract::SetBackgroundImage(FrameNode* frameNode, const ImageSourceInfo& src)
238 {
239     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImage, src, frameNode);
240 }
241 
SetBackgroundImageRepeat(const ImageRepeat & imageRepeat)242 void ViewAbstract::SetBackgroundImageRepeat(const ImageRepeat& imageRepeat)
243 {
244     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
245         return;
246     }
247     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat);
248 }
249 
SetBackgroundImageRepeat(FrameNode * frameNode,const ImageRepeat & imageRepeat)250 void ViewAbstract::SetBackgroundImageRepeat(FrameNode* frameNode, const ImageRepeat& imageRepeat)
251 {
252     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat, frameNode);
253 }
254 
SetBackgroundImageSyncMode(bool syncMode)255 void ViewAbstract::SetBackgroundImageSyncMode(bool syncMode)
256 {
257     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageSyncMode, syncMode);
258 }
259 
SetBackgroundImageSyncMode(FrameNode * frameNode,bool syncMode)260 void ViewAbstract::SetBackgroundImageSyncMode(FrameNode* frameNode, bool syncMode)
261 {
262     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageSyncMode, syncMode, frameNode);
263 }
264 
SetBackgroundImageSize(const BackgroundImageSize & bgImgSize)265 void ViewAbstract::SetBackgroundImageSize(const BackgroundImageSize& bgImgSize)
266 {
267     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
268         return;
269     }
270     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize);
271 }
272 
SetBackgroundImageSize(FrameNode * frameNode,const BackgroundImageSize & bgImgSize)273 void ViewAbstract::SetBackgroundImageSize(FrameNode* frameNode, const BackgroundImageSize& bgImgSize)
274 {
275     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize, frameNode);
276 }
277 
SetBackgroundImagePosition(const BackgroundImagePosition & bgImgPosition)278 void ViewAbstract::SetBackgroundImagePosition(const BackgroundImagePosition& bgImgPosition)
279 {
280     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
281         return;
282     }
283     ACE_UPDATE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition);
284 }
285 
SetBackgroundImagePosition(FrameNode * frameNode,const BackgroundImagePosition & bgImgPosition)286 void ViewAbstract::SetBackgroundImagePosition(FrameNode* frameNode, const BackgroundImagePosition& bgImgPosition)
287 {
288     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition, frameNode);
289 }
290 
SetBackgroundBlurStyle(const BlurStyleOption & bgBlurStyle,const SysOptions & sysOptions)291 void ViewAbstract::SetBackgroundBlurStyle(const BlurStyleOption& bgBlurStyle, const SysOptions& sysOptions)
292 {
293     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
294         return;
295     }
296     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
297     CHECK_NULL_VOID(frameNode);
298     SetBackgroundBlurStyle(frameNode, bgBlurStyle, sysOptions);
299 }
300 
SetForegroundEffect(float radius,const SysOptions & sysOptions)301 void ViewAbstract::SetForegroundEffect(float radius, const SysOptions& sysOptions)
302 {
303     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
304         return;
305     }
306     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
307     CHECK_NULL_VOID(frameNode);
308     auto target = frameNode->GetRenderContext();
309     if (target) {
310         target->UpdateForegroundEffect(radius);
311         target->UpdateForegroundEffectDisableSystemAdaptation(sysOptions);
312     }
313 }
314 
SetMotionBlur(const MotionBlurOption & motionBlurOption)315 void ViewAbstract::SetMotionBlur(const MotionBlurOption &motionBlurOption)
316 {
317     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
318         return;
319     }
320     ACE_UPDATE_RENDER_CONTEXT(MotionBlur, motionBlurOption);
321 }
322 
SetBackgroundEffect(const EffectOption & effectOption,const SysOptions & sysOptions)323 void ViewAbstract::SetBackgroundEffect(const EffectOption& effectOption, const SysOptions& sysOptions)
324 {
325     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
326         return;
327     }
328     SetBackgroundEffect(ViewStackProcessor::GetInstance()->GetMainFrameNode(), effectOption, sysOptions);
329 }
330 
SetForegroundBlurStyle(const BlurStyleOption & fgBlurStyle,const SysOptions & sysOptions)331 void ViewAbstract::SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle, const SysOptions& sysOptions)
332 {
333     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
334         return;
335     }
336     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
337     CHECK_NULL_VOID(frameNode);
338     auto target = frameNode->GetRenderContext();
339     if (target) {
340         target->UpdateFrontBlurStyle(fgBlurStyle, sysOptions);
341         if (target->GetFrontBlurRadius().has_value()) {
342             target->UpdateFrontBlurRadius(Dimension());
343         }
344     }
345 }
346 
SetSphericalEffect(double radio)347 void ViewAbstract::SetSphericalEffect(double radio)
348 {
349     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
350         return;
351     }
352     ACE_UPDATE_RENDER_CONTEXT(SphericalEffect, radio);
353 }
354 
SetPixelStretchEffect(PixStretchEffectOption & option)355 void ViewAbstract::SetPixelStretchEffect(PixStretchEffectOption& option)
356 {
357     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
358         return;
359     }
360     ACE_UPDATE_RENDER_CONTEXT(PixelStretchEffect, option);
361 }
362 
SetLightUpEffect(double radio)363 void ViewAbstract::SetLightUpEffect(double radio)
364 {
365     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
366         return;
367     }
368     ACE_UPDATE_RENDER_CONTEXT(LightUpEffect, radio);
369 }
370 
SetLayoutWeight(float value)371 void ViewAbstract::SetLayoutWeight(float value)
372 {
373     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
374         return;
375     }
376     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, static_cast<float>(value));
377 }
378 
SetChainWeight(const NG::ChainWeightPair & value)379 void ViewAbstract::SetChainWeight(const NG::ChainWeightPair& value)
380 {
381     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
382         return;
383     }
384     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, ChainWeight, value);
385 }
386 
SetPixelRound(uint16_t value)387 void ViewAbstract::SetPixelRound(uint16_t value)
388 {
389     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
390         return;
391     }
392     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, PixelRound, value);
393 }
394 
SetPixelRound(FrameNode * frameNode,uint16_t value)395 void ViewAbstract::SetPixelRound(FrameNode* frameNode, uint16_t value)
396 {
397     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, PixelRound, value, frameNode);
398 }
399 
SetLayoutDirection(TextDirection value)400 void ViewAbstract::SetLayoutDirection(TextDirection value)
401 {
402     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
403         return;
404     }
405     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value);
406 }
407 
SetAlignRules(const std::map<AlignDirection,AlignRule> & alignRules)408 void ViewAbstract::SetAlignRules(const std::map<AlignDirection, AlignRule>& alignRules)
409 {
410     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
411         return;
412     }
413     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules);
414 }
415 
SetChainStyle(const ChainInfo & chainInfo)416 void ViewAbstract::SetChainStyle(const ChainInfo& chainInfo)
417 {
418     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
419         return;
420     }
421     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, ChainStyle, chainInfo);
422 }
423 
SetBias(const BiasPair & biasPair)424 void ViewAbstract::SetBias(const BiasPair& biasPair)
425 {
426     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
427         return;
428     }
429     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Bias, biasPair);
430 }
431 
SetAlignSelf(FlexAlign value)432 void ViewAbstract::SetAlignSelf(FlexAlign value)
433 {
434     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
435         return;
436     }
437     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value);
438 }
439 
SetFlexShrink(float value)440 void ViewAbstract::SetFlexShrink(float value)
441 {
442     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
443         return;
444     }
445     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value);
446 }
447 
ResetFlexShrink()448 void ViewAbstract::ResetFlexShrink()
449 {
450     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
451         return;
452     }
453     ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, FlexShrink);
454 }
455 
SetFlexGrow(float value)456 void ViewAbstract::SetFlexGrow(float value)
457 {
458     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
459         return;
460     }
461     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value);
462 }
463 
SetFlexBasis(const Dimension & value)464 void ViewAbstract::SetFlexBasis(const Dimension& value)
465 {
466     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
467         return;
468     }
469     if (LessNotEqual(value.Value(), 0.0f)) {
470         ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension());
471         return;
472     }
473     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value);
474 }
475 
SetDisplayIndex(int32_t value)476 void ViewAbstract::SetDisplayIndex(int32_t value)
477 {
478     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
479         return;
480     }
481     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value);
482 }
483 
SetPadding(const CalcLength & value)484 void ViewAbstract::SetPadding(const CalcLength& value)
485 {
486     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
487         return;
488     }
489     PaddingProperty padding;
490     padding.SetEdges(value);
491     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding);
492 }
493 
SetPadding(const PaddingProperty & value)494 void ViewAbstract::SetPadding(const PaddingProperty& value)
495 {
496     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
497         return;
498     }
499     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, value);
500 }
501 
SetSafeAreaPadding(const CalcLength & value)502 void ViewAbstract::SetSafeAreaPadding(const CalcLength& value)
503 {
504     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
505         return;
506     }
507     PaddingProperty padding;
508     padding.SetEdges(value);
509     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, padding);
510 }
511 
SetSafeAreaPadding(const PaddingProperty & value)512 void ViewAbstract::SetSafeAreaPadding(const PaddingProperty& value)
513 {
514     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
515         return;
516     }
517     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, value);
518 }
519 
ResetSafeAreaPadding()520 void ViewAbstract::ResetSafeAreaPadding()
521 {
522     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
523         return;
524     }
525     ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding);
526 }
527 
SetSafeAreaPadding(FrameNode * frameNode,const CalcLength & value)528 void ViewAbstract::SetSafeAreaPadding(FrameNode* frameNode, const CalcLength& value)
529 {
530     CHECK_NULL_VOID(frameNode);
531     PaddingProperty padding;
532     padding.SetEdges(value);
533     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, padding, frameNode);
534 }
535 
SetSafeAreaPadding(FrameNode * frameNode,const PaddingProperty & value)536 void ViewAbstract::SetSafeAreaPadding(FrameNode* frameNode, const PaddingProperty& value)
537 {
538     CHECK_NULL_VOID(frameNode);
539     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, value, frameNode);
540 }
541 
ResetSafeAreaPadding(FrameNode * frameNode)542 void ViewAbstract::ResetSafeAreaPadding(FrameNode* frameNode)
543 {
544     CHECK_NULL_VOID(frameNode);
545     ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, frameNode);
546 }
547 
SetMargin(const CalcLength & value)548 void ViewAbstract::SetMargin(const CalcLength& value)
549 {
550     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
551         return;
552     }
553     MarginProperty margin;
554     margin.SetEdges(value);
555     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin);
556 }
557 
SetMargin(const MarginProperty & value)558 void ViewAbstract::SetMargin(const MarginProperty& value)
559 {
560     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
561         return;
562     }
563     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, value);
564 }
565 
SetBorderRadius(const Dimension & value)566 void ViewAbstract::SetBorderRadius(const Dimension& value)
567 {
568     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
569         return;
570     }
571     BorderRadiusProperty borderRadius;
572     borderRadius.SetRadius(value);
573     borderRadius.multiValued = false;
574     ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius);
575 }
576 
SetBorderRadius(const BorderRadiusProperty & value)577 void ViewAbstract::SetBorderRadius(const BorderRadiusProperty& value)
578 {
579     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
580         return;
581     }
582     ACE_UPDATE_RENDER_CONTEXT(BorderRadius, value);
583 }
584 
SetBorderColor(const Color & value)585 void ViewAbstract::SetBorderColor(const Color& value)
586 {
587     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
588         return;
589     }
590     BorderColorProperty borderColor;
591     borderColor.SetColor(value);
592     ACE_UPDATE_RENDER_CONTEXT(BorderColor, borderColor);
593 }
594 
SetBorderColor(const BorderColorProperty & value)595 void ViewAbstract::SetBorderColor(const BorderColorProperty& value)
596 {
597     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
598         return;
599     }
600     ACE_UPDATE_RENDER_CONTEXT(BorderColor, value);
601 }
602 
SetBorderWidth(const Dimension & value)603 void ViewAbstract::SetBorderWidth(const Dimension& value)
604 {
605     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
606         return;
607     }
608     BorderWidthProperty borderWidth;
609     if (Negative(value.Value())) {
610         borderWidth.SetBorderWidth(Dimension(0));
611     } else {
612         borderWidth.SetBorderWidth(value);
613     }
614     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth);
615     ACE_UPDATE_RENDER_CONTEXT(BorderWidth, borderWidth);
616 }
617 
SetBorderWidth(const BorderWidthProperty & value)618 void ViewAbstract::SetBorderWidth(const BorderWidthProperty& value)
619 {
620     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
621         return;
622     }
623     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value);
624     ACE_UPDATE_RENDER_CONTEXT(BorderWidth, value);
625 }
626 
SetBorderStyle(const BorderStyle & value)627 void ViewAbstract::SetBorderStyle(const BorderStyle& value)
628 {
629     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
630         return;
631     }
632     BorderStyleProperty borderStyle;
633     borderStyle.SetBorderStyle(value);
634     ACE_UPDATE_RENDER_CONTEXT(BorderStyle, borderStyle);
635 }
636 
SetBorderStyle(FrameNode * frameNode,const BorderStyle & value)637 void ViewAbstract::SetBorderStyle(FrameNode* frameNode, const BorderStyle& value)
638 {
639     BorderStyleProperty borderStyle;
640     borderStyle.SetBorderStyle(value);
641     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, borderStyle, frameNode);
642 }
643 
SetBorderStyle(const BorderStyleProperty & value)644 void ViewAbstract::SetBorderStyle(const BorderStyleProperty& value)
645 {
646     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
647         return;
648     }
649     ACE_UPDATE_RENDER_CONTEXT(BorderStyle, value);
650 }
651 
SetBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)652 void ViewAbstract::SetBorderStyle(FrameNode* frameNode, const BorderStyleProperty& value)
653 {
654     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, value, frameNode);
655 }
656 
SetDashGap(const Dimension & value)657 void ViewAbstract::SetDashGap(const Dimension& value)
658 {
659     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
660         return;
661     }
662     BorderWidthProperty dashGap;
663     dashGap.SetBorderWidth(value);
664 
665     ACE_UPDATE_RENDER_CONTEXT(DashGap, dashGap);
666 }
667 
SetDashGap(FrameNode * frameNode,const Dimension & value)668 void ViewAbstract::SetDashGap(FrameNode *frameNode, const Dimension& value)
669 {
670     BorderWidthProperty dashGap;
671     dashGap.SetBorderWidth(value);
672 
673     ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, dashGap, frameNode);
674 }
675 
SetDashGap(const BorderWidthProperty & value)676 void ViewAbstract::SetDashGap(const BorderWidthProperty& value)
677 {
678     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
679         return;
680     }
681     ACE_UPDATE_RENDER_CONTEXT(DashGap, value);
682 }
683 
SetDashGap(FrameNode * frameNode,const BorderWidthProperty & value)684 void ViewAbstract::SetDashGap(FrameNode *frameNode, const BorderWidthProperty& value)
685 {
686     ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, value, frameNode);
687 }
688 
SetDashWidth(const Dimension & value)689 void ViewAbstract::SetDashWidth(const Dimension& value)
690 {
691     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
692         return;
693     }
694     BorderWidthProperty dashWidth;
695     dashWidth.SetBorderWidth(value);
696 
697     ACE_UPDATE_RENDER_CONTEXT(DashWidth, dashWidth);
698 }
699 
SetDashWidth(FrameNode * frameNode,const Dimension & value)700 void ViewAbstract::SetDashWidth(FrameNode *frameNode, const Dimension& value)
701 {
702     BorderWidthProperty dashWidth;
703     dashWidth.SetBorderWidth(value);
704 
705     ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, dashWidth, frameNode);
706 }
707 
SetDashWidth(const BorderWidthProperty & value)708 void ViewAbstract::SetDashWidth(const BorderWidthProperty& value)
709 {
710     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
711         return;
712     }
713     ACE_UPDATE_RENDER_CONTEXT(DashWidth, value);
714 }
715 
SetDashWidth(FrameNode * frameNode,const BorderWidthProperty & value)716 void ViewAbstract::SetDashWidth(FrameNode *frameNode, const BorderWidthProperty& value)
717 {
718     ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, value, frameNode);
719 }
720 
SetOuterBorderRadius(const Dimension & value)721 void ViewAbstract::SetOuterBorderRadius(const Dimension& value)
722 {
723     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
724         return;
725     }
726     BorderRadiusProperty borderRadius;
727     borderRadius.SetRadius(value);
728     borderRadius.multiValued = false;
729     ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, borderRadius);
730 }
731 
SetOuterBorderRadius(FrameNode * frameNode,const Dimension & value)732 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const Dimension& value)
733 {
734     BorderRadiusProperty borderRadius;
735     borderRadius.SetRadius(value);
736     borderRadius.multiValued = false;
737     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, borderRadius, frameNode);
738 }
739 
SetOuterBorderRadius(const BorderRadiusProperty & value)740 void ViewAbstract::SetOuterBorderRadius(const BorderRadiusProperty& value)
741 {
742     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
743         return;
744     }
745     ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, value);
746 }
747 
SetOuterBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)748 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const BorderRadiusProperty& value)
749 {
750     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, value, frameNode);
751 }
752 
SetOuterBorderColor(const Color & value)753 void ViewAbstract::SetOuterBorderColor(const Color& value)
754 {
755     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
756         return;
757     }
758     BorderColorProperty borderColor;
759     borderColor.SetColor(value);
760     ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, borderColor);
761 }
762 
SetOuterBorderColor(FrameNode * frameNode,const Color & value)763 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const Color& value)
764 {
765     BorderColorProperty borderColor;
766     borderColor.SetColor(value);
767     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, borderColor, frameNode);
768 }
769 
SetOuterBorderColor(const BorderColorProperty & value)770 void ViewAbstract::SetOuterBorderColor(const BorderColorProperty& value)
771 {
772     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
773         return;
774     }
775     ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, value);
776 }
777 
SetOuterBorderColor(FrameNode * frameNode,const BorderColorProperty & value)778 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const BorderColorProperty& value)
779 {
780     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, value, frameNode);
781 }
782 
SetOuterBorderWidth(const Dimension & value)783 void ViewAbstract::SetOuterBorderWidth(const Dimension& value)
784 {
785     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
786         return;
787     }
788     BorderWidthProperty borderWidth;
789     if (Negative(value.Value())) {
790         borderWidth.SetBorderWidth(Dimension(0));
791     } else {
792         borderWidth.SetBorderWidth(value);
793     }
794     ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, borderWidth);
795 }
796 
SetOuterBorderWidth(FrameNode * frameNode,const Dimension & value)797 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const Dimension& value)
798 {
799     BorderWidthProperty borderWidth;
800     if (Negative(value.Value())) {
801         borderWidth.SetBorderWidth(Dimension(0));
802     } else {
803         borderWidth.SetBorderWidth(value);
804     }
805     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, borderWidth, frameNode);
806 }
807 
SetOuterBorderWidth(const BorderWidthProperty & value)808 void ViewAbstract::SetOuterBorderWidth(const BorderWidthProperty& value)
809 {
810     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
811         return;
812     }
813     ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, value);
814 }
815 
SetOuterBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)816 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value)
817 {
818     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, value, frameNode);
819 }
820 
SetOuterBorderStyle(const BorderStyleProperty & value)821 void ViewAbstract::SetOuterBorderStyle(const BorderStyleProperty& value)
822 {
823     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
824         return;
825     }
826     ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, value);
827 }
828 
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)829 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyleProperty& value)
830 {
831     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, value, frameNode);
832 }
833 
SetOuterBorderStyle(const BorderStyle & value)834 void ViewAbstract::SetOuterBorderStyle(const BorderStyle& value)
835 {
836     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
837         return;
838     }
839     BorderStyleProperty borderStyle;
840     borderStyle.SetBorderStyle(value);
841     ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, borderStyle);
842 }
843 
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyle & value)844 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyle& value)
845 {
846     BorderStyleProperty borderStyle;
847     borderStyle.SetBorderStyle(value);
848     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, borderStyle, frameNode);
849 }
850 
DisableOnClick()851 void ViewAbstract::DisableOnClick()
852 {
853     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
854     CHECK_NULL_VOID(gestureHub);
855     gestureHub->ClearUserOnClick();
856 }
857 
DisableOnTouch()858 void ViewAbstract::DisableOnTouch()
859 {
860     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
861     CHECK_NULL_VOID(gestureHub);
862     gestureHub->ClearUserOnTouch();
863 }
864 
DisableOnKeyEvent()865 void ViewAbstract::DisableOnKeyEvent()
866 {
867     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
868     CHECK_NULL_VOID(focusHub);
869     focusHub->ClearOnKeyCallback();
870 }
871 
DisableOnKeyEventDispatch()872 void ViewAbstract::DisableOnKeyEventDispatch()
873 {
874     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
875     CHECK_NULL_VOID(focusHub);
876     focusHub->ClearOnKeyEventDispatchCallback();
877 }
878 
879 #ifdef SUPPORT_DIGITAL_CROWN
DisableOnCrownEvent()880 void ViewAbstract::DisableOnCrownEvent()
881 {
882     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
883     CHECK_NULL_VOID(focusHub);
884     focusHub->ClearOnCrownCallback();
885 }
886 
DisableOnCrownEvent(FrameNode * frameNode)887 void ViewAbstract::DisableOnCrownEvent(FrameNode* frameNode)
888 {
889     auto focusHub = frameNode->GetOrCreateFocusHub();
890     CHECK_NULL_VOID(focusHub);
891     focusHub->ClearOnCrownCallback();
892 }
893 
SetOnCrownEvent(OnCrownCallbackFunc && onCrownCallback)894 void ViewAbstract::SetOnCrownEvent(OnCrownCallbackFunc &&onCrownCallback)
895 {
896     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
897     CHECK_NULL_VOID(focusHub);
898     focusHub->SetOnCrownCallback(std::move(onCrownCallback));
899 }
900 
SetOnCrownEvent(FrameNode * frameNode,OnCrownCallbackFunc && onCrownCallback)901 void ViewAbstract::SetOnCrownEvent(FrameNode* frameNode, OnCrownCallbackFunc &&onCrownCallback)
902 {
903     CHECK_NULL_VOID(frameNode);
904     auto focusHub = frameNode->GetOrCreateFocusHub();
905     focusHub->SetOnCrownCallback(std::move(onCrownCallback));
906 }
907 #endif
908 
DisableOnHover()909 void ViewAbstract::DisableOnHover()
910 {
911     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
912     CHECK_NULL_VOID(eventHub);
913     eventHub->ClearUserOnHover();
914 }
915 
DisableOnHoverMove()916 void ViewAbstract::DisableOnHoverMove()
917 {
918     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
919     CHECK_NULL_VOID(eventHub);
920     eventHub->ClearUserOnHoverMove();
921 }
922 
DisableOnAccessibilityHover()923 void ViewAbstract::DisableOnAccessibilityHover()
924 {
925     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
926     CHECK_NULL_VOID(eventHub);
927     eventHub->ClearUserOnAccessibilityHover();
928 }
929 
DisableOnMouse()930 void ViewAbstract::DisableOnMouse()
931 {
932     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
933     CHECK_NULL_VOID(eventHub);
934     eventHub->ClearUserOnMouse();
935 }
936 
DisableOnAxisEvent()937 void ViewAbstract::DisableOnAxisEvent()
938 {
939     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
940     CHECK_NULL_VOID(eventHub);
941     eventHub->ClearUserOnAxisEvent();
942 }
943 
DisableOnAppear()944 void ViewAbstract::DisableOnAppear()
945 {
946     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
947     CHECK_NULL_VOID(eventHub);
948     eventHub->ClearUserOnAppear();
949 }
950 
DisableOnDisAppear()951 void ViewAbstract::DisableOnDisAppear()
952 {
953     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
954     CHECK_NULL_VOID(eventHub);
955     eventHub->ClearUserOnDisAppear();
956 }
957 
DisableOnAttach()958 void ViewAbstract::DisableOnAttach()
959 {
960     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
961     CHECK_NULL_VOID(eventHub);
962     eventHub->ClearOnAttach();
963 }
964 
DisableOnDetach()965 void ViewAbstract::DisableOnDetach()
966 {
967     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
968     CHECK_NULL_VOID(eventHub);
969     eventHub->ClearOnDetach();
970 }
971 
DisableOnAreaChange()972 void ViewAbstract::DisableOnAreaChange()
973 {
974     auto pipeline = PipelineContext::GetCurrentContext();
975     CHECK_NULL_VOID(pipeline);
976     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
977     CHECK_NULL_VOID(frameNode);
978     frameNode->ClearUserOnAreaChange();
979 }
980 
DisableOnFocus()981 void ViewAbstract::DisableOnFocus()
982 {
983     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
984     CHECK_NULL_VOID(focusHub);
985     focusHub->ClearOnFocusCallback();
986 }
987 
DisableOnBlur()988 void ViewAbstract::DisableOnBlur()
989 {
990     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
991     CHECK_NULL_VOID(focusHub);
992     focusHub->ClearOnBlurCallback();
993 }
994 
DisableOnFocusAxisEvent()995 void ViewAbstract::DisableOnFocusAxisEvent()
996 {
997     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
998     CHECK_NULL_VOID(focusHub);
999     focusHub->ClearOnFocusAxisCallback();
1000 }
1001 
DisableOnFocusAxisEvent(FrameNode * frameNode)1002 void ViewAbstract::DisableOnFocusAxisEvent(FrameNode* frameNode)
1003 {
1004     auto focusHub = frameNode->GetOrCreateFocusHub();
1005     CHECK_NULL_VOID(focusHub);
1006     focusHub->ClearOnFocusAxisCallback();
1007 }
1008 
DisableOnClick(FrameNode * frameNode)1009 void ViewAbstract::DisableOnClick(FrameNode* frameNode)
1010 {
1011     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1012     CHECK_NULL_VOID(gestureHub);
1013     gestureHub->ClearUserOnClick();
1014 }
1015 
DisableOnDragStart(FrameNode * frameNode)1016 void ViewAbstract::DisableOnDragStart(FrameNode* frameNode)
1017 {
1018     CHECK_NULL_VOID(frameNode);
1019     auto eventHub = frameNode->GetEventHub<EventHub>();
1020     CHECK_NULL_VOID(eventHub);
1021     eventHub->ClearCustomerOnDragStart();
1022 }
1023 
DisableOnDragEnter(FrameNode * frameNode)1024 void ViewAbstract::DisableOnDragEnter(FrameNode* frameNode)
1025 {
1026     CHECK_NULL_VOID(frameNode);
1027     auto eventHub = frameNode->GetEventHub<EventHub>();
1028     CHECK_NULL_VOID(eventHub);
1029     eventHub->ClearCustomerOnDragEnter();
1030 }
1031 
DisableOnDragMove(FrameNode * frameNode)1032 void ViewAbstract::DisableOnDragMove(FrameNode* frameNode)
1033 {
1034     CHECK_NULL_VOID(frameNode);
1035     auto eventHub = frameNode->GetEventHub<EventHub>();
1036     CHECK_NULL_VOID(eventHub);
1037     eventHub->ClearCustomerOnDragMove();
1038 }
1039 
DisableOnDragLeave(FrameNode * frameNode)1040 void ViewAbstract::DisableOnDragLeave(FrameNode* frameNode)
1041 {
1042     CHECK_NULL_VOID(frameNode);
1043     auto eventHub = frameNode->GetEventHub<EventHub>();
1044     CHECK_NULL_VOID(eventHub);
1045     eventHub->ClearCustomerOnDragLeave();
1046 }
1047 
DisableOnDrop(FrameNode * frameNode)1048 void ViewAbstract::DisableOnDrop(FrameNode* frameNode)
1049 {
1050     CHECK_NULL_VOID(frameNode);
1051     auto eventHub = frameNode->GetEventHub<EventHub>();
1052     CHECK_NULL_VOID(eventHub);
1053     eventHub->ClearCustomerOnDrop();
1054 }
1055 
DisableOnDragEnd(FrameNode * frameNode)1056 void ViewAbstract::DisableOnDragEnd(FrameNode* frameNode)
1057 {
1058     CHECK_NULL_VOID(frameNode);
1059     auto eventHub = frameNode->GetEventHub<EventHub>();
1060     CHECK_NULL_VOID(eventHub);
1061     eventHub->ClearCustomerOnDragEnd();
1062 }
1063 
DisableOnTouch(FrameNode * frameNode)1064 void ViewAbstract::DisableOnTouch(FrameNode* frameNode)
1065 {
1066     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1067     CHECK_NULL_VOID(gestureHub);
1068     gestureHub->ClearUserOnTouch();
1069 }
1070 
DisableOnKeyEvent(FrameNode * frameNode)1071 void ViewAbstract::DisableOnKeyEvent(FrameNode* frameNode)
1072 {
1073     auto focusHub = frameNode->GetOrCreateFocusHub();
1074     CHECK_NULL_VOID(focusHub);
1075     focusHub->ClearOnKeyCallback();
1076 }
1077 
DisableOnKeyEventDispatch(FrameNode * frameNode)1078 void ViewAbstract::DisableOnKeyEventDispatch(FrameNode* frameNode)
1079 {
1080     auto focusHub = frameNode->GetOrCreateFocusHub();
1081     CHECK_NULL_VOID(focusHub);
1082     focusHub->ClearOnKeyEventDispatchCallback();
1083 }
1084 
DisableOnHover(FrameNode * frameNode)1085 void ViewAbstract::DisableOnHover(FrameNode* frameNode)
1086 {
1087     auto eventHub = frameNode->GetOrCreateInputEventHub();
1088     CHECK_NULL_VOID(eventHub);
1089     eventHub->ClearUserOnHover();
1090 }
1091 
DisableOnHoverMove(FrameNode * frameNode)1092 void ViewAbstract::DisableOnHoverMove(FrameNode* frameNode)
1093 {
1094     auto eventHub = frameNode->GetOrCreateInputEventHub();
1095     CHECK_NULL_VOID(eventHub);
1096     eventHub->ClearUserOnHoverMove();
1097 }
1098 
DisableOnMouse(FrameNode * frameNode)1099 void ViewAbstract::DisableOnMouse(FrameNode* frameNode)
1100 {
1101     auto eventHub = frameNode->GetOrCreateInputEventHub();
1102     CHECK_NULL_VOID(eventHub);
1103     eventHub->ClearUserOnMouse();
1104 }
1105 
DisableOnAxisEvent(FrameNode * frameNode)1106 void ViewAbstract::DisableOnAxisEvent(FrameNode* frameNode)
1107 {
1108     auto eventHub = frameNode->GetOrCreateInputEventHub();
1109     CHECK_NULL_VOID(eventHub);
1110     eventHub->ClearUserOnAxisEvent();
1111 }
1112 
DisableOnAppear(FrameNode * frameNode)1113 void ViewAbstract::DisableOnAppear(FrameNode* frameNode)
1114 {
1115     auto eventHub = frameNode->GetEventHub<EventHub>();
1116     CHECK_NULL_VOID(eventHub);
1117     eventHub->ClearUserOnAppear();
1118 }
1119 
DisableOnDisappear(FrameNode * frameNode)1120 void ViewAbstract::DisableOnDisappear(FrameNode* frameNode)
1121 {
1122     auto eventHub = frameNode->GetEventHub<EventHub>();
1123     CHECK_NULL_VOID(eventHub);
1124     eventHub->ClearUserOnDisAppear();
1125 }
1126 
DisableOnAttach(FrameNode * frameNode)1127 void ViewAbstract::DisableOnAttach(FrameNode* frameNode)
1128 {
1129     auto eventHub = frameNode->GetEventHub<EventHub>();
1130     CHECK_NULL_VOID(eventHub);
1131     eventHub->ClearOnAttach();
1132 }
1133 
DisableOnDetach(FrameNode * frameNode)1134 void ViewAbstract::DisableOnDetach(FrameNode* frameNode)
1135 {
1136     auto eventHub = frameNode->GetEventHub<EventHub>();
1137     CHECK_NULL_VOID(eventHub);
1138     eventHub->ClearOnDetach();
1139 }
1140 
DisableOnPreDrag(FrameNode * frameNode)1141 void ViewAbstract::DisableOnPreDrag(FrameNode* frameNode)
1142 {
1143     CHECK_NULL_VOID(frameNode);
1144     auto eventHub = frameNode->GetEventHub<EventHub>();
1145     CHECK_NULL_VOID(eventHub);
1146     eventHub->ClearOnPreDrag();
1147 }
1148 
DisableOnFocus(FrameNode * frameNode)1149 void ViewAbstract::DisableOnFocus(FrameNode* frameNode)
1150 {
1151     auto focusHub = frameNode->GetOrCreateFocusHub();
1152     CHECK_NULL_VOID(focusHub);
1153     focusHub->ClearOnFocusCallback();
1154 }
1155 
DisableOnBlur(FrameNode * frameNode)1156 void ViewAbstract::DisableOnBlur(FrameNode* frameNode)
1157 {
1158     auto focusHub = frameNode->GetOrCreateFocusHub();
1159     CHECK_NULL_VOID(focusHub);
1160     focusHub->ClearOnBlurCallback();
1161 }
1162 
DisableOnAreaChange(FrameNode * frameNode)1163 void ViewAbstract::DisableOnAreaChange(FrameNode* frameNode)
1164 {
1165     CHECK_NULL_VOID(frameNode);
1166     frameNode->ClearUserOnAreaChange();
1167 }
1168 
SetOnClick(GestureEventFunc && clickEventFunc,double distanceThreshold)1169 void ViewAbstract::SetOnClick(GestureEventFunc&& clickEventFunc, double distanceThreshold)
1170 {
1171     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1172     CHECK_NULL_VOID(frameNode);
1173     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1174     CHECK_NULL_VOID(gestureHub);
1175     gestureHub->SetUserOnClick(std::move(clickEventFunc), distanceThreshold);
1176 
1177     auto focusHub = frameNode->GetOrCreateFocusHub();
1178     CHECK_NULL_VOID(focusHub);
1179     focusHub->SetFocusable(true, false);
1180 }
1181 
SetOnGestureJudgeBegin(GestureJudgeFunc && gestureJudgeFunc)1182 void ViewAbstract::SetOnGestureJudgeBegin(GestureJudgeFunc&& gestureJudgeFunc)
1183 {
1184     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1185     CHECK_NULL_VOID(gestureHub);
1186     gestureHub->SetOnGestureJudgeBegin(std::move(gestureJudgeFunc));
1187 }
1188 
SetOnTouchIntercept(TouchInterceptFunc && touchInterceptFunc)1189 void ViewAbstract::SetOnTouchIntercept(TouchInterceptFunc&& touchInterceptFunc)
1190 {
1191     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1192     CHECK_NULL_VOID(gestureHub);
1193     gestureHub->SetOnTouchIntercept(std::move(touchInterceptFunc));
1194 }
1195 
SetShouldBuiltInRecognizerParallelWith(NG::ShouldBuiltInRecognizerParallelWithFunc && shouldBuiltInRecognizerParallelWithFunc)1196 void ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
1197     NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc)
1198 {
1199     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1200     CHECK_NULL_VOID(gestureHub);
1201     gestureHub->SetShouldBuildinRecognizerParallelWithFunc(std::move(shouldBuiltInRecognizerParallelWithFunc));
1202 }
1203 
SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc,bool exposeInnerGestureFlag)1204 void ViewAbstract::SetOnGestureRecognizerJudgeBegin(
1205     GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc, bool exposeInnerGestureFlag)
1206 {
1207     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1208     CHECK_NULL_VOID(frameNode);
1209     frameNode->SetExposeInnerGestureFlag(exposeInnerGestureFlag);
1210 
1211     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1212     CHECK_NULL_VOID(gestureHub);
1213     gestureHub->SetOnGestureRecognizerJudgeBegin(std::move(gestureRecognizerJudgeFunc));
1214 }
1215 
SetOnTouch(TouchEventFunc && touchEventFunc)1216 void ViewAbstract::SetOnTouch(TouchEventFunc&& touchEventFunc)
1217 {
1218     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1219     CHECK_NULL_VOID(gestureHub);
1220     gestureHub->SetTouchEvent(std::move(touchEventFunc));
1221 }
1222 
SetOnMouse(OnMouseEventFunc && onMouseEventFunc)1223 void ViewAbstract::SetOnMouse(OnMouseEventFunc&& onMouseEventFunc)
1224 {
1225     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1226     CHECK_NULL_VOID(eventHub);
1227     eventHub->SetMouseEvent(std::move(onMouseEventFunc));
1228 }
1229 
SetOnAxisEvent(OnAxisEventFunc && onAxisEventFunc)1230 void ViewAbstract::SetOnAxisEvent(OnAxisEventFunc&& onAxisEventFunc)
1231 {
1232     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1233     CHECK_NULL_VOID(eventHub);
1234     eventHub->SetAxisEvent(std::move(onAxisEventFunc));
1235 }
1236 
SetOnHover(OnHoverFunc && onHoverEventFunc)1237 void ViewAbstract::SetOnHover(OnHoverFunc&& onHoverEventFunc)
1238 {
1239     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1240     CHECK_NULL_VOID(eventHub);
1241     eventHub->SetHoverEvent(std::move(onHoverEventFunc));
1242 }
1243 
SetOnHoverMove(OnHoverMoveFunc && onHoverMoveEventFunc)1244 void ViewAbstract::SetOnHoverMove(OnHoverMoveFunc&& onHoverMoveEventFunc)
1245 {
1246     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1247     CHECK_NULL_VOID(eventHub);
1248     eventHub->SetHoverMoveEvent(std::move(onHoverMoveEventFunc));
1249 }
1250 
SetOnAccessibilityHover(OnAccessibilityHoverFunc && onAccessibilityHoverEventFunc)1251 void ViewAbstract::SetOnAccessibilityHover(OnAccessibilityHoverFunc &&onAccessibilityHoverEventFunc)
1252 {
1253     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1254     CHECK_NULL_VOID(eventHub);
1255     eventHub->SetAccessibilityHoverEvent(std::move(onAccessibilityHoverEventFunc));
1256 }
1257 
SetHoverEffect(HoverEffectType hoverEffect)1258 void ViewAbstract::SetHoverEffect(HoverEffectType hoverEffect)
1259 {
1260     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1261     CHECK_NULL_VOID(eventHub);
1262     eventHub->SetHoverEffect(hoverEffect);
1263 }
1264 
SetHoverEffectAuto(HoverEffectType hoverEffect)1265 void ViewAbstract::SetHoverEffectAuto(HoverEffectType hoverEffect)
1266 {
1267     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1268     CHECK_NULL_VOID(eventHub);
1269     eventHub->SetHoverEffectAuto(hoverEffect);
1270 }
1271 
SetEnabled(bool enabled)1272 void ViewAbstract::SetEnabled(bool enabled)
1273 {
1274     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1275     CHECK_NULL_VOID(frameNode);
1276     auto eventHub = frameNode->GetEventHub<EventHub>();
1277     if (eventHub) {
1278         eventHub->SetEnabled(enabled);
1279     }
1280 
1281     // The SetEnabled of focusHub must be after at eventHub
1282     auto focusHub = frameNode->GetOrCreateFocusHub();
1283     if (focusHub) {
1284         focusHub->SetEnabled(enabled);
1285     }
1286 }
1287 
SetFocusable(bool focusable)1288 void ViewAbstract::SetFocusable(bool focusable)
1289 {
1290     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1291     CHECK_NULL_VOID(focusHub);
1292     focusHub->SetFocusable(focusable);
1293 }
1294 
SetTabStop(bool tabStop)1295 void ViewAbstract::SetTabStop(bool tabStop)
1296 {
1297     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1298     CHECK_NULL_VOID(frameNode);
1299     auto focusHub = frameNode->GetOrCreateFocusHub();
1300     CHECK_NULL_VOID(focusHub);
1301     focusHub->SetTabStop(tabStop);
1302 }
1303 
SetOnFocus(OnFocusFunc && onFocusCallback)1304 void ViewAbstract::SetOnFocus(OnFocusFunc&& onFocusCallback)
1305 {
1306     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1307     CHECK_NULL_VOID(focusHub);
1308     focusHub->SetOnFocusCallback(std::move(onFocusCallback));
1309 }
1310 
SetOnBlur(OnBlurFunc && onBlurCallback)1311 void ViewAbstract::SetOnBlur(OnBlurFunc&& onBlurCallback)
1312 {
1313     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1314     CHECK_NULL_VOID(focusHub);
1315     focusHub->SetOnBlurCallback(std::move(onBlurCallback));
1316 }
1317 
SetOnKeyEvent(OnKeyConsumeFunc && onKeyCallback)1318 void ViewAbstract::SetOnKeyEvent(OnKeyConsumeFunc&& onKeyCallback)
1319 {
1320     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1321     CHECK_NULL_VOID(focusHub);
1322     focusHub->SetOnKeyCallback(std::move(onKeyCallback));
1323 }
1324 
SetTabIndex(int32_t index)1325 void ViewAbstract::SetTabIndex(int32_t index)
1326 {
1327     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1328     CHECK_NULL_VOID(focusHub);
1329     focusHub->SetTabIndex(index);
1330 }
1331 
SetFocusOnTouch(bool isSet)1332 void ViewAbstract::SetFocusOnTouch(bool isSet)
1333 {
1334     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1335     CHECK_NULL_VOID(focusHub);
1336     focusHub->SetIsFocusOnTouch(isSet);
1337 }
1338 
SetNextFocus(FocusIntension key,const std::string & nextFocus)1339 void ViewAbstract::SetNextFocus(FocusIntension key, const std::string& nextFocus)
1340 {
1341     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1342     CHECK_NULL_VOID(focusHub);
1343     focusHub->SetNextFocus(key, nextFocus);
1344 }
1345 
ResetNextFocus()1346 void ViewAbstract::ResetNextFocus()
1347 {
1348     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1349     CHECK_NULL_VOID(focusHub);
1350     focusHub->ResetNextFocus();
1351 }
1352 
SetFocusBoxStyle(const NG::FocusBoxStyle & style)1353 void ViewAbstract::SetFocusBoxStyle(const NG::FocusBoxStyle& style)
1354 {
1355     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1356     CHECK_NULL_VOID(focusHub);
1357     focusHub->GetFocusBox().SetStyle(style);
1358 }
1359 
SetClickDistance(FrameNode * frameNode,double clickDistance)1360 void ViewAbstract::SetClickDistance(FrameNode* frameNode, double clickDistance)
1361 {
1362     CHECK_NULL_VOID(frameNode);
1363     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1364     CHECK_NULL_VOID(gestureHub);
1365     gestureHub->SetNodeClickDistance(clickDistance);
1366 }
1367 
SetDefaultFocus(bool isSet)1368 void ViewAbstract::SetDefaultFocus(bool isSet)
1369 {
1370     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1371     CHECK_NULL_VOID(focusHub);
1372     focusHub->SetIsDefaultFocus(isSet);
1373 }
1374 
SetGroupDefaultFocus(bool isSet)1375 void ViewAbstract::SetGroupDefaultFocus(bool isSet)
1376 {
1377     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1378     CHECK_NULL_VOID(focusHub);
1379     focusHub->SetIsDefaultGroupFocus(isSet);
1380 }
1381 
SetOnAppear(std::function<void ()> && onAppear)1382 void ViewAbstract::SetOnAppear(std::function<void()>&& onAppear)
1383 {
1384     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1385     CHECK_NULL_VOID(eventHub);
1386     eventHub->SetOnAppear(std::move(onAppear));
1387 }
1388 
SetOnDisappear(std::function<void ()> && onDisappear)1389 void ViewAbstract::SetOnDisappear(std::function<void()>&& onDisappear)
1390 {
1391     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1392     CHECK_NULL_VOID(eventHub);
1393     eventHub->SetOnDisappear(std::move(onDisappear));
1394 }
1395 
SetOnAttach(std::function<void ()> && onAttach)1396 void ViewAbstract::SetOnAttach(std::function<void()> &&onAttach)
1397 {
1398     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1399     CHECK_NULL_VOID(eventHub);
1400     eventHub->SetOnAttach(std::move(onAttach));
1401 }
1402 
SetOnDetach(std::function<void ()> && onDetach)1403 void ViewAbstract::SetOnDetach(std::function<void()> &&onDetach)
1404 {
1405     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1406     CHECK_NULL_VOID(eventHub);
1407     eventHub->SetOnDetach(std::move(onDetach));
1408 }
1409 
SetOnAreaChanged(std::function<void (const RectF & oldRect,const OffsetF & oldOrigin,const RectF & rect,const OffsetF & origin)> && onAreaChanged)1410 void ViewAbstract::SetOnAreaChanged(
1411     std::function<void(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin)>&&
1412         onAreaChanged)
1413 {
1414     auto pipeline = PipelineContext::GetCurrentContext();
1415     CHECK_NULL_VOID(pipeline);
1416     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1417     CHECK_NULL_VOID(frameNode);
1418     frameNode->SetOnAreaChangeCallback(std::move(onAreaChanged));
1419     pipeline->AddOnAreaChangeNode(frameNode->GetId());
1420 }
1421 
SetOnSizeChanged(std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)1422 void ViewAbstract::SetOnSizeChanged(std::function<void(const RectF &oldRect, const RectF &rect)> &&onSizeChanged)
1423 {
1424     auto pipeline = PipelineContext::GetCurrentContext();
1425     CHECK_NULL_VOID(pipeline);
1426     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1427     CHECK_NULL_VOID(frameNode);
1428     frameNode->SetOnSizeChangeCallback(std::move(onSizeChanged));
1429 }
1430 
SetOnVisibleChange(std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList)1431 void ViewAbstract::SetOnVisibleChange(std::function<void(bool, double)> &&onVisibleChange,
1432     const std::vector<double> &ratioList)
1433 {
1434     auto pipeline = PipelineContext::GetCurrentContext();
1435     CHECK_NULL_VOID(pipeline);
1436     auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
1437     CHECK_NULL_VOID(frameNode);
1438     frameNode->CleanVisibleAreaUserCallback();
1439     pipeline->AddVisibleAreaChangeNode(frameNode, ratioList, onVisibleChange);
1440 }
1441 
SetResponseRegion(const std::vector<DimensionRect> & responseRegion)1442 void ViewAbstract::SetResponseRegion(const std::vector<DimensionRect>& responseRegion)
1443 {
1444     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1445     CHECK_NULL_VOID(gestureHub);
1446     gestureHub->SetResponseRegion(responseRegion);
1447 }
1448 
SetMouseResponseRegion(const std::vector<DimensionRect> & mouseRegion)1449 void ViewAbstract::SetMouseResponseRegion(const std::vector<DimensionRect>& mouseRegion)
1450 {
1451     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1452     CHECK_NULL_VOID(gestureHub);
1453     gestureHub->SetMouseResponseRegion(mouseRegion);
1454 }
1455 
SetTouchable(bool touchable)1456 void ViewAbstract::SetTouchable(bool touchable)
1457 {
1458     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1459     CHECK_NULL_VOID(gestureHub);
1460     gestureHub->SetTouchable(touchable);
1461 }
1462 
SetMonopolizeEvents(bool monopolizeEvents)1463 void ViewAbstract::SetMonopolizeEvents(bool monopolizeEvents)
1464 {
1465     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1466     CHECK_NULL_VOID(gestureHub);
1467     gestureHub->SetMonopolizeEvents(monopolizeEvents);
1468 }
1469 
SetHitTestMode(HitTestMode hitTestMode)1470 void ViewAbstract::SetHitTestMode(HitTestMode hitTestMode)
1471 {
1472     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1473     CHECK_NULL_VOID(gestureHub);
1474     gestureHub->SetHitTestMode(hitTestMode);
1475 }
1476 
SetOnTouchTestFunc(NG::OnChildTouchTestFunc && onChildTouchTest)1477 void ViewAbstract::SetOnTouchTestFunc(NG::OnChildTouchTestFunc&& onChildTouchTest)
1478 {
1479     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1480     CHECK_NULL_VOID(gestureHub);
1481     gestureHub->SetOnTouchTestFunc(std::move(onChildTouchTest));
1482 }
1483 
SetOnFocusAxisEvent(OnFocusAxisEventFunc && onFocusAxisCallback)1484 void ViewAbstract::SetOnFocusAxisEvent(OnFocusAxisEventFunc&& onFocusAxisCallback)
1485 {
1486     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1487     CHECK_NULL_VOID(focusHub);
1488     focusHub->SetOnFocusAxisCallback(std::move(onFocusAxisCallback));
1489 }
1490 
SetOnFocusAxisEvent(FrameNode * frameNode,OnFocusAxisEventFunc && onFocusAxisCallback)1491 void ViewAbstract::SetOnFocusAxisEvent(FrameNode* frameNode, OnFocusAxisEventFunc &&onFocusAxisCallback)
1492 {
1493     CHECK_NULL_VOID(frameNode);
1494     auto focusHub = frameNode->GetOrCreateFocusHub();
1495     focusHub->SetOnFocusAxisCallback(std::move(onFocusAxisCallback));
1496 }
1497 
AddDragFrameNodeToManager()1498 void ViewAbstract::AddDragFrameNodeToManager()
1499 {
1500     auto pipeline = PipelineContext::GetCurrentContext();
1501     CHECK_NULL_VOID(pipeline);
1502     auto dragDropManager = pipeline->GetDragDropManager();
1503     CHECK_NULL_VOID(dragDropManager);
1504     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1505     CHECK_NULL_VOID(frameNode);
1506 
1507     dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
1508 }
1509 
AddDragFrameNodeToManager(FrameNode * frameNode)1510 void ViewAbstract::AddDragFrameNodeToManager(FrameNode* frameNode)
1511 {
1512     CHECK_NULL_VOID(frameNode);
1513     auto pipeline = frameNode->GetContext();
1514     CHECK_NULL_VOID(pipeline);
1515     auto dragDropManager = pipeline->GetDragDropManager();
1516     CHECK_NULL_VOID(dragDropManager);
1517 
1518     dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
1519 }
1520 
NotifyDragStartRequest(DragStartRequestStatus dragStatus)1521 void ViewAbstract::NotifyDragStartRequest(DragStartRequestStatus dragStatus)
1522 {
1523     auto pipeline = PipelineContext::GetCurrentContext();
1524     CHECK_NULL_VOID(pipeline);
1525     auto dragDropManager = pipeline->GetDragDropManager();
1526     CHECK_NULL_VOID(dragDropManager);
1527     dragDropManager->HandleSyncOnDragStart(dragStatus);
1528 }
1529 
SetDraggable(bool draggable)1530 void ViewAbstract::SetDraggable(bool draggable)
1531 {
1532     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1533     CHECK_NULL_VOID(frameNode);
1534     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1535     CHECK_NULL_VOID(gestureHub);
1536     if (draggable) {
1537         if (!frameNode->IsDraggable()) {
1538             gestureHub->InitDragDropEvent();
1539         }
1540     } else {
1541         gestureHub->RemoveDragEvent();
1542     }
1543     frameNode->SetCustomerDraggable(draggable);
1544 }
1545 
SetDragPreviewOptions(const DragPreviewOption & previewOption)1546 void ViewAbstract::SetDragPreviewOptions(const DragPreviewOption& previewOption)
1547 {
1548     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1549     CHECK_NULL_VOID(frameNode);
1550     frameNode->SetDragPreviewOptions(previewOption, false);
1551 }
1552 
SetOnDragStart(std::function<DragDropInfo (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragStart)1553 void ViewAbstract::SetOnDragStart(
1554     std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart)
1555 {
1556     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1557     CHECK_NULL_VOID(gestureHub);
1558     gestureHub->InitDragDropEvent();
1559 
1560     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1561     CHECK_NULL_VOID(eventHub);
1562     eventHub->SetOnDragStart(std::move(onDragStart));
1563 }
1564 
SetOnDragStart(FrameNode * frameNode,std::function<DragDropInfo (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragStart)1565 void ViewAbstract::SetOnDragStart(FrameNode* frameNode,
1566     std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart)
1567 {
1568     CHECK_NULL_VOID(frameNode);
1569     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1570     CHECK_NULL_VOID(gestureHub);
1571     gestureHub->InitDragDropEvent();
1572 
1573     auto eventHub = frameNode->GetEventHub<EventHub>();
1574     CHECK_NULL_VOID(eventHub);
1575     eventHub->SetOnDragStart(std::move(onDragStart));
1576 }
1577 
SetOnDragEnter(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragEnter)1578 void ViewAbstract::SetOnDragEnter(FrameNode* frameNode,
1579     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
1580 {
1581     CHECK_NULL_VOID(frameNode);
1582     auto eventHub = frameNode->GetEventHub<EventHub>();
1583     CHECK_NULL_VOID(eventHub);
1584     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
1585 
1586     AddDragFrameNodeToManager(frameNode);
1587 }
1588 
SetOnDragMove(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragMove)1589 void ViewAbstract::SetOnDragMove(FrameNode* frameNode,
1590     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove)
1591 {
1592     CHECK_NULL_VOID(frameNode);
1593     auto eventHub = frameNode->GetEventHub<EventHub>();
1594     CHECK_NULL_VOID(eventHub);
1595     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
1596 
1597     AddDragFrameNodeToManager(frameNode);
1598 }
1599 
SetOnDragLeave(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragLeave)1600 void ViewAbstract::SetOnDragLeave(FrameNode* frameNode,
1601     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave)
1602 {
1603     CHECK_NULL_VOID(frameNode);
1604     auto eventHub = frameNode->GetEventHub<EventHub>();
1605     CHECK_NULL_VOID(eventHub);
1606     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
1607 
1608     AddDragFrameNodeToManager(frameNode);
1609 }
1610 
SetOnPreDrag(std::function<void (const PreDragStatus)> && onPreDragFunc)1611 void ViewAbstract::SetOnPreDrag(std::function<void(const PreDragStatus)>&& onPreDragFunc)
1612 {
1613     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1614     CHECK_NULL_VOID(eventHub);
1615     eventHub->SetOnPreDrag(std::move(onPreDragFunc));
1616 }
1617 
SetOnPreDrag(FrameNode * frameNode,std::function<void (const PreDragStatus)> && onPreDragFunc)1618 void ViewAbstract::SetOnPreDrag(FrameNode* frameNode, std::function<void(const PreDragStatus)>&& onPreDragFunc)
1619 {
1620     CHECK_NULL_VOID(frameNode);
1621     auto eventHub = frameNode->GetEventHub<EventHub>();
1622     CHECK_NULL_VOID(eventHub);
1623     eventHub->SetOnPreDrag(std::move(onPreDragFunc));
1624 }
1625 
SetOnDragEnter(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragEnter)1626 void ViewAbstract::SetOnDragEnter(
1627     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
1628 {
1629     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1630     CHECK_NULL_VOID(eventHub);
1631     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
1632 
1633     AddDragFrameNodeToManager();
1634 }
1635 
SetOnDragLeave(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragLeave)1636 void ViewAbstract::SetOnDragLeave(
1637     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave)
1638 {
1639     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1640     CHECK_NULL_VOID(eventHub);
1641     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
1642 
1643     AddDragFrameNodeToManager();
1644 }
1645 
SetOnDragMove(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragMove)1646 void ViewAbstract::SetOnDragMove(
1647     std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove)
1648 {
1649     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1650     CHECK_NULL_VOID(eventHub);
1651     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
1652 
1653     AddDragFrameNodeToManager();
1654 }
1655 
SetOnDrop(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDrop)1656 void ViewAbstract::SetOnDrop(std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDrop)
1657 {
1658     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1659     CHECK_NULL_VOID(eventHub);
1660     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
1661 
1662     AddDragFrameNodeToManager();
1663 }
1664 
SetOnDragEnd(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &)> && onDragEnd)1665 void ViewAbstract::SetOnDragEnd(std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd)
1666 {
1667     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1668     CHECK_NULL_VOID(eventHub);
1669     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
1670 
1671     AddDragFrameNodeToManager();
1672 }
1673 
SetOnDragEnd(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &)> && onDragEnd)1674 void ViewAbstract::SetOnDragEnd(
1675     FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd)
1676 {
1677     CHECK_NULL_VOID(frameNode);
1678     auto eventHub = frameNode->GetEventHub<EventHub>();
1679     CHECK_NULL_VOID(eventHub);
1680     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
1681 
1682     AddDragFrameNodeToManager(frameNode);
1683 }
1684 
SetOnDrop(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDrop)1685 void ViewAbstract::SetOnDrop(
1686     FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDrop)
1687 {
1688     CHECK_NULL_VOID(frameNode);
1689     auto eventHub = frameNode->GetEventHub<EventHub>();
1690     CHECK_NULL_VOID(eventHub);
1691 
1692     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
1693 
1694     AddDragFrameNodeToManager(frameNode);
1695 }
1696 
SetAlign(Alignment alignment)1697 void ViewAbstract::SetAlign(Alignment alignment)
1698 {
1699     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1700         return;
1701     }
1702     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment);
1703 }
1704 
SetAlign(FrameNode * frameNode,Alignment alignment)1705 void ViewAbstract::SetAlign(FrameNode* frameNode, Alignment alignment)
1706 {
1707     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment, frameNode);
1708 }
1709 
SetVisibility(VisibleType visible)1710 void ViewAbstract::SetVisibility(VisibleType visible)
1711 {
1712     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1713         return;
1714     }
1715     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1716     CHECK_NULL_VOID(frameNode);
1717     auto layoutProperty = frameNode->GetLayoutProperty();
1718     if (layoutProperty) {
1719         layoutProperty->UpdateVisibility(visible, true, true);
1720     }
1721 
1722     auto focusHub = frameNode->GetOrCreateFocusHub();
1723     if (focusHub) {
1724         focusHub->SetShow(visible == VisibleType::VISIBLE);
1725     }
1726 }
1727 
SetGeometryTransition(const std::string & id,bool followWithoutTransition,bool doRegisterSharedTransition)1728 void ViewAbstract::SetGeometryTransition(const std::string& id,
1729     bool followWithoutTransition, bool doRegisterSharedTransition)
1730 {
1731     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1732     CHECK_NULL_VOID(frameNode);
1733     auto layoutProperty = frameNode->GetLayoutProperty();
1734     if (layoutProperty) {
1735         layoutProperty->UpdateGeometryTransition(id, followWithoutTransition, doRegisterSharedTransition);
1736     }
1737 }
1738 
SetGeometryTransition(FrameNode * frameNode,const std::string & id,bool followWithoutTransition,bool doRegisterSharedTransition)1739 void ViewAbstract::SetGeometryTransition(FrameNode *frameNode, const std::string& id,
1740     bool followWithoutTransition, bool doRegisterSharedTransition)
1741 {
1742     CHECK_NULL_VOID(frameNode);
1743     auto layoutProperty = frameNode->GetLayoutProperty();
1744     if (layoutProperty) {
1745         layoutProperty->UpdateGeometryTransition(id, followWithoutTransition, doRegisterSharedTransition);
1746     }
1747 }
1748 
GetGeometryTransition(FrameNode * frameNode,bool * followWithoutTransition,bool * doRegisterSharedTransition)1749 const std::string ViewAbstract::GetGeometryTransition(FrameNode* frameNode,
1750     bool* followWithoutTransition, bool* doRegisterSharedTransition)
1751 {
1752     CHECK_NULL_RETURN(frameNode, "");
1753     auto layoutProperty = frameNode->GetLayoutProperty();
1754     if (layoutProperty) {
1755         auto geometryTransition = layoutProperty->GetGeometryTransition();
1756         if (geometryTransition) {
1757             *followWithoutTransition = geometryTransition->GetFollowWithoutTransition();
1758             *doRegisterSharedTransition = geometryTransition->GetDoRegisterSharedTransition();
1759             return geometryTransition->GetId();
1760         }
1761     }
1762     return "";
1763 }
1764 
SetOpacity(double opacity)1765 void ViewAbstract::SetOpacity(double opacity)
1766 {
1767     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1768         return;
1769     }
1770     ACE_UPDATE_RENDER_CONTEXT(Opacity, opacity);
1771 }
SetAllowDrop(const std::set<std::string> & allowDrop)1772 void ViewAbstract::SetAllowDrop(const std::set<std::string>& allowDrop)
1773 {
1774     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1775     CHECK_NULL_VOID(frameNode);
1776     frameNode->SetAllowDrop(allowDrop);
1777 }
1778 
SetDrawModifier(const RefPtr<NG::DrawModifier> & drawModifier)1779 void ViewAbstract::SetDrawModifier(const RefPtr<NG::DrawModifier>& drawModifier)
1780 {
1781     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1782     CHECK_NULL_VOID(frameNode);
1783     frameNode->SetDrawModifier(drawModifier);
1784 }
1785 
GetFrameNode()1786 void* ViewAbstract::GetFrameNode()
1787 {
1788     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1789     return static_cast<void*>(frameNode);
1790 }
1791 
SetDragPreview(const NG::DragDropInfo & info)1792 void ViewAbstract::SetDragPreview(const NG::DragDropInfo& info)
1793 {
1794     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1795     CHECK_NULL_VOID(frameNode);
1796     frameNode->SetDragPreview(info);
1797 }
1798 
SetPosition(const OffsetT<Dimension> & value)1799 void ViewAbstract::SetPosition(const OffsetT<Dimension>& value)
1800 {
1801     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1802         return;
1803     }
1804     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1805     CHECK_NULL_VOID(frameNode);
1806     CheckIfParentNeedMarkDirty(frameNode);
1807     ACE_RESET_RENDER_CONTEXT(RenderContext, PositionEdges);
1808     ACE_UPDATE_RENDER_CONTEXT(Position, value);
1809 }
1810 
SetPositionEdges(const EdgesParam & value)1811 void ViewAbstract::SetPositionEdges(const EdgesParam& value)
1812 {
1813     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1814         return;
1815     }
1816     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1817     CHECK_NULL_VOID(frameNode);
1818     CheckIfParentNeedMarkDirty(frameNode);
1819     ACE_RESET_RENDER_CONTEXT(RenderContext, Position);
1820     ACE_UPDATE_RENDER_CONTEXT(PositionEdges, value);
1821 }
1822 
CheckIfParentNeedMarkDirty(FrameNode * frameNode)1823 void ViewAbstract::CheckIfParentNeedMarkDirty(FrameNode* frameNode)
1824 {
1825     CHECK_NULL_VOID(frameNode);
1826     auto parentNode = frameNode->GetAncestorNodeOfFrame(false);
1827     CHECK_NULL_VOID(parentNode);
1828     // Row/Column/Flex measure and layout differently depending on whether the child nodes have position property,
1829     // need to remeasure in the dynamic switch scenario.
1830     if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG ||
1831         parentNode->GetTag() == V2::FLEX_ETS_TAG) {
1832         auto renderContext = frameNode->GetRenderContext();
1833         CHECK_NULL_VOID(renderContext);
1834         if (!renderContext->HasPositionEdges() && !renderContext->HasPosition()) {
1835             parentNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
1836         }
1837     }
1838 }
1839 
SetOffset(const OffsetT<Dimension> & value)1840 void ViewAbstract::SetOffset(const OffsetT<Dimension>& value)
1841 {
1842     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1843         return;
1844     }
1845     ACE_RESET_RENDER_CONTEXT(RenderContext, OffsetEdges);
1846     ACE_UPDATE_RENDER_CONTEXT(Offset, value);
1847 }
1848 
SetOffsetEdges(const EdgesParam & value)1849 void ViewAbstract::SetOffsetEdges(const EdgesParam& value)
1850 {
1851     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1852         return;
1853     }
1854     ACE_RESET_RENDER_CONTEXT(RenderContext, Offset);
1855     ACE_UPDATE_RENDER_CONTEXT(OffsetEdges, value);
1856 }
1857 
MarkAnchor(const OffsetT<Dimension> & value)1858 void ViewAbstract::MarkAnchor(const OffsetT<Dimension>& value)
1859 {
1860     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1861         return;
1862     }
1863     ACE_UPDATE_RENDER_CONTEXT(Anchor, value);
1864 }
1865 
ResetPosition()1866 void ViewAbstract::ResetPosition()
1867 {
1868     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1869         return;
1870     }
1871     ACE_RESET_RENDER_CONTEXT(RenderContext, Position);
1872     ACE_RESET_RENDER_CONTEXT(RenderContext, PositionEdges);
1873     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1874     CHECK_NULL_VOID(frameNode);
1875     auto parentNode = frameNode->GetAncestorNodeOfFrame(false);
1876     CHECK_NULL_VOID(parentNode);
1877 
1878     // Row/Column/Flex measure and layout differently depending on whether the child nodes have position property.
1879     if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG ||
1880         parentNode->GetTag() == V2::FLEX_ETS_TAG) {
1881         frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1882     } else {
1883         auto renderContext = frameNode->GetRenderContext();
1884         CHECK_NULL_VOID(renderContext);
1885         renderContext->RecalculatePosition();
1886     }
1887 }
1888 
SetZIndex(int32_t value)1889 void ViewAbstract::SetZIndex(int32_t value)
1890 {
1891     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1892         return;
1893     }
1894     ACE_UPDATE_RENDER_CONTEXT(ZIndex, value);
1895 }
1896 
SetScale(const NG::VectorF & value)1897 void ViewAbstract::SetScale(const NG::VectorF& value)
1898 {
1899     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1900         return;
1901     }
1902     ACE_UPDATE_RENDER_CONTEXT(TransformScale, value);
1903 }
1904 
SetScale(FrameNode * frameNode,const NG::VectorF & value)1905 void ViewAbstract::SetScale(FrameNode* frameNode, const NG::VectorF& value)
1906 {
1907     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformScale, value, frameNode);
1908 }
1909 
SetPivot(const DimensionOffset & value)1910 void ViewAbstract::SetPivot(const DimensionOffset& value)
1911 {
1912     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1913         return;
1914     }
1915     ACE_UPDATE_RENDER_CONTEXT(TransformCenter, value);
1916 }
1917 
SetPivot(FrameNode * frameNode,const DimensionOffset & value)1918 void ViewAbstract::SetPivot(FrameNode* frameNode, const DimensionOffset& value)
1919 {
1920     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformCenter, value, frameNode);
1921 }
1922 
SetTranslate(const NG::TranslateOptions & value)1923 void ViewAbstract::SetTranslate(const NG::TranslateOptions& value)
1924 {
1925     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1926         return;
1927     }
1928     ACE_UPDATE_RENDER_CONTEXT(TransformTranslate, value);
1929 }
1930 
SetTranslate(FrameNode * frameNode,const NG::TranslateOptions & value)1931 void ViewAbstract::SetTranslate(FrameNode* frameNode, const NG::TranslateOptions& value)
1932 {
1933     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformTranslate, value, frameNode);
1934 }
1935 
SetRotate(const NG::Vector5F & value)1936 void ViewAbstract::SetRotate(const NG::Vector5F& value)
1937 {
1938     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1939         return;
1940     }
1941     ACE_UPDATE_RENDER_CONTEXT(TransformRotate, value);
1942 }
1943 
SetRotate(FrameNode * frameNode,const NG::Vector5F & value)1944 void ViewAbstract::SetRotate(FrameNode* frameNode, const NG::Vector5F& value)
1945 {
1946     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformRotate, value, frameNode);
1947 }
1948 
SetTransformMatrix(const Matrix4 & matrix)1949 void ViewAbstract::SetTransformMatrix(const Matrix4& matrix)
1950 {
1951     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1952         return;
1953     }
1954     ACE_UPDATE_RENDER_CONTEXT(TransformMatrix, matrix);
1955 }
1956 
BindPopup(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode,const RefPtr<UINode> & customNode)1957 void ViewAbstract::BindPopup(
1958     const RefPtr<PopupParam>& param, const RefPtr<FrameNode>& targetNode, const RefPtr<UINode>& customNode)
1959 {
1960     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind popup enter");
1961     CHECK_NULL_VOID(targetNode);
1962     auto targetId = targetNode->GetId();
1963     auto targetTag = targetNode->GetTag();
1964     auto context = targetNode->GetContext();
1965     CHECK_NULL_VOID(context);
1966     auto instanceId = context->GetInstanceId();
1967 
1968     auto overlayManager = context->GetOverlayManager();
1969     CHECK_NULL_VOID(overlayManager);
1970     auto popupInfo = overlayManager->GetPopupInfo(targetId);
1971     auto isShow = param->IsShow();
1972     auto isUseCustom = param->IsUseCustom();
1973     auto showInSubWindow = param->IsShowInSubWindow();
1974     if (popupInfo.popupNode) {
1975         showInSubWindow = false;
1976     } else {
1977         // subwindow model needs to use subContainer to get popupInfo
1978         auto subwindow = SubwindowManager::GetInstance()->GetSubwindowByType(instanceId, SubwindowType::TYPE_POPUP);
1979         if (subwindow) {
1980             subwindow->GetPopupInfoNG(targetId, popupInfo);
1981         }
1982         if (popupInfo.popupNode) {
1983             showInSubWindow = true;
1984         }
1985     }
1986 
1987     auto popupId = popupInfo.popupId;
1988     auto popupNode = popupInfo.popupNode;
1989     RefPtr<BubblePattern> popupPattern;
1990     if (popupNode) {
1991         popupPattern = popupNode->GetPattern<BubblePattern>();
1992     }
1993 
1994     if (popupInfo.isCurrentOnShow) {
1995         // Entering / Normal / Exiting
1996         bool popupShowing = popupPattern ? popupPattern->IsOnShow() : false;
1997         popupInfo.markNeedUpdate = popupShowing || !isShow;
1998     } else {
1999         // Invisable
2000         if (!isShow) {
2001             TAG_LOGD(AceLogTag::ACE_DIALOG, "Popup is already hidden");
2002             return;
2003         }
2004         popupInfo.markNeedUpdate = true;
2005     }
2006 
2007     // Create new popup.
2008     if (popupInfo.popupId == -1 || !popupNode) {
2009         if (!isUseCustom) {
2010             popupNode = BubbleView::CreateBubbleNode(targetTag, targetId, param);
2011         } else {
2012             CHECK_NULL_VOID(customNode);
2013             popupNode = BubbleView::CreateCustomBubbleNode(targetTag, targetId, customNode, param);
2014         }
2015         if (popupNode) {
2016             popupId = popupNode->GetId();
2017         }
2018         if (!showInSubWindow) {
2019             // erase popup when target node destroy
2020             auto destructor = [id = targetNode->GetId(), weak = AceType::WeakClaim(context)]() {
2021                 auto pipeline = weak.Upgrade();
2022                 CHECK_NULL_VOID(pipeline);
2023                 auto overlayManager = pipeline->GetOverlayManager();
2024                 CHECK_NULL_VOID(overlayManager);
2025                 overlayManager->ErasePopup(id);
2026                 SubwindowManager::GetInstance()->HideSubWindowNG();
2027             };
2028             targetNode->PushDestroyCallbackWithTag(destructor, std::to_string(popupId));
2029         } else {
2030             // erase popup in subwindow when target node destroy
2031             auto destructor = [id = targetNode->GetId(), containerId = instanceId]() {
2032                 auto subwindow = SubwindowManager::GetInstance()->GetSubwindowByType(
2033                     containerId, SubwindowType::TYPE_POPUP);
2034                 CHECK_NULL_VOID(subwindow);
2035                 auto overlayManager = subwindow->GetOverlayManager();
2036                 CHECK_NULL_VOID(overlayManager);
2037                 overlayManager->ErasePopup(id);
2038                 SubwindowManager::GetInstance()->HideSubWindowNG();
2039             };
2040             targetNode->PushDestroyCallbackWithTag(destructor, std::to_string(popupId));
2041         }
2042     } else {
2043         // use param to update PopupParm
2044         if (!isUseCustom) {
2045             BubbleView::UpdatePopupParam(popupId, param, targetNode);
2046             popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2047         } else {
2048             BubbleView::UpdateCustomPopupParam(popupId, param);
2049             popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2050         }
2051     }
2052     // update PopupInfo props
2053     popupInfo.popupId = popupId;
2054     popupInfo.popupNode = popupNode;
2055     popupInfo.isBlockEvent = param->IsBlockEvent();
2056     popupInfo.isAvoidKeyboard = param->GetKeyBoardAvoidMode() == PopupKeyboardAvoidMode::DEFAULT;
2057     if (popupNode) {
2058         popupNode->MarkModifyDone();
2059         popupPattern = popupNode->GetPattern<BubblePattern>();
2060         popupPattern->SetPopupParam(param);
2061         popupPattern->RegisterDoubleBindCallback(param->GetDoubleBindCallback());
2062         auto accessibilityProperty = popupNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
2063         if (accessibilityProperty) {
2064             accessibilityProperty->SetAccessibilityHoverPriority(param->IsBlockEvent());
2065         }
2066     }
2067     popupInfo.focusable = param->GetFocusable();
2068     popupInfo.target = AceType::WeakClaim(AceType::RawPtr(targetNode));
2069     popupInfo.targetSize = SizeF(param->GetTargetSize().Width(), param->GetTargetSize().Height());
2070     popupInfo.targetOffset = OffsetF(param->GetTargetOffset().GetX(), param->GetTargetOffset().GetY());
2071     if (showInSubWindow) {
2072         if (isShow) {
2073             SubwindowManager::GetInstance()->ShowPopupNG(
2074                 targetNode, popupInfo, param->GetOnWillDismiss(), param->GetInteractiveDismiss());
2075         } else {
2076             SubwindowManager::GetInstance()->HidePopupNG(targetId);
2077         }
2078         return;
2079     }
2080     if (isShow) {
2081         if (popupInfo.isCurrentOnShow != isShow) {
2082             overlayManager->ShowPopup(targetId, popupInfo, param->GetOnWillDismiss(), param->GetInteractiveDismiss());
2083         }
2084     } else {
2085         overlayManager->HidePopup(targetId, popupInfo);
2086     }
2087 }
2088 
BindTips(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode)2089 void ViewAbstract::BindTips(const RefPtr<PopupParam>& param, const RefPtr<FrameNode>& targetNode)
2090 {
2091     CHECK_NULL_VOID(param);
2092     CHECK_NULL_VOID(targetNode);
2093     auto targetId = targetNode->GetId();
2094     auto targetTag = targetNode->GetTag();
2095     auto context = targetNode->GetContext();
2096     CHECK_NULL_VOID(context);
2097     auto instanceId = context->GetInstanceId();
2098     auto overlayManager = context->GetOverlayManager();
2099     CHECK_NULL_VOID(overlayManager);
2100     auto tipsInfo = overlayManager->GetPopupInfo(targetId);
2101     auto showInSubWindow = param->IsShowInSubWindow();
2102     auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(instanceId);
2103     if (subwindow) {
2104         subwindow->GetPopupInfoNG(targetId, tipsInfo);
2105     }
2106     if (tipsInfo.popupNode) {
2107         showInSubWindow = true;
2108     }
2109     HandleHoverTipsInfo(param, targetNode, tipsInfo, showInSubWindow, instanceId);
2110 }
2111 
HandleHoverTipsInfo(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode,PopupInfo & tipsInfo,bool showInSubWindow,int32_t instanceId)2112 void ViewAbstract::HandleHoverTipsInfo(const RefPtr<PopupParam>& param, const RefPtr<FrameNode>& targetNode,
2113     PopupInfo& tipsInfo, bool showInSubWindow, int32_t instanceId)
2114 {
2115     CHECK_NULL_VOID(param);
2116     CHECK_NULL_VOID(targetNode);
2117     auto targetId = targetNode->GetId();
2118     auto targetTag = targetNode->GetTag();
2119     auto popupId = tipsInfo.popupId;
2120     auto popupNode = tipsInfo.popupNode;
2121     RefPtr<BubblePattern> popupPattern;
2122     tipsInfo.markNeedUpdate = true;
2123     popupNode = BubbleView::CreateBubbleNode(targetTag, targetId, param);
2124     if (popupNode) {
2125         popupId = popupNode->GetId();
2126     }
2127     if (!showInSubWindow) {
2128         auto destructor = [id = targetNode->GetId()]() {
2129             auto pipeline = NG::PipelineContext::GetCurrentContext();
2130             CHECK_NULL_VOID(pipeline);
2131             auto overlayManager = pipeline->GetOverlayManager();
2132             CHECK_NULL_VOID(overlayManager);
2133             overlayManager->ErasePopup(id);
2134             SubwindowManager::GetInstance()->HideSubWindowNG();
2135         };
2136         targetNode->PushDestroyCallbackWithTag(destructor, std::to_string(popupId));
2137     } else {
2138         auto destructor = [id = targetNode->GetId(), containerId = instanceId]() {
2139             auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(containerId);
2140             CHECK_NULL_VOID(subwindow);
2141             auto overlayManager = subwindow->GetOverlayManager();
2142             CHECK_NULL_VOID(overlayManager);
2143             overlayManager->ErasePopup(id);
2144             SubwindowManager::GetInstance()->HideSubWindowNG();
2145         };
2146         targetNode->PushDestroyCallbackWithTag(destructor, std::to_string(popupId));
2147     }
2148     tipsInfo.popupId = popupId;
2149     tipsInfo.popupNode = popupNode;
2150     tipsInfo.isBlockEvent = param->IsBlockEvent();
2151     if (popupNode) {
2152         popupNode->MarkModifyDone();
2153     }
2154     AddHoverEventForTips(param, targetNode, tipsInfo, showInSubWindow);
2155 }
2156 
AddHoverEventForTips(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode,PopupInfo & tipsInfo,bool showInSubWindow)2157 void ViewAbstract::AddHoverEventForTips(
2158     const RefPtr<PopupParam>& param, const RefPtr<FrameNode>& targetNode, PopupInfo& tipsInfo, bool showInSubWindow)
2159 {
2160     tipsInfo.disappearingTimeWithContinuousOperation = param->GetDisappearingTimeWithContinuousOperation();
2161     tipsInfo.focusable = param->GetFocusable();
2162     tipsInfo.target = AceType::WeakClaim(AceType::RawPtr(targetNode));
2163     tipsInfo.targetSize = SizeF(param->GetTargetSize().Width(), param->GetTargetSize().Height());
2164     tipsInfo.targetOffset = OffsetF(param->GetTargetOffset().GetX(), param->GetTargetOffset().GetY());
2165     auto popupId = tipsInfo.popupId;
2166     auto popupNode = tipsInfo.popupNode;
2167     auto targetId = targetNode->GetId();
2168     auto context = targetNode->GetContext();
2169     CHECK_NULL_VOID(context);
2170     auto overlayManager = context->GetOverlayManager();
2171     auto eventHub = targetNode->GetEventHub<EventHub>();
2172     CHECK_NULL_VOID(eventHub);
2173     auto inputHub = eventHub->GetOrCreateInputEventHub();
2174     CHECK_NULL_VOID(inputHub);
2175     auto hoverTask = [targetNode, targetId, tipsInfo, param, overlayManager, showInSubWindow, popupId, popupNode](
2176                          bool isHover) {
2177         if (isHover) {
2178             BubbleView::UpdatePopupParam(popupId, param, targetNode);
2179             popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2180             if (showInSubWindow) {
2181                 SubwindowManager::GetInstance()->ShowTipsNG(
2182                     targetNode, tipsInfo, param->GetAppearingTime(), param->GetAppearingTimeWithContinuousOperation());
2183                 return;
2184             }
2185             overlayManager->ShowTips(
2186                 targetId, tipsInfo, param->GetAppearingTime(), param->GetAppearingTimeWithContinuousOperation());
2187         } else {
2188             if (showInSubWindow) {
2189                 SubwindowManager::GetInstance()->HideTipsNG(targetId, param->GetDisappearingTime());
2190                 return;
2191             }
2192             overlayManager->HideTips(targetId, tipsInfo, param->GetDisappearingTime());
2193         }
2194     };
2195     auto hoverEvent = AceType::MakeRefPtr<InputEvent>(std::move(hoverTask));
2196     inputHub->AddOnHoverEvent(hoverEvent);
2197 }
2198 
GetCurOverlayManager(const RefPtr<UINode> & node)2199 RefPtr<OverlayManager> ViewAbstract::GetCurOverlayManager(const RefPtr<UINode>& node)
2200 {
2201     auto context = node->GetContextWithCheck();
2202     CHECK_NULL_RETURN(context, nullptr);
2203     if (GetTargetNodeIsInSubwindow(node)) {
2204         auto instanceId = context->GetInstanceId();
2205         auto subwindow = SubwindowManager::GetInstance()->GetSubwindowByType(instanceId, SubwindowType::TYPE_MENU);
2206         if (subwindow) {
2207             auto overlayManager = subwindow->GetOverlayManager();
2208             return overlayManager;
2209         } else {
2210             return nullptr;
2211         }
2212     }
2213     auto overlayManager = context->GetOverlayManager();
2214     return overlayManager;
2215 }
2216 
GetTargetNodeIsInSubwindow(const RefPtr<UINode> & targetNode)2217 bool ViewAbstract::GetTargetNodeIsInSubwindow(const RefPtr<UINode>& targetNode)
2218 {
2219     CHECK_NULL_RETURN(targetNode, false);
2220     auto pipelineContext = targetNode->GetContext();
2221     CHECK_NULL_RETURN(pipelineContext, false);
2222     auto instanceId = pipelineContext->GetInstanceId();
2223     auto aceContainer = AceEngine::Get().GetContainer(instanceId);
2224     CHECK_NULL_RETURN(aceContainer, false);
2225     return aceContainer->IsSubContainer();
2226 }
2227 
OpenPopup(const RefPtr<PopupParam> & param,const RefPtr<UINode> & customNode)2228 int32_t ViewAbstract::OpenPopup(const RefPtr<PopupParam>& param, const RefPtr<UINode>& customNode)
2229 {
2230     if (!param) {
2231         TAG_LOGE(AceLogTag::ACE_DIALOG, "The param of popup is null.");
2232         return ERROR_CODE_INTERNAL_ERROR;
2233     }
2234     if (!customNode) {
2235         TAG_LOGE(AceLogTag::ACE_DIALOG, "The customNode of popup is null.");
2236         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2237     }
2238     int32_t targetId = StringUtils::StringToInt(param->GetTargetId(), -1);
2239     if (targetId < 0) {
2240         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetId is error.");
2241         return ERROR_CODE_TARGET_INFO_NOT_EXIST;
2242     }
2243     auto targetNode = ElementRegister::GetInstance()->GetSpecificItemById<NG::FrameNode>(targetId);
2244     if (!targetNode) {
2245         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetNode does not exist when oepn popup.");
2246         return ERROR_CODE_TARGET_INFO_NOT_EXIST;
2247     }
2248     if (!targetNode->IsOnMainTree()) {
2249         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetNode does not on main tree.");
2250         return ERROR_CODE_TARGET_NOT_ON_COMPONENT_TREE;
2251     }
2252     auto popupInfo = BubbleView::GetPopupInfoWithCustomNode(customNode);
2253     if (popupInfo.popupNode) {
2254         TAG_LOGE(AceLogTag::ACE_DIALOG, "The customNode of popup is already existed.");
2255         return ERROR_CODE_DIALOG_CONTENT_ALREADY_EXIST;
2256     }
2257     auto overlayManager = BubbleView::GetPopupOverlayManager(customNode, targetId);
2258     if (overlayManager) {
2259         auto popupInfo = overlayManager->GetPopupInfo(targetId);
2260         if (popupInfo.popupNode) {
2261             popupInfo.markNeedUpdate = true;
2262             overlayManager->HidePopup(targetId, popupInfo, true);
2263         }
2264     }
2265     BindPopup(param, targetNode, customNode);
2266     popupInfo = BubbleView::GetPopupInfoWithTargetId(customNode, targetId);
2267     if (!popupInfo.popupNode) {
2268         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popupNode of popup is null.");
2269         return ERROR_CODE_INTERNAL_ERROR;
2270     }
2271     auto popupPattern = popupInfo.popupNode->GetPattern<BubblePattern>();
2272     if (!popupPattern) {
2273         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popupPattern does not exist.");
2274         return ERROR_CODE_INTERNAL_ERROR;
2275     }
2276     popupPattern->SetCustomNode(AceType::WeakClaim(AceType::RawPtr(customNode)));
2277     return ERROR_CODE_NO_ERROR;
2278 }
2279 
UpdatePopup(const RefPtr<PopupParam> & param,const RefPtr<UINode> & customNode)2280 int32_t ViewAbstract::UpdatePopup(const RefPtr<PopupParam>& param, const RefPtr<UINode>& customNode)
2281 {
2282     if (!param) {
2283         TAG_LOGE(AceLogTag::ACE_DIALOG, "The param of popup is null.");
2284         return ERROR_CODE_INTERNAL_ERROR;
2285     }
2286     if (!customNode) {
2287         TAG_LOGE(AceLogTag::ACE_DIALOG, "The customNode of popup is null.");
2288         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2289     }
2290     int32_t targetId = StringUtils::StringToInt(param->GetTargetId(), -1);
2291     if (targetId < 0) {
2292         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetId is error.");
2293         return ERROR_CODE_INTERNAL_ERROR;
2294     }
2295     auto targetNode = ElementRegister::GetInstance()->GetSpecificItemById<NG::FrameNode>(targetId);
2296     if (!targetNode) {
2297         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetNode does not exist when update popup.");
2298         return ERROR_CODE_INTERNAL_ERROR;
2299     }
2300     auto popupInfo = BubbleView::GetPopupInfoWithTargetId(customNode, targetId);
2301     if (!popupInfo.popupNode) {
2302         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popupNode of popup is null.");
2303         return ERROR_CODE_INTERNAL_ERROR;
2304     }
2305     if (!popupInfo.isCurrentOnShow) {
2306         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popup is not on show.");
2307         return ERROR_CODE_INTERNAL_ERROR;
2308     }
2309     BubbleView::ResetBubbleProperty(popupInfo.popupNode->GetId());
2310     BindPopup(param, targetNode, customNode);
2311     return ERROR_CODE_NO_ERROR;
2312 }
2313 
ClosePopup(const RefPtr<UINode> & customNode)2314 int32_t ViewAbstract::ClosePopup(const RefPtr<UINode>& customNode)
2315 {
2316     if (!customNode) {
2317         TAG_LOGE(AceLogTag::ACE_DIALOG, "The customNode of popup is null.");
2318         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2319     }
2320     auto param = AceType::MakeRefPtr<PopupParam>();
2321     if (!param) {
2322         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popupParam is null.");
2323         return ERROR_CODE_INTERNAL_ERROR;
2324     }
2325     auto result = GetPopupParam(param, customNode);
2326     if (result != ERROR_CODE_NO_ERROR) {
2327         TAG_LOGE(AceLogTag::ACE_DIALOG, "GetPopupParam failed");
2328         return result;
2329     }
2330     int32_t targetId = StringUtils::StringToInt(param->GetTargetId(), -1);
2331     if (targetId < 0) {
2332         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetId is error.");
2333         return ERROR_CODE_INTERNAL_ERROR;
2334     }
2335     auto overlayManager = BubbleView::GetPopupOverlayManager(customNode, targetId);
2336     if (!overlayManager) {
2337         TAG_LOGE(AceLogTag::ACE_DIALOG, "The overlayManager of popup is null.");
2338         return ERROR_CODE_INTERNAL_ERROR;
2339     }
2340     auto popupInfo = overlayManager->GetPopupInfo(targetId);
2341     if (!popupInfo.popupNode) {
2342         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popupNode of popup is null.");
2343         return ERROR_CODE_INTERNAL_ERROR;
2344     }
2345     if (!popupInfo.isCurrentOnShow) {
2346         TAG_LOGE(AceLogTag::ACE_DIALOG, "The popup is not on show.");
2347         return ERROR_CODE_DIALOG_CONTENT_NOT_FOUND;
2348     }
2349     popupInfo.markNeedUpdate = true;
2350     overlayManager->HidePopup(targetId, popupInfo);
2351     return ERROR_CODE_NO_ERROR;
2352 }
2353 
GetPopupParam(RefPtr<PopupParam> & param,const RefPtr<UINode> & customNode)2354 int32_t ViewAbstract::GetPopupParam(RefPtr<PopupParam>& param, const RefPtr<UINode>& customNode)
2355 {
2356     CHECK_NULL_RETURN(param, ERROR_CODE_INTERNAL_ERROR);
2357     CHECK_NULL_RETURN(customNode, ERROR_CODE_DIALOG_CONTENT_ERROR);
2358     auto popupInfo = BubbleView::GetPopupInfoWithCustomNode(customNode);
2359     CHECK_NULL_RETURN(popupInfo.popupNode, ERROR_CODE_DIALOG_CONTENT_NOT_FOUND);
2360     auto popupPattern = popupInfo.popupNode->GetPattern<BubblePattern>();
2361     CHECK_NULL_RETURN(popupPattern, ERROR_CODE_INTERNAL_ERROR);
2362     param = popupPattern->GetPopupParam();
2363     CHECK_NULL_RETURN(param, ERROR_CODE_INTERNAL_ERROR);
2364     int32_t targetId = StringUtils::StringToInt(param->GetTargetId(), -1);
2365     if (targetId < 0) {
2366         return ERROR_CODE_INTERNAL_ERROR;
2367     }
2368     return ERROR_CODE_NO_ERROR;
2369 }
2370 
DismissPopup()2371 void ViewAbstract::DismissPopup()
2372 {
2373     auto context = PipelineContext::GetCurrentContext();
2374     CHECK_NULL_VOID(context);
2375     auto overlayManager = context->GetOverlayManager();
2376     CHECK_NULL_VOID(overlayManager);
2377     overlayManager->DismissPopup();
2378 }
2379 
DismissDialog()2380 void ViewAbstract::DismissDialog()
2381 {
2382     auto context = PipelineContext::GetCurrentContext();
2383     CHECK_NULL_VOID(context);
2384     auto overlayManager = context->GetOverlayManager();
2385     CHECK_NULL_VOID(overlayManager);
2386     auto rootNode = overlayManager->GetRootNode().Upgrade();
2387     CHECK_NULL_VOID(rootNode);
2388     RefPtr<FrameNode> dialogNode;
2389     auto dialogId = DialogManager::GetInstance().GetDismissDialogId();
2390     auto dialogTag = DialogManager::GetInstance().GetDialogTag();
2391     if (dialogId && !dialogTag.empty()) {
2392         dialogNode = FrameNode::GetFrameNodeOnly(dialogTag, dialogId);
2393     }
2394     if (!dialogNode) {
2395         if (overlayManager->GetDismissDialogId()) {
2396             dialogNode = overlayManager->GetDialog(overlayManager->GetDismissDialogId());
2397         } else {
2398             dialogNode = AceType::DynamicCast<FrameNode>(rootNode->GetLastChild());
2399         }
2400     }
2401     CHECK_NULL_VOID(dialogNode);
2402     auto pattern = dialogNode->GetPattern();
2403     CHECK_NULL_VOID(pattern);
2404     auto dialogPattern = AceType::DynamicCast<DialogPattern>(pattern);
2405     if (dialogPattern) {
2406         dialogPattern->OverlayDismissDialog(dialogNode);
2407         UiSessionManager::GetInstance()->ReportComponentChangeEvent("onVisibleChange", "destroy");
2408     }
2409 }
2410 
ShowMenuPreview(const RefPtr<FrameNode> & targetNode,const RefPtr<FrameNode> & wrapperNode,NG::MenuParam & menuParam)2411 void ViewAbstract::ShowMenuPreview(
2412     const RefPtr<FrameNode>& targetNode, const RefPtr<FrameNode>& wrapperNode, NG::MenuParam& menuParam)
2413 {
2414 #ifdef PREVIEW
2415     menuParam.previewMode = MenuPreviewMode::NONE;
2416 #endif
2417     CHECK_NULL_VOID(targetNode);
2418     CHECK_NULL_VOID(wrapperNode);
2419     auto menuWrapperPattern = wrapperNode->GetPattern<NG::MenuWrapperPattern>();
2420     CHECK_NULL_VOID(menuWrapperPattern);
2421     if (menuParam.previewMode == MenuPreviewMode::IMAGE || menuParam.isShowHoverImage) {
2422         ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, IsBindOverlay, true, targetNode);
2423         auto context = targetNode->GetRenderContext();
2424         CHECK_NULL_VOID(context);
2425         auto eventHub = targetNode->GetEventHub<EventHub>();
2426         CHECK_NULL_VOID(eventHub);
2427         auto gestureHub = eventHub->GetGestureEventHub();
2428         CHECK_NULL_VOID(gestureHub);
2429         auto pixelMap = context->GetThumbnailPixelMap();
2430         CHECK_NULL_VOID(pixelMap);
2431         gestureHub->SetPixelMap(pixelMap);
2432         menuWrapperPattern->SetIsShowFromUser(true);
2433         MenuView::GetMenuPixelMap(targetNode, menuParam, wrapperNode);
2434     }
2435 }
2436 
OpenMenu(NG::MenuParam & menuParam,const RefPtr<NG::UINode> & customNode,const int32_t & targetId)2437 int32_t ViewAbstract::OpenMenu(NG::MenuParam& menuParam, const RefPtr<NG::UINode>& customNode, const int32_t& targetId)
2438 {
2439     if (!customNode) {
2440         TAG_LOGE(AceLogTag::ACE_DIALOG, "Content of menu is null.");
2441         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2442     }
2443     auto targetNode = ElementRegister::GetInstance()->GetSpecificItemById<NG::FrameNode>(targetId);
2444     if (!targetNode) {
2445         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetNode does not exist.");
2446         return ERROR_CODE_TARGET_INFO_NOT_EXIST;
2447     }
2448     if (!targetNode->IsOnMainTree()) {
2449         TAG_LOGE(AceLogTag::ACE_DIALOG, "The targetNode does not on main tree.");
2450         return ERROR_CODE_TARGET_NOT_ON_COMPONENT_TREE;
2451     }
2452     auto overlayManager = GetCurOverlayManager(customNode);
2453     CHECK_NULL_RETURN(overlayManager, ERROR_CODE_INTERNAL_ERROR);
2454     if (overlayManager->GetMenuNodeWithExistContent(customNode)) {
2455         TAG_LOGW(AceLogTag::ACE_DIALOG, "Content of menu already existed.");
2456         return ERROR_CODE_DIALOG_CONTENT_ALREADY_EXIST;
2457     }
2458     auto isShowMenu = overlayManager->GetMenuNode(targetNode->GetId());
2459     if (isShowMenu) {
2460         // The menu is already opened, close the previous menu and open the new menu
2461         overlayManager->HideMenu(isShowMenu, targetNode->GetId(), false);
2462     }
2463     auto wrapperNode = NG::MenuView::Create(customNode, targetNode->GetId(), targetNode->GetTag(), menuParam);
2464     CHECK_NULL_RETURN(wrapperNode, ERROR_CODE_INTERNAL_ERROR);
2465     ShowMenuPreview(targetNode, wrapperNode, menuParam);
2466     auto menuWrapperPattern = wrapperNode->GetPattern<NG::MenuWrapperPattern>();
2467     CHECK_NULL_RETURN(menuWrapperPattern, ERROR_CODE_INTERNAL_ERROR);
2468     menuWrapperPattern->RegisterMenuCallback(wrapperNode, menuParam);
2469     menuWrapperPattern->SetMenuTransitionEffect(wrapperNode, menuParam);
2470     auto menu = menuWrapperPattern->GetMenu();
2471     CHECK_NULL_RETURN(menu, ERROR_CODE_INTERNAL_ERROR);
2472     auto menuPattern = AceType::DynamicCast<MenuPattern>(menu->GetPattern());
2473     CHECK_NULL_RETURN(menuPattern, ERROR_CODE_INTERNAL_ERROR);
2474     auto node = WeakPtr<UINode>(customNode);
2475     menuPattern->SetCustomNode(node);
2476     auto pipelineContext = targetNode->GetContext();
2477     CHECK_NULL_RETURN(pipelineContext, ERROR_CODE_INTERNAL_ERROR);
2478     auto theme = pipelineContext->GetTheme<SelectTheme>();
2479     CHECK_NULL_RETURN(theme, ERROR_CODE_INTERNAL_ERROR);
2480     auto expandDisplay = theme->GetExpandDisplay();
2481     menuWrapperPattern->SetIsOpenMenu(true);
2482     if (expandDisplay && menuParam.isShowInSubWindow && targetNode->GetTag() != V2::SELECT_ETS_TAG) {
2483         SubwindowManager::GetInstance()->ShowMenuNG(wrapperNode, menuParam, targetNode, menuParam.positionOffset);
2484         return ERROR_CODE_NO_ERROR;
2485     }
2486     overlayManager->ShowMenu(targetNode->GetId(), menuParam.positionOffset, wrapperNode);
2487     return ERROR_CODE_NO_ERROR;
2488 }
2489 
UpdateMenu(const NG::MenuParam & menuParam,const RefPtr<NG::UINode> & customNode)2490 int32_t ViewAbstract::UpdateMenu(const NG::MenuParam& menuParam, const RefPtr<NG::UINode>& customNode)
2491 {
2492     if (!customNode) {
2493         TAG_LOGE(AceLogTag::ACE_DIALOG, "Content of menu is null.");
2494         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2495     }
2496     auto overlayManager = GetCurOverlayManager(customNode);
2497     if (!overlayManager) {
2498         return ERROR_CODE_INTERNAL_ERROR;
2499     }
2500     auto menuWrapperNode = overlayManager->GetMenuNodeWithExistContent(customNode);
2501     if (!menuWrapperNode) {
2502         return ERROR_CODE_DIALOG_CONTENT_NOT_FOUND;
2503     }
2504     auto wrapperPattern = AceType::DynamicCast<MenuWrapperPattern>(menuWrapperNode->GetPattern());
2505     CHECK_NULL_RETURN(wrapperPattern, ERROR_CODE_INTERNAL_ERROR);
2506     auto menu = wrapperPattern->GetMenu();
2507     CHECK_NULL_RETURN(menu, ERROR_CODE_INTERNAL_ERROR);
2508     wrapperPattern->SetMenuParam(menuParam);
2509     MenuView::UpdateMenuParam(menuWrapperNode, menu, menuParam);
2510     MenuView::UpdateMenuProperties(menuWrapperNode, menu, menuParam, menuParam.type);
2511     auto pipeline = menuWrapperNode->GetContextRefPtr();
2512     if (pipeline) {
2513         wrapperPattern->SetForceUpdateEmbeddedMenu(true);
2514     }
2515     auto menuPattern = AceType::DynamicCast<MenuPattern>(menu->GetPattern());
2516     CHECK_NULL_RETURN(menuPattern, ERROR_CODE_INTERNAL_ERROR);
2517     auto embeddedMenuItems = menuPattern->GetEmbeddedMenuItems();
2518     for (auto iter = embeddedMenuItems.begin(); iter != embeddedMenuItems.end(); ++iter) {
2519         auto menuItemPattern = (*iter)->GetPattern<MenuItemPattern>();
2520         if (!menuItemPattern) {
2521             continue;
2522         }
2523         menuItemPattern->HideEmbedded(false);
2524     }
2525     uint32_t minChildrenSize = 1;
2526     if (menuWrapperNode->GetChildren().size() > minChildrenSize) {
2527         auto subMenu = menuWrapperNode->GetChildren().back();
2528         if (subMenu && subMenu->GetTag() == V2::MENU_ETS_TAG) {
2529             wrapperPattern->HideSubMenu();
2530         }
2531     }
2532     menuWrapperNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF_AND_CHILD);
2533     menu->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF_AND_CHILD);
2534     if (pipeline) {
2535         pipeline->FlushUITasks();
2536         wrapperPattern->SetForceUpdateEmbeddedMenu(false);
2537     }
2538     return ERROR_CODE_NO_ERROR;
2539 }
2540 
CloseMenu(const RefPtr<UINode> & customNode)2541 int32_t ViewAbstract::CloseMenu(const RefPtr<UINode>& customNode)
2542 {
2543     if (!customNode) {
2544         TAG_LOGE(AceLogTag::ACE_DIALOG, "Content of menu is null.");
2545         return ERROR_CODE_DIALOG_CONTENT_ERROR;
2546     }
2547     auto overlayManager = GetCurOverlayManager(customNode);
2548     if (!overlayManager) {
2549         return ERROR_CODE_INTERNAL_ERROR;
2550     }
2551     auto menuWrapperNode = overlayManager->GetMenuNodeWithExistContent(customNode);
2552     if (!menuWrapperNode) {
2553         return ERROR_CODE_DIALOG_CONTENT_NOT_FOUND;
2554     }
2555     overlayManager->HideMenu(menuWrapperNode, customNode->GetId(), false);
2556     return ERROR_CODE_NO_ERROR;
2557 }
2558 
BindMenuWithItems(std::vector<OptionParam> && params,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,const MenuParam & menuParam)2559 void ViewAbstract::BindMenuWithItems(std::vector<OptionParam>&& params, const RefPtr<FrameNode>& targetNode,
2560     const NG::OffsetF& offset, const MenuParam& menuParam)
2561 {
2562     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with items enter");
2563     CHECK_NULL_VOID(targetNode);
2564 
2565     if (params.empty()) {
2566         return;
2567     }
2568     auto menuNode =
2569         MenuView::Create(std::move(params), targetNode->GetId(), targetNode->GetTag(), MenuType::MENU, menuParam);
2570     CHECK_NULL_VOID(menuNode);
2571     auto menuWrapperPattern = menuNode->GetPattern<MenuWrapperPattern>();
2572     CHECK_NULL_VOID(menuWrapperPattern);
2573     menuWrapperPattern->RegisterMenuCallback(menuNode, menuParam);
2574     menuWrapperPattern->SetMenuTransitionEffect(menuNode, menuParam);
2575     auto pipeline = PipelineBase::GetCurrentContext();
2576     CHECK_NULL_VOID(pipeline);
2577     auto theme = pipeline->GetTheme<SelectTheme>();
2578     CHECK_NULL_VOID(theme);
2579     auto expandDisplay = theme->GetExpandDisplay();
2580 
2581     auto pipelineContext = targetNode->GetContext();
2582     CHECK_NULL_VOID(pipelineContext);
2583     auto overlayManager = pipelineContext->GetOverlayManager();
2584     CHECK_NULL_VOID(overlayManager);
2585 
2586     if (expandDisplay && menuParam.isShowInSubWindow && targetNode->GetTag() != V2::SELECT_ETS_TAG) {
2587         SubwindowManager::GetInstance()->ShowMenuNG(menuNode, menuParam, targetNode, offset);
2588         return;
2589     }
2590 
2591     overlayManager->ShowMenu(targetNode->GetId(), offset, menuNode);
2592 }
2593 
BindMenuWithCustomNode(std::function<void ()> && buildFunc,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,MenuParam menuParam,std::function<void ()> && previewBuildFunc)2594 void ViewAbstract::BindMenuWithCustomNode(std::function<void()>&& buildFunc, const RefPtr<FrameNode>& targetNode,
2595     const NG::OffsetF& offset, MenuParam menuParam, std::function<void()>&& previewBuildFunc)
2596 {
2597     if (!buildFunc || !targetNode) {
2598         return;
2599     }
2600 #ifdef PREVIEW
2601     // unable to use the subWindow in the Previewer.
2602     menuParam.type = MenuType::MENU;
2603 #endif
2604     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with custom node enter %{public}d", menuParam.type);
2605     auto pipeline = PipelineBase::GetCurrentContext();
2606     CHECK_NULL_VOID(pipeline);
2607     auto theme = pipeline->GetTheme<SelectTheme>();
2608     CHECK_NULL_VOID(theme);
2609     auto expandDisplay = theme->GetExpandDisplay();
2610     auto pipelineContext = targetNode->GetContext();
2611     CHECK_NULL_VOID(pipelineContext);
2612     auto overlayManager = pipelineContext->GetOverlayManager();
2613     CHECK_NULL_VOID(overlayManager);
2614     if (menuParam.type == MenuType::CONTEXT_MENU) {
2615         SubwindowManager::GetInstance()->ShowMenuNG(
2616             std::move(buildFunc), std::move(previewBuildFunc), menuParam, targetNode, offset);
2617         return;
2618     }
2619     if (menuParam.type == MenuType::MENU && expandDisplay && menuParam.isShowInSubWindow &&
2620         targetNode->GetTag() != V2::SELECT_ETS_TAG) {
2621         SubwindowManager::GetInstance()->ShowMenuNG(
2622             std::move(buildFunc), std::move(previewBuildFunc), menuParam, targetNode, offset);
2623         return;
2624     }
2625     NG::ScopedViewStackProcessor builderViewStackProcessor;
2626     buildFunc();
2627     auto customNode = NG::ViewStackProcessor::GetInstance()->Finish();
2628     RefPtr<NG::UINode> previewCustomNode;
2629     if (previewBuildFunc && menuParam.previewMode == MenuPreviewMode::CUSTOM) {
2630         previewBuildFunc();
2631         previewCustomNode = NG::ViewStackProcessor::GetInstance()->Finish();
2632     }
2633     auto menuNode =
2634         NG::MenuView::Create(customNode, targetNode->GetId(), targetNode->GetTag(), menuParam, true, previewCustomNode);
2635     auto menuWrapperPattern = menuNode->GetPattern<NG::MenuWrapperPattern>();
2636     CHECK_NULL_VOID(menuWrapperPattern);
2637     menuWrapperPattern->RegisterMenuCallback(menuNode, menuParam);
2638     menuWrapperPattern->SetMenuTransitionEffect(menuNode, menuParam);
2639     overlayManager->ShowMenu(targetNode->GetId(), offset, menuNode);
2640 }
2641 
SetBackdropBlur(const Dimension & radius,const BlurOption & blurOption,const SysOptions & sysOptions)2642 void ViewAbstract::SetBackdropBlur(const Dimension& radius, const BlurOption& blurOption, const SysOptions& sysOptions)
2643 {
2644     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2645         return;
2646     }
2647     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2648     CHECK_NULL_VOID(frameNode);
2649     auto target = frameNode->GetRenderContext();
2650     if (target) {
2651         if (target->GetBackgroundEffect().has_value()) {
2652             target->UpdateBackgroundEffect(std::nullopt);
2653         }
2654         target->UpdateBackBlur(radius, blurOption, sysOptions);
2655         if (target->GetBackBlurStyle().has_value()) {
2656             target->UpdateBackBlurStyle(std::nullopt);
2657         }
2658     }
2659 }
2660 
SetNodeBackdropBlur(FrameNode * frameNode,const Dimension & radius,const BlurOption & blurOption)2661 void ViewAbstract::SetNodeBackdropBlur(FrameNode *frameNode, const Dimension& radius, const BlurOption& blurOption)
2662 {
2663     CHECK_NULL_VOID(frameNode);
2664     auto target = frameNode->GetRenderContext();
2665     if (target) {
2666         if (target->GetBackgroundEffect().has_value()) {
2667             target->UpdateBackgroundEffect(std::nullopt);
2668         }
2669         if (target->GetBackBlurStyle().has_value()) {
2670             target->UpdateBackBlurStyle(std::nullopt);
2671         }
2672         target->UpdateNodeBackBlur(radius, blurOption);
2673     }
2674 }
2675 
SetBackdropBlur(FrameNode * frameNode,const Dimension & radius,const BlurOption & blurOption,const SysOptions & sysOptions)2676 void ViewAbstract::SetBackdropBlur(
2677     FrameNode* frameNode, const Dimension& radius, const BlurOption& blurOption, const SysOptions& sysOptions)
2678 {
2679     CHECK_NULL_VOID(frameNode);
2680     auto target = frameNode->GetRenderContext();
2681     if (target) {
2682         if (target->GetBackgroundEffect().has_value()) {
2683             target->UpdateBackgroundEffect(std::nullopt);
2684         }
2685         target->UpdateBackBlur(radius, blurOption, sysOptions);
2686         if (target->GetBackBlurStyle().has_value()) {
2687             target->UpdateBackBlurStyle(std::nullopt);
2688         }
2689     }
2690 }
2691 
SetLinearGradientBlur(const NG::LinearGradientBlurPara & blurPara)2692 void ViewAbstract::SetLinearGradientBlur(const NG::LinearGradientBlurPara& blurPara)
2693 {
2694     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2695         return;
2696     }
2697     ACE_UPDATE_RENDER_CONTEXT(LinearGradientBlur, blurPara);
2698 }
2699 
SetDynamicLightUp(float rate,float lightUpDegree)2700 void ViewAbstract::SetDynamicLightUp(float rate, float lightUpDegree)
2701 {
2702     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2703         return;
2704     }
2705     ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpRate, rate);
2706     ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree);
2707 }
2708 
SetBgDynamicBrightness(const BrightnessOption & brightnessOption)2709 void ViewAbstract::SetBgDynamicBrightness(const BrightnessOption& brightnessOption)
2710 {
2711     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2712         return;
2713     }
2714     ACE_UPDATE_RENDER_CONTEXT(BgDynamicBrightnessOption, brightnessOption);
2715 }
2716 
SetFgDynamicBrightness(const BrightnessOption & brightnessOption)2717 void ViewAbstract::SetFgDynamicBrightness(const BrightnessOption& brightnessOption)
2718 {
2719     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2720         return;
2721     }
2722     ACE_UPDATE_RENDER_CONTEXT(FgDynamicBrightnessOption, brightnessOption);
2723 }
2724 
SetBrightnessBlender(const OHOS::Rosen::BrightnessBlender * brightnessBlender)2725 void ViewAbstract::SetBrightnessBlender(const OHOS::Rosen::BrightnessBlender* brightnessBlender)
2726 {
2727     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2728         return;
2729     }
2730     ACE_UPDATE_RENDER_CONTEXT(BrightnessBlender, brightnessBlender);
2731 }
2732 
SetFrontBlur(const Dimension & radius,const BlurOption & blurOption,const SysOptions & sysOptions)2733 void ViewAbstract::SetFrontBlur(const Dimension& radius, const BlurOption& blurOption, const SysOptions& sysOptions)
2734 {
2735     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2736         return;
2737     }
2738     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2739     CHECK_NULL_VOID(frameNode);
2740     auto target = frameNode->GetRenderContext();
2741     if (target) {
2742         target->UpdateFrontBlur(radius, blurOption, sysOptions);
2743         if (target->GetFrontBlurStyle().has_value()) {
2744             target->UpdateFrontBlurStyle(std::nullopt);
2745         }
2746     }
2747 }
2748 
SetDynamicDim(float DimDegree)2749 void ViewAbstract::SetDynamicDim(float DimDegree)
2750 {
2751     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2752         return;
2753     }
2754     ACE_UPDATE_RENDER_CONTEXT(DynamicDimDegree, DimDegree);
2755 }
2756 
SetFrontBlur(FrameNode * frameNode,const Dimension & radius,const BlurOption & blurOption,const SysOptions & sysOptions)2757 void ViewAbstract::SetFrontBlur(
2758     FrameNode* frameNode, const Dimension& radius, const BlurOption& blurOption, const SysOptions& sysOptions)
2759 {
2760     CHECK_NULL_VOID(frameNode);
2761     auto target = frameNode->GetRenderContext();
2762     if (target) {
2763         target->UpdateFrontBlur(radius, blurOption, sysOptions);
2764         if (target->GetFrontBlurStyle().has_value()) {
2765             target->UpdateFrontBlurStyle(std::nullopt);
2766         }
2767     }
2768 }
2769 
SetBackShadow(const Shadow & shadow)2770 void ViewAbstract::SetBackShadow(const Shadow& shadow)
2771 {
2772     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2773         return;
2774     }
2775     ACE_UPDATE_RENDER_CONTEXT(BackShadow, shadow);
2776 }
2777 
SetBackShadow(FrameNode * frameNode,const Shadow & shadow)2778 void ViewAbstract::SetBackShadow(FrameNode* frameNode, const Shadow& shadow)
2779 {
2780     ACE_UPDATE_NODE_RENDER_CONTEXT(BackShadow, shadow, frameNode);
2781 }
2782 
SetBlendMode(BlendMode blendMode)2783 void ViewAbstract::SetBlendMode(BlendMode blendMode)
2784 {
2785     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2786         return;
2787     }
2788     ACE_UPDATE_RENDER_CONTEXT(BackBlendMode, blendMode);
2789 }
2790 
SetBlendApplyType(BlendApplyType blendApplyType)2791 void ViewAbstract::SetBlendApplyType(BlendApplyType blendApplyType)
2792 {
2793     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2794         return;
2795     }
2796     ACE_UPDATE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType);
2797 }
2798 
SetLinearGradient(const NG::Gradient & gradient)2799 void ViewAbstract::SetLinearGradient(const NG::Gradient& gradient)
2800 {
2801     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2802         return;
2803     }
2804     ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::LINEAR);
2805     ACE_UPDATE_RENDER_CONTEXT(LinearGradient, gradient);
2806 }
2807 
SetSweepGradient(const NG::Gradient & gradient)2808 void ViewAbstract::SetSweepGradient(const NG::Gradient& gradient)
2809 {
2810     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2811         return;
2812     }
2813     ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::SWEEP);
2814     ACE_UPDATE_RENDER_CONTEXT(SweepGradient, gradient);
2815 }
2816 
SetRadialGradient(const NG::Gradient & gradient)2817 void ViewAbstract::SetRadialGradient(const NG::Gradient& gradient)
2818 {
2819     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2820         return;
2821     }
2822     ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::RADIAL);
2823     ACE_UPDATE_RENDER_CONTEXT(RadialGradient, gradient);
2824 }
2825 
SetInspectorId(const std::string & inspectorId)2826 void ViewAbstract::SetInspectorId(const std::string& inspectorId)
2827 {
2828     auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2829     if (uiNode) {
2830         if (uiNode->GetInspectorId().has_value() && uiNode->GetInspectorIdValue() != inspectorId) {
2831             ElementRegister::GetInstance()->RemoveFrameNodeByInspectorId(
2832                 uiNode->GetInspectorIdValue(), uiNode->GetId());
2833         }
2834         uiNode->UpdateInspectorId(inspectorId);
2835     }
2836 }
2837 
SetAutoEventParam(const std::string & param)2838 void ViewAbstract::SetAutoEventParam(const std::string& param)
2839 {
2840     auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2841     if (uiNode) {
2842         uiNode->UpdateAutoEventParam(param);
2843     }
2844 }
2845 
SetRestoreId(int32_t restoreId)2846 void ViewAbstract::SetRestoreId(int32_t restoreId)
2847 {
2848     auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2849     if (uiNode) {
2850         uiNode->SetRestoreId(restoreId);
2851     }
2852 }
2853 
SetDebugLine(const std::string & line)2854 void ViewAbstract::SetDebugLine(const std::string& line)
2855 {
2856     auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2857     if (uiNode) {
2858         uiNode->SetDebugLine(line);
2859     }
2860 }
2861 
SetGrid(std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)2862 void ViewAbstract::SetGrid(std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
2863 {
2864     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2865     CHECK_NULL_VOID(frameNode);
2866     auto layoutProperty = frameNode->GetLayoutProperty();
2867     CHECK_NULL_VOID(layoutProperty);
2868     // frame node is mounted to parent when pop from stack later, no grid-container is added here
2869     layoutProperty->UpdateGridProperty(span, offset, type);
2870 }
2871 
Pop()2872 void ViewAbstract::Pop()
2873 {
2874     ViewStackProcessor::GetInstance()->Pop();
2875 }
2876 
SetTransition(const TransitionOptions & options)2877 void ViewAbstract::SetTransition(const TransitionOptions& options)
2878 {
2879     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2880         return;
2881     }
2882     ACE_UPDATE_RENDER_CONTEXT(Transition, options);
2883 }
2884 
CleanTransition()2885 void ViewAbstract::CleanTransition()
2886 {
2887     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2888         return;
2889     }
2890     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2891     CHECK_NULL_VOID(frameNode);
2892     auto target = frameNode->GetRenderContext();
2893     if (target) {
2894         target->CleanTransition();
2895     }
2896 }
2897 
SetChainedTransition(const RefPtr<NG::ChainedTransitionEffect> & effect,NG::TransitionFinishCallback && finishCallback)2898 void ViewAbstract::SetChainedTransition(
2899     const RefPtr<NG::ChainedTransitionEffect>& effect, NG::TransitionFinishCallback&& finishCallback)
2900 {
2901     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2902         return;
2903     }
2904     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2905     CHECK_NULL_VOID(frameNode);
2906     const auto& target = frameNode->GetRenderContext();
2907     if (target) {
2908         target->UpdateChainedTransition(effect);
2909         target->SetTransitionUserCallback(std::move(finishCallback));
2910     }
2911 }
2912 
SetClipShape(const RefPtr<BasicShape> & basicShape)2913 void ViewAbstract::SetClipShape(const RefPtr<BasicShape>& basicShape)
2914 {
2915     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2916         return;
2917     }
2918     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2919     CHECK_NULL_VOID(frameNode);
2920     auto target = frameNode->GetRenderContext();
2921     if (target) {
2922         if (target->GetClipEdge().has_value()) {
2923             target->UpdateClipEdge(false);
2924         }
2925         target->UpdateClipShape(basicShape);
2926     }
2927 }
2928 
SetClipShape(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)2929 void ViewAbstract::SetClipShape(FrameNode* frameNode, const RefPtr<BasicShape>& basicShape)
2930 {
2931     CHECK_NULL_VOID(frameNode);
2932     auto target = frameNode->GetRenderContext();
2933     if (target) {
2934         if (target->GetClipEdge().has_value()) {
2935             target->UpdateClipEdge(false);
2936         }
2937         target->UpdateClipShape(basicShape);
2938     }
2939 }
2940 
SetClipEdge(bool isClip)2941 void ViewAbstract::SetClipEdge(bool isClip)
2942 {
2943     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2944         return;
2945     }
2946     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2947     CHECK_NULL_VOID(frameNode);
2948     auto target = frameNode->GetRenderContext();
2949     if (target) {
2950         if (target->GetClipShape().has_value()) {
2951             target->ResetClipShape();
2952             target->OnClipShapeUpdate(nullptr);
2953         }
2954         target->UpdateClipEdge(isClip);
2955     }
2956 }
2957 
SetClipEdge(FrameNode * frameNode,bool isClip)2958 void ViewAbstract::SetClipEdge(FrameNode* frameNode, bool isClip)
2959 {
2960     CHECK_NULL_VOID(frameNode);
2961     auto target = frameNode->GetRenderContext();
2962     if (target) {
2963         if (target->GetClipShape().has_value()) {
2964             target->ResetClipShape();
2965             target->OnClipShapeUpdate(nullptr);
2966         }
2967         target->UpdateClipEdge(isClip);
2968     }
2969 }
2970 
SetMask(const RefPtr<BasicShape> & basicShape)2971 void ViewAbstract::SetMask(const RefPtr<BasicShape>& basicShape)
2972 {
2973     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2974         return;
2975     }
2976     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2977     CHECK_NULL_VOID(frameNode);
2978     auto target = frameNode->GetRenderContext();
2979     if (target) {
2980         if (target->HasProgressMask()) {
2981             target->ResetProgressMask();
2982             target->OnProgressMaskUpdate(nullptr);
2983         }
2984         target->UpdateClipMask(basicShape);
2985     }
2986 }
2987 
SetProgressMask(const RefPtr<ProgressMaskProperty> & progress)2988 void ViewAbstract::SetProgressMask(const RefPtr<ProgressMaskProperty>& progress)
2989 {
2990     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2991         return;
2992     }
2993     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2994     CHECK_NULL_VOID(frameNode);
2995     auto target = frameNode->GetRenderContext();
2996     if (target) {
2997         if (target->HasClipMask()) {
2998             target->ResetClipMask();
2999             target->OnClipMaskUpdate(nullptr);
3000         }
3001         target->UpdateProgressMask(progress);
3002     }
3003 }
3004 
SetBrightness(const Dimension & brightness)3005 void ViewAbstract::SetBrightness(const Dimension& brightness)
3006 {
3007     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3008         return;
3009     }
3010     ACE_UPDATE_RENDER_CONTEXT(FrontBrightness, brightness);
3011 }
3012 
SetBrightness(FrameNode * frameNode,const Dimension & brightness)3013 void ViewAbstract::SetBrightness(FrameNode* frameNode, const Dimension& brightness)
3014 {
3015     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontBrightness, brightness, frameNode);
3016 }
3017 
SetGrayScale(const Dimension & grayScale)3018 void ViewAbstract::SetGrayScale(const Dimension& grayScale)
3019 {
3020     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3021         return;
3022     }
3023     ACE_UPDATE_RENDER_CONTEXT(FrontGrayScale, grayScale);
3024 }
3025 
SetGrayScale(FrameNode * frameNode,const Dimension & grayScale)3026 void ViewAbstract::SetGrayScale(FrameNode* frameNode, const Dimension& grayScale)
3027 {
3028     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontGrayScale, grayScale, frameNode);
3029 }
3030 
SetContrast(const Dimension & contrast)3031 void ViewAbstract::SetContrast(const Dimension& contrast)
3032 {
3033     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3034         return;
3035     }
3036     ACE_UPDATE_RENDER_CONTEXT(FrontContrast, contrast);
3037 }
3038 
SetContrast(FrameNode * frameNode,const Dimension & contrast)3039 void ViewAbstract::SetContrast(FrameNode* frameNode, const Dimension& contrast)
3040 {
3041     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontContrast, contrast, frameNode);
3042 }
3043 
SetSaturate(const Dimension & saturate)3044 void ViewAbstract::SetSaturate(const Dimension& saturate)
3045 {
3046     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3047         return;
3048     }
3049     ACE_UPDATE_RENDER_CONTEXT(FrontSaturate, saturate);
3050 }
3051 
SetSaturate(FrameNode * frameNode,const Dimension & saturate)3052 void ViewAbstract::SetSaturate(FrameNode* frameNode, const Dimension& saturate)
3053 {
3054     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSaturate, saturate, frameNode);
3055 }
3056 
SetSepia(const Dimension & sepia)3057 void ViewAbstract::SetSepia(const Dimension& sepia)
3058 {
3059     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3060         return;
3061     }
3062     ACE_UPDATE_RENDER_CONTEXT(FrontSepia, sepia);
3063 }
3064 
SetSepia(FrameNode * frameNode,const Dimension & sepia)3065 void ViewAbstract::SetSepia(FrameNode* frameNode, const Dimension& sepia)
3066 {
3067     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSepia, sepia, frameNode);
3068 }
3069 
SetInvert(const InvertVariant & invert)3070 void ViewAbstract::SetInvert(const InvertVariant& invert)
3071 {
3072     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3073         return;
3074     }
3075     ACE_UPDATE_RENDER_CONTEXT(FrontInvert, invert);
3076 }
3077 
SetInvert(FrameNode * frameNode,const InvertVariant & invert)3078 void ViewAbstract::SetInvert(FrameNode* frameNode, const InvertVariant& invert)
3079 {
3080     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontInvert, invert, frameNode);
3081 }
3082 
SetSystemBarEffect(bool systemBarEffect)3083 void ViewAbstract::SetSystemBarEffect(bool systemBarEffect)
3084 {
3085     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3086         return;
3087     }
3088     ACE_UPDATE_RENDER_CONTEXT(SystemBarEffect, systemBarEffect);
3089 }
3090 
SetSystemBarEffect(FrameNode * frameNode,bool enable)3091 void ViewAbstract::SetSystemBarEffect(FrameNode *frameNode, bool enable)
3092 {
3093     ACE_UPDATE_NODE_RENDER_CONTEXT(SystemBarEffect, enable, frameNode);
3094 }
3095 
SetHueRotate(float hueRotate)3096 void ViewAbstract::SetHueRotate(float hueRotate)
3097 {
3098     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3099         return;
3100     }
3101     ACE_UPDATE_RENDER_CONTEXT(FrontHueRotate, hueRotate);
3102 }
3103 
SetHueRotate(FrameNode * frameNode,float hueRotate)3104 void ViewAbstract::SetHueRotate(FrameNode* frameNode, float hueRotate)
3105 {
3106     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontHueRotate, hueRotate, frameNode);
3107 }
3108 
SetColorBlend(const Color & colorBlend)3109 void ViewAbstract::SetColorBlend(const Color& colorBlend)
3110 {
3111     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3112         return;
3113     }
3114     ACE_UPDATE_RENDER_CONTEXT(FrontColorBlend, colorBlend);
3115 }
3116 
SetColorBlend(FrameNode * frameNode,const Color & colorBlend)3117 void ViewAbstract::SetColorBlend(FrameNode* frameNode, const Color& colorBlend)
3118 {
3119     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontColorBlend, colorBlend, frameNode);
3120 }
3121 
SetBorderImage(const RefPtr<BorderImage> & borderImage)3122 void ViewAbstract::SetBorderImage(const RefPtr<BorderImage>& borderImage)
3123 {
3124     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3125         return;
3126     }
3127     ACE_UPDATE_RENDER_CONTEXT(BorderImage, borderImage);
3128 }
3129 
SetBorderImageSource(const std::string & bdImageSrc,const std::string & bundleName,const std::string & moduleName)3130 void ViewAbstract::SetBorderImageSource(
3131     const std::string& bdImageSrc, const std::string& bundleName, const std::string& moduleName)
3132 {
3133     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3134         return;
3135     }
3136     ImageSourceInfo imageSourceInfo(bdImageSrc, bundleName, moduleName);
3137     ACE_UPDATE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo);
3138     ACE_UPDATE_RENDER_CONTEXT(BorderSourceFromImage, true);
3139 }
3140 
SetHasBorderImageSlice(bool tag)3141 void ViewAbstract::SetHasBorderImageSlice(bool tag)
3142 {
3143     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3144         return;
3145     }
3146     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageSlice, tag);
3147 }
3148 
SetHasBorderImageWidth(bool tag)3149 void ViewAbstract::SetHasBorderImageWidth(bool tag)
3150 {
3151     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3152         return;
3153     }
3154     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageWidth, tag);
3155 }
3156 
SetHasBorderImageOutset(bool tag)3157 void ViewAbstract::SetHasBorderImageOutset(bool tag)
3158 {
3159     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3160         return;
3161     }
3162     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageOutset, tag);
3163 }
3164 
SetHasBorderImageRepeat(bool tag)3165 void ViewAbstract::SetHasBorderImageRepeat(bool tag)
3166 {
3167     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3168         return;
3169     }
3170     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageRepeat, tag);
3171 }
3172 
SetBorderImageGradient(const Gradient & gradient)3173 void ViewAbstract::SetBorderImageGradient(const Gradient& gradient)
3174 {
3175     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3176         return;
3177     }
3178     ACE_UPDATE_RENDER_CONTEXT(BorderImageGradient, gradient);
3179     ACE_UPDATE_RENDER_CONTEXT(BorderSourceFromImage, false);
3180 }
3181 
3182 std::mutex ViewAbstract::visualEffectMutex_;
3183 OEMVisualEffectFunc ViewAbstract::oemVisualEffectFunc = nullptr;
RegisterOEMVisualEffect(OEMVisualEffectFunc func)3184 void ViewAbstract::RegisterOEMVisualEffect(OEMVisualEffectFunc func)
3185 {
3186     std::lock_guard<std::mutex> lock(visualEffectMutex_);
3187     ViewAbstract::oemVisualEffectFunc = func;
3188 }
3189 
SetVisualEffect(const OHOS::Rosen::VisualEffect * visualEffect)3190 void ViewAbstract::SetVisualEffect(const OHOS::Rosen::VisualEffect* visualEffect)
3191 {
3192     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3193         return;
3194     }
3195 
3196     std::lock_guard<std::mutex> lock(visualEffectMutex_);
3197     if (!oemVisualEffectFunc) {
3198         ACE_UPDATE_RENDER_CONTEXT(VisualEffect, visualEffect);
3199     } else {
3200         Rosen::VisualEffect* graphicVisualEffect = oemVisualEffectFunc(visualEffect);
3201         ACE_UPDATE_RENDER_CONTEXT(VisualEffect, graphicVisualEffect);
3202     }
3203 }
3204 
SetBackgroundFilter(const OHOS::Rosen::Filter * backgroundFilter)3205 void ViewAbstract::SetBackgroundFilter(const OHOS::Rosen::Filter* backgroundFilter)
3206 {
3207     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3208         return;
3209     }
3210     ACE_UPDATE_RENDER_CONTEXT(BackgroundFilter, backgroundFilter);
3211 }
3212 
SetForegroundFilter(const OHOS::Rosen::Filter * foregroundFilter)3213 void ViewAbstract::SetForegroundFilter(const OHOS::Rosen::Filter* foregroundFilter)
3214 {
3215     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3216         return;
3217     }
3218     ACE_UPDATE_RENDER_CONTEXT(ForegroundFilter, foregroundFilter);
3219 }
3220 
SetCompositingFilter(const OHOS::Rosen::Filter * compositingFilter)3221 void ViewAbstract::SetCompositingFilter(const OHOS::Rosen::Filter* compositingFilter)
3222 {
3223     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3224         return;
3225     }
3226     ACE_UPDATE_RENDER_CONTEXT(CompositingFilter, compositingFilter);
3227 }
3228 
SetOverlay(const OverlayOptions & overlay)3229 void ViewAbstract::SetOverlay(const OverlayOptions& overlay)
3230 {
3231     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3232         return;
3233     }
3234     ACE_UPDATE_RENDER_CONTEXT(OverlayText, overlay);
3235 }
3236 
SetOverlayBuilder(std::function<void ()> && buildFunc,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)3237 void ViewAbstract::SetOverlayBuilder(std::function<void()>&& buildFunc,
3238     const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
3239     const std::optional<Dimension>& offsetY)
3240 {
3241     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3242         return;
3243     }
3244     if (buildFunc) {
3245         auto buildNodeFunc = [func = std::move(buildFunc)]() -> RefPtr<UINode> {
3246             ScopedViewStackProcessor builderViewStackProcessor;
3247             func();
3248             auto customNode = ViewStackProcessor::GetInstance()->Finish();
3249             return customNode;
3250         };
3251         auto node = buildNodeFunc();
3252         auto overlayNode = AceType::DynamicCast<FrameNode>(node);
3253         if (!overlayNode && node) {
3254             auto* stack = ViewStackProcessor::GetInstance();
3255             auto nodeId = stack->ClaimNodeId();
3256             auto stackNode = FrameNode::CreateFrameNode(V2::STACK_ETS_TAG, nodeId, AceType::MakeRefPtr<StackPattern>());
3257             stackNode->AddChild(node);
3258             overlayNode = stackNode;
3259         }
3260         AddOverlayToFrameNode(overlayNode, align, offsetX, offsetY);
3261     } else {
3262         AddOverlayToFrameNode(nullptr, align, offsetX, offsetY);
3263     }
3264 }
3265 
SetOverlayComponentContent(const RefPtr<NG::FrameNode> & contentNode,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)3266 void ViewAbstract::SetOverlayComponentContent(const RefPtr<NG::FrameNode>& contentNode,
3267     const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
3268     const std::optional<Dimension>& offsetY)
3269 {
3270     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3271         return;
3272     }
3273     AddOverlayToFrameNode(contentNode, align, offsetX, offsetY);
3274 }
3275 
AddOverlayToFrameNode(const RefPtr<NG::FrameNode> & overlayNode,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)3276 void ViewAbstract::AddOverlayToFrameNode(const RefPtr<NG::FrameNode>& overlayNode,
3277     const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
3278     const std::optional<Dimension>& offsetY)
3279 {
3280     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3281     CHECK_NULL_VOID(frameNode);
3282     if (overlayNode == nullptr) {
3283         frameNode->SetOverlayNode(nullptr);
3284         return;
3285     }
3286     frameNode->SetOverlayNode(overlayNode);
3287     overlayNode->SetParent(AceType::WeakClaim(frameNode));
3288     overlayNode->SetActive(true);
3289     overlayNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
3290     auto layoutProperty = AceType::DynamicCast<LayoutProperty>(overlayNode->GetLayoutProperty());
3291     CHECK_NULL_VOID(layoutProperty);
3292     layoutProperty->SetIsOverlayNode(true);
3293     layoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT);
3294     layoutProperty->UpdateAlignment(align.value_or(Alignment::TOP_LEFT));
3295     layoutProperty->SetOverlayOffset(offsetX, offsetY);
3296     auto renderContext = overlayNode->GetRenderContext();
3297     CHECK_NULL_VOID(renderContext);
3298     renderContext->UpdateZIndex(INT32_MAX);
3299     auto focusHub = overlayNode->GetOrCreateFocusHub();
3300     CHECK_NULL_VOID(focusHub);
3301     focusHub->SetFocusable(false);
3302 }
3303 
SetMotionPath(const MotionPathOption & motionPath)3304 void ViewAbstract::SetMotionPath(const MotionPathOption& motionPath)
3305 {
3306     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3307         return;
3308     }
3309     ACE_UPDATE_RENDER_CONTEXT(MotionPath, motionPath);
3310 }
3311 
SetSharedTransition(const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)3312 void ViewAbstract::SetSharedTransition(
3313     const std::string& shareId, const std::shared_ptr<SharedTransitionOption>& option)
3314 {
3315     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3316     CHECK_NULL_VOID(frameNode);
3317     auto target = frameNode->GetRenderContext();
3318     if (target) {
3319         target->SetSharedTransitionOptions(option);
3320         target->SetShareId(shareId);
3321     }
3322 }
3323 
SetMask(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)3324 void ViewAbstract::SetMask(FrameNode* frameNode, const RefPtr<BasicShape>& basicShape)
3325 {
3326     CHECK_NULL_VOID(frameNode);
3327     auto target = frameNode->GetRenderContext();
3328     if (target) {
3329         if (target->HasProgressMask()) {
3330             target->ResetProgressMask();
3331             target->OnProgressMaskUpdate(nullptr);
3332         }
3333         target->UpdateClipMask(basicShape);
3334     }
3335 }
3336 
SetProgressMask(FrameNode * frameNode,const RefPtr<ProgressMaskProperty> & progress)3337 void ViewAbstract::SetProgressMask(FrameNode* frameNode, const RefPtr<ProgressMaskProperty>& progress)
3338 {
3339     CHECK_NULL_VOID(frameNode);
3340     auto target = frameNode->GetRenderContext();
3341     if (target) {
3342         if (target->HasClipMask()) {
3343             target->ResetClipMask();
3344             target->OnClipMaskUpdate(nullptr);
3345         }
3346         target->UpdateProgressMask(progress);
3347     }
3348 }
3349 
SetUseEffect(bool useEffect,EffectType effectType)3350 void ViewAbstract::SetUseEffect(bool useEffect, EffectType effectType)
3351 {
3352     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3353         return;
3354     }
3355     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3356     SetUseEffect(frameNode, useEffect, effectType);
3357 }
3358 
SetFreeze(bool freeze)3359 void ViewAbstract::SetFreeze(bool freeze)
3360 {
3361     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3362         return;
3363     }
3364     ACE_UPDATE_RENDER_CONTEXT(Freeze, freeze);
3365 }
3366 
SetUseShadowBatching(bool useShadowBatching)3367 void ViewAbstract::SetUseShadowBatching(bool useShadowBatching)
3368 {
3369     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3370         return;
3371     }
3372     ACE_UPDATE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching);
3373 }
3374 
SetForegroundColor(const Color & color)3375 void ViewAbstract::SetForegroundColor(const Color& color)
3376 {
3377     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3378         return;
3379     }
3380     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3381     CHECK_NULL_VOID(frameNode);
3382     auto renderContext = frameNode->GetRenderContext();
3383     CHECK_NULL_VOID(renderContext);
3384     if (renderContext->GetForegroundColorStrategy().has_value()) {
3385         renderContext->UpdateForegroundColorStrategy(ForegroundColorStrategy::NONE);
3386         renderContext->ResetForegroundColorStrategy();
3387     }
3388     renderContext->UpdateForegroundColor(color);
3389     renderContext->UpdateForegroundColorFlag(true);
3390 }
3391 
SetForegroundColorStrategy(const ForegroundColorStrategy & strategy)3392 void ViewAbstract::SetForegroundColorStrategy(const ForegroundColorStrategy& strategy)
3393 {
3394     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3395         return;
3396     }
3397     ACE_UPDATE_RENDER_CONTEXT(ForegroundColorStrategy, strategy);
3398     ACE_RESET_RENDER_CONTEXT(RenderContext, ForegroundColor);
3399     ACE_UPDATE_RENDER_CONTEXT(ForegroundColorFlag, true);
3400 }
3401 
SetKeyboardShortcut(const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)3402 void ViewAbstract::SetKeyboardShortcut(
3403     const std::string& value, const std::vector<ModifierKey>& keys, std::function<void()>&& onKeyboardShortcutAction)
3404 {
3405     auto pipeline = PipelineContext::GetCurrentContext();
3406     CHECK_NULL_VOID(pipeline);
3407     auto eventManager = pipeline->GetEventManager();
3408     CHECK_NULL_VOID(eventManager);
3409     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
3410     CHECK_NULL_VOID(eventHub);
3411     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3412     CHECK_NULL_VOID(frameNode);
3413     if (value.empty()) {
3414         eventHub->ClearSingleKeyboardShortcut();
3415         return;
3416     }
3417     auto key = eventManager->GetKeyboardShortcutKeys(keys);
3418     if ((key == 0 && value.length() == 1) || (key == 0 && keys.size() > 0 && value.length() > 1)) {
3419         return;
3420     }
3421     if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
3422         return;
3423     }
3424     eventHub->SetKeyboardShortcut(value, key, std::move(onKeyboardShortcutAction));
3425     eventManager->AddKeyboardShortcutNode(AceType::WeakClaim(frameNode));
3426 }
3427 
CreateAnimatablePropertyFloat(const std::string & propertyName,float value,const std::function<void (float)> & onCallbackEvent)3428 void ViewAbstract::CreateAnimatablePropertyFloat(
3429     const std::string& propertyName, float value, const std::function<void(float)>& onCallbackEvent)
3430 {
3431     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3432     CHECK_NULL_VOID(frameNode);
3433     frameNode->CreateAnimatablePropertyFloat(propertyName, value, onCallbackEvent);
3434 }
3435 
UpdateAnimatablePropertyFloat(const std::string & propertyName,float value)3436 void ViewAbstract::UpdateAnimatablePropertyFloat(const std::string& propertyName, float value)
3437 {
3438     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3439     CHECK_NULL_VOID(frameNode);
3440     frameNode->UpdateAnimatablePropertyFloat(propertyName, value);
3441 }
3442 
CreateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value,std::function<void (const RefPtr<CustomAnimatableArithmetic> &)> & onCallbackEvent)3443 void ViewAbstract::CreateAnimatableArithmeticProperty(const std::string& propertyName,
3444     RefPtr<CustomAnimatableArithmetic>& value,
3445     std::function<void(const RefPtr<CustomAnimatableArithmetic>&)>& onCallbackEvent)
3446 {
3447     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3448     CHECK_NULL_VOID(frameNode);
3449     frameNode->CreateAnimatableArithmeticProperty(propertyName, value, onCallbackEvent);
3450 }
3451 
UpdateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value)3452 void ViewAbstract::UpdateAnimatableArithmeticProperty(
3453     const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value)
3454 {
3455     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3456     CHECK_NULL_VOID(frameNode);
3457     frameNode->UpdateAnimatableArithmeticProperty(propertyName, value);
3458 }
3459 
SetObscured(const std::vector<ObscuredReasons> & reasons)3460 void ViewAbstract::SetObscured(const std::vector<ObscuredReasons>& reasons)
3461 {
3462     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3463         return;
3464     }
3465     ACE_UPDATE_RENDER_CONTEXT(Obscured, reasons);
3466     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3467     CHECK_NULL_VOID(frameNode);
3468     frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
3469 }
3470 
SetPrivacySensitive(bool flag)3471 void ViewAbstract::SetPrivacySensitive(bool flag)
3472 {
3473     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3474         return;
3475     }
3476     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3477     CHECK_NULL_VOID(frameNode);
3478     frameNode->SetPrivacySensitive(flag);
3479     frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
3480 }
3481 
SetPrivacySensitive(FrameNode * frameNode,bool flag)3482 void ViewAbstract::SetPrivacySensitive(FrameNode* frameNode, bool flag)
3483 {
3484     CHECK_NULL_VOID(frameNode);
3485     frameNode->SetPrivacySensitive(flag);
3486     frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
3487 }
3488 
UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts & opts)3489 void ViewAbstract::UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts& opts)
3490 {
3491     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3492         return;
3493     }
3494     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts);
3495 }
3496 
SetRenderGroup(bool isRenderGroup)3497 void ViewAbstract::SetRenderGroup(bool isRenderGroup)
3498 {
3499     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3500         return;
3501     }
3502     ACE_UPDATE_RENDER_CONTEXT(RenderGroup, isRenderGroup);
3503     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
3504     CHECK_NULL_VOID(frameNode);
3505     frameNode->SetApplicationRenderGroupMarked(true);
3506 }
3507 
SetRenderFit(RenderFit renderFit)3508 void ViewAbstract::SetRenderFit(RenderFit renderFit)
3509 {
3510     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3511         return;
3512     }
3513     ACE_UPDATE_RENDER_CONTEXT(RenderFit, renderFit);
3514 }
3515 
SetAttractionEffect(const AttractionEffect & effect)3516 void ViewAbstract::SetAttractionEffect(const AttractionEffect& effect)
3517 {
3518     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3519         return;
3520     }
3521     ACE_UPDATE_RENDER_CONTEXT(AttractionEffect, effect);
3522 }
3523 
SetBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)3524 void ViewAbstract::SetBorderRadius(FrameNode *frameNode, const BorderRadiusProperty& value)
3525 {
3526     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, value, frameNode);
3527 }
3528 
SetBorderRadius(FrameNode * frameNode,const Dimension & value)3529 void ViewAbstract::SetBorderRadius(FrameNode* frameNode, const Dimension& value)
3530 {
3531     BorderRadiusProperty borderRadius;
3532     borderRadius.SetRadius(value);
3533     borderRadius.multiValued = false;
3534     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, borderRadius, frameNode);
3535 }
3536 
SetBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)3537 void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value)
3538 {
3539     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value, frameNode);
3540     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, value, frameNode);
3541 }
3542 
SetBorderWidth(FrameNode * frameNode,const Dimension & value)3543 void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const Dimension& value)
3544 {
3545     BorderWidthProperty borderWidth;
3546     if (Negative(value.Value())) {
3547         borderWidth.SetBorderWidth(Dimension(0));
3548         LOGW("border width is negative, reset to 0");
3549     } else {
3550         borderWidth.SetBorderWidth(value);
3551     }
3552     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth, frameNode);
3553     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, borderWidth, frameNode);
3554 }
3555 
SetBorderColor(FrameNode * frameNode,const BorderColorProperty & value)3556 void ViewAbstract::SetBorderColor(FrameNode* frameNode, const BorderColorProperty& value)
3557 {
3558     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, value, frameNode);
3559 }
3560 
SetBorderColor(FrameNode * frameNode,const Color & value)3561 void ViewAbstract::SetBorderColor(FrameNode* frameNode, const Color& value)
3562 {
3563     BorderColorProperty borderColor;
3564     borderColor.SetColor(value);
3565     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, borderColor, frameNode);
3566 }
3567 
SetWidth(FrameNode * frameNode,const CalcLength & width)3568 void ViewAbstract::SetWidth(FrameNode* frameNode, const CalcLength& width)
3569 {
3570     CHECK_NULL_VOID(frameNode);
3571     auto layoutProperty = frameNode->GetLayoutProperty();
3572     CHECK_NULL_VOID(layoutProperty);
3573     // get previously user defined ideal height
3574     std::optional<CalcLength> height = std::nullopt;
3575     auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
3576     if (layoutConstraint && layoutConstraint->selfIdealSize) {
3577         height = layoutConstraint->selfIdealSize->Height();
3578     }
3579     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
3580 }
3581 
SetHeight(FrameNode * frameNode,const CalcLength & height)3582 void ViewAbstract::SetHeight(FrameNode* frameNode, const CalcLength& height)
3583 {
3584     CHECK_NULL_VOID(frameNode);
3585     auto layoutProperty = frameNode->GetLayoutProperty();
3586     CHECK_NULL_VOID(layoutProperty);
3587     std::optional<CalcLength> width = std::nullopt;
3588     auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
3589     if (layoutConstraint && layoutConstraint->selfIdealSize) {
3590         width = layoutConstraint->selfIdealSize->Width();
3591     }
3592     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
3593 }
3594 
ClearWidthOrHeight(FrameNode * frameNode,bool isWidth)3595 void ViewAbstract::ClearWidthOrHeight(FrameNode* frameNode, bool isWidth)
3596 {
3597     CHECK_NULL_VOID(frameNode);
3598     auto layoutProperty = frameNode->GetLayoutProperty();
3599     CHECK_NULL_VOID(layoutProperty);
3600     layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
3601 }
3602 
SetPosition(FrameNode * frameNode,const OffsetT<Dimension> & value)3603 void ViewAbstract::SetPosition(FrameNode* frameNode, const OffsetT<Dimension>& value)
3604 {
3605     CHECK_NULL_VOID(frameNode);
3606     CheckIfParentNeedMarkDirty(frameNode);
3607     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode);
3608     ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode);
3609 }
3610 
SetPositionEdges(FrameNode * frameNode,const EdgesParam & value)3611 void ViewAbstract::SetPositionEdges(FrameNode* frameNode, const EdgesParam& value)
3612 {
3613     CHECK_NULL_VOID(frameNode);
3614     CheckIfParentNeedMarkDirty(frameNode);
3615     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode);
3616     ACE_UPDATE_NODE_RENDER_CONTEXT(PositionEdges, value, frameNode);
3617 }
3618 
ResetPosition(FrameNode * frameNode)3619 void ViewAbstract::ResetPosition(FrameNode* frameNode)
3620 {
3621     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode);
3622     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode);
3623     CHECK_NULL_VOID(frameNode);
3624     auto parentNode = frameNode->GetAncestorNodeOfFrame(false);
3625     CHECK_NULL_VOID(parentNode);
3626     auto parentPattern = parentNode->GetPattern();
3627 
3628     if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG ||
3629         parentNode->GetTag() == V2::FLEX_ETS_TAG) {
3630         frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
3631     } else {
3632         auto renderContext = frameNode->GetRenderContext();
3633         CHECK_NULL_VOID(renderContext);
3634         renderContext->RecalculatePosition();
3635     }
3636 }
3637 
SetTransformMatrix(FrameNode * frameNode,const Matrix4 & matrix)3638 void ViewAbstract::SetTransformMatrix(FrameNode* frameNode, const Matrix4& matrix)
3639 {
3640     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformMatrix, matrix, frameNode);
3641 }
3642 
SetHitTestMode(FrameNode * frameNode,HitTestMode hitTestMode)3643 void ViewAbstract::SetHitTestMode(FrameNode* frameNode, HitTestMode hitTestMode)
3644 {
3645     CHECK_NULL_VOID(frameNode);
3646     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3647     CHECK_NULL_VOID(gestureHub);
3648     gestureHub->SetHitTestMode(hitTestMode);
3649 }
3650 
SetOpacity(FrameNode * frameNode,double opacity)3651 void ViewAbstract::SetOpacity(FrameNode* frameNode, double opacity)
3652 {
3653     ACE_UPDATE_NODE_RENDER_CONTEXT(Opacity, opacity, frameNode);
3654 }
3655 
SetZIndex(FrameNode * frameNode,int32_t value)3656 void ViewAbstract::SetZIndex(FrameNode* frameNode, int32_t value)
3657 {
3658     ACE_UPDATE_NODE_RENDER_CONTEXT(ZIndex, value, frameNode);
3659 }
3660 
SetLinearGradient(FrameNode * frameNode,const NG::Gradient & gradient)3661 void ViewAbstract::SetLinearGradient(FrameNode* frameNode, const NG::Gradient& gradient)
3662 {
3663     ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::LINEAR, frameNode);
3664     ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradient, gradient, frameNode);
3665 }
3666 
SetSweepGradient(FrameNode * frameNode,const NG::Gradient & gradient)3667 void ViewAbstract::SetSweepGradient(FrameNode* frameNode, const NG::Gradient& gradient)
3668 {
3669     ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::SWEEP, frameNode);
3670     ACE_UPDATE_NODE_RENDER_CONTEXT(SweepGradient, gradient, frameNode);
3671 }
3672 
SetRadialGradient(FrameNode * frameNode,const NG::Gradient & gradient)3673 void ViewAbstract::SetRadialGradient(FrameNode* frameNode, const NG::Gradient& gradient)
3674 {
3675     ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::RADIAL, frameNode);
3676     ACE_UPDATE_NODE_RENDER_CONTEXT(RadialGradient, gradient, frameNode);
3677 }
3678 
SetOverlay(FrameNode * frameNode,const NG::OverlayOptions & overlay)3679 void ViewAbstract::SetOverlay(FrameNode* frameNode, const NG::OverlayOptions& overlay)
3680 {
3681     ACE_UPDATE_NODE_RENDER_CONTEXT(OverlayText, overlay, frameNode);
3682 }
3683 
SetBorderImage(FrameNode * frameNode,const RefPtr<BorderImage> & borderImage)3684 void ViewAbstract::SetBorderImage(FrameNode* frameNode, const RefPtr<BorderImage>& borderImage)
3685 {
3686     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImage, borderImage, frameNode);
3687 }
3688 
SetBorderImageSource(FrameNode * frameNode,const std::string & bdImageSrc)3689 void ViewAbstract::SetBorderImageSource(FrameNode* frameNode, const std::string& bdImageSrc)
3690 {
3691     ImageSourceInfo imageSourceInfo(bdImageSrc);
3692     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo, frameNode);
3693     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderSourceFromImage, true, frameNode);
3694 }
3695 
SetHasBorderImageSlice(FrameNode * frameNode,bool tag)3696 void ViewAbstract::SetHasBorderImageSlice(FrameNode* frameNode, bool tag)
3697 {
3698     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageSlice, tag, frameNode);
3699 }
3700 
SetHasBorderImageWidth(FrameNode * frameNode,bool tag)3701 void ViewAbstract::SetHasBorderImageWidth(FrameNode* frameNode, bool tag)
3702 {
3703     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageWidth, tag, frameNode);
3704 }
3705 
SetHasBorderImageOutset(FrameNode * frameNode,bool tag)3706 void ViewAbstract::SetHasBorderImageOutset(FrameNode* frameNode, bool tag)
3707 {
3708     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageOutset, tag, frameNode);
3709 }
3710 
SetHasBorderImageRepeat(FrameNode * frameNode,bool tag)3711 void ViewAbstract::SetHasBorderImageRepeat(FrameNode* frameNode, bool tag)
3712 {
3713     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageRepeat, tag, frameNode);
3714 }
3715 
SetBorderImageGradient(FrameNode * frameNode,const NG::Gradient & gradient)3716 void ViewAbstract::SetBorderImageGradient(FrameNode* frameNode, const NG::Gradient& gradient)
3717 {
3718     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageGradient, gradient, frameNode);
3719     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderSourceFromImage, false, frameNode);
3720 }
3721 
SetForegroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & fgBlurStyle,const SysOptions & sysOptions)3722 void ViewAbstract::SetForegroundBlurStyle(
3723     FrameNode* frameNode, const BlurStyleOption& fgBlurStyle, const SysOptions& sysOptions)
3724 {
3725     const auto target = frameNode->GetRenderContext();
3726     if (target) {
3727         target->UpdateFrontBlurStyle(fgBlurStyle, sysOptions);
3728         if (target->GetFrontBlurRadius().has_value()) {
3729             target->UpdateFrontBlurRadius(Dimension());
3730         }
3731     }
3732 }
3733 
SetLinearGradientBlur(FrameNode * frameNode,const NG::LinearGradientBlurPara & blurPara)3734 void ViewAbstract::SetLinearGradientBlur(FrameNode *frameNode, const NG::LinearGradientBlurPara& blurPara)
3735 {
3736     ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradientBlur, blurPara, frameNode);
3737 }
3738 
SetMagnifier(FrameNode * frameNode,const MagnifierParams & magnifierOffset)3739 void ViewAbstract::SetMagnifier(FrameNode* frameNode, const MagnifierParams& magnifierOffset)
3740 {
3741     ACE_UPDATE_NODE_RENDER_CONTEXT(Magnifier, magnifierOffset, frameNode);
3742 }
3743 
ReSetMagnifier(FrameNode * frameNode)3744 void ViewAbstract::ReSetMagnifier(FrameNode* frameNode)
3745 {
3746     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Magnifier, frameNode);
3747 }
3748 
SetBackgroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & bgBlurStyle,const SysOptions & sysOptions)3749 void ViewAbstract::SetBackgroundBlurStyle(
3750     FrameNode* frameNode, const BlurStyleOption& bgBlurStyle, const SysOptions& sysOptions)
3751 {
3752     auto pipeline = frameNode->GetContext();
3753     CHECK_NULL_VOID(pipeline);
3754     if (bgBlurStyle.policy == BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) {
3755         pipeline->AddWindowFocusChangedCallback(frameNode->GetId());
3756     } else {
3757         pipeline->RemoveWindowFocusChangedCallback(frameNode->GetId());
3758     }
3759     auto target = frameNode->GetRenderContext();
3760     if (target) {
3761         if (target->GetBackgroundEffect().has_value()) {
3762             target->UpdateBackgroundEffect(std::nullopt);
3763         }
3764         target->UpdateBackBlurStyle(bgBlurStyle, sysOptions);
3765         if (target->GetBackBlurRadius().has_value()) {
3766             target->UpdateBackBlurRadius(Dimension());
3767         }
3768     }
3769 }
3770 
SetPixelStretchEffect(FrameNode * frameNode,PixStretchEffectOption & option)3771 void ViewAbstract::SetPixelStretchEffect(FrameNode* frameNode, PixStretchEffectOption& option)
3772 {
3773     ACE_UPDATE_NODE_RENDER_CONTEXT(PixelStretchEffect, option, frameNode);
3774 }
3775 
SetLightUpEffect(FrameNode * frameNode,double radio)3776 void ViewAbstract::SetLightUpEffect(FrameNode* frameNode, double radio)
3777 {
3778     ACE_UPDATE_NODE_RENDER_CONTEXT(LightUpEffect, radio, frameNode);
3779 }
3780 
SetSphericalEffect(FrameNode * frameNode,double radio)3781 void ViewAbstract::SetSphericalEffect(FrameNode* frameNode, double radio)
3782 {
3783     ACE_UPDATE_NODE_RENDER_CONTEXT(SphericalEffect, radio, frameNode);
3784 }
3785 
SetRenderGroup(FrameNode * frameNode,bool isRenderGroup)3786 void ViewAbstract::SetRenderGroup(FrameNode* frameNode, bool isRenderGroup)
3787 {
3788     ACE_UPDATE_NODE_RENDER_CONTEXT(RenderGroup, isRenderGroup, frameNode);
3789     CHECK_NULL_VOID(frameNode);
3790     frameNode->SetApplicationRenderGroupMarked(true);
3791 }
3792 
SetRenderFit(FrameNode * frameNode,RenderFit renderFit)3793 void ViewAbstract::SetRenderFit(FrameNode* frameNode, RenderFit renderFit)
3794 {
3795     ACE_UPDATE_NODE_RENDER_CONTEXT(RenderFit, renderFit, frameNode);
3796 }
3797 
SetUseEffect(FrameNode * frameNode,bool useEffect,EffectType effectType)3798 void ViewAbstract::SetUseEffect(FrameNode* frameNode, bool useEffect, EffectType effectType)
3799 {
3800     CHECK_NULL_VOID(frameNode);
3801     auto* pipeline = frameNode->GetContext();
3802     CHECK_NULL_VOID(pipeline);
3803     if (useEffect && effectType == EffectType::WINDOW_EFFECT) {
3804         pipeline->AddWindowActivateChangedCallback(frameNode->GetId());
3805     } else {
3806         pipeline->RemoveWindowActivateChangedCallback(frameNode->GetId());
3807     }
3808     const auto& target = frameNode->GetRenderContext();
3809     if (target) {
3810         target->UpdateUseEffect(useEffect);
3811         target->UpdateUseEffectType(effectType);
3812     }
3813 }
3814 
SetForegroundColor(FrameNode * frameNode,const Color & color)3815 void ViewAbstract::SetForegroundColor(FrameNode* frameNode, const Color& color)
3816 {
3817     auto renderContext = frameNode->GetRenderContext();
3818     CHECK_NULL_VOID(renderContext);
3819     if (renderContext->GetForegroundColorStrategy().has_value()) {
3820         renderContext->UpdateForegroundColorStrategy(ForegroundColorStrategy::NONE);
3821         renderContext->ResetForegroundColorStrategy();
3822     }
3823     renderContext->UpdateForegroundColor(color);
3824     renderContext->UpdateForegroundColorFlag(true);
3825 }
3826 
SetForegroundColorStrategy(FrameNode * frameNode,const ForegroundColorStrategy & strategy)3827 void ViewAbstract::SetForegroundColorStrategy(FrameNode* frameNode, const ForegroundColorStrategy& strategy)
3828 {
3829     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorStrategy, strategy, frameNode);
3830     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, ForegroundColor, frameNode);
3831     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorFlag, true, frameNode);
3832 }
3833 
SetLightPosition(const CalcDimension & positionX,const CalcDimension & positionY,const CalcDimension & positionZ)3834 void ViewAbstract::SetLightPosition(
3835     const CalcDimension& positionX, const CalcDimension& positionY, const CalcDimension& positionZ)
3836 {
3837     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3838         return;
3839     }
3840     ACE_UPDATE_RENDER_CONTEXT(LightPosition, TranslateOptions(positionX, positionY, positionZ));
3841 }
3842 
SetLightIntensity(const float value)3843 void ViewAbstract::SetLightIntensity(const float value)
3844 {
3845     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3846         return;
3847     }
3848     ACE_UPDATE_RENDER_CONTEXT(LightIntensity, value);
3849 }
3850 
SetLightColor(const Color & value)3851 void ViewAbstract::SetLightColor(const Color& value)
3852 {
3853     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3854         return;
3855     }
3856     ACE_UPDATE_RENDER_CONTEXT(LightColor, value);
3857 }
3858 
SetLightIlluminated(const uint32_t value)3859 void ViewAbstract::SetLightIlluminated(const uint32_t value)
3860 {
3861     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3862         return;
3863     }
3864     ACE_UPDATE_RENDER_CONTEXT(LightIlluminated, value);
3865 }
3866 
SetIlluminatedBorderWidth(const Dimension & value)3867 void ViewAbstract::SetIlluminatedBorderWidth(const Dimension& value)
3868 {
3869     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3870         return;
3871     }
3872     ACE_UPDATE_RENDER_CONTEXT(IlluminatedBorderWidth, value);
3873 }
3874 
SetBloom(const float value)3875 void ViewAbstract::SetBloom(const float value)
3876 {
3877     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3878         return;
3879     }
3880     ACE_UPDATE_RENDER_CONTEXT(Bloom, value);
3881 }
3882 
SetLightPosition(FrameNode * frameNode,const CalcDimension & positionX,const CalcDimension & positionY,const CalcDimension & positionZ)3883 void ViewAbstract::SetLightPosition(FrameNode* frameNode, const CalcDimension& positionX,
3884     const CalcDimension& positionY, const CalcDimension& positionZ)
3885 {
3886     CHECK_NULL_VOID(frameNode);
3887     ACE_UPDATE_NODE_RENDER_CONTEXT(LightPosition, TranslateOptions(positionX, positionY, positionZ), frameNode);
3888 }
3889 
SetLightIntensity(FrameNode * frameNode,const float value)3890 void ViewAbstract::SetLightIntensity(FrameNode* frameNode, const float value)
3891 {
3892     CHECK_NULL_VOID(frameNode);
3893     ACE_UPDATE_NODE_RENDER_CONTEXT(LightIntensity, value, frameNode);
3894 }
3895 
SetLightColor(FrameNode * frameNode,const Color & value)3896 void ViewAbstract::SetLightColor(FrameNode* frameNode, const Color& value)
3897 {
3898     CHECK_NULL_VOID(frameNode);
3899     ACE_UPDATE_NODE_RENDER_CONTEXT(LightColor, value, frameNode);
3900 }
3901 
SetLightIlluminated(FrameNode * frameNode,const uint32_t value)3902 void ViewAbstract::SetLightIlluminated(FrameNode* frameNode, const uint32_t value)
3903 {
3904     CHECK_NULL_VOID(frameNode);
3905     ACE_UPDATE_NODE_RENDER_CONTEXT(LightIlluminated, value, frameNode);
3906 }
3907 
SetIlluminatedBorderWidth(FrameNode * frameNode,const Dimension & value)3908 void ViewAbstract::SetIlluminatedBorderWidth(FrameNode* frameNode, const Dimension& value)
3909 {
3910     CHECK_NULL_VOID(frameNode);
3911     ACE_UPDATE_NODE_RENDER_CONTEXT(IlluminatedBorderWidth, value, frameNode);
3912 }
3913 
SetBloom(FrameNode * frameNode,const float value)3914 void ViewAbstract::SetBloom(FrameNode* frameNode, const float value)
3915 {
3916     CHECK_NULL_VOID(frameNode);
3917     ACE_UPDATE_NODE_RENDER_CONTEXT(Bloom, value, frameNode);
3918 }
3919 
SetMotionPath(FrameNode * frameNode,const MotionPathOption & motionPath)3920 void ViewAbstract::SetMotionPath(FrameNode* frameNode, const MotionPathOption& motionPath)
3921 {
3922     ACE_UPDATE_NODE_RENDER_CONTEXT(MotionPath, motionPath, frameNode);
3923 }
3924 
SetFocusOnTouch(FrameNode * frameNode,bool isSet)3925 void ViewAbstract::SetFocusOnTouch(FrameNode* frameNode, bool isSet)
3926 {
3927     CHECK_NULL_VOID(frameNode);
3928     auto focusHub = frameNode->GetOrCreateFocusHub();
3929     CHECK_NULL_VOID(focusHub);
3930     focusHub->SetIsFocusOnTouch(isSet);
3931 }
3932 
SetGroupDefaultFocus(FrameNode * frameNode,bool isSet)3933 void ViewAbstract::SetGroupDefaultFocus(FrameNode* frameNode, bool isSet)
3934 {
3935     CHECK_NULL_VOID(frameNode);
3936     auto focusHub = frameNode->GetOrCreateFocusHub();
3937     CHECK_NULL_VOID(focusHub);
3938     focusHub->SetIsDefaultGroupFocus(isSet);
3939 }
3940 
SetFocusable(FrameNode * frameNode,bool focusable)3941 void ViewAbstract::SetFocusable(FrameNode* frameNode, bool focusable)
3942 {
3943     CHECK_NULL_VOID(frameNode);
3944     auto focusHub = frameNode->GetOrCreateFocusHub();
3945     CHECK_NULL_VOID(focusHub);
3946     focusHub->SetFocusable(focusable);
3947 }
3948 
SetTabStop(FrameNode * frameNode,bool tabStop)3949 void ViewAbstract::SetTabStop(FrameNode* frameNode, bool tabStop)
3950 {
3951     CHECK_NULL_VOID(frameNode);
3952     auto focusHub = frameNode->GetOrCreateFocusHub();
3953     CHECK_NULL_VOID(focusHub);
3954     focusHub->SetTabStop(tabStop);
3955 }
3956 
SetFocusType(FrameNode * frameNode,FocusType focusType)3957 void ViewAbstract::SetFocusType(FrameNode* frameNode, FocusType focusType)
3958 {
3959     CHECK_NULL_VOID(frameNode);
3960     auto focusHub = frameNode->GetOrCreateFocusHub();
3961     CHECK_NULL_VOID(focusHub);
3962     focusHub->SetFocusType(focusType);
3963 }
3964 
SetTouchable(FrameNode * frameNode,bool touchable)3965 void ViewAbstract::SetTouchable(FrameNode* frameNode, bool touchable)
3966 {
3967     CHECK_NULL_VOID(frameNode);
3968     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3969     CHECK_NULL_VOID(gestureHub);
3970     gestureHub->SetTouchable(touchable);
3971 }
3972 
SetDefaultFocus(FrameNode * frameNode,bool isSet)3973 void ViewAbstract::SetDefaultFocus(FrameNode* frameNode, bool isSet)
3974 {
3975     CHECK_NULL_VOID(frameNode);
3976     auto focusHub = frameNode->GetOrCreateFocusHub();
3977     CHECK_NULL_VOID(focusHub);
3978     focusHub->SetIsDefaultFocus(isSet);
3979 }
3980 
SetDisplayIndex(FrameNode * frameNode,int32_t value)3981 void ViewAbstract::SetDisplayIndex(FrameNode* frameNode, int32_t value)
3982 {
3983     CHECK_NULL_VOID(frameNode);
3984     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value, frameNode);
3985 }
3986 
SetOffset(FrameNode * frameNode,const OffsetT<Dimension> & value)3987 void ViewAbstract::SetOffset(FrameNode* frameNode, const OffsetT<Dimension>& value)
3988 {
3989     CHECK_NULL_VOID(frameNode);
3990     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, OffsetEdges, frameNode);
3991     ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, value, frameNode);
3992 }
3993 
SetOffsetEdges(FrameNode * frameNode,const EdgesParam & value)3994 void ViewAbstract::SetOffsetEdges(FrameNode* frameNode, const EdgesParam& value)
3995 {
3996     CHECK_NULL_VOID(frameNode);
3997     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Offset, frameNode);
3998     ACE_UPDATE_NODE_RENDER_CONTEXT(OffsetEdges, value, frameNode);
3999 }
4000 
MarkAnchor(FrameNode * frameNode,const OffsetT<Dimension> & value)4001 void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT<Dimension>& value)
4002 {
4003     CHECK_NULL_VOID(frameNode);
4004     ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, value, frameNode);
4005 }
4006 
SetVisibility(FrameNode * frameNode,VisibleType visible)4007 void ViewAbstract::SetVisibility(FrameNode* frameNode, VisibleType visible)
4008 {
4009     CHECK_NULL_VOID(frameNode);
4010     auto layoutProperty = frameNode->GetLayoutProperty();
4011     if (layoutProperty) {
4012         layoutProperty->UpdateVisibility(visible, true, true);
4013     }
4014 
4015     auto focusHub = frameNode->GetOrCreateFocusHub();
4016     if (focusHub) {
4017         focusHub->SetShow(visible == VisibleType::VISIBLE);
4018     }
4019 }
4020 
SetPadding(FrameNode * frameNode,const CalcLength & value)4021 void ViewAbstract::SetPadding(FrameNode* frameNode, const CalcLength& value)
4022 {
4023     CHECK_NULL_VOID(frameNode);
4024     PaddingProperty padding;
4025     padding.SetEdges(value);
4026     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding, frameNode);
4027 }
4028 
SetPadding(FrameNode * frameNode,const PaddingProperty & value)4029 void ViewAbstract::SetPadding(FrameNode* frameNode, const PaddingProperty& value)
4030 {
4031     CHECK_NULL_VOID(frameNode);
4032     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, value, frameNode);
4033 }
4034 
SetMargin(FrameNode * frameNode,const CalcLength & value)4035 void ViewAbstract::SetMargin(FrameNode* frameNode, const CalcLength& value)
4036 {
4037     CHECK_NULL_VOID(frameNode);
4038     MarginProperty margin;
4039     margin.SetEdges(value);
4040     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin, frameNode);
4041 }
4042 
SetMargin(FrameNode * frameNode,const PaddingProperty & value)4043 void ViewAbstract::SetMargin(FrameNode* frameNode, const PaddingProperty& value)
4044 {
4045     CHECK_NULL_VOID(frameNode);
4046     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, value, frameNode);
4047 }
4048 
SetLayoutDirection(FrameNode * frameNode,TextDirection value)4049 void ViewAbstract::SetLayoutDirection(FrameNode* frameNode, TextDirection value)
4050 {
4051     CHECK_NULL_VOID(frameNode);
4052     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value, frameNode);
4053 }
4054 
UpdateSafeAreaExpandOpts(FrameNode * frameNode,const SafeAreaExpandOpts & opts)4055 void ViewAbstract::UpdateSafeAreaExpandOpts(FrameNode* frameNode, const SafeAreaExpandOpts& opts)
4056 {
4057     CHECK_NULL_VOID(frameNode);
4058     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts, frameNode);
4059 }
4060 
SetAspectRatio(FrameNode * frameNode,float ratio)4061 void ViewAbstract::SetAspectRatio(FrameNode* frameNode, float ratio)
4062 {
4063     CHECK_NULL_VOID(frameNode);
4064     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio, frameNode);
4065 }
4066 
SetAlignSelf(FrameNode * frameNode,FlexAlign value)4067 void ViewAbstract::SetAlignSelf(FrameNode* frameNode, FlexAlign value)
4068 {
4069     CHECK_NULL_VOID(frameNode);
4070     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value, frameNode);
4071 }
4072 
SetFlexBasis(FrameNode * frameNode,const Dimension & value)4073 void ViewAbstract::SetFlexBasis(FrameNode* frameNode, const Dimension& value)
4074 {
4075     CHECK_NULL_VOID(frameNode);
4076     if (LessNotEqual(value.Value(), 0.0f)) {
4077         ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension(), frameNode);
4078         return;
4079     }
4080     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value, frameNode);
4081 }
4082 
ResetFlexShrink(FrameNode * frameNode)4083 void ViewAbstract::ResetFlexShrink(FrameNode* frameNode)
4084 {
4085     CHECK_NULL_VOID(frameNode);
4086     ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, frameNode);
4087 }
4088 
SetFlexShrink(FrameNode * frameNode,float value)4089 void ViewAbstract::SetFlexShrink(FrameNode* frameNode, float value)
4090 {
4091     CHECK_NULL_VOID(frameNode);
4092     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value, frameNode);
4093 }
4094 
SetFlexGrow(FrameNode * frameNode,float value)4095 void ViewAbstract::SetFlexGrow(FrameNode* frameNode, float value)
4096 {
4097     CHECK_NULL_VOID(frameNode);
4098     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value, frameNode);
4099 }
4100 
SetLayoutWeight(FrameNode * frameNode,float value)4101 void ViewAbstract::SetLayoutWeight(FrameNode* frameNode, float value)
4102 {
4103     CHECK_NULL_VOID(frameNode);
4104     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, value, frameNode);
4105 }
4106 
SetChainWeight(FrameNode * frameNode,const NG::ChainWeightPair & value)4107 void ViewAbstract::SetChainWeight(FrameNode* frameNode, const NG::ChainWeightPair& value)
4108 {
4109     CHECK_NULL_VOID(frameNode);
4110     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, ChainWeight, value, frameNode);
4111 }
4112 
ResetMaxSize(FrameNode * frameNode,bool resetWidth)4113 void ViewAbstract::ResetMaxSize(FrameNode* frameNode, bool resetWidth)
4114 {
4115     CHECK_NULL_VOID(frameNode);
4116     auto layoutProperty = frameNode->GetLayoutProperty();
4117     CHECK_NULL_VOID(layoutProperty);
4118     layoutProperty->ResetCalcMaxSize(resetWidth);
4119 }
4120 
ResetMinSize(FrameNode * frameNode,bool resetWidth)4121 void ViewAbstract::ResetMinSize(FrameNode* frameNode, bool resetWidth)
4122 {
4123     CHECK_NULL_VOID(frameNode);
4124     auto layoutProperty = frameNode->GetLayoutProperty();
4125     CHECK_NULL_VOID(layoutProperty);
4126     layoutProperty->ResetCalcMinSize(resetWidth);
4127 }
4128 
SetMinWidth(FrameNode * frameNode,const CalcLength & minWidth)4129 void ViewAbstract::SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth)
4130 {
4131     CHECK_NULL_VOID(frameNode);
4132     auto layoutProperty = frameNode->GetLayoutProperty();
4133     CHECK_NULL_VOID(layoutProperty);
4134     layoutProperty->UpdateCalcMinSize(CalcSize(minWidth, std::nullopt));
4135 }
4136 
SetMaxWidth(FrameNode * frameNode,const CalcLength & maxWidth)4137 void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth)
4138 {
4139     CHECK_NULL_VOID(frameNode);
4140     auto layoutProperty = frameNode->GetLayoutProperty();
4141     CHECK_NULL_VOID(layoutProperty);
4142     layoutProperty->UpdateCalcMaxSize(CalcSize(maxWidth, std::nullopt));
4143 }
4144 
SetMinHeight(FrameNode * frameNode,const CalcLength & minHeight)4145 void ViewAbstract::SetMinHeight(FrameNode* frameNode, const CalcLength& minHeight)
4146 {
4147     CHECK_NULL_VOID(frameNode);
4148     auto layoutProperty = frameNode->GetLayoutProperty();
4149     CHECK_NULL_VOID(layoutProperty);
4150     layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, minHeight));
4151 }
4152 
SetMaxHeight(FrameNode * frameNode,const CalcLength & maxHeight)4153 void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeight)
4154 {
4155     CHECK_NULL_VOID(frameNode);
4156     auto layoutProperty = frameNode->GetLayoutProperty();
4157     CHECK_NULL_VOID(layoutProperty);
4158     layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, maxHeight));
4159 }
4160 
SetAlignRules(FrameNode * frameNode,const std::map<AlignDirection,AlignRule> & alignRules)4161 void ViewAbstract::SetAlignRules(FrameNode* frameNode, const std::map<AlignDirection, AlignRule>& alignRules)
4162 {
4163     CHECK_NULL_VOID(frameNode);
4164     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules, frameNode);
4165 }
4166 
GetAlignRules(FrameNode * frameNode)4167 std::map<AlignDirection, AlignRule> ViewAbstract::GetAlignRules(FrameNode* frameNode)
4168 {
4169     std::map<AlignDirection, AlignRule> alignRules;
4170     CHECK_NULL_RETURN(frameNode, alignRules);
4171     auto layoutProperty = frameNode->GetLayoutProperty();
4172     CHECK_NULL_RETURN(layoutProperty, alignRules);
4173     CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), alignRules);
4174     return layoutProperty->GetFlexItemProperty()->GetAlignRules().value_or(alignRules);
4175 }
4176 
ResetAlignRules(FrameNode * frameNode)4177 void ViewAbstract::ResetAlignRules(FrameNode* frameNode)
4178 {
4179     CHECK_NULL_VOID(frameNode);
4180     auto layoutProperty = frameNode->GetLayoutProperty();
4181     CHECK_NULL_VOID(layoutProperty);
4182     CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
4183     return layoutProperty->GetFlexItemProperty()->ResetAlignRules();
4184 }
4185 
SetChainStyle(FrameNode * frameNode,const ChainInfo & chainInfo)4186 void ViewAbstract::SetChainStyle(FrameNode* frameNode, const ChainInfo& chainInfo)
4187 {
4188     CHECK_NULL_VOID(frameNode);
4189     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, ChainStyle, chainInfo, frameNode);
4190 }
4191 
GetChainStyle(FrameNode * frameNode)4192 ChainInfo ViewAbstract::GetChainStyle(FrameNode* frameNode)
4193 {
4194     ChainInfo chainInfo;
4195     CHECK_NULL_RETURN(frameNode, chainInfo);
4196     auto layoutProperty = frameNode->GetLayoutProperty();
4197     CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), chainInfo);
4198     layoutProperty->GetFlexItemProperty()->GetHorizontalChainStyle().value_or(chainInfo);
4199     if (chainInfo.direction.has_value()) {
4200         return chainInfo;
4201     }
4202     return layoutProperty->GetFlexItemProperty()->GetVerticalChainStyle().value_or(chainInfo);
4203 }
4204 
ResetChainStyle(FrameNode * frameNode)4205 void ViewAbstract::ResetChainStyle(FrameNode* frameNode)
4206 {
4207     CHECK_NULL_VOID(frameNode);
4208     ChainInfo nullChainInfo;
4209     auto layoutProperty = frameNode->GetLayoutProperty();
4210     CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
4211     layoutProperty->GetFlexItemProperty()->UpdateHorizontalChainStyle(nullChainInfo);
4212     layoutProperty->GetFlexItemProperty()->UpdateVerticalChainStyle(nullChainInfo);
4213 }
4214 
SetGrid(FrameNode * frameNode,std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)4215 void ViewAbstract::SetGrid(
4216     FrameNode* frameNode, std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
4217 {
4218     CHECK_NULL_VOID(frameNode);
4219     auto layoutProperty = frameNode->GetLayoutProperty();
4220     CHECK_NULL_VOID(layoutProperty);
4221     // frame node is mounted to parent when pop from stack later, no grid-container is added here
4222     layoutProperty->UpdateGridProperty(span, offset, type);
4223 }
4224 
ResetAspectRatio(FrameNode * frameNode)4225 void ViewAbstract::ResetAspectRatio(FrameNode* frameNode)
4226 {
4227     ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, frameNode);
4228 }
4229 
SetAllowDrop(FrameNode * frameNode,const std::set<std::string> & allowDrop)4230 void ViewAbstract::SetAllowDrop(FrameNode* frameNode, const std::set<std::string>& allowDrop)
4231 {
4232     CHECK_NULL_VOID(frameNode);
4233     frameNode->SetAllowDrop(allowDrop);
4234 }
4235 
SetInspectorId(FrameNode * frameNode,const std::string & inspectorId)4236 void ViewAbstract::SetInspectorId(FrameNode* frameNode, const std::string& inspectorId)
4237 {
4238     if (frameNode) {
4239         if (frameNode->GetInspectorId().has_value() && frameNode->GetInspectorIdValue() != inspectorId) {
4240             ElementRegister::GetInstance()->RemoveFrameNodeByInspectorId(
4241                 frameNode->GetInspectorIdValue(), frameNode->GetId());
4242         }
4243         frameNode->UpdateInspectorId(inspectorId);
4244     }
4245 }
4246 
SetRestoreId(FrameNode * frameNode,int32_t restoreId)4247 void ViewAbstract::SetRestoreId(FrameNode* frameNode, int32_t restoreId)
4248 {
4249     if (frameNode) {
4250         frameNode->SetRestoreId(restoreId);
4251     }
4252 }
4253 
SetTabIndex(FrameNode * frameNode,int32_t index)4254 void ViewAbstract::SetTabIndex(FrameNode* frameNode, int32_t index)
4255 {
4256     CHECK_NULL_VOID(frameNode);
4257     auto focusHub = frameNode->GetOrCreateFocusHub();
4258     CHECK_NULL_VOID(focusHub);
4259     focusHub->SetTabIndex(index);
4260 }
4261 
SetObscured(FrameNode * frameNode,const std::vector<ObscuredReasons> & reasons)4262 void ViewAbstract::SetObscured(FrameNode* frameNode, const std::vector<ObscuredReasons>& reasons)
4263 {
4264     CHECK_NULL_VOID(frameNode);
4265     ACE_UPDATE_NODE_RENDER_CONTEXT(Obscured, reasons, frameNode);
4266     frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
4267 }
4268 
SetForegroundEffect(FrameNode * frameNode,float radius,const SysOptions & sysOptions)4269 void ViewAbstract::SetForegroundEffect(FrameNode* frameNode, float radius, const SysOptions& sysOptions)
4270 {
4271     CHECK_NULL_VOID(frameNode);
4272     auto target = frameNode->GetRenderContext();
4273     if (target) {
4274         target->UpdateForegroundEffect(radius);
4275         target->UpdateForegroundEffectDisableSystemAdaptation(sysOptions);
4276     }
4277 }
4278 
SetMotionBlur(FrameNode * frameNode,const MotionBlurOption & motionBlurOption)4279 void ViewAbstract::SetMotionBlur(FrameNode* frameNode, const MotionBlurOption &motionBlurOption)
4280 {
4281     ACE_UPDATE_NODE_RENDER_CONTEXT(MotionBlur, motionBlurOption, frameNode);
4282 }
4283 
SetBackgroundEffect(FrameNode * frameNode,const EffectOption & effectOption,const SysOptions & sysOptions)4284 void ViewAbstract::SetBackgroundEffect(
4285     FrameNode* frameNode, const EffectOption& effectOption, const SysOptions& sysOptions)
4286 {
4287     CHECK_NULL_VOID(frameNode);
4288     auto pipeline = frameNode->GetContext();
4289     CHECK_NULL_VOID(pipeline);
4290     if (effectOption.policy == BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) {
4291         pipeline->AddWindowFocusChangedCallback(frameNode->GetId());
4292     } else {
4293         pipeline->RemoveWindowFocusChangedCallback(frameNode->GetId());
4294     }
4295     auto target = frameNode->GetRenderContext();
4296     if (target) {
4297         if (target->GetBackBlurRadius().has_value()) {
4298             target->UpdateBackBlurRadius(Dimension());
4299         }
4300         if (target->GetBackBlurStyle().has_value()) {
4301             target->UpdateBackBlurStyle(std::nullopt);
4302         }
4303         target->UpdateBackgroundEffect(effectOption, sysOptions);
4304     }
4305 }
4306 
SetDynamicLightUp(FrameNode * frameNode,float rate,float lightUpDegree)4307 void ViewAbstract::SetDynamicLightUp(FrameNode* frameNode, float rate, float lightUpDegree)
4308 {
4309     ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpRate, rate, frameNode);
4310     ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree, frameNode);
4311 }
4312 
SetBgDynamicBrightness(FrameNode * frameNode,const BrightnessOption & brightnessOption)4313 void ViewAbstract::SetBgDynamicBrightness(FrameNode* frameNode, const BrightnessOption& brightnessOption)
4314 {
4315     CHECK_NULL_VOID(frameNode);
4316     ACE_UPDATE_NODE_RENDER_CONTEXT(BgDynamicBrightnessOption, brightnessOption, frameNode);
4317 }
4318 
SetFgDynamicBrightness(FrameNode * frameNode,const BrightnessOption & brightnessOption)4319 void ViewAbstract::SetFgDynamicBrightness(FrameNode* frameNode, const BrightnessOption& brightnessOption)
4320 {
4321     CHECK_NULL_VOID(frameNode);
4322     ACE_UPDATE_NODE_RENDER_CONTEXT(FgDynamicBrightnessOption, brightnessOption, frameNode);
4323 }
4324 
SetBrightnessBlender(FrameNode * frameNode,const OHOS::Rosen::BrightnessBlender * brightnessBlender)4325 void ViewAbstract::SetBrightnessBlender(FrameNode* frameNode, const OHOS::Rosen::BrightnessBlender* brightnessBlender)
4326 {
4327     CHECK_NULL_VOID(frameNode);
4328     ACE_UPDATE_NODE_RENDER_CONTEXT(BrightnessBlender, brightnessBlender, frameNode);
4329 }
4330 
SetDragPreviewOptions(FrameNode * frameNode,const DragPreviewOption & previewOption)4331 void ViewAbstract::SetDragPreviewOptions(FrameNode* frameNode, const DragPreviewOption& previewOption)
4332 {
4333     CHECK_NULL_VOID(frameNode);
4334     frameNode->SetDragPreviewOptions(previewOption, false);
4335 }
4336 
SetDragPreview(FrameNode * frameNode,const DragDropInfo & dragDropInfo)4337 void ViewAbstract::SetDragPreview(FrameNode* frameNode, const DragDropInfo& dragDropInfo)
4338 {
4339     CHECK_NULL_VOID(frameNode);
4340     frameNode->SetDragPreview(dragDropInfo);
4341 }
4342 
SetResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & responseRegion)4343 void ViewAbstract::SetResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& responseRegion)
4344 {
4345     CHECK_NULL_VOID(frameNode);
4346     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4347     CHECK_NULL_VOID(gestureHub);
4348     gestureHub->SetResponseRegion(responseRegion);
4349 }
4350 
SetMouseResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & mouseResponseRegion)4351 void ViewAbstract::SetMouseResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& mouseResponseRegion)
4352 {
4353     CHECK_NULL_VOID(frameNode);
4354     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4355     CHECK_NULL_VOID(gestureHub);
4356     gestureHub->SetMouseResponseRegion(mouseResponseRegion);
4357 }
4358 
SetSharedTransition(FrameNode * frameNode,const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)4359 void ViewAbstract::SetSharedTransition(
4360     FrameNode* frameNode, const std::string& shareId, const std::shared_ptr<SharedTransitionOption>& option)
4361 {
4362     CHECK_NULL_VOID(frameNode);
4363     const auto& target = frameNode->GetRenderContext();
4364     if (target) {
4365         target->SetSharedTransitionOptions(option);
4366         target->SetShareId(shareId);
4367     }
4368 }
4369 
SetTransition(FrameNode * frameNode,const TransitionOptions & options)4370 void ViewAbstract::SetTransition(FrameNode* frameNode, const TransitionOptions& options)
4371 {
4372     ACE_UPDATE_NODE_RENDER_CONTEXT(Transition, options, frameNode);
4373 }
4374 
CleanTransition(FrameNode * frameNode)4375 void ViewAbstract::CleanTransition(FrameNode* frameNode)
4376 {
4377     CHECK_NULL_VOID(frameNode);
4378     const auto& renderContext = frameNode->GetRenderContext();
4379     if (renderContext) {
4380         renderContext->CleanTransition();
4381     }
4382 }
4383 
SetChainedTransition(FrameNode * frameNode,const RefPtr<NG::ChainedTransitionEffect> & effect,NG::TransitionFinishCallback && finishCallback)4384 void ViewAbstract::SetChainedTransition(FrameNode* frameNode, const RefPtr<NG::ChainedTransitionEffect>& effect,
4385     NG::TransitionFinishCallback&& finishCallback)
4386 {
4387     CHECK_NULL_VOID(frameNode);
4388     const auto& target = frameNode->GetRenderContext();
4389     if (target) {
4390         target->UpdateChainedTransition(effect);
4391         target->SetTransitionUserCallback(std::move(finishCallback));
4392     }
4393 }
4394 
SetEnabled(FrameNode * frameNode,bool enabled)4395 void ViewAbstract::SetEnabled(FrameNode* frameNode, bool enabled)
4396 {
4397     CHECK_NULL_VOID(frameNode);
4398     auto eventHub = frameNode->GetEventHub<EventHub>();
4399     if (eventHub) {
4400         eventHub->SetEnabled(enabled);
4401     }
4402     auto focusHub = frameNode->GetOrCreateFocusHub();
4403     if (focusHub) {
4404         focusHub->SetEnabled(enabled);
4405     }
4406 }
4407 
SetUseShadowBatching(FrameNode * frameNode,bool useShadowBatching)4408 void ViewAbstract::SetUseShadowBatching(FrameNode* frameNode, bool useShadowBatching)
4409 {
4410     ACE_UPDATE_NODE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching, frameNode);
4411 }
4412 
SetBlendMode(FrameNode * frameNode,BlendMode blendMode)4413 void ViewAbstract::SetBlendMode(FrameNode* frameNode, BlendMode blendMode)
4414 {
4415     ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendMode, blendMode, frameNode);
4416 }
4417 
SetBlendApplyType(FrameNode * frameNode,BlendApplyType blendApplyType)4418 void ViewAbstract::SetBlendApplyType(FrameNode* frameNode, BlendApplyType blendApplyType)
4419 {
4420     ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType, frameNode);
4421 }
4422 
SetMonopolizeEvents(FrameNode * frameNode,bool monopolizeEvents)4423 void ViewAbstract::SetMonopolizeEvents(FrameNode* frameNode, bool monopolizeEvents)
4424 {
4425     CHECK_NULL_VOID(frameNode);
4426     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4427     CHECK_NULL_VOID(gestureHub);
4428     gestureHub->SetMonopolizeEvents(monopolizeEvents);
4429 }
4430 
SetDraggable(FrameNode * frameNode,bool draggable)4431 void ViewAbstract::SetDraggable(FrameNode* frameNode, bool draggable)
4432 {
4433     CHECK_NULL_VOID(frameNode);
4434     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4435     CHECK_NULL_VOID(gestureHub);
4436     if (draggable) {
4437         if (!frameNode->IsDraggable()) {
4438             gestureHub->InitDragDropEvent();
4439         }
4440     } else {
4441         gestureHub->RemoveDragEvent();
4442     }
4443     frameNode->SetCustomerDraggable(draggable);
4444 }
4445 
SetHoverEffect(FrameNode * frameNode,HoverEffectType hoverEffect)4446 void ViewAbstract::SetHoverEffect(FrameNode* frameNode, HoverEffectType hoverEffect)
4447 {
4448     CHECK_NULL_VOID(frameNode);
4449     auto eventHub = frameNode->GetOrCreateInputEventHub();
4450     CHECK_NULL_VOID(eventHub);
4451     eventHub->SetHoverEffect(hoverEffect);
4452 }
4453 
SetClickEffectLevel(FrameNode * frameNode,const ClickEffectLevel & level,float scaleValue)4454 void ViewAbstract::SetClickEffectLevel(FrameNode* frameNode, const ClickEffectLevel& level, float scaleValue)
4455 {
4456     ClickEffectInfo clickEffectInfo;
4457     clickEffectInfo.level = level;
4458     clickEffectInfo.scaleNumber = scaleValue;
4459     ACE_UPDATE_NODE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo, frameNode);
4460 }
4461 
SetKeyboardShortcut(FrameNode * frameNode,const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)4462 void ViewAbstract::SetKeyboardShortcut(FrameNode* frameNode, const std::string& value,
4463     const std::vector<ModifierKey>& keys, std::function<void()>&& onKeyboardShortcutAction)
4464 {
4465     CHECK_NULL_VOID(frameNode);
4466     auto pipeline = frameNode->GetContext();
4467     CHECK_NULL_VOID(pipeline);
4468     auto eventManager = pipeline->GetEventManager();
4469     CHECK_NULL_VOID(eventManager);
4470     auto eventHub = frameNode->GetEventHub<EventHub>();
4471     CHECK_NULL_VOID(eventHub);
4472     auto frameNodeRef = AceType::Claim<FrameNode>(frameNode);
4473     if (value.empty() || keys.empty()) {
4474         eventHub->ClearSingleKeyboardShortcut();
4475         return;
4476     }
4477     auto key = eventManager->GetKeyboardShortcutKeys(keys);
4478     if ((key == 0 && value.length() == 1) || (key == 0 && !keys.empty() && value.length() > 1)) {
4479         return;
4480     }
4481     if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
4482         return;
4483     }
4484     eventHub->SetKeyboardShortcut(value, key, onKeyboardShortcutAction);
4485     eventManager->AddKeyboardShortcutNode(WeakPtr<NG::FrameNode>(frameNodeRef));
4486 }
4487 
SetOnAppear(FrameNode * frameNode,std::function<void ()> && onAppear)4488 void ViewAbstract::SetOnAppear(FrameNode* frameNode, std::function<void()> &&onAppear)
4489 {
4490     CHECK_NULL_VOID(frameNode);
4491     auto eventHub = frameNode->GetEventHub<EventHub>();
4492     CHECK_NULL_VOID(eventHub);
4493     eventHub->SetOnAppear(std::move(onAppear));
4494 }
4495 
SetOnDisappear(FrameNode * frameNode,std::function<void ()> && onDisappear)4496 void ViewAbstract::SetOnDisappear(FrameNode* frameNode, std::function<void()> &&onDisappear)
4497 {
4498     CHECK_NULL_VOID(frameNode);
4499     auto eventHub = frameNode->GetEventHub<EventHub>();
4500     CHECK_NULL_VOID(eventHub);
4501     eventHub->SetOnDisappear(std::move(onDisappear));
4502 }
4503 
SetOnAttach(FrameNode * frameNode,std::function<void ()> && onAttach)4504 void ViewAbstract::SetOnAttach(FrameNode* frameNode, std::function<void()> &&onAttach)
4505 {
4506     CHECK_NULL_VOID(frameNode);
4507     auto eventHub = frameNode->GetEventHub<EventHub>();
4508     CHECK_NULL_VOID(eventHub);
4509     eventHub->SetOnAttach(std::move(onAttach));
4510 }
4511 
SetOnDetach(FrameNode * frameNode,std::function<void ()> && onDetach)4512 void ViewAbstract::SetOnDetach(FrameNode* frameNode, std::function<void()> &&onDetach)
4513 {
4514     CHECK_NULL_VOID(frameNode);
4515     auto eventHub = frameNode->GetEventHub<EventHub>();
4516     CHECK_NULL_VOID(eventHub);
4517     eventHub->SetOnDetach(std::move(onDetach));
4518 }
4519 
SetOnAreaChanged(FrameNode * frameNode,std::function<void (const RectF & oldRect,const OffsetF & oldOrigin,const RectF & rect,const OffsetF & origin)> && onAreaChanged)4520 void ViewAbstract::SetOnAreaChanged(FrameNode* frameNode, std::function<void(const RectF &oldRect,
4521     const OffsetF &oldOrigin, const RectF &rect, const OffsetF &origin)> &&onAreaChanged)
4522 {
4523     CHECK_NULL_VOID(frameNode);
4524     auto pipeline = frameNode->GetContext();
4525     CHECK_NULL_VOID(pipeline);
4526     frameNode->SetOnAreaChangeCallback(std::move(onAreaChanged));
4527     pipeline->AddOnAreaChangeNode(frameNode->GetId());
4528 }
4529 
SetOnFocus(FrameNode * frameNode,OnFocusFunc && onFocusCallback)4530 void ViewAbstract::SetOnFocus(FrameNode* frameNode, OnFocusFunc &&onFocusCallback)
4531 {
4532     CHECK_NULL_VOID(frameNode);
4533     auto focusHub = frameNode->GetOrCreateFocusHub();
4534     focusHub->SetOnFocusCallback(std::move(onFocusCallback));
4535 }
4536 
SetOnBlur(FrameNode * frameNode,OnBlurFunc && onBlurCallback)4537 void ViewAbstract::SetOnBlur(FrameNode* frameNode, OnBlurFunc &&onBlurCallback)
4538 {
4539     CHECK_NULL_VOID(frameNode);
4540     auto focusHub = frameNode->GetOrCreateFocusHub();
4541     focusHub->SetOnBlurCallback(std::move(onBlurCallback));
4542 }
4543 
SetOnClick(FrameNode * frameNode,GestureEventFunc && clickEventFunc,double distanceThreshold)4544 void ViewAbstract::SetOnClick(FrameNode* frameNode, GestureEventFunc&& clickEventFunc, double distanceThreshold)
4545 {
4546     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4547     CHECK_NULL_VOID(gestureHub);
4548     gestureHub->SetUserOnClick(std::move(clickEventFunc), distanceThreshold);
4549 
4550     auto focusHub = frameNode->GetOrCreateFocusHub();
4551     CHECK_NULL_VOID(focusHub);
4552     focusHub->SetFocusable(true, false);
4553 }
4554 
SetOnTouch(FrameNode * frameNode,TouchEventFunc && touchEventFunc)4555 void ViewAbstract::SetOnTouch(FrameNode* frameNode, TouchEventFunc &&touchEventFunc)
4556 {
4557     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4558     CHECK_NULL_VOID(gestureHub);
4559     gestureHub->SetTouchEvent(std::move(touchEventFunc));
4560 }
4561 
SetOnMouse(FrameNode * frameNode,OnMouseEventFunc && onMouseEventFunc)4562 void ViewAbstract::SetOnMouse(FrameNode* frameNode, OnMouseEventFunc &&onMouseEventFunc)
4563 {
4564     auto eventHub = frameNode->GetOrCreateInputEventHub();
4565     CHECK_NULL_VOID(eventHub);
4566     eventHub->SetMouseEvent(std::move(onMouseEventFunc));
4567 }
4568 
SetOnAxisEvent(FrameNode * frameNode,OnAxisEventFunc && onAxisEventFunc)4569 void ViewAbstract::SetOnAxisEvent(FrameNode* frameNode, OnAxisEventFunc&& onAxisEventFunc)
4570 {
4571     auto eventHub = frameNode->GetOrCreateInputEventHub();
4572     CHECK_NULL_VOID(eventHub);
4573     eventHub->SetAxisEvent(std::move(onAxisEventFunc));
4574 }
4575 
SetOnHover(FrameNode * frameNode,OnHoverFunc && onHoverEventFunc)4576 void ViewAbstract::SetOnHover(FrameNode* frameNode, OnHoverFunc &&onHoverEventFunc)
4577 {
4578     auto eventHub = frameNode->GetOrCreateInputEventHub();
4579     CHECK_NULL_VOID(eventHub);
4580     eventHub->SetHoverEvent(std::move(onHoverEventFunc));
4581 }
4582 
SetOnHoverMove(FrameNode * frameNode,OnHoverMoveFunc && onHoverMoveEventFunc)4583 void ViewAbstract::SetOnHoverMove(FrameNode* frameNode, OnHoverMoveFunc &&onHoverMoveEventFunc)
4584 {
4585     auto eventHub = frameNode->GetOrCreateInputEventHub();
4586     CHECK_NULL_VOID(eventHub);
4587     eventHub->SetHoverMoveEvent(std::move(onHoverMoveEventFunc));
4588 }
4589 
SetOnKeyEvent(FrameNode * frameNode,OnKeyConsumeFunc && onKeyCallback)4590 void ViewAbstract::SetOnKeyEvent(FrameNode* frameNode, OnKeyConsumeFunc &&onKeyCallback)
4591 {
4592     auto focusHub = frameNode->GetOrCreateFocusHub();
4593     CHECK_NULL_VOID(focusHub);
4594     focusHub->SetOnKeyCallback(std::move(onKeyCallback));
4595 }
4596 
SetOnKeyEventDispatch(OnKeyEventDispatchFunc && onKeyDispatchCallback)4597 void ViewAbstract::SetOnKeyEventDispatch(OnKeyEventDispatchFunc&& onKeyDispatchCallback)
4598 {
4599     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
4600     CHECK_NULL_VOID(focusHub);
4601     focusHub->SetOnKeyEventDispatchCallback(std::move(onKeyDispatchCallback));
4602 }
4603 
SetOnKeyEventDispatch(FrameNode * frameNode,OnKeyEventDispatchFunc && onKeyDispatchCallback)4604 void ViewAbstract::SetOnKeyEventDispatch(FrameNode* frameNode, OnKeyEventDispatchFunc&& onKeyDispatchCallback)
4605 {
4606     CHECK_NULL_VOID(frameNode);
4607     auto focusHub = frameNode->GetOrCreateFocusHub();
4608     CHECK_NULL_VOID(focusHub);
4609     focusHub->SetOnKeyEventDispatchCallback(std::move(onKeyDispatchCallback));
4610 }
4611 
DispatchKeyEvent(FrameNode * frameNode,KeyEvent & keyEvent)4612 void ViewAbstract::DispatchKeyEvent(FrameNode* frameNode, KeyEvent& keyEvent)
4613 {
4614     CHECK_NULL_VOID(frameNode);
4615     auto focusHub = frameNode->GetOrCreateFocusHub();
4616     CHECK_NULL_VOID(focusHub);
4617     focusHub->HandleEvent(keyEvent);
4618 }
4619 
GetFocusable(FrameNode * frameNode)4620 bool ViewAbstract::GetFocusable(FrameNode* frameNode)
4621 {
4622     CHECK_NULL_RETURN(frameNode, false);
4623     auto focusHub = frameNode->GetOrCreateFocusHub();
4624     CHECK_NULL_RETURN(focusHub, false);
4625     return focusHub->IsFocusable();
4626 }
4627 
GetTabStop(FrameNode * frameNode)4628 bool ViewAbstract::GetTabStop(FrameNode* frameNode)
4629 {
4630     CHECK_NULL_RETURN(frameNode, false);
4631     auto focusHub = frameNode->GetOrCreateFocusHub();
4632     CHECK_NULL_RETURN(focusHub, false);
4633     return focusHub->IsTabStop();
4634 }
4635 
GetDefaultFocus(FrameNode * frameNode)4636 bool ViewAbstract::GetDefaultFocus(FrameNode* frameNode)
4637 {
4638     CHECK_NULL_RETURN(frameNode, false);
4639     auto focusHub = frameNode->GetOrCreateFocusHub();
4640     CHECK_NULL_RETURN(focusHub, false);
4641     return focusHub->IsDefaultFocus();
4642 }
4643 
GetResponseRegion(FrameNode * frameNode)4644 std::vector<DimensionRect> ViewAbstract::GetResponseRegion(FrameNode* frameNode)
4645 {
4646     std::vector<DimensionRect> defaultRect;
4647     CHECK_NULL_RETURN(frameNode, defaultRect);
4648     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4649     CHECK_NULL_RETURN(gestureHub, defaultRect);
4650     return gestureHub->GetResponseRegion();
4651 }
4652 
GetOverlay(FrameNode * frameNode)4653 NG::OverlayOptions ViewAbstract::GetOverlay(FrameNode* frameNode)
4654 {
4655     NG::OverlayOptions defaultOptions;
4656     const auto& target = frameNode->GetRenderContext();
4657     return target->GetOverlayTextValue(defaultOptions);
4658 }
4659 
SetNeedFocus(FrameNode * frameNode,bool value)4660 void ViewAbstract::SetNeedFocus(FrameNode* frameNode, bool value)
4661 {
4662     CHECK_NULL_VOID(frameNode);
4663     auto focusHub = frameNode->GetOrCreateFocusHub();
4664     CHECK_NULL_VOID(focusHub);
4665     if (value) {
4666         auto context = frameNode->GetContext();
4667         CHECK_NULL_VOID(context);
4668         auto instanceId = context->GetInstanceId();
4669         ContainerScope scope(instanceId);
4670         focusHub->RequestFocus();
4671     } else {
4672         auto context = frameNode->GetAttachedContext();
4673         if (!context) {
4674             TAG_LOGW(AceLogTag::ACE_FOCUS,
4675                 "Can't find Node %{public}s/%{public}d attachedContext, please check the timing of the function call.",
4676                 frameNode->GetTag().c_str(), frameNode->GetId());
4677             return;
4678         }
4679         auto instanceId = context->GetInstanceId();
4680         ContainerScope scope(instanceId);
4681         focusHub->LostFocusToViewRoot();
4682     }
4683 }
4684 
GetNeedFocus(FrameNode * frameNode)4685 bool ViewAbstract::GetNeedFocus(FrameNode* frameNode)
4686 {
4687     CHECK_NULL_RETURN(frameNode, false);
4688     auto focusHub = frameNode->GetOrCreateFocusHub();
4689     CHECK_NULL_RETURN(focusHub, false);
4690     return focusHub->IsCurrentFocus();
4691 }
4692 
RequestFocus(FrameNode * frameNode)4693 int ViewAbstract::RequestFocus(FrameNode* frameNode)
4694 {
4695     CHECK_NULL_RETURN(frameNode, ERROR_CODE_NON_EXIST);
4696     auto context = frameNode->GetContext();
4697     CHECK_NULL_RETURN(context, ERROR_CODE_NON_EXIST);
4698     auto instanceId = context->GetInstanceId();
4699     ContainerScope scope(instanceId);
4700     auto focusManager = context->GetOrCreateFocusManager();
4701     focusManager->ResetRequestFocusResult();
4702     auto focusHub = frameNode->GetOrCreateFocusHub();
4703     // check node focusable
4704     if (focusHub->IsSyncRequestFocusable()) {
4705         focusHub->RequestFocusImmediately();
4706     }
4707     auto retCode = focusManager->GetRequestFocusResult();
4708     focusManager->ResetRequestFocusResult();
4709     return retCode;
4710 }
4711 
ClearFocus(int32_t instanceId)4712 void ViewAbstract::ClearFocus(int32_t instanceId)
4713 {
4714     auto context = PipelineContext::GetContextByContainerId(instanceId);
4715     if (!context) {
4716         TAG_LOGW(AceLogTag::ACE_FOCUS, "Can't find attachedContext, please check the timing of the function call.");
4717         return;
4718     }
4719     FocusHub::LostFocusToViewRoot();
4720 }
4721 
FocusActivate(int32_t instanceId,bool isActive,bool isAutoInactive)4722 void ViewAbstract::FocusActivate(int32_t instanceId, bool isActive, bool isAutoInactive)
4723 {
4724     auto context = PipelineContext::GetContextByContainerId(instanceId);
4725     if (!context) {
4726         TAG_LOGW(AceLogTag::ACE_FOCUS, "Can't find attachedContext, please check the timing of the function call.");
4727         return;
4728     }
4729     context->SetIsFocusActive(isActive, NG::FocusActiveReason::USE_API, isAutoInactive);
4730 }
4731 
SetAutoFocusTransfer(int32_t instanceId,bool isAutoFocusTransfer)4732 void ViewAbstract::SetAutoFocusTransfer(int32_t instanceId, bool isAutoFocusTransfer)
4733 {
4734     auto context = PipelineContext::GetContextByContainerId(instanceId);
4735     if (!context) {
4736         TAG_LOGW(AceLogTag::ACE_FOCUS, "Can't find attachedContext, please check the timing of the function call.");
4737         return;
4738     }
4739     auto focusManager = context->GetOrCreateFocusManager();
4740     CHECK_NULL_VOID(focusManager);
4741     focusManager->SetIsAutoFocusTransfer(isAutoFocusTransfer);
4742 }
4743 
GetOpacity(FrameNode * frameNode)4744 double ViewAbstract::GetOpacity(FrameNode* frameNode)
4745 {
4746     double opacity = 1.0f;
4747     const auto& target = frameNode->GetRenderContext();
4748     CHECK_NULL_RETURN(target, opacity);
4749     return target->GetOpacityValue(opacity);
4750 }
4751 
GetBorderWidth(FrameNode * frameNode)4752 BorderWidthProperty ViewAbstract::GetBorderWidth(FrameNode* frameNode)
4753 {
4754     Dimension defaultDimension(0);
4755     BorderWidthProperty borderWidths = { defaultDimension, defaultDimension, defaultDimension, defaultDimension,
4756         std::nullopt, std::nullopt};
4757     const auto& target = frameNode->GetRenderContext();
4758     CHECK_NULL_RETURN(target, borderWidths);
4759     return target->GetBorderWidthValue(borderWidths);
4760 }
4761 
GetLayoutBorderWidth(FrameNode * frameNode)4762 BorderWidthProperty ViewAbstract::GetLayoutBorderWidth(FrameNode* frameNode)
4763 {
4764     Dimension defaultDimen = Dimension(0, DimensionUnit::VP);
4765     BorderWidthProperty borderWidths;
4766     borderWidths.topDimen = std::optional<Dimension>(defaultDimen);
4767     borderWidths.rightDimen = std::optional<Dimension>(defaultDimen);
4768     borderWidths.bottomDimen = std::optional<Dimension>(defaultDimen);
4769     borderWidths.leftDimen = std::optional<Dimension>(defaultDimen);
4770     const auto& layoutProperty = frameNode->GetLayoutProperty();
4771     CHECK_NULL_RETURN(layoutProperty, borderWidths);
4772     const auto& property = layoutProperty->GetBorderWidthProperty();
4773     CHECK_NULL_RETURN(property, borderWidths);
4774     borderWidths.topDimen = std::optional<Dimension>(property->topDimen);
4775     borderWidths.rightDimen = std::optional<Dimension>(property->rightDimen);
4776     borderWidths.bottomDimen = std::optional<Dimension>(property->bottomDimen);
4777     borderWidths.leftDimen = std::optional<Dimension>(property->leftDimen);
4778     return borderWidths;
4779 }
4780 
GetBorderRadius(FrameNode * frameNode)4781 BorderRadiusProperty ViewAbstract::GetBorderRadius(FrameNode* frameNode)
4782 {
4783     Dimension defaultDimension(0);
4784     BorderRadiusProperty borderRadius = { defaultDimension, defaultDimension, defaultDimension, defaultDimension };
4785     const auto& target = frameNode->GetRenderContext();
4786     CHECK_NULL_RETURN(target, borderRadius);
4787     return target->GetBorderRadiusValue(borderRadius);
4788 }
4789 
GetBorderColor(FrameNode * frameNode)4790 BorderColorProperty ViewAbstract::GetBorderColor(FrameNode* frameNode)
4791 {
4792     Color defaultColor(0xff000000);
4793     BorderColorProperty borderColors = { defaultColor, defaultColor, defaultColor, defaultColor,
4794         std::nullopt, std::nullopt };
4795     const auto& target = frameNode->GetRenderContext();
4796     CHECK_NULL_RETURN(target, borderColors);
4797     return target->GetBorderColorValue(borderColors);
4798 }
4799 
GetBorderStyle(FrameNode * frameNode)4800 BorderStyleProperty ViewAbstract::GetBorderStyle(FrameNode* frameNode)
4801 {
4802     BorderStyle defaultStyle = BorderStyle::SOLID;
4803     BorderStyleProperty borderStyles = { defaultStyle, defaultStyle, defaultStyle, defaultStyle };
4804     const auto& target = frameNode->GetRenderContext();
4805     CHECK_NULL_RETURN(target, borderStyles);
4806     return target->GetBorderStyleValue(borderStyles);
4807 }
4808 
GetZIndex(FrameNode * frameNode)4809 int ViewAbstract::GetZIndex(FrameNode* frameNode)
4810 {
4811     int zindex = 0;
4812     const auto& target = frameNode->GetRenderContext();
4813     CHECK_NULL_RETURN(target, zindex);
4814     return target->GetZIndexValue(zindex);
4815 }
4816 
GetVisibility(FrameNode * frameNode)4817 VisibleType ViewAbstract::GetVisibility(FrameNode* frameNode)
4818 {
4819     VisibleType visibility = VisibleType::VISIBLE;
4820     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(LayoutProperty, Visibility, visibility, frameNode, visibility);
4821     return visibility;
4822 }
4823 
GetClip(FrameNode * frameNode)4824 bool ViewAbstract::GetClip(FrameNode* frameNode)
4825 {
4826     bool value = false;
4827     const auto& target = frameNode->GetRenderContext();
4828     CHECK_NULL_RETURN(target, value);
4829     return target->GetClipEdgeValue(value);
4830 }
4831 
GetClipShape(FrameNode * frameNode)4832 RefPtr<BasicShape> ViewAbstract::GetClipShape(FrameNode* frameNode)
4833 {
4834     RefPtr<BasicShape> value = AceType::MakeRefPtr<BasicShape>();
4835     const auto& target = frameNode->GetRenderContext();
4836     CHECK_NULL_RETURN(target, value);
4837     return target->GetClipShapeValue(value);
4838 }
4839 
GetTransform(FrameNode * frameNode)4840 Matrix4 ViewAbstract::GetTransform(FrameNode* frameNode)
4841 {
4842     Matrix4 value;
4843     const auto& target = frameNode->GetRenderContext();
4844     CHECK_NULL_RETURN(target, value);
4845     return target->GetTransformMatrixValue(value);
4846 }
4847 
GetHitTestBehavior(FrameNode * frameNode)4848 HitTestMode ViewAbstract::GetHitTestBehavior(FrameNode* frameNode)
4849 {
4850     auto gestureHub = frameNode->GetHitTestMode();
4851     return gestureHub;
4852 }
4853 
GetPosition(FrameNode * frameNode)4854 OffsetT<Dimension> ViewAbstract::GetPosition(FrameNode* frameNode)
4855 {
4856     Dimension PositionX(0, DimensionUnit::VP);
4857     Dimension PositionY(0, DimensionUnit::VP);
4858     OffsetT<Dimension> position(PositionX, PositionY);
4859     const auto& target = frameNode->GetRenderContext();
4860     CHECK_NULL_RETURN(target, position);
4861     return target->GetPositionValue(position);
4862 }
4863 
GetShadow(FrameNode * frameNode)4864 std::optional<Shadow> ViewAbstract::GetShadow(FrameNode* frameNode)
4865 {
4866     Shadow value;
4867     const auto& target = frameNode->GetRenderContext();
4868     CHECK_NULL_RETURN(target, value);
4869     return target->GetBackShadowValue(value);
4870 }
4871 
GetSweepGradient(FrameNode * frameNode)4872 NG::Gradient ViewAbstract::GetSweepGradient(FrameNode* frameNode)
4873 {
4874     Gradient value;
4875     value.CreateGradientWithType(NG::GradientType::SWEEP);
4876     const auto& target = frameNode->GetRenderContext();
4877     CHECK_NULL_RETURN(target, value);
4878     return target->GetSweepGradientValue(value);
4879 }
4880 
GetRadialGradient(FrameNode * frameNode)4881 NG::Gradient ViewAbstract::GetRadialGradient(FrameNode* frameNode)
4882 {
4883     Gradient value;
4884     value.CreateGradientWithType(NG::GradientType::RADIAL);
4885     const auto& target = frameNode->GetRenderContext();
4886     CHECK_NULL_RETURN(target, value);
4887     return target->GetRadialGradientValue(value);
4888 }
4889 
GetMask(FrameNode * frameNode)4890 RefPtr<BasicShape> ViewAbstract::GetMask(FrameNode* frameNode)
4891 {
4892     RefPtr<BasicShape> value = AceType::MakeRefPtr<BasicShape>();
4893     const auto& target = frameNode->GetRenderContext();
4894     CHECK_NULL_RETURN(target, nullptr);
4895     if (target->HasClipMask()) {
4896         return target->GetClipMaskValue(value);
4897     }
4898     return nullptr;
4899 }
4900 
GetMaskProgress(FrameNode * frameNode)4901 RefPtr<ProgressMaskProperty> ViewAbstract::GetMaskProgress(FrameNode* frameNode)
4902 {
4903     RefPtr<ProgressMaskProperty> value = AceType::MakeRefPtr<ProgressMaskProperty>();
4904     const auto& target = frameNode->GetRenderContext();
4905     CHECK_NULL_RETURN(target, nullptr);
4906     if (target->HasProgressMask()) {
4907         return target->GetProgressMaskValue(value);
4908     }
4909     return nullptr;
4910 }
4911 
GetBlendMode(FrameNode * frameNode)4912 BlendMode ViewAbstract::GetBlendMode(FrameNode* frameNode)
4913 {
4914     BlendMode value = BlendMode::NONE;
4915     auto target = frameNode->GetRenderContext();
4916     CHECK_NULL_RETURN(target, value);
4917     return target->GetBackBlendModeValue(value);
4918 }
4919 
GetDirection(FrameNode * frameNode)4920 TextDirection ViewAbstract::GetDirection(FrameNode* frameNode)
4921 {
4922     TextDirection direction = TextDirection::AUTO;
4923     auto target = frameNode->GetLayoutProperty<LayoutProperty>();
4924     direction = target->GetLayoutDirection();
4925     return direction;
4926 }
4927 
GetAlignSelf(FrameNode * frameNode)4928 FlexAlign ViewAbstract::GetAlignSelf(FrameNode* frameNode)
4929 {
4930     FlexAlign value = FlexAlign::AUTO;
4931     const auto& flexItemProperty = frameNode->GetLayoutProperty()->GetFlexItemProperty();
4932     CHECK_NULL_RETURN(flexItemProperty, value);
4933     auto getValue = flexItemProperty->GetAlignSelf();
4934     if (getValue.has_value()) {
4935         return getValue.value();
4936     }
4937     return value;
4938 }
4939 
GetFlexGrow(FrameNode * frameNode)4940 float ViewAbstract::GetFlexGrow(FrameNode* frameNode)
4941 {
4942     float value = 0.0f;
4943     const auto& layoutProperty = frameNode->GetLayoutProperty();
4944     CHECK_NULL_RETURN(layoutProperty, value);
4945     const auto& property = layoutProperty->GetFlexItemProperty();
4946     CHECK_NULL_RETURN(property, value);
4947     auto getValue = property->GetFlexGrow();
4948     if (getValue.has_value()) {
4949         return getValue.value();
4950     }
4951     return value;
4952 }
4953 
GetFlexShrink(FrameNode * frameNode)4954 float ViewAbstract::GetFlexShrink(FrameNode* frameNode)
4955 {
4956     float value = 0.0f;
4957     const auto& layoutProperty = frameNode->GetLayoutProperty();
4958     CHECK_NULL_RETURN(layoutProperty, value);
4959     const auto& property = layoutProperty->GetFlexItemProperty();
4960     CHECK_NULL_RETURN(property, value);
4961     auto getValue = property->GetFlexShrink();
4962     if (getValue.has_value()) {
4963         return getValue.value();
4964     }
4965     return value;
4966 }
4967 
GetFlexBasis(FrameNode * frameNode)4968 Dimension ViewAbstract::GetFlexBasis(FrameNode* frameNode)
4969 {
4970     Dimension value;
4971     const auto& layoutProperty = frameNode->GetLayoutProperty();
4972     CHECK_NULL_RETURN(layoutProperty, value);
4973     const auto& property = layoutProperty->GetFlexItemProperty();
4974     CHECK_NULL_RETURN(property, value);
4975     auto getValue = property->GetFlexBasis();
4976     if (getValue.has_value()) {
4977         return getValue.value();
4978     }
4979     return value;
4980 }
4981 
GetMinWidth(FrameNode * frameNode)4982 Dimension ViewAbstract::GetMinWidth(FrameNode* frameNode)
4983 {
4984     Dimension value = Dimension(0.0f);
4985     const auto& layoutProperty = frameNode->GetLayoutProperty();
4986     CHECK_NULL_RETURN(layoutProperty, value);
4987     const auto& property = layoutProperty->GetCalcLayoutConstraint();
4988     CHECK_NULL_RETURN(property, value);
4989     auto size = property->minSize;
4990     if (size.has_value()) {
4991         auto width = size->Width();
4992         if (width.has_value()) {
4993             return width.value().GetDimension();
4994         }
4995     }
4996     return value;
4997 }
4998 
GetMaxWidth(FrameNode * frameNode)4999 Dimension ViewAbstract::GetMaxWidth(FrameNode* frameNode)
5000 {
5001     Dimension value = Dimension(0.0f);
5002     const auto& layoutProperty = frameNode->GetLayoutProperty();
5003     CHECK_NULL_RETURN(layoutProperty, value);
5004     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5005     CHECK_NULL_RETURN(property, value);
5006     auto size = property->maxSize;
5007     if (size.has_value()) {
5008         auto width = size->Width();
5009         if (width.has_value()) {
5010             return width.value().GetDimension();
5011         }
5012     }
5013     return value;
5014 }
5015 
GetMinHeight(FrameNode * frameNode)5016 Dimension ViewAbstract::GetMinHeight(FrameNode* frameNode)
5017 {
5018     Dimension value = Dimension(0.0f);
5019     const auto& layoutProperty = frameNode->GetLayoutProperty();
5020     CHECK_NULL_RETURN(layoutProperty, value);
5021     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5022     CHECK_NULL_RETURN(property, value);
5023     auto size = property->minSize;
5024     if (size.has_value()) {
5025         auto height = size->Height();
5026         if (height.has_value()) {
5027             return height.value().GetDimension();
5028         }
5029     }
5030     return value;
5031 }
5032 
GetMaxHeight(FrameNode * frameNode)5033 Dimension ViewAbstract::GetMaxHeight(FrameNode* frameNode)
5034 {
5035     Dimension value = Dimension(0.0f);
5036     const auto& layoutProperty = frameNode->GetLayoutProperty();
5037     CHECK_NULL_RETURN(layoutProperty, value);
5038     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5039     CHECK_NULL_RETURN(property, value);
5040     auto size = property->maxSize;
5041     if (size.has_value()) {
5042         auto height = size->Height();
5043         if (height.has_value()) {
5044             return height.value().GetDimension();
5045         }
5046     }
5047     return value;
5048 }
5049 
GetGrayScale(FrameNode * frameNode)5050 Dimension ViewAbstract::GetGrayScale(FrameNode* frameNode)
5051 {
5052     Dimension value;
5053     auto target = frameNode->GetRenderContext();
5054     CHECK_NULL_RETURN(target, value);
5055     return target->GetFrontGrayScaleValue(value);
5056 }
5057 
GetInvert(FrameNode * frameNode)5058 InvertVariant ViewAbstract::GetInvert(FrameNode* frameNode)
5059 {
5060     InvertVariant value = 0.0f;
5061     auto target = frameNode->GetRenderContext();
5062     CHECK_NULL_RETURN(target, value);
5063     return target->GetFrontInvertValue(value);
5064 }
5065 
GetSepia(FrameNode * frameNode)5066 Dimension ViewAbstract::GetSepia(FrameNode* frameNode)
5067 {
5068     Dimension value;
5069     auto target = frameNode->GetRenderContext();
5070     CHECK_NULL_RETURN(target, value);
5071     return target->GetFrontSepiaValue(value);
5072 }
5073 
GetContrast(FrameNode * frameNode)5074 Dimension ViewAbstract::GetContrast(FrameNode* frameNode)
5075 {
5076     Dimension value(1.0f);
5077     auto target = frameNode->GetRenderContext();
5078     CHECK_NULL_RETURN(target, value);
5079     return target->GetFrontContrastValue(value);
5080 }
5081 
GetForegroundColor(FrameNode * frameNode)5082 Color ViewAbstract::GetForegroundColor(FrameNode* frameNode)
5083 {
5084     Color value;
5085     auto target = frameNode->GetRenderContext();
5086     CHECK_NULL_RETURN(target, value);
5087     return target->GetForegroundColorValue(value);
5088 }
5089 
GetScale(FrameNode * frameNode)5090 NG::VectorF ViewAbstract::GetScale(FrameNode* frameNode)
5091 {
5092     NG::VectorF defaultVector = { 1.0f, 1.0f };
5093     CHECK_NULL_RETURN(frameNode, defaultVector);
5094     auto renderContext = frameNode->GetRenderContext();
5095     CHECK_NULL_RETURN(renderContext, defaultVector);
5096     return renderContext->GetTransformScale().value_or(defaultVector);
5097 }
5098 
GetRotate(FrameNode * frameNode)5099 NG::Vector5F ViewAbstract::GetRotate(FrameNode* frameNode)
5100 {
5101     NG::Vector5F defaultVector = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
5102     CHECK_NULL_RETURN(frameNode, defaultVector);
5103     auto renderContext = frameNode->GetRenderContext();
5104     CHECK_NULL_RETURN(renderContext, defaultVector);
5105     return renderContext->GetTransformRotate().value_or(defaultVector);
5106 }
5107 
GetBrightness(FrameNode * frameNode)5108 Dimension ViewAbstract::GetBrightness(FrameNode* frameNode)
5109 {
5110     Dimension defaultBrightness(1.0);
5111     CHECK_NULL_RETURN(frameNode, defaultBrightness);
5112     auto renderContext = frameNode->GetRenderContext();
5113     CHECK_NULL_RETURN(renderContext, defaultBrightness);
5114     return renderContext->GetFrontBrightness().value_or(defaultBrightness);
5115 }
5116 
GetSaturate(FrameNode * frameNode)5117 Dimension ViewAbstract::GetSaturate(FrameNode* frameNode)
5118 {
5119     Dimension defaultSaturate(1.0);
5120     CHECK_NULL_RETURN(frameNode, defaultSaturate);
5121     auto renderContext = frameNode->GetRenderContext();
5122     CHECK_NULL_RETURN(renderContext, defaultSaturate);
5123     return renderContext->GetFrontSaturate().value_or(defaultSaturate);
5124 }
5125 
GetBackgroundImagePosition(FrameNode * frameNode)5126 BackgroundImagePosition ViewAbstract::GetBackgroundImagePosition(FrameNode* frameNode)
5127 {
5128     BackgroundImagePosition defaultImagePosition;
5129     CHECK_NULL_RETURN(frameNode, defaultImagePosition);
5130     auto renderContext = frameNode->GetRenderContext();
5131     CHECK_NULL_RETURN(renderContext, defaultImagePosition);
5132     return renderContext->GetBackgroundImagePosition().value_or(defaultImagePosition);
5133 }
5134 
GetFrontBlur(FrameNode * frameNode)5135 Dimension ViewAbstract::GetFrontBlur(FrameNode* frameNode)
5136 {
5137     Dimension value;
5138     auto target = frameNode->GetRenderContext();
5139     CHECK_NULL_RETURN(target, value);
5140     auto& property = target->GetForeground();
5141     CHECK_NULL_RETURN(property, value);
5142     auto getValue = property->propBlurRadius;
5143     if (getValue.has_value()) {
5144         return getValue.value();
5145     }
5146     return value;
5147 }
5148 
GetLinearGradient(FrameNode * frameNode)5149 NG::Gradient ViewAbstract::GetLinearGradient(FrameNode *frameNode)
5150 {
5151     NG::Gradient value;
5152     value.CreateGradientWithType(NG::GradientType::LINEAR);
5153     auto target = frameNode->GetRenderContext();
5154     CHECK_NULL_RETURN(target, value);
5155     return target->GetLinearGradientValue(value);
5156 }
5157 
GetAlign(FrameNode * frameNode)5158 Alignment ViewAbstract::GetAlign(FrameNode *frameNode)
5159 {
5160     Alignment value = Alignment::CENTER;
5161     const auto& layoutProperty = frameNode->GetLayoutProperty();
5162     CHECK_NULL_RETURN(layoutProperty, value);
5163     const auto& property = layoutProperty->GetPositionProperty();
5164     CHECK_NULL_RETURN(property, value);
5165     auto getValue = property->GetAlignment();
5166     if (getValue.has_value()) {
5167         return getValue.value();
5168     }
5169     return value;
5170 }
5171 
GetWidth(FrameNode * frameNode)5172 Dimension ViewAbstract::GetWidth(FrameNode* frameNode)
5173 {
5174     Dimension value = Dimension(-1.0f);
5175     const auto& layoutProperty = frameNode->GetLayoutProperty();
5176     CHECK_NULL_RETURN(layoutProperty, value);
5177     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5178     CHECK_NULL_RETURN(property, value);
5179     auto size = property->selfIdealSize;
5180     if (size.has_value()) {
5181         auto width = size->Width();
5182         if (width.has_value()) {
5183             return width.value().GetDimension();
5184         }
5185     }
5186     return value;
5187 }
5188 
GetHeight(FrameNode * frameNode)5189 Dimension ViewAbstract::GetHeight(FrameNode* frameNode)
5190 {
5191     Dimension value = Dimension(-1.0f);
5192     const auto& layoutProperty = frameNode->GetLayoutProperty();
5193     CHECK_NULL_RETURN(layoutProperty, value);
5194     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5195     CHECK_NULL_RETURN(property, value);
5196     auto size = property->selfIdealSize;
5197     if (size.has_value()) {
5198         auto height = size->Height();
5199         if (height.has_value()) {
5200             return height.value().GetDimension();
5201         }
5202     }
5203     return value;
5204 }
5205 
GetBackgroundColor(FrameNode * frameNode)5206 Color ViewAbstract::GetBackgroundColor(FrameNode* frameNode)
5207 {
5208     Color value;
5209     auto target = frameNode->GetRenderContext();
5210     CHECK_NULL_RETURN(target, value);
5211     return target->GetBackgroundColorValue(value);
5212 }
5213 
GetBackgroundImageSrc(FrameNode * frameNode)5214 std::string ViewAbstract::GetBackgroundImageSrc(FrameNode* frameNode)
5215 {
5216     auto target = frameNode->GetRenderContext();
5217     CHECK_NULL_RETURN(target, "");
5218     if (target->GetBackgroundImage().has_value()) {
5219         return target->GetBackgroundImage()->GetSrc();
5220     }
5221     return "";
5222 }
5223 
GetBackgroundImageRepeat(FrameNode * frameNode)5224 ImageRepeat ViewAbstract::GetBackgroundImageRepeat(FrameNode* frameNode)
5225 {
5226     ImageRepeat value = ImageRepeat::NO_REPEAT;
5227     auto target = frameNode->GetRenderContext();
5228     CHECK_NULL_RETURN(target, value);
5229     if (target->GetBackgroundImageRepeat().has_value()) {
5230         return target->GetBackgroundImageRepeat().value();
5231     }
5232     return value;
5233 }
5234 
GetPadding(FrameNode * frameNode)5235 PaddingProperty ViewAbstract::GetPadding(FrameNode* frameNode)
5236 {
5237     CalcLength defaultDimen = CalcLength(0, DimensionUnit::VP);
5238     PaddingProperty paddings;
5239     paddings.top = std::optional<CalcLength>(defaultDimen);
5240     paddings.right = std::optional<CalcLength>(defaultDimen);
5241     paddings.bottom = std::optional<CalcLength>(defaultDimen);
5242     paddings.left = std::optional<CalcLength>(defaultDimen);
5243     const auto& layoutProperty = frameNode->GetLayoutProperty();
5244     CHECK_NULL_RETURN(layoutProperty, paddings);
5245     const auto& property = layoutProperty->GetPaddingProperty();
5246     CHECK_NULL_RETURN(property, paddings);
5247     paddings.top = std::optional<CalcLength>(property->top);
5248     paddings.right = std::optional<CalcLength>(property->right);
5249     paddings.bottom = std::optional<CalcLength>(property->bottom);
5250     paddings.left = std::optional<CalcLength>(property->left);
5251     return paddings;
5252 }
5253 
GetConfigSize(FrameNode * frameNode)5254 std::optional<CalcSize> ViewAbstract::GetConfigSize(FrameNode* frameNode)
5255 {
5256     auto value = std::optional<CalcSize>();
5257     const auto& layoutProperty = frameNode->GetLayoutProperty();
5258     CHECK_NULL_RETURN(layoutProperty, value);
5259     const auto& property = layoutProperty->GetCalcLayoutConstraint();
5260     CHECK_NULL_RETURN(property, value);
5261     auto size = property->selfIdealSize;
5262     if (size.has_value()) {
5263         value = size;
5264     }
5265     return value;
5266 }
5267 
GetKey(FrameNode * frameNode)5268 std::string ViewAbstract::GetKey(FrameNode* frameNode)
5269 {
5270     std::string value;
5271     CHECK_NULL_RETURN(frameNode, value);
5272     return value = frameNode->GetInspectorIdValue();
5273 }
5274 
GetEnabled(FrameNode * frameNode)5275 bool ViewAbstract::GetEnabled(FrameNode* frameNode)
5276 {
5277     auto eventHub = frameNode->GetEventHub<EventHub>();
5278     CHECK_NULL_RETURN(eventHub, false);
5279     return eventHub->IsEnabled();
5280 }
5281 
GetMargin(FrameNode * frameNode)5282 MarginProperty ViewAbstract::GetMargin(FrameNode* frameNode)
5283 {
5284     CalcLength defaultDimen = CalcLength(0, DimensionUnit::VP);
5285     MarginProperty margins;
5286     margins.top = std::optional<CalcLength>(defaultDimen);
5287     margins.right = std::optional<CalcLength>(defaultDimen);
5288     margins.bottom = std::optional<CalcLength>(defaultDimen);
5289     margins.left = std::optional<CalcLength>(defaultDimen);
5290     const auto& layoutProperty = frameNode->GetLayoutProperty();
5291     CHECK_NULL_RETURN(layoutProperty, margins);
5292     const auto& property = layoutProperty->GetMarginProperty();
5293     CHECK_NULL_RETURN(property, margins);
5294     margins.top = std::optional<CalcLength>(property->top);
5295     margins.right = std::optional<CalcLength>(property->right);
5296     margins.bottom = std::optional<CalcLength>(property->bottom);
5297     margins.left = std::optional<CalcLength>(property->left);
5298     return margins;
5299 }
5300 
GetTranslate(FrameNode * frameNode)5301 TranslateOptions ViewAbstract::GetTranslate(FrameNode* frameNode)
5302 {
5303     TranslateOptions value(0.0f, 0.0f, 0.0f);
5304     auto target = frameNode->GetRenderContext();
5305     CHECK_NULL_RETURN(target, value);
5306     return target->GetTransformTranslateValue(value);
5307 }
5308 
GetAspectRatio(FrameNode * frameNode)5309 float ViewAbstract::GetAspectRatio(FrameNode* frameNode)
5310 {
5311     float aspectRatio = 1.0f;
5312     const auto& layoutProperty = frameNode->GetLayoutProperty();
5313     CHECK_NULL_RETURN(layoutProperty, aspectRatio);
5314     aspectRatio = layoutProperty->GetAspectRatio();
5315     return aspectRatio;
5316 }
5317 
SetJSFrameNodeOnClick(FrameNode * frameNode,GestureEventFunc && clickEventFunc)5318 void ViewAbstract::SetJSFrameNodeOnClick(FrameNode* frameNode, GestureEventFunc&& clickEventFunc)
5319 {
5320     CHECK_NULL_VOID(frameNode);
5321     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5322     CHECK_NULL_VOID(gestureHub);
5323     gestureHub->SetJSFrameNodeOnClick(std::move(clickEventFunc));
5324     auto focusHub = frameNode->GetOrCreateFocusHub();
5325     CHECK_NULL_VOID(focusHub);
5326     focusHub->SetFocusable(true, false);
5327 }
5328 
ClearJSFrameNodeOnClick(FrameNode * frameNode)5329 void ViewAbstract::ClearJSFrameNodeOnClick(FrameNode* frameNode)
5330 {
5331     CHECK_NULL_VOID(frameNode);
5332     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5333     CHECK_NULL_VOID(gestureHub);
5334     gestureHub->ClearJSFrameNodeOnClick();
5335 }
5336 
SetJSFrameNodeOnTouch(FrameNode * frameNode,TouchEventFunc && touchEventFunc)5337 void ViewAbstract::SetJSFrameNodeOnTouch(FrameNode* frameNode, TouchEventFunc&& touchEventFunc)
5338 {
5339     CHECK_NULL_VOID(frameNode);
5340     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5341     CHECK_NULL_VOID(gestureHub);
5342     gestureHub->SetJSFrameNodeOnTouchEvent(std::move(touchEventFunc));
5343 }
5344 
ClearJSFrameNodeOnTouch(FrameNode * frameNode)5345 void ViewAbstract::ClearJSFrameNodeOnTouch(FrameNode* frameNode)
5346 {
5347     CHECK_NULL_VOID(frameNode);
5348     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5349     CHECK_NULL_VOID(gestureHub);
5350     gestureHub->ClearJSFrameNodeOnTouch();
5351 }
5352 
SetJSFrameNodeOnAppear(FrameNode * frameNode,std::function<void ()> && onAppear)5353 void ViewAbstract::SetJSFrameNodeOnAppear(FrameNode* frameNode, std::function<void()>&& onAppear)
5354 {
5355     CHECK_NULL_VOID(frameNode);
5356     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5357     CHECK_NULL_VOID(eventHub);
5358     eventHub->SetJSFrameNodeOnAppear(std::move(onAppear));
5359 }
5360 
ClearJSFrameNodeOnAppear(FrameNode * frameNode)5361 void ViewAbstract::ClearJSFrameNodeOnAppear(FrameNode* frameNode)
5362 {
5363     CHECK_NULL_VOID(frameNode);
5364     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5365     CHECK_NULL_VOID(eventHub);
5366     eventHub->ClearJSFrameNodeOnAppear();
5367 }
5368 
SetJSFrameNodeOnDisappear(FrameNode * frameNode,std::function<void ()> && onDisappear)5369 void ViewAbstract::SetJSFrameNodeOnDisappear(FrameNode* frameNode, std::function<void()>&& onDisappear)
5370 {
5371     CHECK_NULL_VOID(frameNode);
5372     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5373     CHECK_NULL_VOID(eventHub);
5374     eventHub->SetJSFrameNodeOnDisappear(std::move(onDisappear));
5375 }
5376 
ClearJSFrameNodeOnDisappear(FrameNode * frameNode)5377 void ViewAbstract::ClearJSFrameNodeOnDisappear(FrameNode* frameNode)
5378 {
5379     CHECK_NULL_VOID(frameNode);
5380     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5381     CHECK_NULL_VOID(eventHub);
5382     eventHub->ClearJSFrameNodeOnDisappear();
5383 }
5384 
SetJSFrameNodeOnKeyCallback(FrameNode * frameNode,OnKeyCallbackFunc && onKeyCallback)5385 void ViewAbstract::SetJSFrameNodeOnKeyCallback(FrameNode* frameNode, OnKeyCallbackFunc&& onKeyCallback)
5386 {
5387     CHECK_NULL_VOID(frameNode);
5388     auto focusHub = frameNode->GetOrCreateFocusHub();
5389     CHECK_NULL_VOID(focusHub);
5390     focusHub->SetJSFrameNodeOnKeyCallback(std::move(onKeyCallback));
5391 }
5392 
ClearJSFrameNodeOnKeyCallback(FrameNode * frameNode)5393 void ViewAbstract::ClearJSFrameNodeOnKeyCallback(FrameNode* frameNode)
5394 {
5395     CHECK_NULL_VOID(frameNode);
5396     auto focusHub = frameNode->GetOrCreateFocusHub();
5397     CHECK_NULL_VOID(focusHub);
5398     focusHub->ClearJSFrameNodeOnKeyCallback();
5399 }
5400 
SetJSFrameNodeOnFocusCallback(FrameNode * frameNode,OnFocusFunc && onFocusCallback)5401 void ViewAbstract::SetJSFrameNodeOnFocusCallback(FrameNode* frameNode, OnFocusFunc&& onFocusCallback)
5402 {
5403     CHECK_NULL_VOID(frameNode);
5404     auto focusHub = frameNode->GetOrCreateFocusHub();
5405     CHECK_NULL_VOID(focusHub);
5406     focusHub->SetJSFrameNodeOnFocusCallback(std::move(onFocusCallback));
5407 }
5408 
ClearJSFrameNodeOnFocusCallback(FrameNode * frameNode)5409 void ViewAbstract::ClearJSFrameNodeOnFocusCallback(FrameNode* frameNode)
5410 {
5411     CHECK_NULL_VOID(frameNode);
5412     auto focusHub = frameNode->GetOrCreateFocusHub();
5413     CHECK_NULL_VOID(focusHub);
5414     focusHub->ClearJSFrameNodeOnFocusCallback();
5415 }
5416 
SetJSFrameNodeOnBlurCallback(FrameNode * frameNode,OnBlurFunc && onBlurCallback)5417 void ViewAbstract::SetJSFrameNodeOnBlurCallback(FrameNode* frameNode, OnBlurFunc&& onBlurCallback)
5418 {
5419     CHECK_NULL_VOID(frameNode);
5420     auto focusHub = frameNode->GetOrCreateFocusHub();
5421     CHECK_NULL_VOID(focusHub);
5422     focusHub->SetJSFrameNodeOnBlurCallback(std::move(onBlurCallback));
5423 }
5424 
ClearJSFrameNodeOnBlurCallback(FrameNode * frameNode)5425 void ViewAbstract::ClearJSFrameNodeOnBlurCallback(FrameNode* frameNode)
5426 {
5427     CHECK_NULL_VOID(frameNode);
5428     auto focusHub = frameNode->GetOrCreateFocusHub();
5429     CHECK_NULL_VOID(focusHub);
5430     focusHub->ClearJSFrameNodeOnBlurCallback();
5431 }
5432 
SetJSFrameNodeOnHover(FrameNode * frameNode,OnHoverFunc && onHoverEventFunc)5433 void ViewAbstract::SetJSFrameNodeOnHover(FrameNode* frameNode, OnHoverFunc&& onHoverEventFunc)
5434 {
5435     CHECK_NULL_VOID(frameNode);
5436     auto eventHub = frameNode->GetOrCreateInputEventHub();
5437     CHECK_NULL_VOID(eventHub);
5438     eventHub->SetJSFrameNodeOnHoverEvent(std::move(onHoverEventFunc));
5439 }
5440 
ClearJSFrameNodeOnHover(FrameNode * frameNode)5441 void ViewAbstract::ClearJSFrameNodeOnHover(FrameNode* frameNode)
5442 {
5443     CHECK_NULL_VOID(frameNode);
5444     auto eventHub = frameNode->GetOrCreateInputEventHub();
5445     CHECK_NULL_VOID(eventHub);
5446     eventHub->ClearJSFrameNodeOnHover();
5447 }
5448 
SetJSFrameNodeOnHoverMove(FrameNode * frameNode,OnHoverMoveFunc && onHoverMoveEventFunc)5449 void ViewAbstract::SetJSFrameNodeOnHoverMove(FrameNode* frameNode, OnHoverMoveFunc&& onHoverMoveEventFunc)
5450 {
5451     CHECK_NULL_VOID(frameNode);
5452     auto eventHub = frameNode->GetOrCreateInputEventHub();
5453     CHECK_NULL_VOID(eventHub);
5454     eventHub->SetJSFrameNodeOnHoverMoveEvent(std::move(onHoverMoveEventFunc));
5455 }
5456 
ClearJSFrameNodeOnHoverMove(FrameNode * frameNode)5457 void ViewAbstract::ClearJSFrameNodeOnHoverMove(FrameNode* frameNode)
5458 {
5459     CHECK_NULL_VOID(frameNode);
5460     auto eventHub = frameNode->GetOrCreateInputEventHub();
5461     CHECK_NULL_VOID(eventHub);
5462     eventHub->ClearJSFrameNodeOnHoverMove();
5463 }
5464 
SetJSFrameNodeOnMouse(FrameNode * frameNode,OnMouseEventFunc && onMouseEventFunc)5465 void ViewAbstract::SetJSFrameNodeOnMouse(FrameNode* frameNode, OnMouseEventFunc&& onMouseEventFunc)
5466 {
5467     CHECK_NULL_VOID(frameNode);
5468     auto eventHub = frameNode->GetOrCreateInputEventHub();
5469     CHECK_NULL_VOID(eventHub);
5470     eventHub->SetJSFrameNodeOnMouseEvent(std::move(onMouseEventFunc));
5471 }
5472 
ClearJSFrameNodeOnMouse(FrameNode * frameNode)5473 void ViewAbstract::ClearJSFrameNodeOnMouse(FrameNode* frameNode)
5474 {
5475     CHECK_NULL_VOID(frameNode);
5476     auto eventHub = frameNode->GetOrCreateInputEventHub();
5477     CHECK_NULL_VOID(eventHub);
5478     eventHub->ClearJSFrameNodeOnMouse();
5479 }
5480 
GetBlendApplyType(FrameNode * frameNode)5481 BlendApplyType ViewAbstract::GetBlendApplyType(FrameNode* frameNode)
5482 {
5483     BlendApplyType value = BlendApplyType::FAST;
5484     const auto& target = frameNode->GetRenderContext();
5485     CHECK_NULL_RETURN(target, value);
5486     return target->GetBackBlendApplyTypeValue(value);
5487 }
5488 
SetJSFrameNodeOnSizeChange(FrameNode * frameNode,std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)5489 void ViewAbstract::SetJSFrameNodeOnSizeChange(
5490     FrameNode* frameNode, std::function<void(const RectF& oldRect, const RectF& rect)>&& onSizeChanged)
5491 {
5492     CHECK_NULL_VOID(frameNode);
5493     frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(onSizeChanged));
5494 }
5495 
ClearJSFrameNodeOnSizeChange(FrameNode * frameNode)5496 void ViewAbstract::ClearJSFrameNodeOnSizeChange(FrameNode* frameNode)
5497 {
5498     CHECK_NULL_VOID(frameNode);
5499     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5500     CHECK_NULL_VOID(eventHub);
5501     eventHub->ClearJSFrameNodeOnSizeChange();
5502 }
5503 
SetJSFrameNodeOnVisibleAreaApproximateChange(FrameNode * frameNode,const std::function<void (bool,double)> && jsCallback,const std::vector<double> & ratioList,int32_t interval)5504 void ViewAbstract::SetJSFrameNodeOnVisibleAreaApproximateChange(FrameNode* frameNode,
5505     const std::function<void(bool, double)>&& jsCallback, const std::vector<double>& ratioList,
5506     int32_t interval)
5507 {
5508     CHECK_NULL_VOID(frameNode);
5509     auto pipeline = frameNode->GetContext();
5510     CHECK_NULL_VOID(pipeline);
5511     frameNode->CleanVisibleAreaUserCallback(true);
5512 
5513     constexpr uint32_t minInterval = 100; // 100ms
5514     if (interval < 0 || static_cast<uint32_t>(interval) < minInterval) {
5515         interval = minInterval;
5516     }
5517     VisibleCallbackInfo callback;
5518     callback.callback = std::move(jsCallback);
5519     callback.isCurrentVisible = false;
5520     callback.period = static_cast<uint32_t>(interval);
5521     pipeline->AddVisibleAreaChangeNode(frameNode->GetId());
5522     frameNode->SetVisibleAreaUserCallback(ratioList, callback);
5523 }
5524 
ClearJSFrameNodeOnVisibleAreaApproximateChange(FrameNode * frameNode)5525 void ViewAbstract::ClearJSFrameNodeOnVisibleAreaApproximateChange(FrameNode* frameNode)
5526 {
5527     CHECK_NULL_VOID(frameNode);
5528     frameNode->CleanVisibleAreaUserCallback(true);
5529 }
5530 
SetOnGestureJudgeBegin(FrameNode * frameNode,GestureJudgeFunc && gestureJudgeFunc)5531 void ViewAbstract::SetOnGestureJudgeBegin(FrameNode* frameNode, GestureJudgeFunc&& gestureJudgeFunc)
5532 {
5533     CHECK_NULL_VOID(frameNode);
5534     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5535     CHECK_NULL_VOID(gestureHub);
5536     gestureHub->SetOnGestureJudgeBegin(std::move(gestureJudgeFunc));
5537 }
5538 
SetOnSizeChanged(FrameNode * frameNode,std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)5539 void ViewAbstract::SetOnSizeChanged(
5540     FrameNode* frameNode, std::function<void(const RectF& oldRect, const RectF& rect)>&& onSizeChanged)
5541 {
5542     CHECK_NULL_VOID(frameNode);
5543     frameNode->SetOnSizeChangeCallback(std::move(onSizeChanged));
5544 }
5545 
SetOnGestureRecognizerJudgeBegin(FrameNode * frameNode,GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc)5546 void ViewAbstract::SetOnGestureRecognizerJudgeBegin(
5547     FrameNode* frameNode, GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc)
5548 {
5549     CHECK_NULL_VOID(frameNode);
5550     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5551     CHECK_NULL_VOID(gestureHub);
5552     gestureHub->SetOnGestureRecognizerJudgeBegin(std::move(gestureRecognizerJudgeFunc));
5553 }
5554 
SetShouldBuiltInRecognizerParallelWith(FrameNode * frameNode,NG::ShouldBuiltInRecognizerParallelWithFunc && shouldBuiltInRecognizerParallelWithFunc)5555 void ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
5556     FrameNode* frameNode, NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc)
5557 {
5558     CHECK_NULL_VOID(frameNode);
5559     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5560     CHECK_NULL_VOID(gestureHub);
5561     gestureHub->SetShouldBuildinRecognizerParallelWithFunc(std::move(shouldBuiltInRecognizerParallelWithFunc));
5562 }
5563 
SetNextFocus(FrameNode * frameNode,FocusIntension key,std::variant<WeakPtr<AceType>,std::string> nextFocus)5564 void ViewAbstract::SetNextFocus(FrameNode* frameNode, FocusIntension key,
5565     std::variant<WeakPtr<AceType>, std::string> nextFocus)
5566 {
5567     CHECK_NULL_VOID(frameNode);
5568     auto focusHub = frameNode->GetOrCreateFocusHub();
5569     CHECK_NULL_VOID(focusHub);
5570     focusHub->SetNextFocus(key, nextFocus);
5571 }
5572 
ResetNextFocus(FrameNode * frameNode)5573 void ViewAbstract::ResetNextFocus(FrameNode* frameNode)
5574 {
5575     CHECK_NULL_VOID(frameNode);
5576     auto focusHub = frameNode->GetOrCreateFocusHub();
5577     CHECK_NULL_VOID(focusHub);
5578     focusHub->ResetNextFocus();
5579 }
5580 
SetFocusBoxStyle(FrameNode * frameNode,const NG::FocusBoxStyle & style)5581 void ViewAbstract::SetFocusBoxStyle(FrameNode* frameNode, const NG::FocusBoxStyle& style)
5582 {
5583     CHECK_NULL_VOID(frameNode);
5584     auto focusHub = frameNode->GetOrCreateFocusHub();
5585     CHECK_NULL_VOID(focusHub);
5586     focusHub->GetFocusBox().SetStyle(style);
5587 }
5588 
SetDragEventStrictReportingEnabled(bool dragEventStrictReportingEnabled)5589 void ViewAbstract::SetDragEventStrictReportingEnabled(bool dragEventStrictReportingEnabled)
5590 {
5591     auto pipeline = PipelineContext::GetCurrentContext();
5592     CHECK_NULL_VOID(pipeline);
5593     auto dragDropManager = pipeline->GetDragDropManager();
5594     CHECK_NULL_VOID(dragDropManager);
5595     dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
5596 }
5597 
SetDragEventStrictReportingEnabled(int32_t instanceId,bool dragEventStrictReportingEnabled)5598 void ViewAbstract::SetDragEventStrictReportingEnabled(int32_t instanceId, bool dragEventStrictReportingEnabled)
5599 {
5600     auto pipeline = PipelineContext::GetContextByContainerId(instanceId);
5601     CHECK_NULL_VOID(pipeline);
5602     auto dragDropManager = pipeline->GetDragDropManager();
5603     CHECK_NULL_VOID(dragDropManager);
5604     dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
5605 }
5606 
SetDisallowDropForcedly(bool isDisallowDropForcedly)5607 void ViewAbstract::SetDisallowDropForcedly(bool isDisallowDropForcedly)
5608 {
5609     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
5610     CHECK_NULL_VOID(frameNode);
5611     frameNode->SetDisallowDropForcedly(isDisallowDropForcedly);
5612 }
5613 
SetBackgroundImageResizableSlice(const ImageResizableSlice & slice)5614 void ViewAbstract::SetBackgroundImageResizableSlice(const ImageResizableSlice& slice)
5615 {
5616     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
5617         return;
5618     }
5619     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageResizableSlice, slice);
5620 }
5621 
SetBackgroundImageResizableSlice(FrameNode * frameNode,const ImageResizableSlice & slice)5622 void ViewAbstract::SetBackgroundImageResizableSlice(FrameNode* frameNode, const ImageResizableSlice& slice)
5623 {
5624     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageResizableSlice, slice, frameNode);
5625 }
5626 
GetBackgroundImageResizableSlice(FrameNode * frameNode)5627 ImageResizableSlice ViewAbstract::GetBackgroundImageResizableSlice(FrameNode* frameNode)
5628 {
5629     ImageResizableSlice slice;
5630     CHECK_NULL_RETURN(frameNode, slice);
5631     const auto& target = frameNode->GetRenderContext();
5632     CHECK_NULL_RETURN(target, slice);
5633     return target->GetBackgroundImageResizableSliceValue(slice);
5634 }
5635 
SetOnTouchIntercept(FrameNode * frameNode,TouchInterceptFunc && touchInterceptFunc)5636 void ViewAbstract::SetOnTouchIntercept(FrameNode* frameNode, TouchInterceptFunc&& touchInterceptFunc)
5637 {
5638     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
5639     CHECK_NULL_VOID(gestureHub);
5640     gestureHub->SetOnTouchIntercept(std::move(touchInterceptFunc));
5641 }
5642 
GetLayoutWeight(FrameNode * frameNode)5643 float ViewAbstract::GetLayoutWeight(FrameNode* frameNode)
5644 {
5645     float layoutWeight = 0.0f;
5646     CHECK_NULL_RETURN(frameNode, layoutWeight);
5647     auto layoutProperty = frameNode->GetLayoutProperty();
5648     CHECK_NULL_RETURN(layoutProperty, layoutWeight);
5649     auto& magicItemProperty = layoutProperty->GetMagicItemProperty();
5650     if (magicItemProperty.HasLayoutWeight()) {
5651         return magicItemProperty.GetLayoutWeight().value_or(layoutWeight);
5652     }
5653     return layoutWeight;
5654 }
5655 
GetDisplayIndex(FrameNode * frameNode)5656 int32_t ViewAbstract::GetDisplayIndex(FrameNode* frameNode)
5657 {
5658     int32_t defaultDisplayIndex = 0;
5659     CHECK_NULL_RETURN(frameNode, defaultDisplayIndex);
5660     const auto& layoutProperty = frameNode->GetLayoutProperty();
5661     CHECK_NULL_RETURN(layoutProperty, defaultDisplayIndex);
5662     const auto& flexItemProperty = layoutProperty->GetFlexItemProperty();
5663     CHECK_NULL_RETURN(flexItemProperty, defaultDisplayIndex);
5664     return flexItemProperty->GetDisplayIndex().value_or(defaultDisplayIndex);
5665 }
5666 
GetOuterBorderWidth(FrameNode * frameNode)5667 NG::BorderWidthProperty ViewAbstract::GetOuterBorderWidth(FrameNode* frameNode)
5668 {
5669     BorderWidthProperty borderWidth;
5670     CHECK_NULL_RETURN(frameNode, borderWidth);
5671     auto context = frameNode->GetRenderContext();
5672     CHECK_NULL_RETURN(context, borderWidth);
5673     auto outBorderWidth = context->GetOuterBorder()->GetOuterBorderWidth();
5674     CHECK_NULL_RETURN(outBorderWidth, borderWidth);
5675     return outBorderWidth.value_or(borderWidth);
5676 }
5677 
SetBias(FrameNode * frameNode,const BiasPair & biasPair)5678 void ViewAbstract::SetBias(FrameNode* frameNode, const BiasPair& biasPair)
5679 {
5680     CHECK_NULL_VOID(frameNode);
5681     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Bias, biasPair, frameNode);
5682 }
5683 
GetBias(FrameNode * frameNode)5684 BiasPair ViewAbstract::GetBias(FrameNode* frameNode)
5685 {
5686     BiasPair biasPair(-1.0f, -1.0f);
5687     CHECK_NULL_RETURN(frameNode, biasPair);
5688     auto layoutProperty = frameNode->GetLayoutProperty();
5689     CHECK_NULL_RETURN(layoutProperty, biasPair);
5690     CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), biasPair);
5691     return layoutProperty->GetFlexItemProperty()->GetBias().value_or(biasPair);
5692 }
5693 
ResetBias(FrameNode * frameNode)5694 void ViewAbstract::ResetBias(FrameNode* frameNode)
5695 {
5696     CHECK_NULL_VOID(frameNode);
5697     auto layoutProperty = frameNode->GetLayoutProperty();
5698     CHECK_NULL_VOID(layoutProperty);
5699     CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
5700     layoutProperty->GetFlexItemProperty()->ResetBias();
5701 }
5702 
GetRenderFit(FrameNode * frameNode)5703 RenderFit ViewAbstract::GetRenderFit(FrameNode* frameNode)
5704 {
5705     RenderFit defalutRenderFit = RenderFit::TOP_LEFT;
5706     CHECK_NULL_RETURN(frameNode, defalutRenderFit);
5707     auto renderContext = frameNode->GetRenderContext();
5708     CHECK_NULL_RETURN(renderContext, defalutRenderFit);
5709     return renderContext->GetRenderFit().value_or(defalutRenderFit);
5710 }
5711 
GetOuterBorderColor(FrameNode * frameNode)5712 BorderColorProperty ViewAbstract::GetOuterBorderColor(FrameNode* frameNode)
5713 {
5714     Color defaultColor(0xff000000);
5715     BorderColorProperty borderColors = { defaultColor, defaultColor, defaultColor, defaultColor,
5716         std::nullopt, std::nullopt };
5717     CHECK_NULL_RETURN(frameNode, borderColors);
5718     const auto& target = frameNode->GetRenderContext();
5719     CHECK_NULL_RETURN(target, borderColors);
5720     return target->GetOuterBorderColorValue(borderColors);
5721 }
5722 
GetRenderGroup(FrameNode * frameNode)5723 bool ViewAbstract::GetRenderGroup(FrameNode* frameNode)
5724 {
5725     CHECK_NULL_RETURN(frameNode, false);
5726     const auto& target = frameNode->GetRenderContext();
5727     CHECK_NULL_RETURN(target, false);
5728     return target->GetRenderGroupValue(false);
5729 }
5730 
SetOnVisibleChange(FrameNode * frameNode,std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList)5731 void ViewAbstract::SetOnVisibleChange(FrameNode* frameNode, std::function<void(bool, double)>&& onVisibleChange,
5732     const std::vector<double> &ratioList)
5733 {
5734     CHECK_NULL_VOID(frameNode);
5735     auto pipeline = frameNode->GetContext();
5736     CHECK_NULL_VOID(pipeline);
5737     frameNode->CleanVisibleAreaUserCallback();
5738     pipeline->AddVisibleAreaChangeNode(AceType::Claim<FrameNode>(frameNode), ratioList, onVisibleChange);
5739 }
5740 
SetOnVisibleAreaApproximateChange(FrameNode * frameNode,const std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList,int32_t expectedUpdateInterval)5741 void ViewAbstract::SetOnVisibleAreaApproximateChange(FrameNode* frameNode,
5742     const std::function<void(bool, double)>&& onVisibleChange, const std::vector<double>& ratioList,
5743     int32_t expectedUpdateInterval)
5744 {
5745     CHECK_NULL_VOID(frameNode);
5746     auto pipeline = frameNode->GetContext();
5747     CHECK_NULL_VOID(pipeline);
5748     frameNode->CleanVisibleAreaUserCallback(true);
5749 
5750     constexpr uint32_t minInterval = 100; // 100ms
5751     if (expectedUpdateInterval < 0 || static_cast<uint32_t>(expectedUpdateInterval) < minInterval) {
5752         expectedUpdateInterval = minInterval;
5753     }
5754     VisibleCallbackInfo callback;
5755     callback.callback = std::move(onVisibleChange);
5756     callback.isCurrentVisible = false;
5757     callback.period = static_cast<uint32_t>(expectedUpdateInterval);
5758     pipeline->AddVisibleAreaChangeNode(frameNode->GetId());
5759     frameNode->SetVisibleAreaUserCallback(ratioList, callback);
5760 }
5761 
SetOnVisibleAreaApproximateChange(const std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList,int32_t expectedUpdateInterval)5762 void ViewAbstract::SetOnVisibleAreaApproximateChange(const std::function<void(bool, double)>&& onVisibleChange,
5763     const std::vector<double>& ratioList, int32_t expectedUpdateInterval)
5764 {
5765     auto pipeline = PipelineContext::GetCurrentContext();
5766     CHECK_NULL_VOID(pipeline);
5767     auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
5768     CHECK_NULL_VOID(frameNode);
5769     frameNode->CleanVisibleAreaUserCallback(true);
5770 
5771     constexpr uint32_t minInterval = 100; // 100ms
5772     if (expectedUpdateInterval < 0 || static_cast<uint32_t>(expectedUpdateInterval) < minInterval) {
5773         expectedUpdateInterval = minInterval;
5774     }
5775     VisibleCallbackInfo callback;
5776     callback.callback = std::move(onVisibleChange);
5777     callback.isCurrentVisible = false;
5778     callback.period = static_cast<uint32_t>(expectedUpdateInterval);
5779     pipeline->AddVisibleAreaChangeNode(frameNode->GetId());
5780     frameNode->SetVisibleAreaUserCallback(ratioList, callback);
5781 }
5782 
GetColorBlend(FrameNode * frameNode)5783 Color ViewAbstract::GetColorBlend(FrameNode* frameNode)
5784 {
5785     Color defaultColor = Color::TRANSPARENT;
5786     CHECK_NULL_RETURN(frameNode, defaultColor);
5787     const auto& target = frameNode->GetRenderContext();
5788     CHECK_NULL_RETURN(target, defaultColor);
5789     return target->GetFrontColorBlendValue(defaultColor);
5790 }
5791 
ResetAreaChanged(FrameNode * frameNode)5792 void ViewAbstract::ResetAreaChanged(FrameNode* frameNode)
5793 {
5794     CHECK_NULL_VOID(frameNode);
5795     auto pipeline = frameNode->GetContext();
5796     CHECK_NULL_VOID(pipeline);
5797     frameNode->ClearUserOnAreaChange();
5798     pipeline->RemoveOnAreaChangeNode(frameNode->GetId());
5799 }
5800 
ResetVisibleChange(FrameNode * frameNode)5801 void ViewAbstract::ResetVisibleChange(FrameNode* frameNode)
5802 {
5803     CHECK_NULL_VOID(frameNode);
5804     auto pipeline = frameNode->GetContext();
5805     CHECK_NULL_VOID(pipeline);
5806     frameNode->CleanVisibleAreaUserCallback();
5807     pipeline->RemoveVisibleAreaChangeNode(frameNode->GetId());
5808 }
5809 
SetLayoutRect(FrameNode * frameNode,const NG::RectF & rect)5810 void ViewAbstract::SetLayoutRect(FrameNode* frameNode, const NG::RectF& rect)
5811 {
5812     CHECK_NULL_VOID(frameNode);
5813     frameNode->SetIsMeasureBoundary(true);
5814     const auto& layoutProperty = frameNode->GetLayoutProperty();
5815     CHECK_NULL_VOID(layoutProperty);
5816     layoutProperty->SetLayoutRect(rect);
5817 }
5818 
ResetLayoutRect(FrameNode * frameNode)5819 void ViewAbstract::ResetLayoutRect(FrameNode* frameNode)
5820 {
5821     CHECK_NULL_VOID(frameNode);
5822     frameNode->SetIsMeasureBoundary(false);
5823     const auto& layoutProperty = frameNode->GetLayoutProperty();
5824     CHECK_NULL_VOID(layoutProperty);
5825     layoutProperty->ResetLayoutRect();
5826 }
5827 
GetLayoutRect(FrameNode * frameNode)5828 NG::RectF ViewAbstract::GetLayoutRect(FrameNode* frameNode)
5829 {
5830     CHECK_NULL_RETURN(frameNode, NG::RectF());
5831     const auto& layoutProperty = frameNode->GetLayoutProperty();
5832     CHECK_NULL_RETURN(layoutProperty, NG::RectF());
5833     return layoutProperty->GetLayoutRect().value_or(NG::RectF());
5834 }
5835 
GetFocusOnTouch(FrameNode * frameNode)5836 bool ViewAbstract::GetFocusOnTouch(FrameNode* frameNode)
5837 {
5838     CHECK_NULL_RETURN(frameNode, false);
5839     auto focusHub = frameNode->GetFocusHub();
5840     CHECK_NULL_RETURN(focusHub, false);
5841     return focusHub->IsFocusOnTouch().value_or(false);
5842 }
5843 
SetFocusScopeId(const std::string & focusScopeId,bool isGroup,bool arrowKeyStepOut)5844 void ViewAbstract::SetFocusScopeId(const std::string& focusScopeId, bool isGroup, bool arrowKeyStepOut)
5845 {
5846     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
5847     CHECK_NULL_VOID(focusHub);
5848     focusHub->SetFocusScopeId(focusScopeId, isGroup, arrowKeyStepOut);
5849 }
5850 
SetFocusScopePriority(const std::string & focusScopeId,const uint32_t focusPriority)5851 void ViewAbstract::SetFocusScopePriority(const std::string& focusScopeId, const uint32_t focusPriority)
5852 {
5853     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
5854     CHECK_NULL_VOID(focusHub);
5855     focusHub->SetFocusScopePriority(focusScopeId, focusPriority);
5856 }
5857 
SetFocusScopeId(FrameNode * frameNode,const std::string & focusScopeId,bool isGroup,bool arrowKeyStepOut)5858 void ViewAbstract::SetFocusScopeId(FrameNode* frameNode, const std::string& focusScopeId, bool isGroup,
5859     bool arrowKeyStepOut)
5860 {
5861     CHECK_NULL_VOID(frameNode);
5862     auto focusHub = frameNode->GetOrCreateFocusHub();
5863     CHECK_NULL_VOID(focusHub);
5864     focusHub->SetFocusScopeId(focusScopeId, isGroup, arrowKeyStepOut);
5865 }
5866 
SetFocusScopePriority(FrameNode * frameNode,const std::string & focusScopeId,const uint32_t focusPriority)5867 void ViewAbstract::SetFocusScopePriority(FrameNode* frameNode, const std::string& focusScopeId,
5868     const uint32_t focusPriority)
5869 {
5870     CHECK_NULL_VOID(frameNode);
5871     auto focusHub = frameNode->GetOrCreateFocusHub();
5872     CHECK_NULL_VOID(focusHub);
5873     focusHub->SetFocusScopePriority(focusScopeId, focusPriority);
5874 }
5875 
FreezeUINodeById(const std::string & id,bool isFreeze)5876 void ViewAbstract::FreezeUINodeById(const std::string& id, bool isFreeze)
5877 {
5878     auto targetNode = ElementRegister::GetInstance()->GetAttachedFrameNodeById(id, true);
5879     CHECK_NULL_VOID(targetNode);
5880     auto pipeline = targetNode->GetContext();
5881     if (pipeline != nullptr) {
5882         pipeline->SetOpenInvisibleFreeze(true);
5883     }
5884     targetNode->SetFreeze(isFreeze, true, true);
5885 }
5886 
FreezeUINodeByUniqueId(const int32_t & uniqueId,bool isFreeze)5887 void ViewAbstract::FreezeUINodeByUniqueId(const int32_t& uniqueId, bool isFreeze)
5888 {
5889     auto targetNodeElement = ElementRegister::GetInstance()->GetNodeById(uniqueId);
5890     auto targetNode = AceType::DynamicCast<NG::FrameNode>(targetNodeElement);
5891     CHECK_NULL_VOID(targetNode);
5892     auto pipeline = targetNode->GetContext();
5893     if (pipeline != nullptr) {
5894         pipeline->SetOpenInvisibleFreeze(true);
5895     }
5896     targetNode->SetFreeze(isFreeze, true, true);
5897 }
5898 
GetSafeAreaExpandType(FrameNode * frameNode)5899 uint32_t ViewAbstract::GetSafeAreaExpandType(FrameNode* frameNode)
5900 {
5901     uint32_t value = SAFE_AREA_TYPE_ALL;
5902     CHECK_NULL_RETURN(frameNode, value);
5903     const auto& layoutProperty = frameNode->GetLayoutProperty();
5904     CHECK_NULL_RETURN(layoutProperty, value);
5905     const auto& SafeAreaExpandOpts = layoutProperty->GetSafeAreaExpandOpts();
5906     CHECK_NULL_RETURN(SafeAreaExpandOpts, value);
5907     if (SafeAreaExpandOpts->type > 0) {
5908         value = SafeAreaExpandOpts->type;
5909     }
5910     return value;
5911 }
5912 
GetSafeAreaExpandEdges(FrameNode * frameNode)5913 uint32_t ViewAbstract::GetSafeAreaExpandEdges(FrameNode* frameNode)
5914 {
5915     uint32_t value = SAFE_AREA_EDGE_ALL;
5916     CHECK_NULL_RETURN(frameNode, value);
5917     const auto& layoutProperty = frameNode->GetLayoutProperty();
5918     CHECK_NULL_RETURN(layoutProperty, value);
5919     const auto& SafeAreaExpandOpts = layoutProperty->GetSafeAreaExpandOpts();
5920     CHECK_NULL_RETURN(SafeAreaExpandOpts, value);
5921     if (SafeAreaExpandOpts->edges > 0) {
5922         value = SafeAreaExpandOpts->edges;
5923     }
5924     return value;
5925 }
5926 
SetPositionLocalizedEdges(bool needLocalized)5927 void ViewAbstract::SetPositionLocalizedEdges(bool needLocalized)
5928 {
5929     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
5930     CHECK_NULL_VOID(frameNode);
5931     auto layoutProperty = frameNode->GetLayoutProperty();
5932     CHECK_NULL_VOID(layoutProperty);
5933     layoutProperty->UpdateNeedPositionLocalizedEdges(needLocalized);
5934 }
5935 
SetMarkAnchorStart(Dimension & markAnchorStart)5936 void ViewAbstract::SetMarkAnchorStart(Dimension& markAnchorStart)
5937 {
5938     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
5939     CHECK_NULL_VOID(frameNode);
5940     auto layoutProperty = frameNode->GetLayoutProperty();
5941     CHECK_NULL_VOID(layoutProperty);
5942     layoutProperty->UpdateMarkAnchorStart(markAnchorStart);
5943 }
5944 
ResetMarkAnchorStart()5945 void ViewAbstract::ResetMarkAnchorStart()
5946 {
5947     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
5948     CHECK_NULL_VOID(frameNode);
5949     auto layoutProperty = frameNode->GetLayoutProperty();
5950     CHECK_NULL_VOID(layoutProperty);
5951     layoutProperty->ResetMarkAnchorStart();
5952 }
5953 
SetOffsetLocalizedEdges(bool needLocalized)5954 void ViewAbstract::SetOffsetLocalizedEdges(bool needLocalized)
5955 {
5956     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
5957     CHECK_NULL_VOID(frameNode);
5958     auto layoutProperty = frameNode->GetLayoutProperty();
5959     CHECK_NULL_VOID(layoutProperty);
5960     layoutProperty->UpdateNeedOffsetLocalizedEdges(needLocalized);
5961 }
5962 
SetSystemColorModeChangeEvent(FrameNode * frameNode,std::function<void (int32_t)> && onColorModeChange)5963 void ViewAbstract::SetSystemColorModeChangeEvent(
5964     FrameNode* frameNode, std::function<void(int32_t)>&& onColorModeChange)
5965 {
5966     CHECK_NULL_VOID(frameNode);
5967     frameNode->SetNDKColorModeUpdateCallback(std::move(onColorModeChange));
5968 }
5969 
SetSystemFontChangeEvent(FrameNode * frameNode,std::function<void (float,float)> && onFontChange)5970 void ViewAbstract::SetSystemFontChangeEvent(FrameNode* frameNode, std::function<void(float, float)>&& onFontChange)
5971 {
5972     CHECK_NULL_VOID(frameNode);
5973     frameNode->SetNDKFontUpdateCallback(std::move(onFontChange));
5974 }
5975 
SetDrawCompleteEvent(FrameNode * frameNode,std::function<void ()> && onDraw)5976 void ViewAbstract::SetDrawCompleteEvent(
5977     FrameNode* frameNode, std::function<void()>&& onDraw)
5978 {
5979     CHECK_NULL_VOID(frameNode);
5980     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5981     CHECK_NULL_VOID(eventHub);
5982     eventHub->SetNDKDrawCompletedCallback(std::move(onDraw));
5983 }
5984 
SetLayoutEvent(FrameNode * frameNode,std::function<void ()> && onLayout)5985 void ViewAbstract::SetLayoutEvent(
5986     FrameNode* frameNode, std::function<void()>&& onLayout)
5987 {
5988     CHECK_NULL_VOID(frameNode);
5989     auto eventHub = frameNode->GetEventHub<NG::EventHub>();
5990     CHECK_NULL_VOID(eventHub);
5991     eventHub->SetNDKLayoutCallback(std::move(onLayout));
5992 }
5993 
AddCustomProperty(UINode * frameNode,const std::string & key,const std::string & value)5994 void ViewAbstract::AddCustomProperty(UINode* frameNode, const std::string& key, const std::string& value)
5995 {
5996     CHECK_NULL_VOID(frameNode);
5997     frameNode->AddCustomProperty(key, value);
5998 }
5999 
RemoveCustomProperty(UINode * frameNode,const std::string & key)6000 void ViewAbstract::RemoveCustomProperty(UINode* frameNode, const std::string& key)
6001 {
6002     CHECK_NULL_VOID(frameNode);
6003     frameNode->RemoveCustomProperty(key);
6004 }
6005 
CancelDataLoading(const std::string & key)6006 int32_t ViewAbstract::CancelDataLoading(const std::string& key)
6007 {
6008     auto pipeline = PipelineContext::GetCurrentContext();
6009     CHECK_NULL_RETURN(pipeline, -1);
6010     auto dragDropManager = pipeline->GetDragDropManager();
6011     CHECK_NULL_RETURN(dragDropManager, -1);
6012     return dragDropManager->CancelUDMFDataLoading(key);
6013 }
6014 
SetDisableDataPrefetch(bool disableDataPrefetch)6015 void ViewAbstract::SetDisableDataPrefetch(bool disableDataPrefetch)
6016 {
6017     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
6018     CHECK_NULL_VOID(eventHub);
6019     eventHub->SetDisableDataPrefetch(disableDataPrefetch);
6020 }
6021 
SetDisableDataPrefetch(FrameNode * frameNode,bool disableDataPrefetch)6022 void ViewAbstract::SetDisableDataPrefetch(FrameNode* frameNode, bool disableDataPrefetch)
6023 {
6024     CHECK_NULL_VOID(frameNode);
6025     auto eventHub = frameNode->GetEventHub<EventHub>();
6026     CHECK_NULL_VOID(eventHub);
6027 
6028     eventHub->SetDisableDataPrefetch(disableDataPrefetch);
6029 }
6030 } // namespace OHOS::Ace::NG
6031