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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H
18 
19 #include <functional>
20 #include <list>
21 #include <utility>
22 
23 #include "base/geometry/ng/offset_t.h"
24 #include "base/geometry/ng/point_t.h"
25 #include "base/geometry/ng/rect_t.h"
26 #include "base/geometry/ng/vector.h"
27 #include "base/memory/ace_type.h"
28 #include "base/memory/referenced.h"
29 #include "base/thread/cancelable_callback.h"
30 #include "base/thread/task_executor.h"
31 #include "base/utils/macros.h"
32 #include "base/utils/utils.h"
33 #include "core/accessibility/accessibility_utils.h"
34 #include "core/common/recorder/exposure_processor.h"
35 #include "core/common/resource/resource_configuration.h"
36 #include "core/components/common/layout/constants.h"
37 #include "core/components_ng/base/extension_handler.h"
38 #include "core/components_ng/base/frame_scene_status.h"
39 #include "core/components_ng/base/geometry_node.h"
40 #include "core/components_ng/base/modifier.h"
41 #include "core/components_ng/base/ui_node.h"
42 #include "core/components_ng/event/event_hub.h"
43 #include "core/components_ng/event/focus_hub.h"
44 #include "core/components_ng/event/gesture_event_hub.h"
45 #include "core/components_ng/event/input_event_hub.h"
46 #include "core/components_ng/event/target_component.h"
47 #include "core/components_ng/layout/layout_property.h"
48 #include "core/components_ng/property/accessibility_property.h"
49 #include "core/components_ng/property/layout_constraint.h"
50 #include "core/components_ng/property/property.h"
51 #include "core/components_ng/render/paint_property.h"
52 #include "core/components_ng/render/paint_wrapper.h"
53 #include "core/components_ng/render/render_context.h"
54 #include "core/components_v2/inspector/inspector_constants.h"
55 #include "core/components_v2/inspector/inspector_node.h"
56 
57 namespace OHOS::Accessibility {
58 class AccessibilityElementInfo;
59 class AccessibilityEventInfo;
60 } // namespace OHOS::Accessibility
61 
62 namespace OHOS::Ace::NG {
63 class InspectorFilter;
64 class PipelineContext;
65 class Pattern;
66 class StateModifyTask;
67 class UITask;
68 struct DirtySwapConfig;
69 
70 struct CacheVisibleRectResult {
71     OffsetF windowOffset = OffsetF();
72     RectF visibleRect = RectF();
73     RectF innerVisibleRect = RectF();
74     VectorF cumulativeScale = {1.0f, 1.0f};
75     RectF frameRect = RectF();
76     RectF innerBoundaryRect = RectF();
77 };
78 
79 // FrameNode will display rendering region in the screen.
80 class ACE_FORCE_EXPORT FrameNode : public UINode, public LayoutWrapper {
81     DECLARE_ACE_TYPE(FrameNode, UINode, LayoutWrapper);
82 
83 private:
84     class FrameProxy;
85 
86 public:
87     // create a new child element with new element tree.
88     static RefPtr<FrameNode> CreateFrameNodeWithTree(
89         const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern);
90 
91     static RefPtr<FrameNode> GetOrCreateFrameNode(
92         const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator);
93 
94     static RefPtr<FrameNode> GetOrCreateCommonNode(const std::string& tag, int32_t nodeId, bool isLayoutNode,
95         const std::function<RefPtr<Pattern>(void)>& patternCreator);
96 
97     // create a new element with new pattern.
98     static RefPtr<FrameNode> CreateFrameNode(
99         const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot = false);
100 
101     static RefPtr<FrameNode> CreateCommonNode(const std::string& tag, int32_t nodeId, bool isLayoutNode,
102         const RefPtr<Pattern>& pattern, bool isRoot = false);
103 
104     // get element with nodeId from node map.
105     static RefPtr<FrameNode> GetFrameNode(const std::string& tag, int32_t nodeId);
106 
107     static void ProcessOffscreenNode(const RefPtr<FrameNode>& node);
108     // avoid use creator function, use CreateFrameNode
109 
110     FrameNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern,
111         bool isRoot = false, bool isLayoutNode = false);
112 
113     ~FrameNode() override;
114 
FrameCount()115     int32_t FrameCount() const override
116     {
117         return 1;
118     }
119 
CurrentFrameCount()120     int32_t CurrentFrameCount() const override
121     {
122         return 1;
123     }
124 
SetCheckboxFlag(const bool checkboxFlag)125     void SetCheckboxFlag(const bool checkboxFlag)
126     {
127         checkboxFlag_ = checkboxFlag;
128     }
129 
GetCheckboxFlag()130     bool GetCheckboxFlag() const
131     {
132         return checkboxFlag_;
133     }
134 
SetDisallowDropForcedly(bool isDisallowDropForcedly)135     void SetDisallowDropForcedly(bool isDisallowDropForcedly)
136     {
137         isDisallowDropForcedly_ = isDisallowDropForcedly;
138     }
139 
GetDisallowDropForcedly()140     bool GetDisallowDropForcedly() const
141     {
142         return isDisallowDropForcedly_;
143     }
144 
145     void OnInspectorIdUpdate(const std::string& id) override;
146 
147     void UpdateGeometryTransition() override;
148 
149     struct ZIndexComparator {
operatorZIndexComparator150         bool operator()(const WeakPtr<FrameNode>& weakLeft, const WeakPtr<FrameNode>& weakRight) const
151         {
152             auto left = weakLeft.Upgrade();
153             auto right = weakRight.Upgrade();
154             if (left && right) {
155                 return left->GetRenderContext()->GetZIndexValue(ZINDEX_DEFAULT_VALUE) <
156                        right->GetRenderContext()->GetZIndexValue(ZINDEX_DEFAULT_VALUE);
157             }
158             return false;
159         }
160     };
161 
GetFrameChildren()162     const std::multiset<WeakPtr<FrameNode>, ZIndexComparator>& GetFrameChildren() const
163     {
164         return frameChildren_;
165     }
166 
167     void InitializePatternAndContext();
168 
169     virtual void MarkModifyDone();
170 
171     void MarkDirtyNode(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL) override;
172 
173     void ProcessFreezeNode();
174 
175     void OnFreezeStateChange() override;
176 
ProcessPropertyDiff()177     void ProcessPropertyDiff()
178     {
179         if (isPropertyDiffMarked_) {
180             MarkModifyDone();
181             MarkDirtyNode();
182             isPropertyDiffMarked_ = false;
183         }
184     }
185 
186     void FlushUpdateAndMarkDirty() override;
187 
188     void MarkNeedFrameFlushDirty(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL) override
189     {
190         MarkDirtyNode(extraFlag);
191     }
192 
193     void OnMountToParentDone();
194 
195     void AfterMountToParent() override;
196 
197     bool GetIsLayoutNode();
198 
199     bool GetIsFind();
200 
201     void SetIsFind(bool isFind);
202 
203     void GetOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& children);
204 
205     void GetOneDepthVisibleFrameWithOffset(std::list<RefPtr<FrameNode>>& children, OffsetF& offset);
206 
207     void UpdateLayoutConstraint(const MeasureProperty& calcLayoutConstraint);
208 
209     RefPtr<LayoutWrapperNode> CreateLayoutWrapper(bool forceMeasure = false, bool forceLayout = false) override;
210 
211     RefPtr<LayoutWrapperNode> UpdateLayoutWrapper(
212         RefPtr<LayoutWrapperNode> layoutWrapper, bool forceMeasure = false, bool forceLayout = false);
213 
214     void CreateLayoutTask(bool forceUseMainThread = false);
215 
216     std::optional<UITask> CreateRenderTask(bool forceUseMainThread = false);
217 
218     void SwapDirtyLayoutWrapperOnMainThread(const RefPtr<LayoutWrapper>& dirty);
219 
220     // Clear the user callback.
221     void ClearUserOnAreaChange();
222 
223     void SetOnAreaChangeCallback(OnAreaChangedFunc&& callback);
224 
225     void TriggerOnAreaChangeCallback(uint64_t nanoTimestamp);
226 
227     void OnConfigurationUpdate(const ConfigurationChange& configurationChange) override;
228 
SetVisibleAreaUserCallback(const std::vector<double> & ratios,const VisibleCallbackInfo & callback)229     void SetVisibleAreaUserCallback(const std::vector<double>& ratios, const VisibleCallbackInfo& callback)
230     {
231         eventHub_->SetVisibleAreaRatiosAndCallback(callback, ratios, true);
232     }
233 
234     void CleanVisibleAreaUserCallback(bool isApproximate = false)
235     {
236         if (isApproximate) {
237             eventHub_->CleanVisibleAreaCallback(true, isApproximate);
238         } else {
239             eventHub_->CleanVisibleAreaCallback(true, false);
240         }
241     }
242 
243     void SetVisibleAreaInnerCallback(const std::vector<double>& ratios, const VisibleCallbackInfo& callback,
244         bool isCalculateInnerClip = false)
245     {
246         isCalculateInnerVisibleRectClip_ = isCalculateInnerClip;
247         eventHub_->SetVisibleAreaRatiosAndCallback(callback, ratios, false);
248     }
249 
250     void SetIsCalculateInnerClip(bool isCalculateInnerClip = false)
251     {
252         isCalculateInnerVisibleRectClip_ = isCalculateInnerClip;
253     }
254 
CleanVisibleAreaInnerCallback()255     void CleanVisibleAreaInnerCallback()
256     {
257         eventHub_->CleanVisibleAreaCallback(false);
258     }
259 
260     void TriggerVisibleAreaChangeCallback(uint64_t timestamp, bool forceDisappear = false);
261 
262     void SetOnSizeChangeCallback(OnSizeChangedFunc&& callback);
263 
264     void AddInnerOnSizeChangeCallback(int32_t id, OnSizeChangedFunc&& callback);
265 
266     void SetJSFrameNodeOnSizeChangeCallback(OnSizeChangedFunc&& callback);
267 
268     void TriggerOnSizeChangeCallback();
269 
270     void SetGeometryNode(const RefPtr<GeometryNode>& node);
271 
GetRenderContext()272     const RefPtr<RenderContext>& GetRenderContext() const
273     {
274         return renderContext_;
275     }
276 
277     const RefPtr<Pattern>& GetPattern() const;
278 
279     template<typename T>
GetPatternPtr()280     T* GetPatternPtr() const
281     {
282         return reinterpret_cast<T*>(RawPtr(pattern_));
283     }
284 
285     template<typename T>
GetPattern()286     RefPtr<T> GetPattern() const
287     {
288         return DynamicCast<T>(pattern_);
289     }
290 
291     template<typename T>
GetAccessibilityProperty()292     RefPtr<T> GetAccessibilityProperty() const
293     {
294         return DynamicCast<T>(accessibilityProperty_);
295     }
296 
297     template<typename T>
GetLayoutPropertyPtr()298     T* GetLayoutPropertyPtr() const
299     {
300         return reinterpret_cast<T*>(RawPtr(layoutProperty_));
301     }
302 
303     template<typename T>
GetLayoutProperty()304     RefPtr<T> GetLayoutProperty() const
305     {
306         return DynamicCast<T>(layoutProperty_);
307     }
308 
309     template<typename T>
GetPaintPropertyPtr()310     T* GetPaintPropertyPtr() const
311     {
312         return reinterpret_cast<T*>(RawPtr(paintProperty_));
313     }
314 
315     template<typename T>
GetPaintProperty()316     RefPtr<T> GetPaintProperty() const
317     {
318         return DynamicCast<T>(paintProperty_);
319     }
320 
321     template<typename T>
GetEventHub()322     RefPtr<T> GetEventHub() const
323     {
324         return DynamicCast<T>(eventHub_);
325     }
326 
GetOrCreateGestureEventHub()327     RefPtr<GestureEventHub> GetOrCreateGestureEventHub() const
328     {
329         return eventHub_->GetOrCreateGestureEventHub();
330     }
331 
GetOrCreateInputEventHub()332     RefPtr<InputEventHub> GetOrCreateInputEventHub() const
333     {
334         return eventHub_->GetOrCreateInputEventHub();
335     }
336 
337     RefPtr<FocusHub> GetOrCreateFocusHub() const;
338 
GetFocusHub()339     const RefPtr<FocusHub>& GetFocusHub() const
340     {
341         return eventHub_->GetFocusHub();
342     }
343 
HasVirtualNodeAccessibilityProperty()344     bool HasVirtualNodeAccessibilityProperty() override
345     {
346         if (accessibilityProperty_ && accessibilityProperty_->GetAccessibilityVirtualNodePtr()) {
347             return true;
348         }
349         return false;
350     }
351 
GetFocusType()352     FocusType GetFocusType() const
353     {
354         FocusType type = FocusType::DISABLE;
355         auto focusHub = GetFocusHub();
356         if (focusHub) {
357             type = focusHub->GetFocusType();
358         }
359         return type;
360     }
361 
362     void PostIdleTask(std::function<void(int64_t deadline, bool canUseLongPredictTask)>&& task);
363 
364     void AddJudgeToTargetComponent(RefPtr<TargetComponent>& targetComponent);
365 
366     // If return true, will prevent TouchTest Bubbling to parent and brother nodes.
367     HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
368         TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
369         bool isDispatch = false) override;
370 
371     HitTestResult MouseTest(const PointF& globalPoint, const PointF& parentLocalPoint, MouseTestResult& onMouseResult,
372         MouseTestResult& onHoverResult, RefPtr<FrameNode>& hoverNode) override;
373 
374     HitTestResult AxisTest(const PointF &globalPoint, const PointF &parentLocalPoint, const PointF &parentRevertPoint,
375         TouchRestrict &touchRestrict, AxisTestResult &axisResult) override;
376 
377     void CollectSelfAxisResult(const PointF& globalPoint, const PointF& localPoint, bool& consumed,
378         const PointF& parentRevertPoint, AxisTestResult& axisResult, bool& preventBubbling, HitTestResult& testResult,
379         TouchRestrict& touchRestrict);
380 
381     void AnimateHoverEffect(bool isHovered) const;
382 
383     bool IsAtomicNode() const override;
384 
385     void MarkNeedSyncRenderTree(bool needRebuild = false) override;
386 
387     void RebuildRenderContextTree() override;
388 
389     bool IsContextTransparent() override;
390 
IsVisible()391     bool IsVisible() const
392     {
393         return layoutProperty_->GetVisibility().value_or(VisibleType::VISIBLE) == VisibleType::VISIBLE;
394     }
395 
IsPrivacySensitive()396     bool IsPrivacySensitive() const
397     {
398         return isPrivacySensitive_;
399     }
400 
SetPrivacySensitive(bool flag)401     void SetPrivacySensitive(bool flag)
402     {
403         isPrivacySensitive_ = flag;
404     }
405 
406     void ChangeSensitiveStyle(bool isSensitive);
407 
408     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
409 
410     void FromJson(const std::unique_ptr<JsonValue>& json) override;
411 
412     RefPtr<FrameNode> GetAncestorNodeOfFrame(bool checkBoundary = false) const;
413 
GetNodeName()414     std::string& GetNodeName()
415     {
416         return nodeName_;
417     }
418 
SetNodeName(std::string & nodeName)419     void SetNodeName(std::string& nodeName)
420     {
421         nodeName_ = nodeName;
422     }
423 
424     void OnWindowShow() override;
425 
426     void OnWindowHide() override;
427 
428     void OnWindowFocused() override;
429 
430     void OnWindowUnfocused() override;
431 
432     void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override;
433 
434     void OnNotifyMemoryLevel(int32_t level) override;
435 
436     // call by recycle framework.
437     void OnRecycle() override;
438     void OnReuse() override;
439 
440     OffsetF GetOffsetRelativeToWindow() const;
441 
442     OffsetF GetPositionToScreen();
443 
444     OffsetF GetPositionToParentWithTransform() const;
445 
446     OffsetF GetPositionToScreenWithTransform();
447 
448     OffsetF GetPositionToWindowWithTransform(bool fromBottom = false) const;
449 
450     OffsetF GetTransformRelativeOffset() const;
451 
452     RectF GetTransformRectRelativeToWindow() const;
453 
454     OffsetF GetPaintRectOffset(bool excludeSelf = false) const;
455 
456     OffsetF GetPaintRectOffsetNG(bool excludeSelf = false) const;
457 
458     bool GetRectPointToParentWithTransform(std::vector<Point>& pointList, const RefPtr<FrameNode>& parent) const;
459 
460     RectF GetPaintRectToWindowWithTransform();
461 
462     OffsetF GetPaintRectCenter(bool checkWindowBoundary = true) const;
463 
464     std::pair<OffsetF, bool> GetPaintRectGlobalOffsetWithTranslate(bool excludeSelf = false) const;
465 
466     OffsetF GetPaintRectOffsetToPage() const;
467 
468     RectF GetPaintRectWithTransform() const;
469 
470     VectorF GetTransformScale() const;
471 
472     void AdjustGridOffset();
473 
IsInternal()474     bool IsInternal() const
475     {
476         return isInternal_;
477     }
478 
SetInternal()479     void SetInternal()
480     {
481         isInternal_ = true;
482     }
483 
484     int32_t GetAllDepthChildrenCount();
485 
486     void OnAccessibilityEvent(
487         AccessibilityEventType eventType, WindowsContentChangeTypes windowsContentChangeType =
488                                               WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_INVALID) const;
489 
490     void OnAccessibilityEventForVirtualNode(AccessibilityEventType eventType, int64_t accessibilityId);
491 
492     void OnAccessibilityEvent(
493         AccessibilityEventType eventType, std::string beforeText, std::string latestContent);
494 
495     void OnAccessibilityEvent(
496         AccessibilityEventType eventType, int64_t stackNodeId, WindowsContentChangeTypes windowsContentChangeType);
497 
498     void OnAccessibilityEvent(
499         AccessibilityEventType eventType, std::string textAnnouncedForAccessibility);
500     void MarkNeedRenderOnly();
501 
502     void OnDetachFromMainTree(bool recursive, PipelineContext* context) override;
503     void OnAttachToMainTree(bool recursive) override;
504     void OnAttachToBuilderNode(NodeStatus nodeStatus) override;
505     bool RenderCustomChild(int64_t deadline) override;
506     void TryVisibleChangeOnDescendant(VisibleType preVisibility, VisibleType currentVisibility) override;
507     void NotifyVisibleChange(VisibleType preVisibility, VisibleType currentVisibility);
PushDestroyCallback(std::function<void ()> && callback)508     void PushDestroyCallback(std::function<void()>&& callback)
509     {
510         destroyCallbacks_.emplace_back(callback);
511     }
512 
PushDestroyCallbackWithTag(std::function<void ()> && callback,std::string tag)513     void PushDestroyCallbackWithTag(std::function<void()>&& callback, std::string tag)
514     {
515         destroyCallbacksMap_[tag] = callback;
516     }
517 
GetDestroyCallback()518     std::list<std::function<void()>> GetDestroyCallback() const
519     {
520         return destroyCallbacks_;
521     }
522 
SetColorModeUpdateCallback(const std::function<void ()> && callback)523     void SetColorModeUpdateCallback(const std::function<void()>&& callback)
524     {
525         colorModeUpdateCallback_ = callback;
526     }
527 
SetNDKColorModeUpdateCallback(const std::function<void (int32_t)> && callback)528     void SetNDKColorModeUpdateCallback(const std::function<void(int32_t)>&& callback)
529     {
530         ndkColorModeUpdateCallback_ = callback;
531         colorMode_ = SystemProperties::GetColorMode();
532     }
533 
SetNDKFontUpdateCallback(const std::function<void (float,float)> && callback)534     void SetNDKFontUpdateCallback(const std::function<void(float, float)>&& callback)
535     {
536         ndkFontUpdateCallback_ = callback;
537     }
538 
539     bool MarkRemoving() override;
540 
541     void AddHotZoneRect(const DimensionRect& hotZoneRect) const;
542     void RemoveLastHotZoneRect() const;
543 
544     virtual bool IsOutOfTouchTestRegion(const PointF& parentLocalPoint, const TouchEvent& touchEvent);
545 
IsLayoutDirtyMarked()546     bool IsLayoutDirtyMarked() const
547     {
548         return isLayoutDirtyMarked_;
549     }
550 
SetLayoutDirtyMarked(bool marked)551     void SetLayoutDirtyMarked(bool marked)
552     {
553         isLayoutDirtyMarked_ = marked;
554     }
555 
HasPositionProp()556     bool HasPositionProp() const
557     {
558         CHECK_NULL_RETURN(renderContext_, false);
559         return renderContext_->HasPosition() || renderContext_->HasOffset() || renderContext_->HasPositionEdges() ||
560                renderContext_->HasOffsetEdges() || renderContext_->HasAnchor();
561     }
562 
563     // The function is only used for fast preview.
FastPreviewUpdateChildDone()564     void FastPreviewUpdateChildDone() override
565     {
566         OnMountToParentDone();
567     }
568 
IsExclusiveEventForChild()569     bool IsExclusiveEventForChild() const
570     {
571         return exclusiveEventForChild_;
572     }
573 
SetExclusiveEventForChild(bool exclusiveEventForChild)574     void SetExclusiveEventForChild(bool exclusiveEventForChild)
575     {
576         exclusiveEventForChild_ = exclusiveEventForChild;
577     }
578 
SetDraggable(bool draggable)579     void SetDraggable(bool draggable)
580     {
581         draggable_ = draggable;
582         userSet_ = true;
583         customerSet_ = false;
584     }
585 
SetCustomerDraggable(bool draggable)586     void SetCustomerDraggable(bool draggable)
587     {
588         draggable_ = draggable;
589         userSet_ = true;
590         customerSet_ = true;
591     }
592 
SetDragPreviewOptions(const DragPreviewOption & previewOption)593     void SetDragPreviewOptions(const DragPreviewOption& previewOption)
594     {
595         previewOption_ = previewOption;
596         previewOption_.onApply = std::move(previewOption.onApply);
597     }
598 
SetOptionsAfterApplied(const OptionsAfterApplied & optionsAfterApplied)599     void SetOptionsAfterApplied(const OptionsAfterApplied& optionsAfterApplied)
600     {
601         previewOption_.options = optionsAfterApplied;
602     }
603 
GetDragPreviewOption()604     DragPreviewOption GetDragPreviewOption() const
605     {
606         return previewOption_;
607     }
608 
SetBackgroundFunction(std::function<RefPtr<UINode> ()> && buildFunc)609     void SetBackgroundFunction(std::function<RefPtr<UINode>()>&& buildFunc)
610     {
611         builderFunc_ = std::move(buildFunc);
612         backgroundNode_ = nullptr;
613     }
614 
IsDraggable()615     bool IsDraggable() const
616     {
617         return draggable_;
618     }
619 
IsLayoutComplete()620     bool IsLayoutComplete() const
621     {
622         return isLayoutComplete_;
623     }
624 
IsUserSet()625     bool IsUserSet() const
626     {
627         return userSet_;
628     }
629 
IsCustomerSet()630     bool IsCustomerSet() const
631     {
632         return customerSet_;
633     }
634 
SetAllowDrop(const std::set<std::string> & allowDrop)635     void SetAllowDrop(const std::set<std::string>& allowDrop)
636     {
637         allowDrop_ = allowDrop;
638     }
639 
GetAllowDrop()640     const std::set<std::string>& GetAllowDrop() const
641     {
642         return allowDrop_;
643     }
644 
SetDrawModifier(const RefPtr<NG::DrawModifier> & drawModifier)645     void SetDrawModifier(const RefPtr<NG::DrawModifier>& drawModifier)
646     {
647         if (!extensionHandler_) {
648             extensionHandler_ = MakeRefPtr<ExtensionHandler>();
649             extensionHandler_->AttachFrameNode(this);
650         }
651         extensionHandler_->SetDrawModifier(drawModifier);
652     }
653 
654     bool IsSupportDrawModifier();
655 
SetDragPreview(const NG::DragDropInfo & info)656     void SetDragPreview(const NG::DragDropInfo& info)
657     {
658         dragPreviewInfo_ = info;
659     }
660 
GetDragPreview()661     const DragDropInfo& GetDragPreview() const
662     {
663         return dragPreviewInfo_;
664     }
665 
SetOverlayNode(const RefPtr<FrameNode> & overlayNode)666     void SetOverlayNode(const RefPtr<FrameNode>& overlayNode)
667     {
668         overlayNode_ = overlayNode;
669     }
670 
GetOverlayNode()671     RefPtr<FrameNode> GetOverlayNode() const
672     {
673         return overlayNode_;
674     }
675 
676     RefPtr<FrameNode> FindChildByPosition(float x, float y);
677     // some developer use translate to make Grid drag animation, using old function can't find accurate child.
678     // new function will ignore child's position and translate properties.
679     RefPtr<FrameNode> FindChildByPositionWithoutChildTransform(float x, float y);
680 
681     RefPtr<NodeAnimatablePropertyBase> GetAnimatablePropertyFloat(const std::string& propertyName) const;
682     static RefPtr<FrameNode> FindChildByName(const RefPtr<FrameNode>& parentNode, const std::string& nodeName);
683     void CreateAnimatablePropertyFloat(const std::string& propertyName, float value,
684         const std::function<void(float)>& onCallbackEvent, const PropertyUnit& propertyType = PropertyUnit::UNKNOWN);
685     void DeleteAnimatablePropertyFloat(const std::string& propertyName);
686     void UpdateAnimatablePropertyFloat(const std::string& propertyName, float value);
687     void CreateAnimatableArithmeticProperty(const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value,
688         std::function<void(const RefPtr<CustomAnimatableArithmetic>&)>& onCallbackEvent);
689     void UpdateAnimatableArithmeticProperty(const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value);
690 
691     void SetHitTestMode(HitTestMode mode);
692     HitTestMode GetHitTestMode() const override;
693 
694     TouchResult GetOnChildTouchTestRet(const std::vector<TouchTestInfo>& touchInfo);
695     OnChildTouchTestFunc GetOnTouchTestFunc();
696     void CollectTouchInfos(
697         const PointF& globalPoint, const PointF& parentRevertPoint, std::vector<TouchTestInfo>& touchInfos);
698     RefPtr<FrameNode> GetDispatchFrameNode(const TouchResult& touchRes);
699 
700     std::string ProvideRestoreInfo();
701 
702     static std::vector<RefPtr<FrameNode>> GetNodesById(const std::unordered_set<int32_t>& set);
703     static std::vector<FrameNode*> GetNodesPtrById(const std::unordered_set<int32_t>& set);
704 
705     double GetPreviewScaleVal() const;
706 
707     bool IsPreviewNeedScale() const;
708 
SetViewPort(RectF viewPort)709     void SetViewPort(RectF viewPort)
710     {
711         viewPort_ = viewPort;
712     }
713 
GetSelfViewPort()714     std::optional<RectF> GetSelfViewPort() const
715     {
716         return viewPort_;
717     }
718 
719     std::optional<RectF> GetViewPort() const;
720 
721     // Frame Rate Controller(FRC) decides FrameRateRange by scene, speed and scene status
722     // speed is measured by millimeter/second
723     void AddFRCSceneInfo(const std::string& scene, float speed, SceneStatus status);
724 
725     OffsetF GetParentGlobalOffsetDuringLayout() const;
OnSetCacheCount(int32_t cacheCount,const std::optional<LayoutConstraintF> & itemConstraint)726     void OnSetCacheCount(int32_t cacheCount, const std::optional<LayoutConstraintF>& itemConstraint) override {};
727 
728     // layoutwrapper function override
729     const RefPtr<LayoutAlgorithmWrapper>& GetLayoutAlgorithm(bool needReset = false) override;
730 
731     void Measure(const std::optional<LayoutConstraintF>& parentConstraint) override;
732 
733     // Called to perform layout children.
734     void Layout() override;
735 
GetTotalChildCount()736     int32_t GetTotalChildCount() const override
737     {
738         return UINode::TotalChildCount();
739     }
740 
GetTotalChildCountWithoutExpanded()741     int32_t GetTotalChildCountWithoutExpanded() const
742     {
743         return UINode::CurrentFrameCount();
744     }
745 
GetGeometryNode()746     const RefPtr<GeometryNode>& GetGeometryNode() const override
747     {
748         return geometryNode_;
749     }
750 
SetLayoutProperty(const RefPtr<LayoutProperty> & layoutProperty)751     void SetLayoutProperty(const RefPtr<LayoutProperty>& layoutProperty)
752     {
753         layoutProperty_ = layoutProperty;
754         layoutProperty_->SetHost(WeakClaim(this));
755     }
756 
GetLayoutProperty()757     const RefPtr<LayoutProperty>& GetLayoutProperty() const override
758     {
759         return layoutProperty_;
760     }
761 
762     RefPtr<LayoutWrapper> GetOrCreateChildByIndex(
763         uint32_t index, bool addToRenderTree = true, bool isCache = false) override;
764     RefPtr<LayoutWrapper> GetChildByIndex(uint32_t index, bool isCache = false) override;
765 
766     FrameNode* GetFrameNodeChildByIndex(uint32_t index, bool isCache = false, bool isExpand = true);
767     /**
768      * @brief Get the index of Child among all FrameNode children of [this].
769      * Handles intermediate SyntaxNodes like LazyForEach.
770      *
771      * @param child pointer to the Child FrameNode.
772      * @return index of Child, or -1 if not found.
773      */
774     int32_t GetChildTrueIndex(const RefPtr<LayoutWrapper>& child) const;
775     uint32_t GetChildTrueTotalCount() const;
776     ChildrenListWithGuard GetAllChildrenWithBuild(bool addToRenderTree = true) override;
777     void RemoveChildInRenderTree(uint32_t index) override;
778     void RemoveAllChildInRenderTree() override;
779     void DoRemoveChildInRenderTree(uint32_t index, bool isAll) override;
780     void SetActiveChildRange(
781         int32_t start, int32_t end, int32_t cacheStart = 0, int32_t cacheEnd = 0, bool showCached = false) override;
782     void SetActiveChildRange(const std::optional<ActiveChildSets>& activeChildSets,
783         const std::optional<ActiveChildRange>& activeChildRange = std::nullopt) override;
784     void DoSetActiveChildRange(
785         int32_t start, int32_t end, int32_t cacheStart, int32_t cacheEnd, bool showCache = false) override;
786     void RecycleItemsByIndex(int32_t start, int32_t end) override;
GetHostTag()787     const std::string& GetHostTag() const override
788     {
789         return GetTag();
790     }
791 
792     void UpdateFocusState();
793     bool SelfOrParentExpansive();
794     bool SelfExpansive();
795     bool SelfExpansiveToKeyboard();
796     bool ParentExpansive();
797 
IsActive()798     bool IsActive() const override
799     {
800         return isActive_;
801     }
802 
803     void SetActive(bool active = true, bool needRebuildRenderContext = false) override;
804 
GetAccessibilityVisible()805     bool GetAccessibilityVisible() const
806     {
807         return accessibilityVisible_;
808     }
809 
SetAccessibilityVisible(const bool accessibilityVisible)810     void SetAccessibilityVisible(const bool accessibilityVisible)
811     {
812         accessibilityVisible_ = accessibilityVisible;
813     }
814 
IsOutOfLayout()815     bool IsOutOfLayout() const override
816     {
817         return renderContext_->HasPosition() || renderContext_->HasPositionEdges();
818     }
819     void ProcessSafeAreaPadding();
820 
821     bool SkipMeasureContent() const override;
822     float GetBaselineDistance() const override;
823     void SetCacheCount(
824         int32_t cacheCount = 0, const std::optional<LayoutConstraintF>& itemConstraint = std::nullopt) override;
825 
826     void SyncGeometryNode(bool needSyncRsNode, const DirtySwapConfig& config);
827     RefPtr<UINode> GetFrameChildByIndex(
828         uint32_t index, bool needBuild, bool isCache = false, bool addToRenderTree = false) override;
829     RefPtr<UINode> GetFrameChildByIndexWithoutExpanded(uint32_t index) override;
830     bool CheckNeedForceMeasureAndLayout() override;
831 
832     bool SetParentLayoutConstraint(const SizeF& size) const override;
833     void ForceSyncGeometryNode();
834 
835     template<typename T>
FindFocusChildNodeOfClass()836     RefPtr<T> FindFocusChildNodeOfClass()
837     {
838         const auto& children = GetChildren();
839         for (auto iter = children.rbegin(); iter != children.rend(); ++iter) {
840             auto& child = *iter;
841             auto target = DynamicCast<FrameNode>(child->FindChildNodeOfClass<T>());
842             if (target) {
843                 auto focusEvent = target->eventHub_->GetFocusHub();
844                 if (focusEvent && focusEvent->IsCurrentFocus()) {
845                     return AceType::DynamicCast<T>(target);
846                 }
847             }
848         }
849 
850         if (AceType::InstanceOf<T>(this)) {
851             auto target = DynamicCast<FrameNode>(this);
852             if (target) {
853                 auto focusEvent = target->eventHub_->GetFocusHub();
854                 if (focusEvent && focusEvent->IsCurrentFocus()) {
855                     return Claim(AceType::DynamicCast<T>(this));
856                 }
857             }
858         }
859         return nullptr;
860     }
861 
862     virtual std::vector<RectF> GetResponseRegionList(const RectF& rect, int32_t sourceType);
863     bool InResponseRegionList(const PointF& parentLocalPoint, const std::vector<RectF>& responseRegionList) const;
864 
IsFirstBuilding()865     bool IsFirstBuilding() const
866     {
867         return isFirstBuilding_;
868     }
869 
MarkBuildDone()870     void MarkBuildDone()
871     {
872         isFirstBuilding_ = false;
873     }
874 
GetLocalMatrix()875     Matrix4 GetLocalMatrix() const
876     {
877         return localMat_;
878     }
879     OffsetF GetOffsetInScreen();
880     OffsetF GetOffsetInSubwindow(const OffsetF& subwindowOffset);
881     RefPtr<PixelMap> GetPixelMap();
882     RefPtr<FrameNode> GetPageNode();
883     RefPtr<FrameNode> GetFirstAutoFillContainerNode();
884     RefPtr<FrameNode> GetNodeContainer();
885     RefPtr<ContentModifier> GetContentModifier();
886 
GetExtensionHandler()887     ExtensionHandler* GetExtensionHandler() const
888     {
889         return RawPtr(extensionHandler_);
890     }
891 
SetExtensionHandler(const RefPtr<ExtensionHandler> & handler)892     void SetExtensionHandler(const RefPtr<ExtensionHandler>& handler)
893     {
894         extensionHandler_ = handler;
895         if (extensionHandler_) {
896             extensionHandler_->AttachFrameNode(this);
897         }
898     }
899 
900     void NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap,
901         RefPtr<PageNodeInfoWrap> nodeWrap, AceAutoFillType autoFillType);
902     void NotifyFillRequestFailed(int32_t errCode, const std::string& fillContent = "", bool isPopup = false);
903 
904     int32_t GetUiExtensionId();
905     int64_t WrapExtensionAbilityId(int64_t extensionOffset, int64_t abilityId);
906     void SearchExtensionElementInfoByAccessibilityIdNG(
907         int64_t elementId, int32_t mode, int64_t offset, std::list<Accessibility::AccessibilityElementInfo>& output);
908     void SearchElementInfosByTextNG(int64_t elementId, const std::string& text, int64_t offset,
909         std::list<Accessibility::AccessibilityElementInfo>& output);
910     void FindFocusedExtensionElementInfoNG(
911         int64_t elementId, int32_t focusType, int64_t offset, Accessibility::AccessibilityElementInfo& output);
912     void FocusMoveSearchNG(
913         int64_t elementId, int32_t direction, int64_t offset, Accessibility::AccessibilityElementInfo& output);
914     bool TransferExecuteAction(
915         int64_t elementId, const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t offset);
916 
917     bool GetMonopolizeEvents() const;
918 
919     std::vector<RectF> GetResponseRegionListForRecognizer(int32_t sourceType);
920 
921     std::vector<RectF> GetResponseRegionListForTouch(const RectF& rect);
922 
923     void GetResponseRegionListByTraversal(std::vector<RectF>& responseRegionList);
924 
IsWindowBoundary()925     bool IsWindowBoundary() const
926     {
927         return isWindowBoundary_;
928     }
929 
930     void SetWindowBoundary(bool isWindowBoundary = true)
931     {
932         isWindowBoundary_ = isWindowBoundary;
933     }
934 
SetIsMeasureBoundary(bool isMeasureBoundary)935     void SetIsMeasureBoundary(bool isMeasureBoundary)
936     {
937         isMeasureBoundary_ = isMeasureBoundary;
938     }
939 
940     void InitLastArea();
941 
942     OffsetF CalculateCachedTransformRelativeOffset(uint64_t nanoTimestamp);
943 
944     RectF GetRectWithRender();
945     RectF GetRectWithFrame();
946 
947     void PaintDebugBoundary(bool flag) override;
948     static std::pair<float, float> ContextPositionConvertToPX(
949         const RefPtr<RenderContext>& context, const SizeF& percentReference);
950 
951     void AttachContext(PipelineContext* context, bool recursive = false) override;
952     void DetachContext(bool recursive = false) override;
953     bool CheckAncestorPageShow();
SetRemoveCustomProperties(std::function<void ()> func)954     void SetRemoveCustomProperties(std::function<void()> func)
955     {
956         if (!removeCustomProperties_) {
957             removeCustomProperties_ = func;
958         }
959     }
960 
961     void SetExposureProcessor(const RefPtr<Recorder::ExposureProcessor>& processor);
962 
963     void GetVisibleRect(RectF& visibleRect, RectF& frameRect) const;
964     void GetVisibleRectWithClip(RectF& visibleRect, RectF& visibleInnerRect, RectF& frameRect,
965                                 bool withClip = false) const;
966 
GetIsGeometryTransitionIn()967     bool GetIsGeometryTransitionIn() const
968     {
969         return isGeometryTransitionIn_;
970     }
971 
SetIsGeometryTransitionIn(bool isGeometryTransitionIn)972     void SetIsGeometryTransitionIn(bool isGeometryTransitionIn)
973     {
974         isGeometryTransitionIn_ = isGeometryTransitionIn;
975     }
976 
SetGeometryTransitionInRecursive(bool isGeometryTransitionIn)977     void SetGeometryTransitionInRecursive(bool isGeometryTransitionIn) override
978     {
979         SetIsGeometryTransitionIn(isGeometryTransitionIn);
980         UINode::SetGeometryTransitionInRecursive(isGeometryTransitionIn);
981     }
982 
AddPredictLayoutNode(const RefPtr<FrameNode> & node)983     void AddPredictLayoutNode(const RefPtr<FrameNode>& node)
984     {
985         predictLayoutNode_.emplace_back(node);
986     }
987 
CheckAccessibilityLevelNo()988     bool CheckAccessibilityLevelNo() const {
989         return false;
990     }
991 
992     void UpdateAccessibilityNodeRect();
993 
GetVirtualNodeTransformRectRelativeToWindow()994     RectF GetVirtualNodeTransformRectRelativeToWindow()
995     {
996         auto parentUinode = GetVirtualNodeParent().Upgrade();
997         CHECK_NULL_RETURN(parentUinode, RectF {});
998         auto parentFrame = AceType::DynamicCast<FrameNode>(parentUinode);
999         CHECK_NULL_RETURN(parentFrame, RectF {});
1000         auto parentRect = parentFrame->GetTransformRectRelativeToWindow();
1001         auto currentRect = GetTransformRectRelativeToWindow();
1002         currentRect.SetTop(currentRect.Top() + parentRect.Top());
1003         currentRect.SetLeft(currentRect.Left() + parentRect.Left());
1004         return currentRect;
1005     }
1006 
HasAccessibilityVirtualNode(bool hasAccessibilityVirtualNode)1007     void HasAccessibilityVirtualNode(bool hasAccessibilityVirtualNode)
1008     {
1009         hasAccessibilityVirtualNode_ = hasAccessibilityVirtualNode;
1010     }
1011 
SetIsUseTransitionAnimator(bool isUseTransitionAnimator)1012     void SetIsUseTransitionAnimator(bool isUseTransitionAnimator)
1013     {
1014         isUseTransitionAnimator_ = isUseTransitionAnimator;
1015     }
1016 
GetIsUseTransitionAnimator()1017     bool GetIsUseTransitionAnimator()
1018     {
1019         return isUseTransitionAnimator_;
1020     }
1021 
1022     void ProcessAccessibilityVirtualNode();
1023     void SetSuggestOpIncMarked(bool flag);
1024     bool GetSuggestOpIncMarked();
1025     void SetCanSuggestOpInc(bool flag);
1026     bool GetCanSuggestOpInc();
1027     void SetApplicationRenderGroupMarked(bool flag);
1028     bool GetApplicationRenderGroupMarked();
1029     void SetSuggestOpIncActivatedOnce();
1030     bool GetSuggestOpIncActivatedOnce();
1031     bool MarkSuggestOpIncGroup(bool suggest, bool calc);
1032     void SetOpIncGroupCheckedThrough(bool flag);
1033     bool GetOpIncGroupCheckedThrough();
1034     void SetOpIncCheckedOnce();
1035     bool GetOpIncCheckedOnce();
1036     void MarkAndCheckNewOpIncNode();
1037     ChildrenListWithGuard GetAllChildren();
1038     OPINC_TYPE_E FindSuggestOpIncNode(std::string& path, const SizeF& boundary, int32_t depth);
1039     // Notified by render context when any transform attributes updated,
1040     // this flag will be used to refresh the transform matrix cache if it's dirty
NotifyTransformInfoChanged()1041     void NotifyTransformInfoChanged()
1042     {
1043         isLocalRevertMatrixAvailable_ = false;
1044     }
1045 
1046     // this method will check the cache state and return the cached revert matrix preferentially,
1047     // but the caller can pass in true to forcible refresh the cache
1048     Matrix4& GetOrRefreshRevertMatrixFromCache(bool forceRefresh = false);
1049 
1050     // apply the matrix to the given point specified by dst
1051     static void MapPointTo(PointF& dst, Matrix4& matrix);
1052 
GetChangeInfoFlag()1053     FrameNodeChangeInfoFlag GetChangeInfoFlag()
1054     {
1055         return changeInfoFlag_;
1056     }
1057 
1058     void ClearSubtreeLayoutAlgorithm(bool includeSelf = true, bool clearEntireTree = false) override;
1059 
ClearChangeInfoFlag()1060     void ClearChangeInfoFlag()
1061     {
1062         changeInfoFlag_ = FRAME_NODE_CHANGE_INFO_NONE;
1063     }
1064 
1065     void OnSyncGeometryFrameFinish(const RectF& paintRect);
1066     void AddFrameNodeChangeInfoFlag(FrameNodeChangeInfoFlag changeFlag = FRAME_NODE_CHANGE_INFO_NONE);
1067     void RegisterNodeChangeListener();
1068     void UnregisterNodeChangeListener();
1069     void ProcessFrameNodeChangeFlag();
1070     void OnNodeTransformInfoUpdate(bool changed);
1071     void OnNodeTransitionInfoUpdate();
1072     uint32_t GetWindowPatternType() const;
1073 
ResetLayoutAlgorithm()1074     void ResetLayoutAlgorithm()
1075     {
1076         layoutAlgorithm_.Reset();
1077     }
1078 
HasLayoutAlgorithm()1079     bool HasLayoutAlgorithm()
1080     {
1081         return layoutAlgorithm_ != nullptr;
1082     }
1083 
GetDragHitTestBlock()1084     bool GetDragHitTestBlock() const
1085     {
1086         return dragHitTestBlock_;
1087     }
1088 
SetDragHitTestBlock(bool dragHitTestBlock)1089     void SetDragHitTestBlock(bool dragHitTestBlock)
1090     {
1091         dragHitTestBlock_ = dragHitTestBlock;
1092     }
1093     void GetInspectorValue() override;
1094     void NotifyWebPattern(bool isRegister) override;
1095 
1096     void NotifyChange(int32_t changeIdx, int32_t count, int64_t id, NotificationType notificationType) override;
1097 
1098     void ChildrenUpdatedFrom(int32_t index);
GetChildrenUpdated()1099     int32_t GetChildrenUpdated() const
1100     {
1101         return childrenUpdatedFrom_;
1102     }
1103 
1104     void SetJSCustomProperty(std::function<bool()> func, std::function<std::string(const std::string&)> getFunc);
1105     bool GetJSCustomProperty(const std::string& key, std::string& value);
1106     bool GetCapiCustomProperty(const std::string& key, std::string& value);
1107 
1108     void AddCustomProperty(const std::string& key, const std::string& value) override;
1109     void RemoveCustomProperty(const std::string& key) override;
1110 
1111     LayoutConstraintF GetLayoutConstraint() const;
1112 
GetTargetComponent()1113     WeakPtr<TargetComponent> GetTargetComponent() const
1114     {
1115         return targetComponent_;
1116     }
1117 
SetExposeInnerGestureFlag(bool exposeInnerGestureFlag)1118     void SetExposeInnerGestureFlag(bool exposeInnerGestureFlag)
1119     {
1120         exposeInnerGestureFlag_ = exposeInnerGestureFlag;
1121     }
1122 
GetExposeInnerGestureFlag()1123     bool GetExposeInnerGestureFlag() const
1124     {
1125         return exposeInnerGestureFlag_;
1126     }
1127 
1128     RefPtr<UINode> GetCurrentPageRootNode() override;
1129 
1130     std::list<RefPtr<FrameNode>> GetActiveChildren();
1131 
SetVisibleAreaChangeTriggerReason(VisibleAreaChangeTriggerReason triggerReason)1132     void SetVisibleAreaChangeTriggerReason(VisibleAreaChangeTriggerReason triggerReason)
1133     {
1134         if (visibleAreaChangeTriggerReason_ != triggerReason) {
1135             visibleAreaChangeTriggerReason_ = triggerReason;
1136         }
1137     }
1138 
1139     void SetFrameNodeDestructorCallback(const std::function<void(int32_t)>&& callback);
1140     void FireFrameNodeDestructorCallback();
1141 
1142 protected:
1143     void DumpInfo() override;
1144     void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override;
1145 
1146     std::list<std::function<void()>> destroyCallbacks_;
1147     std::unordered_map<std::string, std::function<void()>> destroyCallbacksMap_;
1148 
1149 private:
1150     void MarkDirtyNode(
1151         bool isMeasureBoundary, bool isRenderBoundary, PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL);
1152     OPINC_TYPE_E IsOpIncValidNode(const SizeF& boundary, int32_t childNumber = 0);
1153     static int GetValidLeafChildNumber(const RefPtr<FrameNode>& host, int32_t thresh);
1154     void MarkNeedRender(bool isRenderBoundary);
1155     bool IsNeedRequestParentMeasure() const;
1156     void UpdateLayoutPropertyFlag() override;
1157     void ForceUpdateLayoutPropertyFlag(PropertyChangeFlag propertyChangeFlag) override;
1158     void AdjustParentLayoutFlag(PropertyChangeFlag& flag) override;
1159     /**
1160      * @brief try to mark Parent dirty with flag PROPERTY_UPDATE_BY_CHILD_REQUEST.
1161      *
1162      * @return true if Parent is successfully marked dirty.
1163      */
1164     virtual bool RequestParentDirty();
1165 
1166     void UpdateChildrenLayoutWrapper(const RefPtr<LayoutWrapperNode>& self, bool forceMeasure, bool forceLayout);
1167     void AdjustLayoutWrapperTree(const RefPtr<LayoutWrapperNode>& parent, bool forceMeasure, bool forceLayout) override;
1168 
1169     OffsetF GetParentGlobalOffset() const;
1170 
1171     RefPtr<PaintWrapper> CreatePaintWrapper();
1172     void LayoutOverlay();
1173 
1174     void OnGenerateOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& visibleList) override;
1175     void OnGenerateOneDepthVisibleFrameWithTransition(std::list<RefPtr<FrameNode>>& visibleList) override;
1176     void OnGenerateOneDepthVisibleFrameWithOffset(
1177         std::list<RefPtr<FrameNode>>& visibleList, OffsetF& offset) override;
1178     void OnGenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>>& allList) override;
1179 
1180     bool IsMeasureBoundary();
1181     bool IsRenderBoundary();
1182 
1183     bool OnRemoveFromParent(bool allowTransition) override;
1184     bool RemoveImmediately() const override;
1185 
1186     bool IsPaintRectWithTransformValid();
1187 
1188     // dump self info.
1189     void DumpDragInfo();
1190     void DumpOverlayInfo();
1191     void DumpCommonInfo();
1192     void DumpSimplifyCommonInfo(std::unique_ptr<JsonValue>& json);
1193     void DumpSimplifySafeAreaInfo(std::unique_ptr<JsonValue>& json);
1194     void DumpSimplifyOverlayInfo(std::unique_ptr<JsonValue>& json);
1195     void DumpBorder(const std::unique_ptr<NG::BorderWidthProperty>& border, std::string label,
1196         std::unique_ptr<JsonValue>& json);
1197     void DumpPadding(const std::unique_ptr<NG::PaddingProperty>& border, std::string label,
1198         std::unique_ptr<JsonValue>& json);
1199     void DumpSafeAreaInfo();
1200     void DumpAlignRulesInfo();
1201     void DumpExtensionHandlerInfo();
1202     void DumpAdvanceInfo() override;
1203     void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) override;
1204     void DumpOnSizeChangeInfo();
1205     bool CheckAutoSave() override;
1206     void MouseToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const;
1207     void TouchToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const;
1208     void GeometryNodeToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const;
1209 
1210     bool GetTouchable() const;
1211     bool OnLayoutFinish(bool& needSyncRsNode, DirtySwapConfig& config);
1212 
1213     void ProcessVisibleAreaChangeEvent(const RectF& visibleRect, const RectF& frameRect,
1214         const std::vector<double>& visibleAreaRatios, VisibleCallbackInfo& visibleAreaCallback, bool isUser);
1215     void ProcessAllVisibleCallback(const std::vector<double>& visibleAreaUserRatios,
1216         VisibleCallbackInfo& visibleAreaUserCallback, double currentVisibleRatio,
1217         double lastVisibleRatio, bool isThrottled = false, bool isInner = false);
1218     void ProcessThrottledVisibleCallback();
1219     bool IsFrameDisappear() const;
1220     bool IsFrameDisappear(uint64_t timestamp);
1221     bool IsFrameAncestorDisappear(uint64_t timestamp);
1222     void ThrottledVisibleTask();
1223 
1224     void OnPixelRoundFinish(const SizeF& pixelGridRoundSize);
1225 
1226     double CalculateCurrentVisibleRatio(const RectF& visibleRect, const RectF& renderRect);
1227 
1228     // set costom background layoutConstraint
1229     void SetBackgroundLayoutConstraint(const RefPtr<FrameNode>& customNode);
1230 
1231     void GetPercentSensitive();
1232     void UpdatePercentSensitive();
1233 
1234     void AddFrameNodeSnapshot(bool isHit, int32_t parentId, std::vector<RectF> responseRegionList, EventTreeType type);
1235 
1236     int32_t GetNodeExpectedRate();
1237 
1238     void RecordExposureInner();
1239 
1240     OffsetF CalculateOffsetRelativeToWindow(uint64_t nanoTimestamp);
1241 
1242     const std::pair<uint64_t, OffsetF>& GetCachedGlobalOffset() const;
1243 
1244     void SetCachedGlobalOffset(const std::pair<uint64_t, OffsetF>& timestampOffset);
1245 
1246     const std::pair<uint64_t, OffsetF>& GetCachedTransformRelativeOffset() const;
1247 
1248     void SetCachedTransformRelativeOffset(const std::pair<uint64_t, OffsetF>& timestampOffset);
1249 
1250     HitTestMode TriggerOnTouchIntercept(const TouchEvent& touchEvent);
1251 
1252     void TriggerShouldParallelInnerWith(
1253         const ResponseLinkResult& currentRecognizers, const ResponseLinkResult& responseLinkRecognizers);
1254 
1255     void TriggerRsProfilerNodeMountCallbackIfExist();
1256 
1257     void AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEvent& touchEvent);
1258 
1259     RectF ApplyFrameNodeTranformToRect(const RectF& rect, const RefPtr<FrameNode>& parent) const;
1260 
1261     CacheVisibleRectResult GetCacheVisibleRect(uint64_t timestamp);
1262 
1263     CacheVisibleRectResult CalculateCacheVisibleRect(CacheVisibleRectResult& parentCacheVisibleRect,
1264         const RefPtr<FrameNode>& parentUi, RectF& rectToParent, VectorF scale, uint64_t timestamp);
1265 
1266     void NotifyConfigurationChangeNdk(const ConfigurationChange& configurationChange);
1267 
1268     bool AllowVisibleAreaCheck() const;
1269 
1270     void ResetPredictNodes();
1271 
1272     bool ProcessMouseTestHit(const PointF& globalPoint, const PointF& localPoint,
1273     TouchRestrict& touchRestrict, TouchTestResult& newComingTargets);
1274 
1275     // sort in ZIndex.
1276     std::multiset<WeakPtr<FrameNode>, ZIndexComparator> frameChildren_;
1277     RefPtr<GeometryNode> geometryNode_ = MakeRefPtr<GeometryNode>();
1278 
1279     std::function<void()> colorModeUpdateCallback_;
1280     std::function<void(int32_t)> ndkColorModeUpdateCallback_;
1281     std::function<void(float, float)> ndkFontUpdateCallback_;
1282     RefPtr<AccessibilityProperty> accessibilityProperty_;
1283     bool hasAccessibilityVirtualNode_ = false;
1284     RefPtr<LayoutProperty> layoutProperty_;
1285     RefPtr<PaintProperty> paintProperty_;
1286     RefPtr<RenderContext> renderContext_ = RenderContext::Create();
1287     RefPtr<EventHub> eventHub_;
1288     RefPtr<Pattern> pattern_;
1289 
1290     RefPtr<ExtensionHandler> extensionHandler_;
1291 
1292     RefPtr<FrameNode> backgroundNode_;
1293     std::function<RefPtr<UINode>()> builderFunc_;
1294     std::unique_ptr<RectF> lastFrameRect_;
1295     std::unique_ptr<OffsetF> lastParentOffsetToWindow_;
1296     std::unique_ptr<RectF> lastFrameNodeRect_;
1297     std::set<std::string> allowDrop_;
1298     const static std::set<std::string> layoutTags_;
1299     std::function<void()> removeCustomProperties_;
1300     std::function<std::string(const std::string& key)> getCustomProperty_;
1301     std::optional<RectF> viewPort_;
1302     NG::DragDropInfo dragPreviewInfo_;
1303 
1304     RefPtr<LayoutAlgorithmWrapper> layoutAlgorithm_;
1305     RefPtr<GeometryNode> oldGeometryNode_;
1306     std::optional<bool> skipMeasureContent_;
1307     std::unique_ptr<FrameProxy> frameProxy_;
1308     WeakPtr<TargetComponent> targetComponent_;
1309 
1310     bool needSyncRenderTree_ = false;
1311 
1312     bool isPropertyDiffMarked_ = false;
1313     bool isLayoutDirtyMarked_ = false;
1314     bool isRenderDirtyMarked_ = false;
1315     bool isMeasureBoundary_ = false;
1316     bool hasPendingRequest_ = false;
1317     bool isPrivacySensitive_ = false;
1318 
1319     // for container, this flag controls only the last child in touch area is consuming event.
1320     bool exclusiveEventForChild_ = false;
1321     bool isActive_ = false;
1322     bool accessibilityVisible_ = true;
1323     bool isResponseRegion_ = false;
1324     bool isLayoutComplete_ = false;
1325     bool isFirstBuilding_ = true;
1326 
1327     double lastVisibleRatio_ = 0.0;
1328     double lastInnerVisibleRatio_ = 0.0;
1329     double lastVisibleCallbackRatio_ = 0.0;
1330     double lastInnerVisibleCallbackRatio_ = 0.0;
1331     double lastThrottledVisibleRatio_ = 0.0;
1332     double lastThrottledVisibleCbRatio_ = 0.0;
1333     int64_t lastThrottledTriggerTime_ = 0;
1334     bool throttledCallbackOnTheWay_ = false;
1335 
1336     // internal node such as Text in Button CreateWithLabel
1337     // should not seen by preview inspector or accessibility
1338     bool isInternal_ = false;
1339 
1340     std::string nodeName_;
1341 
1342     ColorMode colorMode_ = ColorMode::LIGHT;
1343 
1344     bool draggable_ = false;
1345     bool userSet_ = false;
1346     bool customerSet_ = false;
1347     bool isWindowBoundary_ = false;
1348     uint8_t suggestOpIncByte_ = 0;
1349     uint64_t getCacheNanoTime_ = 0;
1350     RectF prePaintRect_;
1351 
1352     std::map<std::string, RefPtr<NodeAnimatablePropertyBase>> nodeAnimatablePropertyMap_;
1353     Matrix4 localMat_ = Matrix4::CreateIdentity();
1354     // this is just used for the hit test process of event handling, do not used for other purpose
1355     Matrix4 localRevertMatrix_ = Matrix4::CreateIdentity();
1356     // control the localMat_ and localRevertMatrix_ available or not, set to false when any transform info is set
1357     bool isLocalRevertMatrixAvailable_ = false;
1358     bool isFind_ = false;
1359 
1360     bool isRestoreInfoUsed_ = false;
1361     bool checkboxFlag_ = false;
1362     bool isDisallowDropForcedly_ = false;
1363     bool isGeometryTransitionIn_ = false;
1364     bool isLayoutNode_ = false;
1365     bool isCalculateInnerVisibleRectClip_ = false;
1366     bool dragHitTestBlock_ = false;
1367 
1368     bool isUseTransitionAnimator_ = false;
1369 
1370     bool exposeInnerGestureFlag_ = false;
1371 
1372     RefPtr<FrameNode> overlayNode_;
1373 
1374     std::unordered_map<std::string, int32_t> sceneRateMap_;
1375 
1376     std::unordered_map<std::string, std::string> customPropertyMap_;
1377 
1378     RefPtr<Recorder::ExposureProcessor> exposureProcessor_;
1379 
1380     std::pair<uint64_t, OffsetF> cachedGlobalOffset_ = { 0, OffsetF() };
1381     std::pair<uint64_t, OffsetF> cachedTransformRelativeOffset_ = { 0, OffsetF() };
1382     std::pair<uint64_t, bool> cachedIsFrameDisappear_ = { 0, false };
1383     std::pair<uint64_t, CacheVisibleRectResult> cachedVisibleRectResult_ = { 0, CacheVisibleRectResult() };
1384 
1385     DragPreviewOption previewOption_ { true, false, false, false, false, false, true, { .isShowBadge = true } };
1386     struct onSizeChangeDumpInfo {
1387         int64_t onSizeChangeTimeStamp;
1388         RectF lastFrameRect;
1389         RectF currFrameRect;
1390     };
1391     std::vector<onSizeChangeDumpInfo> onSizeChangeDumpInfos;
1392     std::list<WeakPtr<FrameNode>> predictLayoutNode_;
1393     FrameNodeChangeInfoFlag changeInfoFlag_ = FRAME_NODE_CHANGE_INFO_NONE;
1394     std::optional<RectF> syncedFramePaintRect_;
1395 
1396     int32_t childrenUpdatedFrom_ = -1;
1397     VisibleAreaChangeTriggerReason visibleAreaChangeTriggerReason_ = VisibleAreaChangeTriggerReason::IDLE;
1398     std::function<void(int32_t)> frameNodeDestructorCallback_;
1399 
1400     friend class RosenRenderContext;
1401     friend class RenderContext;
1402     friend class Pattern;
1403 
1404     ACE_DISALLOW_COPY_AND_MOVE(FrameNode);
1405 };
1406 } // namespace OHOS::Ace::NG
1407 
1408 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H
1409