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/pattern/node_container/node_container_pattern.h"
18
19 namespace OHOS::Ace::NG {
Rebuild(int32_t nodeId)20 void Rebuild(int32_t nodeId)
21 {
22 auto nativeNodePt = OHOS::Ace::ElementRegister::GetInstance()->GetNodeById(nodeId);
23 auto frameNode = AceType::DynamicCast<FrameNode>(nativeNodePt);
24 CHECK_NULL_VOID(frameNode);
25 auto pattern = AceType::DynamicCast<NodeContainerPattern>(frameNode->GetPattern());
26 CHECK_NULL_VOID(pattern);
27 pattern->RemakeNode();
28 }
29
Clean(ArkUINodeHandle node)30 void Clean(ArkUINodeHandle node)
31 {
32 auto* frameNode = reinterpret_cast<FrameNode*>(node);
33 CHECK_NULL_VOID(frameNode);
34 auto pattern = AceType::DynamicCast<NodeContainerPattern>(frameNode->GetPattern());
35 CHECK_NULL_VOID(pattern);
36 pattern->CleanChild();
37 }
38
39 namespace NodeModifier {
GetNodeContainerModifier()40 const ArkUINodeContainerModifier* GetNodeContainerModifier()
41 {
42 CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
43 static const ArkUINodeContainerModifier modifier = {
44 .rebuild = Rebuild,
45 .clean = Clean,
46 };
47 CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
48 return &modifier;
49 }
50
GetCJUINodeContainerModifier()51 const CJUINodeContainerModifier* GetCJUINodeContainerModifier()
52 {
53 CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
54 static const CJUINodeContainerModifier modifier = {
55 .rebuild = Rebuild,
56 .clean = Clean,
57 };
58 CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
59 return &modifier;
60 }
61 }
62 }
63