diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 131c034cb38..8933bbe2c50 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace facebook { diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index b30fdbe2252..3d246235d00 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 80b225a7504..33a4f9a9024 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -173,63 +173,5 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, void deleteAnimationsForStoppedSurfaces() const; }; -static inline bool shouldFirstComeBeforeSecondRemovesOnly( - ShadowViewMutation const &lhs, - ShadowViewMutation const &rhs) noexcept { - // Make sure that removes on the same level are sorted - highest indices must - // come first. - return (lhs.type == ShadowViewMutation::Type::Remove && - lhs.type == rhs.type) && - (lhs.parentShadowView.tag == rhs.parentShadowView.tag) && - (lhs.index > rhs.index); -} - -static inline bool shouldFirstComeBeforeSecondMutation( - ShadowViewMutation const &lhs, - ShadowViewMutation const &rhs) noexcept { - if (lhs.type != rhs.type) { - // Deletes always come last - if (lhs.type == ShadowViewMutation::Type::Delete) { - return false; - } - if (rhs.type == ShadowViewMutation::Type::Delete) { - return true; - } - - // Remove comes before insert - if (lhs.type == ShadowViewMutation::Type::Remove && - rhs.type == ShadowViewMutation::Type::Insert) { - return true; - } - if (rhs.type == ShadowViewMutation::Type::Remove && - lhs.type == ShadowViewMutation::Type::Insert) { - return false; - } - - // Create comes before insert - if (lhs.type == ShadowViewMutation::Type::Create && - rhs.type == ShadowViewMutation::Type::Insert) { - return true; - } - if (rhs.type == ShadowViewMutation::Type::Create && - lhs.type == ShadowViewMutation::Type::Insert) { - return false; - } - } else { - // Make sure that removes on the same level are sorted - highest indices - // must come first. - if (lhs.type == ShadowViewMutation::Type::Remove && - lhs.parentShadowView.tag == rhs.parentShadowView.tag) { - if (lhs.index > rhs.index) { - return true; - } else { - return false; - } - } - } - - return false; -} - } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/animations/utils.h b/ReactCommon/react/renderer/animations/utils.h new file mode 100644 index 00000000000..c5b68342d0f --- /dev/null +++ b/ReactCommon/react/renderer/animations/utils.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook { +namespace react { + +static inline bool shouldFirstComeBeforeSecondRemovesOnly( + ShadowViewMutation const &lhs, + ShadowViewMutation const &rhs) noexcept { + // Make sure that removes on the same level are sorted - highest indices must + // come first. + return (lhs.type == ShadowViewMutation::Type::Remove && + lhs.type == rhs.type) && + (lhs.parentShadowView.tag == rhs.parentShadowView.tag) && + (lhs.index > rhs.index); +} + +static inline bool shouldFirstComeBeforeSecondMutation( + ShadowViewMutation const &lhs, + ShadowViewMutation const &rhs) noexcept { + if (lhs.type != rhs.type) { + // Deletes always come last + if (lhs.type == ShadowViewMutation::Type::Delete) { + return false; + } + if (rhs.type == ShadowViewMutation::Type::Delete) { + return true; + } + + // Remove comes before insert + if (lhs.type == ShadowViewMutation::Type::Remove && + rhs.type == ShadowViewMutation::Type::Insert) { + return true; + } + if (rhs.type == ShadowViewMutation::Type::Remove && + lhs.type == ShadowViewMutation::Type::Insert) { + return false; + } + + // Create comes before insert + if (lhs.type == ShadowViewMutation::Type::Create && + rhs.type == ShadowViewMutation::Type::Insert) { + return true; + } + if (rhs.type == ShadowViewMutation::Type::Create && + lhs.type == ShadowViewMutation::Type::Insert) { + return false; + } + } else { + // Make sure that removes on the same level are sorted - highest indices + // must come first. + if (lhs.type == ShadowViewMutation::Type::Remove && + lhs.parentShadowView.tag == rhs.parentShadowView.tag) { + if (lhs.index > rhs.index) { + return true; + } else { + return false; + } + } + } + + return false; +} + +} // namespace react +} // namespace facebook