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/coverage/render_coverage.h" 17 18 #include "base/log/log.h" 19 #include "core/components/common/properties/alignment.h" 20 21 namespace OHOS::Ace { 22 Create()23RefPtr<RenderNode> RenderCoverage::Create() 24 { 25 return AceType::MakeRefPtr<RenderCoverage>(); 26 } 27 RenderCoverage()28RenderCoverage::RenderCoverage() {} 29 Update(const RefPtr<Component> & component)30void RenderCoverage::Update(const RefPtr<Component>& component) 31 { 32 auto coverageComponent = AceType::DynamicCast<CoverageComponent>(component); 33 title_ = coverageComponent->GetTextVal(); 34 x_ = coverageComponent->GetX(); 35 y_ = coverageComponent->GetY(); 36 align_ = coverageComponent->GetAlignment(); 37 } 38 PerformLayout()39void RenderCoverage::PerformLayout() 40 { 41 const std::list<RefPtr<RenderNode>>& children = GetChildren(); 42 LayoutParam innerLayout = GetLayoutParam(); 43 auto firstChild = children.begin(); 44 if (firstChild == children.end()) { 45 LOGD("RenderCoverage: firstChild is null."); 46 return; 47 } 48 (*firstChild)->Layout(innerLayout); 49 Size size = (*firstChild)->GetLayoutSize(); 50 SetLayoutSize(size); 51 52 auto secondChild = ++firstChild; 53 if (secondChild == children.end()) { 54 LOGD("RenderCoverage: secondChild is null."); 55 return; 56 } 57 LayoutParam secondChildLayoutParam; 58 secondChildLayoutParam.SetMaxSize(size); 59 (*secondChild)->Layout(secondChildLayoutParam); 60 } 61 62 } // namespace OHOS::Ace 63