Fabric: Simplification of UIManager::getRelativeLayoutMetrics

Summary:
Using of the new API makes clear that we don't need to calculate the newest descendant node.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21480202

fbshipit-source-id: c54998573baffe4a05726e3402da027f052b049a
This commit is contained in:
Valentin Shergin authored and Facebook GitHub Bot committed 2020-05-18 14:08:27 -07:00
1 parent caab26e0c3
commit dafa975352
1 file changed
+6 -11
+6 -11
View File
@@ -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<LayoutableShadowNode const *>(newestShadowNode.get());
auto layoutableAncestorShadowNode =
traitCast<LayoutableShadowNode const *>(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 {