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