1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "core/interfaces/native/node/node_container_modifier.h"
16 
17 #include "core/components_ng/base/frame_node.h"
18 #include "core/components_ng/pattern/node_container/node_container_pattern.h"
19 #include "core/pipeline/base/element_register.h"
20 
21 namespace OHOS::Ace::NG {
Rebuild(int32_t nodeId)22 void Rebuild(int32_t nodeId)
23 {
24     auto nativeNodePt = OHOS::Ace::ElementRegister::GetInstance()->GetNodeById(nodeId);
25     auto frameNode = AceType::DynamicCast<FrameNode>(nativeNodePt);
26     CHECK_NULL_VOID(frameNode);
27     auto pattern = AceType::DynamicCast<NodeContainerPattern>(frameNode->GetPattern());
28     CHECK_NULL_VOID(pattern);
29     pattern->RemakeNode();
30 }
31 
Clean(ArkUINodeHandle node)32 void Clean(ArkUINodeHandle node)
33 {
34     auto* frameNode = reinterpret_cast<FrameNode*>(node);
35     CHECK_NULL_VOID(frameNode);
36     auto pattern = AceType::DynamicCast<NodeContainerPattern>(frameNode->GetPattern());
37     CHECK_NULL_VOID(pattern);
38     pattern->CleanChild();
39 }
40 
41 namespace NodeModifier {
GetNodeContainerModifier()42 const ArkUINodeContainerModifier* GetNodeContainerModifier()
43 {
44     static const ArkUINodeContainerModifier modifier = { Rebuild, Clean };
45     return &modifier;
46 }
47 
GetCJUINodeContainerModifier()48 const CJUINodeContainerModifier* GetCJUINodeContainerModifier()
49 {
50     static const CJUINodeContainerModifier modifier = { Rebuild, Clean };
51     return &modifier;
52 }
53 }
54 }
55