Skip to content

Commit

Permalink
LayoutAnimations: assert that tag >0 instead of != 0
Browse files Browse the repository at this point in the history
Summary:
LayoutAnimations: assert that tag >0 instead of != 0. It's possible that a corrupt tag value would be below zero which is not valid.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271515

fbshipit-source-id: a62445ad29d60e5180e62ec4c6d5b08784655808
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 5, 2021
1 parent 1c2a95d commit 95cab24
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
// All generated Update mutations must have an "old" and "new"
// ShadowView. Checking for nonzero tag doesn't guarantee that the views
// are valid/correct, just that something is there.
assert(updateMutation.oldChildShadowView.tag != 0);
assert(updateMutation.newChildShadowView.tag != 0);
assert(updateMutation.oldChildShadowView.tag > 0);
assert(updateMutation.newChildShadowView.tag > 0);

mutationsList.push_back(updateMutation);
PrintMutationInstruction("Animation Progress:", updateMutation);
Expand Down Expand Up @@ -125,9 +125,9 @@ void LayoutAnimationDriver::animationMutationsForFrame(
keyframe.viewPrev,
finalMutationForKeyFrame.newChildShadowView,
finalMutationForKeyFrame.index};
assert(mutation.oldChildShadowView.tag != 0);
assert(mutation.oldChildShadowView.tag > 0);
assert(
mutation.newChildShadowView.tag != 0 ||
mutation.newChildShadowView.tag > 0 ||
finalMutationForKeyFrame.type == ShadowViewMutation::Remove ||
finalMutationForKeyFrame.type == ShadowViewMutation::Delete);
mutationsList.push_back(mutation);
Expand All @@ -142,8 +142,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
keyframe.viewPrev,
keyframe.viewEnd,
-1};
assert(mutation.oldChildShadowView.tag != 0);
assert(mutation.newChildShadowView.tag != 0);
assert(mutation.oldChildShadowView.tag > 0);
assert(mutation.newChildShadowView.tag > 0);
mutationsList.push_back(mutation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ LayoutAnimationKeyFrameManager::pullTransaction(
// already made in the current animation, and start the animation
// from this point.
keyFrame.viewStart = conflictingKeyFrame.viewPrev;
assert(keyFrame.viewStart.tag != 0);
assert(keyFrame.viewStart.tag > 0);
keyFrame.initialProgress = 0;

// We're guaranteed that a tag only has one animation associated
Expand All @@ -1154,9 +1154,9 @@ LayoutAnimationKeyFrameManager::pullTransaction(
}
}

assert(keyFrame.viewStart.tag != 0);
assert(keyFrame.viewEnd.tag != 0);
assert(keyFrame.viewPrev.tag != 0);
assert(keyFrame.viewStart.tag > 0);
assert(keyFrame.viewEnd.tag > 0);
assert(keyFrame.viewPrev.tag > 0);
keyFramesToAnimate.push_back(keyFrame);
}

Expand Down Expand Up @@ -1245,9 +1245,9 @@ LayoutAnimationKeyFrameManager::pullTransaction(
PrintMutationInstruction(
"Queueing up final mutation instruction - update:",
mutationInstruction);
assert(mutationInstruction.oldChildShadowView.tag != 0);
assert(mutationInstruction.oldChildShadowView.tag > 0);
assert(
mutationInstruction.newChildShadowView.tag != 0 ||
mutationInstruction.newChildShadowView.tag > 0 ||
mutationInstruction.type == ShadowViewMutation::Delete ||
mutationInstruction.type == ShadowViewMutation::Remove);
finalConflictingMutations.push_back(mutationInstruction);
Expand All @@ -1268,17 +1268,17 @@ LayoutAnimationKeyFrameManager::pullTransaction(
auto generatedPenultimateMutation =
ShadowViewMutation::UpdateMutation(
keyFrame.viewPrev, mutatedShadowView);
assert(generatedPenultimateMutation.oldChildShadowView.tag != 0);
assert(generatedPenultimateMutation.newChildShadowView.tag != 0);
assert(generatedPenultimateMutation.oldChildShadowView.tag > 0);
assert(generatedPenultimateMutation.newChildShadowView.tag > 0);
PrintMutationInstruction(
"Queueing up penultimate mutation instruction - synthetic",
generatedPenultimateMutation);
finalConflictingMutations.push_back(generatedPenultimateMutation);

auto generatedMutation = ShadowViewMutation::UpdateMutation(
mutatedShadowView, keyFrame.viewEnd);
assert(generatedMutation.oldChildShadowView.tag != 0);
assert(generatedMutation.newChildShadowView.tag != 0);
assert(generatedMutation.oldChildShadowView.tag > 0);
assert(generatedMutation.newChildShadowView.tag > 0);
PrintMutationInstruction(
"Queueing up final mutation instruction - synthetic",
generatedMutation);
Expand Down Expand Up @@ -1451,8 +1451,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
auto generatedPenultimateMutation =
ShadowViewMutation::UpdateMutation(
keyFrame.viewPrev, mutatedShadowView);
assert(generatedPenultimateMutation.oldChildShadowView.tag != 0);
assert(generatedPenultimateMutation.newChildShadowView.tag != 0);
assert(generatedPenultimateMutation.oldChildShadowView.tag > 0);
assert(generatedPenultimateMutation.newChildShadowView.tag > 0);
PrintMutationInstruction(
"No Animation: Queueing up penultimate mutation instruction - synthetic",
generatedPenultimateMutation);
Expand All @@ -1461,8 +1461,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(

auto generatedMutation = ShadowViewMutation::UpdateMutation(
mutatedShadowView, keyFrame.viewEnd);
assert(generatedMutation.oldChildShadowView.tag != 0);
assert(generatedMutation.newChildShadowView.tag != 0);
assert(generatedMutation.oldChildShadowView.tag > 0);
assert(generatedMutation.newChildShadowView.tag > 0);
PrintMutationInstruction(
"No Animation: Queueing up final mutation instruction - synthetic",
generatedMutation);
Expand Down

0 comments on commit 95cab24

Please sign in to comment.