• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
17 
18 #include "core/components_ng/base/view_stack_processor.h"
19 #include "core/components_ng/base/view_stack_model_ng.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/models/view_stack_model_impl.h"
21 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
22 
23 namespace OHOS::Ace {
24 
25 std::unique_ptr<ViewStackModel> ViewStackModel::instance_ = nullptr;
26 
GetInstance()27 ViewStackModel* ViewStackModel::GetInstance()
28 {
29     if (!instance_) {
30 #ifdef NG_BUILD
31         instance_.reset(new NG::ViewStackModelNG());
32 #else
33         if (Container::IsCurrentUseNewPipeline()) {
34             instance_.reset(new NG::ViewStackModelNG());
35         } else {
36             instance_.reset(new Framework::ViewStackModelImpl());
37         }
38 #endif
39     }
40     return instance_.get();
41 }
42 
43 } // namespace OHOS::Ace
44 
45 namespace OHOS::Ace::Framework {
Pop()46 void JSContainerBase::Pop()
47 {
48     ViewStackModel::GetInstance()->PopContainer();
49 }
50 
JSBind()51 void JSContainerBase::JSBind()
52 {
53     JSClass<JSContainerBase>::Declare("JSContainerBase");
54     // staticmethods
55     MethodOptions opt = MethodOptions::NONE;
56     JSClass<JSContainerBase>::StaticMethod("pop", &JSContainerBase::Pop, opt);
57     JSClass<JSContainerBase>::Inherit<JSViewAbstract>();
58 }
59 } // namespace OHOS::Ace::Framework
60