Skip to content

Commit

Permalink
Fix bad fix for size_t -> int truncation from RN merge (#10688)
Browse files Browse the repository at this point in the history
* Fix bad fix for size_t -> int truncation from RN merge

* Change files
  • Loading branch information
acoates-ms committed Oct 6, 2022
1 parent 6a9f59a commit 3ef3a98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix bad fix for size_t -> int truncation from RN merge",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ static LayoutableSmallVector<Rect> calculateTransformedFrames(
auto transformedFrames = LayoutableSmallVector<Rect>{size};
auto transformation = Transform::Identity();

for (size_t i = size - 1; i >= 0; --i) { // changed from int to size_t, make PR upstream
for (size_t i = size; i > 0; --i) { // use size_t instead of int, and modify loop to avoid underflow, make PR upstream (Note changes to all uses of i in loop)
auto currentShadowNode =
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i));
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i - 1));
auto currentFrame = currentShadowNode->getLayoutMetrics().frame;

if (policy.includeTransform) {
if (Transform::isVerticalInversion(transformation)) {
auto parentShadowNode =
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i + 1));
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i));
currentFrame.origin.y =
parentShadowNode->getLayoutMetrics().frame.size.height -
currentFrame.size.height - currentFrame.origin.y;
}

if (Transform::isHorizontalInversion(transformation)) {
auto parentShadowNode =
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i + 1));
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i));
currentFrame.origin.x =
parentShadowNode->getLayoutMetrics().frame.size.width -
currentFrame.size.width - currentFrame.origin.x;
}

if (i != size - 1) {
if (i != size) {
auto parentShadowNode =
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i + 1));
traitCast<LayoutableShadowNode const *>(shadowNodeList.at(i));
auto contentOritinOffset = parentShadowNode->getContentOriginOffset();
if (Transform::isVerticalInversion(transformation)) {
contentOritinOffset.y = -contentOritinOffset.y;
Expand All @@ -65,7 +65,7 @@ static LayoutableSmallVector<Rect> calculateTransformedFrames(
transformation = transformation * currentShadowNode->getTransform();
}

transformedFrames[i] = currentFrame;
transformedFrames[i - 1] = currentFrame;
}

return transformedFrames;
Expand Down

0 comments on commit 3ef3a98

Please sign in to comment.