Exit early if currentShadowNode cannot be casted

Summary:
This diff fixes the bug T127619309 by exit early during calculateTransformedFrames if currentShadowNode cannot be casted

This is a bug that fired in fb4a but we didn't have a way to reproduce locally.
We are going to release this and enable feature flag with a MC

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38280674

fbshipit-source-id: 1c42c17678d8473564e4075a78d3c688efed1a23
This commit is contained in:
David Vacca
2022-08-01 13:57:36 -07:00
committed by Facebook GitHub Bot
parent c504d038c4
commit a561df0e96
@@ -30,6 +30,11 @@ static LayoutableSmallVector<Rect> calculateTransformedFrames(
for (int i = size - 1; i >= 0; --i) {
auto currentShadowNode =
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i));
if (!currentShadowNode) {
return {};
}
auto currentFrame = currentShadowNode->getLayoutMetrics().frame;
if (policy.includeTransform) {
@@ -166,6 +171,11 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
auto transformedFrames = shouldCalculateTransformedFrames
? calculateTransformedFrames(shadowNodeList, policy)
: LayoutableSmallVector<Rect>();
if (transformedFrames.empty()) {
return EmptyLayoutMetrics;
}
auto layoutMetrics = descendantLayoutableNode->getLayoutMetrics();
auto &resultFrame = layoutMetrics.frame;
resultFrame.origin = {0, 0};