From 95cab24a6e58eadfcd638060563cb70d1220fca2 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 5 Feb 2021 00:54:02 -0800 Subject: [PATCH] LayoutAnimations: assert that tag >0 instead of != 0 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 --- .../animations/LayoutAnimationDriver.cpp | 12 ++++---- .../LayoutAnimationKeyFrameManager.cpp | 28 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 7acf7a02826..4c970f87bcb 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -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); @@ -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); @@ -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); } } diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 6fb792cb320..cb742975a16 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -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 @@ -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); } @@ -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); @@ -1268,8 +1268,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( "Queueing up penultimate mutation instruction - synthetic", generatedPenultimateMutation); @@ -1277,8 +1277,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( "Queueing up final mutation instruction - synthetic", generatedMutation); @@ -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); @@ -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);