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