From c4cd46e246655b8e062a53466aa2a81dca5e760d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 27 Apr 2023 09:47:26 -0700 Subject: [PATCH 1/3] Deprecate Java YogaConfig.setUseLegacyStretchBehaviour() Summary: Now that our own usages are removed, mark this as deprecated to encourage users to move to the errata API. The same will be done to variants of this function on other platforms before releasing, and the functions will be removed after releasing. Differential Revision: D45300343 fbshipit-source-id: 1dd6265edda7446ca2763c8f1dc238957c95eb5e --- java/com/facebook/yoga/YogaConfig.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com/facebook/yoga/YogaConfig.java b/java/com/facebook/yoga/YogaConfig.java index 87928f02..93131359 100644 --- a/java/com/facebook/yoga/YogaConfig.java +++ b/java/com/facebook/yoga/YogaConfig.java @@ -22,7 +22,13 @@ public abstract class YogaConfig { * Yoga previously had an error where containers would take the maximum space possible instead of the minimum * like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch; * Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour. + * + * @deprecated "setUseLegacyStretchBehaviour" will be removed in the next release. Usage should be replaced with + * "setErrata(YogaErrata.ALL)" to opt out of all future breaking conformance fixes, or + * "setErrata(YogaErrata.STRETCH_FLEX_BASIS)" to opt out of the specific conformance fix previously disabled by + * "UseLegacyStretchBehaviour". */ + @Deprecated public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour); public abstract void setErrata(YogaErrata errata); -- 2.50.1.windows.1 From d67606a0cc26e58b6d47b25914d8ab91e5416d83 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 27 Apr 2023 09:47:26 -0700 Subject: [PATCH 2/3] Move YogaKit to YGErrataClassic Summary: YogaKit integrates Yoga with UIKit as a higher level framework. It does not expose config setting to users. We set YGErrataClassic for now to prioritize compatibility instead of conformance (YogaKit is relatively used in fbsource as well). I'm also tempted to remove the usage of ExperimentalWebFlexBasis since last I heard rozelle thought it was generally broken, but I am a bit afraid to if it has been enabled so long, and is used in many cases in Meta. Differential Revision: https://internalfb.com/D45298803 fbshipit-source-id: 37a097b06edc5043416303ca0d7b51ed70925797 --- YogaKit/Source/YGLayout.m | 1 + 1 file changed, 1 insertion(+) diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index 1627a74f..638a81da 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -175,6 +175,7 @@ static YGConfigRef globalConfig; globalConfig = YGConfigNew(); YGConfigSetExperimentalFeatureEnabled( globalConfig, YGExperimentalFeatureWebFlexBasis, true); + YGConfigSetErrata(globalConfig, YGErrataClassic); YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale); } -- 2.50.1.windows.1 From 10bf9f11fdbb16de66504a33b324c60649c28827 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 27 Apr 2023 09:47:48 -0700 Subject: [PATCH 3/3] Add C# bindings for Errata API (#1259) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1259 Wires C ABI to C# bindings using `System.Runtime.InteropServices`. Note that we don't have a working C# build right now, but there is [effort to address that](https://github.com/facebook/yoga/pull/1207) which may get some more effort before the Yoga release, so this keeps the bindings up to date. Reviewed By: yungsters Differential Revision: D45297676 fbshipit-source-id: 10cfb71a6220e4c7a6fc15032cd74033d4472f4b --- csharp/Facebook.Yoga/Native.cs | 6 ++++++ csharp/Facebook.Yoga/YogaConfig.cs | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 1bdc24f0..f22e5888 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -73,6 +73,12 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + public static extern void YGConfigSetErrata(YGConfigHandle config, YogaErrata errata); + + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + public static extern YogaErrata YGConfigGetErrata(YGConfigHandle config); + [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGConfigSetPointScaleFactor( YGConfigHandle config, diff --git a/csharp/Facebook.Yoga/YogaConfig.cs b/csharp/Facebook.Yoga/YogaConfig.cs index 8424401f..c4162d31 100644 --- a/csharp/Facebook.Yoga/YogaConfig.cs +++ b/csharp/Facebook.Yoga/YogaConfig.cs @@ -117,8 +117,12 @@ namespace Facebook.Yoga } } - public bool UseLegacyStretchBehaviour - { + [ObsoleteAttribute("\"UseLegacyStretchBehaviour\" will be removed in the next release. " + + "Usage should be replaced with \"Errata\" set to \"YogaErrata.All\" to opt out of all " + + "future breaking conformance fixes, or \"YogaErrata.StretchFlexBasis\" toopt out of " + + "the specific conformance fix previously disabled by \"UseLegacyStretchBehaviour\".", + true /*error*/)] + public bool UseLegacyStretchBehaviour { get { return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig); @@ -130,6 +134,19 @@ namespace Facebook.Yoga } } + public YogaErrata Errata + { + get + { + return Native.YGConfigGetErrata(_ygConfig); + } + + set + { + Native.YGConfigSetErrata(_ygConfig, value); + } + } + public float PointScaleFactor { set -- 2.50.1.windows.1