in ComponentKit/Core/CKComponentLayout.mm [70:104]
CKComponentRootLayout CKComputeRootComponentLayout(id<CKMountable> rootComponent,
const CKSizeRange &sizeRange,
id<CKAnalyticsListener> analyticsListener,
CK::Optional<CKBuildTrigger> buildTrigger,
CKComponentScopeRoot *scopeRoot,
std::shared_ptr<RCLayoutCache> layoutCache)
{
[analyticsListener willLayoutComponentTreeWithRootComponent:rootComponent buildTrigger:buildTrigger];
CK::Component::LayoutSystraceContext systraceContext([analyticsListener systraceListener]);
RCLayoutResult layoutResult;
if (layoutCache) {
layoutResult = RCComputeRootLayout(rootComponent, sizeRange, layoutCache);
} else {
layoutResult = {CKComputeComponentLayout(rootComponent, sizeRange, sizeRange.max), nil};
}
auto layoutLookup = CKComponentRootLayout::ComponentLayoutCache {};
layoutResult.layout.enumerateLayouts([&](const auto &l){
if ([l.component isKindOfClass:[CKComponent class]] && ((CKComponent *)l.component).controller) {
layoutLookup[l.component] = l;
}
});
const auto componentsByPredicate = buildComponentsByPredicateMap(layoutResult.layout, CKComponentAnimationPredicates());
const auto rootLayout = CKComponentRootLayout {
layoutResult,
layoutLookup,
componentsByPredicate,
};
CKDetectDuplicateComponent(rootLayout.layout());
CKVerifyTreeNodesToParentLinks(scopeRoot, rootLayout.layout());
[analyticsListener didLayoutComponentTreeWithRootComponent:rootComponent];
return rootLayout;
}