• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_UI_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_UI_NODE_H
18 
19 #include <cstdint>
20 #include <list>
21 #include <memory>
22 #include <string>
23 #include <unordered_map>
24 
25 #include "base/geometry/ng/point_t.h"
26 #include "base/geometry/ng/size_t.h"
27 #include "base/log/ace_performance_check.h"
28 #include "base/memory/ace_type.h"
29 #include "base/memory/referenced.h"
30 #include "base/utils/macros.h"
31 #include "base/view_data/view_data_wrap.h"
32 #include "core/common/resource/resource_configuration.h"
33 #include "core/common/window_animation_config.h"
34 #include "core/components_ng/event/focus_hub.h"
35 #include "core/components_ng/event/gesture_event_hub.h"
36 #include "core/components_ng/export_texture_info/export_texture_info.h"
37 #include "core/components_ng/layout/layout_wrapper.h"
38 #include "core/components_ng/layout/layout_wrapper_node.h"
39 #include "core/components_ng/property/accessibility_property.h"
40 #include "core/event/touch_event.h"
41 #include "core/event/mouse_event.h"
42 
43 namespace OHOS::Ace::NG {
44 class AccessibilityProperty;
45 
46 struct ExtraInfo {
47     std::string page;
48     int32_t line = 0;
49     int32_t col = 0;
50 };
51 
52 enum class NodeStatus : char {
53     NORMAL_NODE = 0,               // Indicates it is a normal node;
54     BUILDER_NODE_OFF_MAINTREE = 1, // Indicates it is a BuilderNode and is detach from the mainTree;
55     BUILDER_NODE_ON_MAINTREE = 2   // Indicates it is a BuilderNode and is attach to the mainTree;
56 };
57 
58 enum class RootNodeType : int32_t {
59     PAGE_ETS_TAG = 0,
60     NAVDESTINATION_VIEW_ETS_TAG = 1,
61     WINDOW_SCENE_ETS_TAG = 2
62 };
63 
64 struct InteractionEventBindingInfo  {
65     bool baseEventRegistered = false;
66     bool nodeEventRegistered = false;
67     bool nativeEventRegistered = false;
68     bool builtInEventRegistered = false;
69 
SetModifierEventRegisteredInteractionEventBindingInfo70     void SetModifierEventRegistered(bool isCNode, bool state)
71     {
72         if (isCNode) {
73             nativeEventRegistered = state;
74         } else {
75             baseEventRegistered = state;
76         }
77     }
78 
SetNodeEventRegisteredInteractionEventBindingInfo79     void SetNodeEventRegistered(bool state)
80     {
81         nodeEventRegistered = state;
82     }
83 
SetBuiltInEventRegisteredInteractionEventBindingInfo84     void SetBuiltInEventRegistered(bool state)
85     {
86         builtInEventRegistered = state;
87     }
88 };
89 
90 class InspectorFilter;
91 class PipelineContext;
92 constexpr int32_t DEFAULT_NODE_SLOT = -1;
93 
94 // UINode is the base class of FrameNode and SyntaxNode.
95 class ACE_FORCE_EXPORT UINode : public virtual AceType {
96     DECLARE_ACE_TYPE(UINode, AceType);
97 
98 public:
99     UINode(const std::string& tag, int32_t nodeId, bool isRoot = false);
100     ~UINode() override;
101 
102     void RegisterReleaseFunc(bool enableRegister);
103     virtual void OnDelete();
104 
105     // atomic node is like button, image, custom node and so on.
106     // In ets UI compiler, the atomic node does not Add Pop function, only have Create function.
107     virtual bool IsAtomicNode() const = 0;
108 
109     virtual void AttachContext(PipelineContext* context, bool recursive = false);
110     virtual void DetachContext(bool recursive = false);
111 
112     virtual int32_t FrameCount() const;
113     virtual int32_t CurrentFrameCount() const;
114     virtual RefPtr<LayoutWrapperNode> CreateLayoutWrapper(bool forceMeasure = false, bool forceLayout = false);
115 
116     // Tree operation start.
117     virtual void AddChild(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT, bool silently = false,
118         bool addDefaultTransition = false, bool addModalUiextension = false);
119     void AddChildAfter(const RefPtr<UINode>& child, const RefPtr<UINode>& siblingNode);
120     void AddChildBefore(const RefPtr<UINode>& child, const RefPtr<UINode>& siblingNode);
121 
122     std::list<RefPtr<UINode>>::iterator RemoveChild(const RefPtr<UINode>& child, bool allowTransition = false);
123     bool RemoveChildSilently(const RefPtr<UINode>& child);
124     int32_t RemoveChildAndReturnIndex(const RefPtr<UINode>& child);
125     void ReplaceChild(const RefPtr<UINode>& oldNode, const RefPtr<UINode>& newNode);
126     void MovePosition(int32_t slot);
127     virtual void MountToParent(const RefPtr<UINode>& parent, int32_t slot = DEFAULT_NODE_SLOT, bool silently = false,
128         bool addDefaultTransition = false, bool addModalUiextension = false);
129     void MountToParentAfter(const RefPtr<UINode>& parent, const RefPtr<UINode>& siblingNode);
130     void MountToParentBefore(const RefPtr<UINode>& parent, const RefPtr<UINode>& siblingNode);
131     RefPtr<FrameNode> GetParentFrameNode() const;
132     RefPtr<CustomNode> GetParentCustomNode() const;
133     RefPtr<FrameNode> GetFocusParentWithBoundary() const;
134     RefPtr<FrameNode> GetFocusParent() const;
135     RefPtr<FocusHub> GetFirstFocusHubChild() const;
136 
137     // Only for the currently loaded children, do not expand.
138     void GetCurrentChildrenFocusHub(std::list<RefPtr<FocusHub>>& focusNodes);
139 
140     void GetFocusChildren(std::list<RefPtr<FrameNode>>& children) const;
141     void Clean(bool cleanDirectly = false, bool allowTransition = false, int32_t branchId = -1);
142     void RemoveChildAtIndex(int32_t index);
143     RefPtr<UINode> GetChildAtIndex(int32_t index) const;
144     int32_t GetChildIndex(const RefPtr<UINode>& child) const;
145     [[deprecated]] void AttachToMainTree(bool recursive = false);
146     void AttachToMainTree(bool recursive, PipelineContext* context);
147     void DetachFromMainTree(bool recursive = false, bool needCheckThreadSafeNodeTree = false);
148     virtual void FireCustomDisappear();
149     // Traverse downwards to update system environment variables.
150     void UpdateConfigurationUpdate();
151     void UpdateConfigurationUpdate(const ConfigurationChange& configurationChange);
152 
153     // Return value: 0 indicates successful execution, non - zero indicates failed execution.
OnRecvCommand(const std::string & command)154     virtual int32_t OnRecvCommand(const std::string& command) { return 0; }
155 
OnConfigurationUpdate(const ConfigurationChange & configurationChange)156     virtual void OnConfigurationUpdate(const ConfigurationChange& configurationChange) {}
157 
158     // process offscreen process.
159     void ProcessOffscreenTask(bool recursive = false);
160 
161     // Determine if the node is a SyntaxNode, default returns false.
162     // SyntaxNode classes need to override the method and return true.
IsSyntaxNode()163     virtual bool IsSyntaxNode() const
164     {
165         return false;
166     }
167 
UpdateModalUiextensionCount(bool addNode)168     void UpdateModalUiextensionCount(bool addNode)
169     {
170         if (addNode) {
171             modalUiextensionCount_++;
172         } else {
173             modalUiextensionCount_--;
174         }
175     }
176 
177     int32_t TotalChildCount() const;
178     virtual void UpdateGeometryTransition();
179 
180     // Returns index in the flatten tree structure
181     // of the node with given id and type
182     // Returns std::pair with
183     // boolean first - indication of node is found
184     // int32_t second - index of the node
185     std::pair<bool, int32_t> GetChildFlatIndex(int32_t id);
186 
187     virtual const std::list<RefPtr<UINode>>& GetChildren(bool notDetach = false) const
188     {
189         return children_;
190     }
191 
192     // Return children for get inspector tree calling, return cache children directly
193     virtual const std::list<RefPtr<UINode>>& GetChildrenForInspector(bool needCacheNode = false) const
194     {
195         return children_;
196     }
197 
GetLastChild()198     RefPtr<UINode> GetLastChild() const
199     {
200         if (children_.empty()) {
201             return nullptr;
202         }
203         return children_.back();
204     }
205 
GetFirstChild()206     RefPtr<UINode> GetFirstChild() const
207     {
208         if (children_.empty()) {
209             return nullptr;
210         }
211         return children_.front();
212     }
213 
214     void GenerateOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& visibleList);
215     void GenerateOneDepthVisibleFrameWithTransition(std::list<RefPtr<FrameNode>>& visibleList);
216     void GenerateOneDepthVisibleFrameWithOffset(
217         std::list<RefPtr<FrameNode>>& visibleList, OffsetF& offset);
218     void GenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>>& visibleList);
219 
220     int32_t GetChildIndexById(int32_t id);
221 
GetParent()222     RefPtr<UINode> GetParent() const
223     {
224         return parent_.Upgrade();
225     }
226 
227     RefPtr<UINode> GetAncestor() const;
228 
SetNeedCallChildrenUpdate(bool needCallChildrenUpdate)229     void SetNeedCallChildrenUpdate(bool needCallChildrenUpdate)
230     {
231         needCallChildrenUpdate_ = needCallChildrenUpdate;
232     }
233 
234     virtual void SetParent(const WeakPtr<UINode>& parent, bool needDetect = true);
235     void SetAncestor(const WeakPtr<UINode>& parent);
236     // Tree operation end.
237 
238     // performance.
239     PipelineContext* GetContext() const;
240     PipelineContext* GetAttachedContext() const;
241     PipelineContext* GetContextWithCheck();
242 
243     RefPtr<PipelineContext> GetContextRefPtr() const;
244 
245     // When FrameNode creates a layout task, the corresponding LayoutWrapper tree is created, and UINode needs to update
246     // the corresponding LayoutWrapper tree node at this time like add self wrapper to wrapper tree.
247     virtual void AdjustLayoutWrapperTree(const RefPtr<LayoutWrapperNode>& parent, bool forceMeasure, bool forceLayout);
248 
249     bool IsAutoFillContainerNode();
250     void DumpViewDataPageNodes(
251         RefPtr<ViewDataWrap> viewDataWrap, bool skipSubAutoFillContainer = false, bool needsRecordData = false);
252     bool NeedRequestAutoSave();
253     // DFX info.
254     virtual void DumpTree(int32_t depth, bool hasJson = false);
255     void DumpTreeJsonForDiff(std::unique_ptr<JsonValue>& json);
256     void DumpSimplifyTree(int32_t depth, std::shared_ptr<JsonValue>& current);
257     virtual bool IsContextTransparent();
258 
259     bool DumpTreeById(int32_t depth, const std::string& id, bool hasJson = false);
260     bool DumpTreeByComponentName(const std::string& name);
261 
GetTag()262     const std::string& GetTag() const
263     {
264         return tag_;
265     }
266 
GetId()267     int32_t GetId() const
268     {
269         return nodeId_;
270     }
271 
GetAccessibilityId()272     int64_t GetAccessibilityId() const
273     {
274         return accessibilityId_;
275     }
276 
SetDepth(int32_t depth)277     void SetDepth(int32_t depth)
278     {
279         depth_ = depth;
280         for (auto& child : children_) {
281             child->SetDepth(depth_ + 1);
282         }
283     }
284 
IsRootNode()285     bool IsRootNode() const
286     {
287         return isRoot_;
288     }
289 
GetDepth()290     int32_t GetDepth() const
291     {
292         return depth_;
293     }
294 
GetRootId()295     int32_t GetRootId() const
296     {
297         return hostRootId_;
298     }
299 
GetPageId()300     int32_t GetPageId() const
301     {
302         return hostPageId_;
303     }
304 
305     // TODO: SetHostRootId step on create node.
SetHostRootId(int32_t id)306     void SetHostRootId(int32_t id)
307     {
308         hostRootId_ = id;
309     }
310 
311     // TODO: SetHostPageId step on mount to page.
SetHostPageId(int32_t id)312     void SetHostPageId(int32_t id)
313     {
314         hostPageId_ = id;
315         for (auto& child : children_) {
316             child->SetHostPageId(id);
317         }
318     }
319 
SetRemoveSilently(bool removeSilently)320     void SetRemoveSilently(bool removeSilently)
321     {
322         removeSilently_ = removeSilently;
323     }
324 
SetUndefinedNodeId()325     void SetUndefinedNodeId()
326     {
327         nodeId_ = -1;
328     }
329 
IsRemoving()330     bool IsRemoving() const
331     {
332         return isRemoving_;
333     }
334 
GetLayoutPriority()335     int32_t GetLayoutPriority() const
336     {
337         return layoutPriority_;
338     }
339 
SetLayoutPriority(int32_t priority)340     void SetLayoutPriority(int32_t priority)
341     {
342         layoutPriority_ = priority;
343     }
344 
SetInDestroying()345     void SetInDestroying()
346     {
347         isInDestroying_ = true;
348     }
349 
IsInDestroying()350     bool IsInDestroying() const
351     {
352         return isInDestroying_;
353     }
354 
IsDestroyingState()355     bool IsDestroyingState() const
356     {
357         return isDestroyingState_;
358     }
359 
360     void SetChildrenInDestroying();
361 
362     virtual HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint,
363         const PointF& parentRevertPoint, TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId,
364         ResponseLinkResult& responseLinkResult, bool isDispatch = false);
GetHitTestMode()365     virtual HitTestMode GetHitTestMode() const
366     {
367         return HitTestMode::HTMDEFAULT;
368     }
369 
370     virtual HitTestResult MouseTest(const PointF& globalPoint, const PointF& parentLocalPoint,
371         MouseTestResult& onMouseResult, MouseTestResult& onHoverResult, RefPtr<FrameNode>& hoverNode);
372 
373     virtual HitTestResult AxisTest(const PointF& globalPoint, const PointF& parentLocalPoint,
374         const PointF& parentRevertPoint, TouchRestrict& touchRestrict, AxisTestResult& onAxisResult);
375 
376     // In the request to re-layout the scene, needs to obtain the changed state of the child node for the creation
377     // of parent's layout wrapper
378     virtual void UpdateLayoutPropertyFlag();
379 
ForceUpdateLayoutPropertyFlag(PropertyChangeFlag propertyChangeFlag)380     virtual void ForceUpdateLayoutPropertyFlag(PropertyChangeFlag propertyChangeFlag) {}
381 
382     virtual void AdjustParentLayoutFlag(PropertyChangeFlag& flag);
383 
384     virtual void MarkDirtyNode(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL);
385 
386     virtual void MarkNeedFrameFlushDirty(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL);
387 
FlushUpdateAndMarkDirty()388     virtual void FlushUpdateAndMarkDirty()
389     {
390         for (const auto& child : children_) {
391             child->FlushUpdateAndMarkDirty();
392         }
393     }
394 
395     virtual void MarkNeedSyncRenderTree(bool needRebuild = false);
396 
397     virtual void RebuildRenderContextTree();
398 
OnWindowShow()399     virtual void OnWindowShow() {}
400 
OnWindowHide()401     virtual void OnWindowHide() {}
402     virtual void Build(std::shared_ptr<std::list<ExtraInfo>> extraInfos);
403 
404     virtual bool RenderCustomChild(int64_t deadline);
405 
OnWindowFocused()406     virtual void OnWindowFocused() {}
407 
OnWindowUnfocused()408     virtual void OnWindowUnfocused() {}
409 
OnWindowActivated()410     virtual void OnWindowActivated() {}
411 
OnWindowDeactivated()412     virtual void OnWindowDeactivated() {}
413 
OnWindowSizeChanged(int32_t width,int32_t height,WindowSizeChangeReason type)414     virtual void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) {}
415 
OnNotifyMemoryLevel(int32_t level)416     virtual void OnNotifyMemoryLevel(int32_t level) {}
417 
418     virtual void SetActive(bool active, bool needRebuildRenderContext = false);
419 
420     virtual void SetJSViewActive(bool active, bool isLazyForEachNode = false, bool isReuse = false);
421 
422     virtual void TryVisibleChangeOnDescendant(VisibleType preVisibility, VisibleType currentVisibility);
423 
424     // call by recycle framework.
425     virtual void OnRecycle();
426     virtual void OnReuse();
427 
428     virtual void NotifyColorModeChange(uint32_t colorMode);
429 
430     virtual bool MarkRemoving();
431 
IsOnMainTree()432     bool IsOnMainTree() const
433     {
434         return onMainTree_;
435     }
436 
UseOffscreenProcess()437     bool UseOffscreenProcess() const
438     {
439         return useOffscreenProcess_;
440     }
441 
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)442     virtual void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const {}
443 
ToTreeJson(std::unique_ptr<JsonValue> & json,const InspectorConfig & config)444     virtual void ToTreeJson(std::unique_ptr<JsonValue>& json, const InspectorConfig& config) const {}
445 
FromJson(const std::unique_ptr<JsonValue> & json)446     virtual void FromJson(const std::unique_ptr<JsonValue>& json) {}
447 
448     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(InspectorId, std::string);
OnInspectorIdUpdate(const std::string &)449     virtual void OnInspectorIdUpdate(const std::string& /*unused*/) {}
450 
451     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(AutoEventParam, std::string);
OnAutoEventParamUpdate(const std::string &)452     virtual void OnAutoEventParamUpdate(const std::string& /*unused*/) {}
453 
454     template<typename T>
FindChildNodeOfClass()455     RefPtr<T> FindChildNodeOfClass()
456     {
457         const auto& children = GetChildren();
458         for (auto iter = children.rbegin(); iter != children.rend(); ++iter) {
459             auto& child = *iter;
460 
461             auto target = child->FindChildNodeOfClass<T>();
462             if (target) {
463                 return target;
464             }
465         }
466 
467         RefPtr<UINode> uiNode = AceType::Claim<UINode>(this);
468         if (AceType::InstanceOf<T>(uiNode)) {
469             return AceType::DynamicCast<T>(uiNode);
470         }
471         return nullptr;
472     }
473 
474     // utility function for adding child to disappearingChildren_
475     void AddDisappearingChild(const RefPtr<UINode>& child, uint32_t index = UINT32_MAX, int32_t branchId = -1);
476     // utility function for removing child from disappearingChildren_, return true if child is removed
477     bool RemoveDisappearingChild(const RefPtr<UINode>& child);
478     // return if we are in parent's disappearing children
IsDisappearing()479     bool IsDisappearing() const
480     {
481         return isDisappearing_;
482     }
483     RefPtr<UINode> GetDisappearingChildById(const std::string& id, int32_t branchId) const;
484 
485     // These two interfaces are only used for fast preview.
486     // FastPreviewUpdateChild: Replace the old child at the specified slot with the new created node.
487     // FastPreviewUpdateChildDone: the new created node performs some special operations.
FastPreviewUpdateChild(int32_t slot,const RefPtr<UINode> & newChild)488     virtual void FastPreviewUpdateChild(int32_t slot, const RefPtr<UINode>& newChild)
489     {
490         RemoveChildAtIndex(slot);
491         newChild->MountToParent(AceType::Claim(this), slot, false);
492     }
FastPreviewUpdateChildDone()493     virtual void FastPreviewUpdateChildDone() {}
494     virtual RefPtr<UINode> GetFrameChildByIndex(uint32_t index, bool needBuild, bool isCache = false,
495         bool addToRenderTree = false);
496     virtual RefPtr<UINode> GetFrameChildByIndexWithoutExpanded(uint32_t index);
497     // Get current frameNode index with or without expanded all LazyForEachNode;
498     virtual int32_t GetFrameNodeIndex(const RefPtr<FrameNode>& node, bool isExpanded = true);
SetDebugLine(const std::string & line)499     void SetDebugLine(const std::string& line)
500     {
501         debugLine_ = line;
502     }
GetDebugLine()503     std::string GetDebugLine() const
504     {
505         return debugLine_;
506     }
507 
SetViewId(const std::string & viewId)508     void SetViewId(const std::string& viewId)
509     {
510         viewId_ = viewId;
511     }
512 
GetViewId()513     std::string GetViewId() const
514     {
515         return viewId_;
516     }
517 
SetRestoreId(int32_t restoreId)518     void SetRestoreId(int32_t restoreId)
519     {
520         restoreId_ = restoreId;
521     }
522 
GetRestoreId()523     int32_t GetRestoreId()
524     {
525         return restoreId_;
526     }
527 
UpdateRecycleElmtId(int32_t newElmtId)528     void UpdateRecycleElmtId(int32_t newElmtId)
529     {
530         nodeId_ = newElmtId;
531     }
532 
533     // --------------------------------------------------------------------------------
534     // performance check get child count, depth, flex layout times and layout time
535     void GetPerformanceCheckData(PerformanceCheckNodeMap& nodeMap);
SetLayoutTime(int64_t time)536     void SetLayoutTime(int64_t time)
537     {
538         if (nodeInfo_) {
539             nodeInfo_->layoutTime = time;
540         }
541     }
GetLayoutTime()542     int64_t GetLayoutTime()
543     {
544         if (nodeInfo_) {
545             return nodeInfo_->layoutTime;
546         }
547         return 0;
548     }
GetFlexLayouts()549     int32_t GetFlexLayouts()
550     {
551         if (nodeInfo_) {
552             return nodeInfo_->flexLayouts;
553         }
554         return 0;
555     }
GetRow()556     int32_t GetRow() const
557     {
558         if (nodeInfo_) {
559             return nodeInfo_->codeRow;
560         }
561         return 0;
562     }
GetCol()563     int32_t GetCol() const
564     {
565         if (nodeInfo_) {
566             return nodeInfo_->codeCol;
567         }
568         return 0;
569     }
SetRow(const int32_t row)570     void SetRow(const int32_t row)
571     {
572         if (nodeInfo_) {
573             nodeInfo_->codeRow = row;
574         }
575     }
SetCol(const int32_t col)576     void SetCol(const int32_t col)
577     {
578         if (nodeInfo_) {
579             nodeInfo_->codeCol = col;
580         }
581     }
SetFilePath(const std::string & sources)582     void SetFilePath(const std::string& sources)
583     {
584         if (nodeInfo_) {
585             nodeInfo_->pagePath = sources;
586         }
587     }
588 
GetFilePath()589     std::string GetFilePath() const
590     {
591         if (nodeInfo_) {
592             return nodeInfo_->pagePath;
593         }
594         return "";
595     }
SetForeachItem()596     void SetForeachItem()
597     {
598         if (nodeInfo_) {
599             nodeInfo_->isForEachItem = true;
600         }
601     }
AddFlexLayouts()602     void AddFlexLayouts()
603     {
604         if (nodeInfo_) {
605             nodeInfo_->flexLayouts++;
606         }
607     }
GetCustomTag()608     virtual std::string GetCustomTag()
609     {
610         return GetTag();
611     }
SetBuildByJs(bool isBuildByJS)612     void SetBuildByJs(bool isBuildByJS)
613     {
614         isBuildByJS_ = isBuildByJS;
615     }
616 
GetExternalData()617     void* GetExternalData() const
618     {
619         return externalData_;
620     }
621 
SetExternalData(void * externalData)622     void SetExternalData(void* externalData)
623     {
624         externalData_ = externalData;
625     }
626 
627     // --------------------------------------------------------------------------------
628 
629     virtual void DoRemoveChildInRenderTree(uint32_t index, bool isAll = false);
630     virtual void DoSetActiveChildRange(
631         int32_t start, int32_t end, int32_t cacheStart, int32_t cacheEnd, bool showCache = false);
DoSetActiveChildRange(const std::set<int32_t> & activeItems,const std::set<int32_t> & cachedItems,int32_t baseIndex)632     virtual void DoSetActiveChildRange(
633         const std::set<int32_t>& activeItems, const std::set<int32_t>& cachedItems, int32_t baseIndex)
634     {}
635     virtual void OnSetCacheCount(int32_t cacheCount, const std::optional<LayoutConstraintF>& itemConstraint);
636 
637     // return value: true if the node can be removed immediately.
638     virtual bool OnRemoveFromParent(bool allowTransition);
639 
MarkForceMeasure()640     void MarkForceMeasure()
641     {
642         MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
643         for (const auto& child : children_) {
644             child->MarkForceMeasure();
645         }
646     }
647 
648     std::string GetCurrentCustomNodeInfo();
649     static int64_t GenerateAccessibilityId();
650 
651     // used by BuilderNode
652     NodeStatus GetNodeStatus() const;
653     void UpdateNodeStatus(NodeStatus nodeStatus);
654     void SetIsRootBuilderNode(bool isRootBuilderNode);
SetJsBuilderNodeId(int32_t jsBuilderNodeId)655     void SetJsBuilderNodeId(int32_t jsBuilderNodeId)
656     {
657         jsBuilderNodeId_ = jsBuilderNodeId;
658     }
659 
GetJsBuilderNodeId()660     int32_t GetJsBuilderNodeId() const
661     {
662         return jsBuilderNodeId_;
663     }
664 
665     bool GetIsRootBuilderNode() const;
SetNodeAdapter(bool enable)666     void SetNodeAdapter(bool enable)
667     {
668         isNodeAdapter_ = enable;
669     }
670 
671 
IsArkTsFrameNode()672     bool IsArkTsFrameNode() const
673     {
674         return isArkTsFrameNode_;
675     }
676 
SetIsArkTsFrameNode(bool isArkTsFrameNode)677     void SetIsArkTsFrameNode(bool isArkTsFrameNode)
678     {
679         isArkTsFrameNode_ = isArkTsFrameNode;
680     }
681 
GetExportTextureInfo()682     const RefPtr<ExportTextureInfo>& GetExportTextureInfo() const
683     {
684         return exportTextureInfo_;
685     }
686 
687     void CreateExportTextureInfoIfNeeded();
688 
689     bool IsNeedExportTexture() const;
690 
691     virtual bool SetParentLayoutConstraint(const SizeF& size) const;
692 
SetNodeIndexOffset(int32_t start,int32_t count)693     virtual void SetNodeIndexOffset(int32_t start, int32_t count) {}
694 
IsLayoutSeperately()695     bool IsLayoutSeperately() const
696     {
697         return layoutSeperately_;
698     }
699 
700     virtual void PaintDebugBoundaryTreeAll(bool flag);
701     static void DFSAllChild(const RefPtr<UINode>& root, std::vector<RefPtr<UINode>>& res);
702     static void GetBestBreakPoint(RefPtr<UINode>& breakPointChild, RefPtr<UINode>& breakPointParent);
703 
HasVirtualNodeAccessibilityProperty()704     virtual bool HasVirtualNodeAccessibilityProperty()
705     {
706         return false;
707     }
708 
AddFlag(uint32_t flag)709     void AddFlag(uint32_t flag)
710     {
711         nodeFlag_ |= flag;
712     }
713 
IsNodeHasFlag(uint32_t flag)714     bool IsNodeHasFlag(uint32_t flag) const
715     {
716         return (flag & nodeFlag_) == flag;
717     }
718 
SetAccessibilityNodeVirtual()719     void SetAccessibilityNodeVirtual()
720     {
721         isAccessibilityVirtualNode_ = true;
722         for (auto& it : GetChildren()) {
723             it->SetAccessibilityNodeVirtual();
724         }
725     }
726 
IsAccessibilityVirtualNode()727     bool IsAccessibilityVirtualNode() const
728     {
729         return isAccessibilityVirtualNode_;
730     }
731 
SetAccessibilityVirtualNodeParent(const RefPtr<UINode> & parent)732     void SetAccessibilityVirtualNodeParent(const RefPtr<UINode>& parent)
733     {
734         parentForAccessibilityVirtualNode_ = parent;
735         for (auto& it : GetChildren()) {
736             it->SetAccessibilityVirtualNodeParent(parent);
737         }
738     }
739 
GetVirtualNodeParent()740     WeakPtr<UINode> GetVirtualNodeParent() const
741     {
742         return parentForAccessibilityVirtualNode_;
743     }
744 
IsFirstVirtualNode()745     bool IsFirstVirtualNode() const
746     {
747         return isFirstAccessibilityVirtualNode_;
748     }
749 
SetFirstAccessibilityVirtualNode()750     void SetFirstAccessibilityVirtualNode()
751     {
752         isFirstAccessibilityVirtualNode_ = true;
753     }
754 
SetRootNodeId(int32_t rootNodeId)755     void SetRootNodeId(int32_t rootNodeId)
756     {
757         rootNodeId_ = rootNodeId;
758     }
759 
GetRootNodeId()760     int32_t GetRootNodeId() const
761     {
762         return rootNodeId_;
763     }
764 
RootNodeIsPage()765     bool RootNodeIsPage() const
766     {
767         return rootNodeType_ == RootNodeType::PAGE_ETS_TAG;
768     }
769 
SetRootNodeType(RootNodeType rootNodeType)770     void SetRootNodeType(RootNodeType rootNodeType)
771     {
772         rootNodeType_ = rootNodeType;
773     }
774 
GetRootNodeType()775     RootNodeType GetRootNodeType() const
776     {
777         return rootNodeType_;
778     }
779 
780     virtual void ClearSubtreeLayoutAlgorithm(bool includeSelf = true, bool clearEntireTree = false);
781 
782     void GetPageNodeCountAndDepth(int32_t* count, int32_t* depth);
783 
RegisterUpdateJSInstanceCallback(std::function<void (int32_t)> && callback)784     virtual void RegisterUpdateJSInstanceCallback(std::function<void(int32_t)>&& callback)
785     {
786         updateJSInstanceCallback_ = std::move(callback);
787     }
788 
GetInstanceId()789     int32_t GetInstanceId() const
790     {
791         return instanceId_;
792     }
793 
GetLayoutTags()794     static std::set<std::string> GetLayoutTags()
795     {
796         return layoutTags_;
797     }
798 
SetGeometryTransitionInRecursive(bool isGeometryTransitionIn)799     virtual void SetGeometryTransitionInRecursive(bool isGeometryTransitionIn)
800     {
801         for (const auto& child : GetChildren()) {
802             child->SetGeometryTransitionInRecursive(isGeometryTransitionIn);
803         }
804     }
805 
SetOnNodeDestroyCallback(std::function<void (int32_t)> && destroyCallback)806     virtual void SetOnNodeDestroyCallback(std::function<void(int32_t)>&& destroyCallback)
807     {
808         destroyCallback_ = std::move(destroyCallback);
809     }
810 
HasOnNodeDestroyCallback()811     virtual bool HasOnNodeDestroyCallback()
812     {
813         return destroyCallback_ != nullptr;
814     }
815 
FireOnNodeDestroyCallback()816     virtual void FireOnNodeDestroyCallback()
817     {
818         CHECK_NULL_VOID(destroyCallback_);
819         destroyCallback_(nodeId_);
820     }
821 
IsAllowAddChildBelowModalUec()822     bool IsAllowAddChildBelowModalUec() const
823     {
824         return isAllowAddChildBelowModalUec_;
825     }
826 
SetIsAllowAddChildBelowModalUec(bool isAllowAddChildBelowModalUec)827     void SetIsAllowAddChildBelowModalUec(bool isAllowAddChildBelowModalUec)
828     {
829         isAllowAddChildBelowModalUec_ = isAllowAddChildBelowModalUec;
830     }
831 
SetBuilderFunc(std::function<void ()> && lazyBuilderFunc)832     void SetBuilderFunc(std::function<void()>&& lazyBuilderFunc)
833     {
834         lazyBuilderFunc_ = lazyBuilderFunc;
835     }
836 
GetBuilderFunc()837     std::function<void()> GetBuilderFunc() const
838     {
839         return lazyBuilderFunc_;
840     }
841 
SetUpdateNodeFunc(std::function<void (int32_t,RefPtr<UINode> &)> && updateNodeFunc)842     void SetUpdateNodeFunc(std::function<void(int32_t, RefPtr<UINode>&)>&& updateNodeFunc)
843     {
844         updateNodeFunc_ = updateNodeFunc;
845     }
846 
GetUpdateNodeFunc()847     std::function<void(int32_t, RefPtr<UINode>&)> GetUpdateNodeFunc()
848     {
849         return updateNodeFunc_;
850     }
851 
SetUpdateNodeConfig(std::function<void ()> && updateNodeConfig)852     void SetUpdateNodeConfig(std::function<void()>&& updateNodeConfig)
853     {
854         updateNodeConfig_ = updateNodeConfig;
855     }
856 
GetUpdateNodeConfig()857     std::function<void()> GetUpdateNodeConfig()
858     {
859         return updateNodeConfig_;
860     }
861 
862     virtual void GetInspectorValue();
863     virtual void NotifyWebPattern(bool isRegister);
864     void GetContainerComponentText(std::u16string& text);
865 
866     enum class NotificationType : int32_t {
867         START_CHANGE_POSITION = 0,
868         END_CHANGE_POSITION = 1,
869         START_AND_END_CHANGE_POSITION = 2
870     };
871     /**
872      * @brief For a DataChange happened in child [id], notify the corresponding change position to parent.
873      *
874      * @param changeIdx change index in child [id].
875      * @param count change of item count.
876      * @param id the accessibilityId of child who call this function.
877      * @param notificationType the type of notification.
878      */
879     virtual void NotifyChange(int32_t changeIdx, int32_t count, int64_t id, NotificationType notificationType);
880 
881     int32_t GetThemeScopeId() const;
882     void SetThemeScopeId(int32_t themeScopeId);
883     virtual void UpdateThemeScopeId(int32_t themeScopeId);
884     virtual void UpdateThemeScopeUpdate(int32_t themeScopeId);
OnThemeScopeUpdate(int32_t themeScopeId)885     virtual void OnThemeScopeUpdate(int32_t themeScopeId) {}
886     void AllowUseParentTheme(bool isAllow);
887     bool IsAllowUseParentTheme() const;
888     ColorMode GetLocalColorMode() const;
889 
890     // Used to mark freeze and block dirty mark.
891     virtual void SetFreeze(bool isFreeze, bool isForceUpdateFreezeVaule = false, bool isUserFreeze = false);
892 
893     void SetUserFreeze(bool isUserFreeze);
894 
895     bool IsUserFreeze();
896 
IsFreeze()897     bool IsFreeze() const
898     {
899         return isFreeze_;
900     }
901 
IsCNode()902     bool IsCNode() const
903     {
904         return isCNode_;
905     }
906 
setIsCNode(bool createByCapi)907     void setIsCNode(bool createByCapi)
908     {
909         isCNode_ = createByCapi;
910     }
911 
IsReusableNode()912     bool IsReusableNode() const
913     {
914         return isCNode_ || isArkTsFrameNode_ || isRootBuilderNode_ || isArkTsRenderNode_;
915     }
916 
GetCurrentPageRootNode()917     virtual RefPtr<UINode> GetCurrentPageRootNode()
918     {
919         return nullptr;
920     }
921 
AddCustomProperty(const std::string & key,const std::string & value)922     virtual void AddCustomProperty(const std::string& key, const std::string& value) {}
RemoveCustomProperty(const std::string & key)923     virtual void RemoveCustomProperty(const std::string& key) {}
924 
IsMoving()925     bool IsMoving() const
926     {
927         return isMoving_;
928     }
929 
setIsMoving(bool isMoving)930     void setIsMoving(bool isMoving)
931     {
932         isMoving_ = isMoving;
933         for (auto& child : children_) {
934             child->setIsMoving(isMoving);
935         }
936     }
937 
isCrossLanguageAttributeSetting()938     bool isCrossLanguageAttributeSetting() const
939     {
940         return isCrossLanguageAttributeSetting_;
941     }
942 
SetIsCrossLanguageAttributeSetting(bool isCrossLanguageAttributeSetting)943     void SetIsCrossLanguageAttributeSetting(bool isCrossLanguageAttributeSetting)
944     {
945         isCrossLanguageAttributeSetting_ = isCrossLanguageAttributeSetting;
946     }
947 
948     /**
949      * flag used by Repeat virtual scroll
950      * to mark a child UINode of RepeatVirtualScroll as either allowing or not allowing
951      * adding a @ReusableV2 @ComponentV2 CustomNode
952      * allowReusableV2Descendant_ default value is true
953      */
954     void SetAllowReusableV2Descendant(bool allow);
955     bool IsAllowReusableV2Descendant() const;
956 
957     bool HasSkipNode();
OnDestroyingStateChange(bool isDestroying,bool cleanStatus)958     virtual void OnDestroyingStateChange(bool isDestroying, bool cleanStatus)
959     {
960         isDestroyingState_ = isDestroying;
961     }
962     virtual void SetDestroying(bool isDestroying = true, bool cleanStatus = true);
963 
964     /**
965      * @description: Compare whether the target api version of the application is greater than or equal to the incoming
966      * target. It can be used in scenarios where the uiNode can be obtained.
967      * @param: Target version to be isolated.
968      * @return: return the compare result.
969      */
970     bool GreatOrEqualAPITargetVersion(PlatformVersion version) const;
971 
972     /**
973      * @description: Compare whether the target api version of the application is less than the incoming
974      * target. It can be used in scenarios where the uiNode can be obtained.
975      * @param: Target version to be isolated.
976      * @return: return the compare result.
977      */
978     bool LessThanAPITargetVersion(PlatformVersion version) const;
979 
SetRerenderable(bool shouldRerender)980     void SetRerenderable(bool shouldRerender)
981     {
982         shouldRerender_ = shouldRerender;
983     }
984 
GetRerenderable()985     bool GetRerenderable()
986     {
987         return shouldRerender_;
988     }
989 
SetDarkMode(bool isDarkMode)990     void SetDarkMode(bool isDarkMode)
991     {
992         isDarkMode_ = isDarkMode;
993     }
994 
CheckIsDarkMode()995     bool CheckIsDarkMode()
996     {
997         return isDarkMode_;
998     }
999 
SetMeasureAnyway(bool measureAnyWay)1000     void SetMeasureAnyway(bool measureAnyWay)
1001     {
1002         measureAnyWay_  = measureAnyWay;
1003     }
1004 
CheckMeasureAnyway()1005     bool CheckMeasureAnyway()
1006     {
1007         return measureAnyWay_;
1008     }
1009 
SetShouldClearCache(bool shouldClearCache)1010     void SetShouldClearCache(bool shouldClearCache)
1011     {
1012         shouldClearCache_ = shouldClearCache;
1013     }
1014 
CheckShouldClearCache()1015     bool CheckShouldClearCache()
1016     {
1017         return shouldClearCache_;
1018     }
1019 
IsArkTsRenderNode()1020     bool IsArkTsRenderNode() const
1021     {
1022         return isArkTsRenderNode_;
1023     }
1024 
SetIsArkTsRenderNode(bool isArkTsRenderNode)1025     void SetIsArkTsRenderNode(bool isArkTsRenderNode)
1026     {
1027         isArkTsRenderNode_ = isArkTsRenderNode;
1028     }
1029 
1030     void ProcessIsInDestroyingForReuseableNode(const RefPtr<UINode>& child);
CheckVisibleOrActive()1031     virtual bool CheckVisibleOrActive()
1032     {
1033         return true;
1034     }
1035 
SetModifierEventRegistrationState(bool isCNode,bool state)1036     void SetModifierEventRegistrationState(bool isCNode, bool state) {
1037         InteractionEventBindingInfo currentInfo = GetInteractionEventBindingInfo();
1038         currentInfo.SetModifierEventRegistered(isCNode, state);
1039         SetInteractionEventBindingInfo(currentInfo);
1040     }
1041 
SetNodeEventRegistrationState(bool state)1042     void SetNodeEventRegistrationState(bool state) {
1043         InteractionEventBindingInfo currentInfo = GetInteractionEventBindingInfo();
1044         currentInfo.SetNodeEventRegistered(state);
1045         SetInteractionEventBindingInfo(currentInfo);
1046     }
1047 
SetBuiltInEventRegistrationState(bool state)1048     void SetBuiltInEventRegistrationState(bool state) {
1049         InteractionEventBindingInfo currentInfo = GetInteractionEventBindingInfo();
1050         currentInfo.SetBuiltInEventRegistered(state);
1051         SetInteractionEventBindingInfo(currentInfo);
1052     }
1053 
SetInteractionEventBindingInfo(const InteractionEventBindingInfo & eventBindingInfo)1054     void SetInteractionEventBindingInfo(const InteractionEventBindingInfo &eventBindingInfo)
1055     {
1056         eventBindingInfo_ = eventBindingInfo;
1057     }
1058 
GetInteractionEventBindingInfo()1059     const InteractionEventBindingInfo& GetInteractionEventBindingInfo() const
1060     {
1061         return eventBindingInfo_;
1062     }
1063 
IsObservedByDrawChildren()1064     bool IsObservedByDrawChildren() const
1065     {
1066         return isObservedByDrawChildren_;
1067     }
1068 
GetObserverParentForDrawChildren()1069     RefPtr<UINode> GetObserverParentForDrawChildren() const
1070     {
1071         return drawChildrenParent_.Upgrade();
1072     }
1073 
IsThreadSafeNode()1074     bool IsThreadSafeNode() const
1075     {
1076         return isThreadSafeNode_;
1077     }
1078 
IsFree()1079     bool IsFree() const
1080     {
1081         return isFree_;
1082     }
1083 
PostAfterAttachMainTreeTask(std::function<void ()> && task)1084     void PostAfterAttachMainTreeTask(std::function<void()>&& task)
1085     {
1086         if (IsOnMainTree()) {
1087             return;
1088         }
1089         afterAttachMainTreeTasks_.emplace_back(std::move(task));
1090     }
1091 
1092     void FindTopNavDestination(RefPtr<FrameNode>& result);
1093 
SubtreeWithIgnoreChild()1094     bool SubtreeWithIgnoreChild() const
1095     {
1096         return subtreeIgnoreCount_ != 0;
1097     }
1098 
1099 protected:
ModifyChildren()1100     std::list<RefPtr<UINode>>& ModifyChildren()
1101     {
1102         return children_;
1103     }
1104 
OnGenerateOneDepthVisibleFrame(std::list<RefPtr<FrameNode>> & visibleList)1105     virtual void OnGenerateOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& visibleList)
1106     {
1107         for (const auto& child : GetChildren()) {
1108             child->OnGenerateOneDepthVisibleFrame(visibleList);
1109         }
1110     }
1111 
1112     virtual void OnGenerateOneDepthVisibleFrameWithTransition(std::list<RefPtr<FrameNode>>& visibleList);
1113 
1114     virtual void OnGenerateOneDepthVisibleFrameWithOffset(
1115         std::list<RefPtr<FrameNode>>& visibleList, OffsetF& offset);
1116 
OnGenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>> & allList)1117     virtual void OnGenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>>& allList)
1118     {
1119         for (const auto& child : GetChildren()) {
1120             child->OnGenerateOneDepthAllFrame(allList);
1121         }
1122     }
1123 
AfterMountToParent()1124     virtual void AfterMountToParent() {}
OnContextAttached()1125     virtual void OnContextAttached() {}
1126     // dump self info.
DumpInfo()1127     virtual void DumpInfo() {}
DumpInfo(std::unique_ptr<JsonValue> & json)1128     virtual void DumpInfo(std::unique_ptr<JsonValue>& json) {}
DumpSimplifyInfo(std::shared_ptr<JsonValue> & json)1129     virtual void DumpSimplifyInfo(std::shared_ptr<JsonValue>& json) {}
DumpAdvanceInfo()1130     virtual void DumpAdvanceInfo() {}
DumpAdvanceInfo(std::unique_ptr<JsonValue> & json)1131     virtual void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) {}
1132     virtual void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) {}
CheckAutoSave()1133     virtual bool CheckAutoSave()
1134     {
1135         return false;
1136     }
1137     // Mount to the main tree to display.
1138     virtual void OnAttachToMainTree(bool recursive = false);
1139     virtual void OnDetachFromMainTree(bool recursive = false, PipelineContext* context = nullptr);
OnAttachToBuilderNode(NodeStatus nodeStatus)1140     virtual void OnAttachToBuilderNode(NodeStatus nodeStatus) {}
1141 
OnFreezeStateChange()1142     virtual void OnFreezeStateChange() {}
1143     virtual void UpdateChildrenFreezeState(bool isFreeze, bool isForceUpdateFreezeVaule = false);
1144 
1145     // run offscreen process.
OnOffscreenProcess(bool recursive)1146     virtual void OnOffscreenProcess(bool recursive) {}
1147 
1148     bool isRemoving_ = false;
1149 
1150     virtual bool RemoveImmediately() const;
1151     void ResetParent();
1152     static void RemoveFromParentCleanly(const RefPtr<UINode>& child, const RefPtr<UINode>& parent);
1153 
1154     // update visible change signal to children
1155     void UpdateChildrenVisible(VisibleType preVisibility, VisibleType currentVisibility) const;
1156 
1157     void CollectRemovedChildren(const std::list<RefPtr<UINode>>& children,
1158         std::list<int32_t>& removedElmtId, bool isEntry);
1159     void CollectRemovedChild(const RefPtr<UINode>& child, std::list<int32_t>& removedElmtId);
1160     void CollectCleanedChildren(const std::list<RefPtr<UINode>>& children, std::list<int32_t>& removedElmtId,
1161         std::list<int32_t>& reservedElmtId, bool isEntry);
1162     void CollectReservedChildren(std::list<int32_t>& reservedElmtId);
OnCollectRemoved()1163     virtual void OnCollectRemoved() {}
1164 
1165     bool needCallChildrenUpdate_ = true;
1166 
1167     bool layoutSeperately_ = false;
1168 
PaintDebugBoundary(bool flag)1169     virtual void PaintDebugBoundary(bool flag) {}
1170 
1171     void TraversingCheck(RefPtr<UINode> node = nullptr, bool withAbort = false);
1172 
1173     PipelineContext* context_ = nullptr;
1174 
1175     /**
1176      * @brief Transform the [changeIdx] given by child [id] to corresponding position in [this] node.
1177      *
1178      * @param changeIdx change index in child [id].
1179      * @param id the accessibilityId of child.
1180      */
1181     int32_t CalcAbsPosition(int32_t changeIdx, int64_t id) const;
1182     const static std::set<std::string> layoutTags_;
1183     std::string tag_ = "UINode";
1184     int32_t depth_ = Infinity<int32_t>();
1185     int32_t hostRootId_ = 0;
1186     int32_t hostPageId_ = 0;
1187     int32_t nodeId_ = 0;
1188     int32_t jsBuilderNodeId_ = -1;
1189     int64_t accessibilityId_ = -1;
1190     int32_t layoutPriority_ = 0;
1191     int32_t rootNodeId_ = 0; // host is Page or NavDestination
1192     int32_t themeScopeId_ = 0;
1193     int32_t subtreeIgnoreCount_ = 0;
1194 
1195 private:
1196     void DoAddChild(std::list<RefPtr<UINode>>::iterator& it, const RefPtr<UINode>& child, bool silently = false,
1197         bool addDefaultTransition = false);
1198     bool CanAddChildWhenTopNodeIsModalUec(std::list<RefPtr<UINode>>::iterator& curIter);
1199     void UpdateDrawChildObserver(const RefPtr<UINode>& child);
1200 
1201     void SetObserverParentForDrawChildren(const RefPtr<UINode>& parent);
ClearObserverParentForDrawChildren()1202     void ClearObserverParentForDrawChildren()
1203     {
1204         drawChildrenParent_.Reset();
1205         isObservedByDrawChildren_ = false;
1206         for (const auto& child : GetChildren()) {
1207             child->ClearObserverParentForDrawChildren();
1208         }
1209     }
1210 
ExecuteAfterAttachMainTreeTasks()1211     void ExecuteAfterAttachMainTreeTasks()
1212     {
1213         for (auto& task : afterAttachMainTreeTasks_) {
1214             if (task) {
1215                 task();
1216             }
1217         }
1218         afterAttachMainTreeTasks_.clear();
1219     }
1220     bool CheckThreadSafeNodeTree(bool needCheck);
1221     virtual bool MaybeRelease() override;
1222 
1223     std::list<RefPtr<UINode>> children_;
1224     // disappearingChild、index、branchId
1225     std::list<std::tuple<RefPtr<UINode>, uint32_t, int32_t>> disappearingChildren_;
1226     std::unique_ptr<PerformanceCheckNode> nodeInfo_;
1227     WeakPtr<UINode> parent_; // maybe wrong when not on the tree
1228     WeakPtr<UINode> ancestor_; // always correct parent ptr, used to remove duplicates when inserting child nodes
1229     bool isRoot_ = false;
1230     bool onMainTree_ = false;
1231     bool isThreadSafeNode_ = false;
1232     bool isFree_ = false; // the thread safe node in free state can be operated by non UI threads
1233     std::vector<std::function<void()>> afterAttachMainTreeTasks_;
1234     bool removeSilently_ = true;
1235     bool isInDestroying_ = false;
1236     bool isDisappearing_ = false;
1237     bool isBuildByJS_ = false;
1238     bool isRootBuilderNode_ = false;
1239     bool isArkTsFrameNode_ = false;
1240     bool isArkTsRenderNode_ = false;
1241     bool isTraversing_ = false;
1242     bool isAllowUseParentTheme_ = true;
1243     NodeStatus nodeStatus_ = NodeStatus::NORMAL_NODE;
1244     RootNodeType rootNodeType_ = RootNodeType::PAGE_ETS_TAG;
1245     InteractionEventBindingInfo eventBindingInfo_;
1246     RefPtr<ExportTextureInfo> exportTextureInfo_;
1247     int32_t instanceId_ = -1;
1248     int32_t apiVersion_ = 0;
1249     uint32_t nodeFlag_ { 0 };
1250     bool isNodeAdapter_ = false;
1251 
1252     int32_t restoreId_ = -1;
1253 
1254     bool useOffscreenProcess_ = false;
1255 
1256     bool isCNode_ = false;
1257     bool isDestroyingState_ = false;
1258     bool isAllowAddChildBelowModalUec_ = true;
1259 
1260     std::function<void(int32_t)> updateJSInstanceCallback_;
1261     std::function<void()> lazyBuilderFunc_;
1262     std::function<void(int32_t, RefPtr<UINode>&)> updateNodeFunc_;
1263     std::function<void()> updateNodeConfig_;
1264 
1265     std::string debugLine_;
1266     std::string viewId_;
1267     void* externalData_ = nullptr;
1268     std::function<void(int32_t)> destroyCallback_;
1269     // Other components cannot be masked above the modal uiextension,
1270     // except for the modal uiextension
1271     // Used to mark modal uiextension count below the root node
1272     int32_t modalUiextensionCount_ = 0;
1273     bool isAccessibilityVirtualNode_ = false;
1274     WeakPtr<UINode> parentForAccessibilityVirtualNode_;
1275     bool isFirstAccessibilityVirtualNode_ = false;
1276     // the flag to block dirty mark.
1277     bool isFreeze_ = false;
1278     bool allowReusableV2Descendant_ = true;
1279     bool shouldRerender_ = true;
1280     bool isDarkMode_ = false;
1281     bool measureAnyWay_ = false;
1282     bool shouldClearCache_ = true;
1283     friend class RosenRenderContext;
1284     ACE_DISALLOW_COPY_AND_MOVE(UINode);
1285     bool isMoving_ = false;
1286     bool isCrossLanguageAttributeSetting_ = false;
1287     std::optional<bool> userFreeze_;
1288     WeakPtr<UINode> drawChildrenParent_;
1289     bool isObservedByDrawChildren_ = false;
1290 
1291     bool uiNodeGcEnable_ = false;
1292 };
1293 
1294 } // namespace OHOS::Ace::NG
1295 
1296 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_UI_NODE_H
1297