diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index 3de1d006fde..761a87c3efe 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -213,27 +213,22 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( true); }); } else { + // It is possible for JavaScript (or other callers) to have a reference + // to a previous version of ShadowNodes, but we enforce that + // metrics are only calculated on most recently committed versions. owningAncestorShadowNode = getNewestCloneOfShadowNode(*ancestorShadowNode); ancestorShadowNode = owningAncestorShadowNode.get(); } - // Get latest version of both the ShadowNode and its ancestor. - // It is possible for JS (or other callers) to have a reference - // to a previous version of ShadowNodes, but we enforce that - // metrics are only calculated on most recently committed versions. - auto newestShadowNode = getNewestCloneOfShadowNode(shadowNode); - - auto layoutableShadowNode = - traitCast(newestShadowNode.get()); auto layoutableAncestorShadowNode = traitCast(ancestorShadowNode); - if (!layoutableShadowNode || !layoutableAncestorShadowNode) { + if (!layoutableAncestorShadowNode) { return EmptyLayoutMetrics; } - return layoutableShadowNode->getRelativeLayoutMetrics( - *layoutableAncestorShadowNode, policy); + return LayoutableShadowNode::computeRelativeLayoutMetrics( + shadowNode.getFamily(), *layoutableAncestorShadowNode, policy); } void UIManager::updateState(StateUpdate const &stateUpdate) const {