• 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 "ui/view_stack/view_stack_processor.h"
17 
18 #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h"
19 #include "ui/base/utils/utils.h"
20 
21 #include "core/components_ng/base/view_stack_processor.h"
22 
23 namespace OHOS::Ace::Kit {
24 
ClaimNodeId()25 int32_t ViewStackProcessor::ClaimNodeId()
26 {
27     return NG::ViewStackProcessor::GetInstance()->ClaimNodeId();
28 }
29 
Push(const RefPtr<FrameNode> & node)30 void ViewStackProcessor::Push(const RefPtr<FrameNode>& node)
31 {
32     auto nodeImpl = AceType::DynamicCast<FrameNodeImpl>(node);
33     CHECK_NULL_VOID(nodeImpl);
34     NG::ViewStackProcessor::GetInstance()->Push(nodeImpl->PopAceNode());
35 }
36 
GetTopNode()37 RefPtr<FrameNode> ViewStackProcessor::GetTopNode()
38 {
39     auto* mainNode = NG::ViewStackProcessor::GetInstance()->GetMainFrameNode();
40     CHECK_NULL_RETURN(mainNode, nullptr);
41     auto kitNode = mainNode->GetKitNode();
42     if (!kitNode) {
43         kitNode = Referenced::MakeRefPtr<FrameNodeImpl>(AceType::Claim(mainNode));
44     }
45     return kitNode;
46 }
47 
48 } // namespace OHOS::Ace::Kit
49