1 /*
2  * Copyright (c) 2022 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_ng/layout/layout_wrapper_builder.h"
17 
18 #include "base/utils/utils.h"
19 #include "core/components_ng/layout/layout_wrapper.h"
20 
21 namespace OHOS::Ace::NG {
22 
GetOrCreateWrapperByIndex(int32_t index)23 RefPtr<LayoutWrapper> LayoutWrapperBuilder::GetOrCreateWrapperByIndex(int32_t index)
24 {
25     auto realIndex = index - startIndex_;
26     auto iter = wrapperMap_.find(realIndex);
27     if (iter != wrapperMap_.end()) {
28         return iter->second;
29     }
30     auto wrapper = OnGetOrCreateWrapperByIndex(realIndex);
31     CHECK_NULL_RETURN(wrapper, nullptr);
32     wrapperMap_.try_emplace(realIndex, wrapper);
33     return wrapper;
34 }
35 
ExpandAllChildWrappers()36 const std::list<RefPtr<LayoutWrapper>>& LayoutWrapperBuilder::ExpandAllChildWrappers()
37 {
38     return OnExpandChildLayoutWrapper();
39 }
40 
RemoveAllChildInRenderTree()41 void LayoutWrapperBuilder::RemoveAllChildInRenderTree()
42 {
43     for (auto& child : wrapperMap_) {
44         child.second->SetActive(false);
45     }
46 }
47 
48 } // namespace OHOS::Ace::NG
49