1 /* 2 * Copyright (c) 2021 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 "core/components/navigator/navigator_element.h" 17 18 #include "core/components/navigator/render_navigator.h" 19 #include "core/components/stage/stage_element.h" 20 21 namespace OHOS::Ace { 22 PerformBuild()23void NavigatorElement::PerformBuild() 24 { 25 SoleChildElement::PerformBuild(); 26 27 auto parent = GetParent().Upgrade(); 28 while (parent) { 29 auto stage = AceType::DynamicCast<SectionStageElement>(parent); 30 if (stage) { 31 SetTargetContainer(stage); 32 return; 33 } 34 parent = parent->GetParent().Upgrade(); 35 } 36 } 37 OnClick()38void NavigatorElement::OnClick() 39 { 40 auto renderNode = AceType::DynamicCast<RenderNavigator>(renderNode_); 41 renderNode->NavigatePage(); 42 } 43 SetTargetContainer(const WeakPtr<StageElement> & targetContainer,bool useSubStage)44void NavigatorElement::SetTargetContainer(const WeakPtr<StageElement>& targetContainer, bool useSubStage) 45 { 46 auto renderNode = AceType::DynamicCast<RenderNavigator>(renderNode_); 47 if (renderNode) { 48 renderNode->SetTargetContainer(targetContainer, useSubStage); 49 } 50 } 51 52 } // namespace OHOS::Ace 53