• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "interfaces/inner_api/ace_kit/include/ui/view_factory/abstract_view_factory.h"
17 
18 #include "interfaces/inner_api/ace_kit/include/ui/view/frame_node.h"
19 #include "interfaces/inner_api/ace_kit/src/view/extend_pattern.h"
20 #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h"
21 
22 #include "core/components_ng/base/frame_node.h"
23 
24 namespace OHOS::Ace::Kit {
CreateFrameNode(const std::string & tag,int32_t nodeId,const RefPtr<Pattern> & pattern,bool isRoot,bool isLayoutNode)25 RefPtr<FrameNode> AbstractViewFactory::CreateFrameNode(
26     const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot, bool isLayoutNode)
27 {
28     auto aceFrameNode = NG::FrameNode::GetOrCreateFrameNode(
29         tag, nodeId, [pattern]() { return AceType::MakeRefPtr<ExtendPattern>(pattern); });
30     CHECK_NULL_RETURN(aceFrameNode, nullptr);
31     auto frameNode = AceType::DynamicCast<FrameNodeImpl>(aceFrameNode->GetKitNode());
32     if (frameNode == nullptr) {
33         frameNode = AceType::MakeRefPtr<FrameNodeImpl>(aceFrameNode, pattern);
34         frameNode->InitializePatternAndContext();
35         pattern->SetHost(frameNode);
36     }
37 
38     return frameNode;
39 }
40 } // namespace OHOS::Ace::Kit
41