From 60297d50dcb4a97d4d4d68f46047288014df5b79 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Mon, 23 Oct 2023 18:20:24 -0700 Subject: [PATCH] Add errata supporting changes to position: static (#41130) Summary: X-link: https://github.com/facebook/yoga/pull/1434 Pull Request resolved: https://github.com/facebook/react-native/pull/41130 I will use this errata to gate my changes that actually make position: static behave like the web. We have future plans to make position: relative the default again but users could still have declared certain nodes as position: static, so I think this is needed regardless. Reviewed By: NickGerleman Differential Revision: D50506915 fbshipit-source-id: b0d9e6883167de6ff002352c9288053324464cb9 --- .../src/main/java/com/facebook/yoga/YogaErrata.java | 2 ++ packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp | 2 ++ packages/react-native/ReactCommon/yoga/yoga/YGEnums.h | 1 + packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaErrata.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaErrata.java index bafb67333731df..99f53f5a8187cb 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaErrata.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaErrata.java @@ -13,6 +13,7 @@ public enum YogaErrata { NONE(0), STRETCH_FLEX_BASIS(1), STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION(2), + POSITION_STATIC_BEHAVES_LIKE_RELATIVE(4), ALL(2147483647), CLASSIC(2147483646); @@ -31,6 +32,7 @@ public static YogaErrata fromInt(int value) { case 0: return NONE; case 1: return STRETCH_FLEX_BASIS; case 2: return STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION; + case 4: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE; case 2147483647: return ALL; case 2147483646: return CLASSIC; default: throw new IllegalArgumentException("Unknown enum value: " + value); diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp b/packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp index 77e5c802376b8a..04fd7be9336bec 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp @@ -97,6 +97,8 @@ const char* YGErrataToString(const YGErrata value) { return "stretch-flex-basis"; case YGErrataStartingEndingEdgeFromFlexDirection: return "starting-ending-edge-from-flex-direction"; + case YGErrataPositionStaticBehavesLikeRelative: + return "position-static-behaves-like-relative"; case YGErrataAll: return "all"; case YGErrataClassic: diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGEnums.h b/packages/react-native/ReactCommon/yoga/yoga/YGEnums.h index ef09668c811e99..e1197444db8274 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGEnums.h +++ b/packages/react-native/ReactCommon/yoga/yoga/YGEnums.h @@ -57,6 +57,7 @@ YG_ENUM_DECL( YGErrataNone = 0, YGErrataStretchFlexBasis = 1, YGErrataStartingEndingEdgeFromFlexDirection = 2, + YGErrataPositionStaticBehavesLikeRelative = 4, YGErrataAll = 2147483647, YGErrataClassic = 2147483646) YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata) diff --git a/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h b/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h index 257e7b2409c2c7..6a085bf58da825 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h +++ b/packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h @@ -19,6 +19,7 @@ enum class Errata : uint32_t { None = YGErrataNone, StretchFlexBasis = YGErrataStretchFlexBasis, StartingEndingEdgeFromFlexDirection = YGErrataStartingEndingEdgeFromFlexDirection, + PositionStaticBehavesLikeRelative = YGErrataPositionStaticBehavesLikeRelative, All = YGErrataAll, Classic = YGErrataClassic, }; @@ -27,7 +28,7 @@ YG_DEFINE_ENUM_FLAG_OPERATORS(Errata) template <> constexpr inline int32_t ordinalCount() { - return 5; + return 6; } template <>