Set up gating for position: relative as default (#41711)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41711

We want the default position to be relative for a number of reasons. This should be fine for the most part but putting a killswitch around this change just in case things blow up.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D51643446

fbshipit-source-id: 4f7d1e498eb663801ef6d88ba9cd9b64c781d66b
This commit is contained in:
Joe Vilches
2023-11-29 20:35:14 -08:00
committed by Facebook GitHub Bot
parent ee31ec9a3f
commit 05ed0079ff
6 changed files with 16 additions and 1 deletions
@@ -284,6 +284,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
CoreFeatures::enableClonelessStateProgression = true;
}
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:position_relative_default")) {
CoreFeatures::positionRelativeDefault = true;
}
auto componentRegistryFactory =
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) {
@@ -182,4 +182,7 @@ public class ReactFeatureFlags {
* when there is work to do.
*/
public static boolean enableOnDemandReactChoreographer = false;
/** When enabled, the default value of the position style property is relative. */
public static boolean positionRelativeDefault = false;
}
@@ -424,6 +424,8 @@ void Binding::installFabricUIManager(
getFeatureFlagValue("enableClonelessStateProgression");
CoreFeatures::excludeYogaFromRawProps =
getFeatureFlagValue("excludeYogaFromRawProps");
CoreFeatures::positionRelativeDefault =
getFeatureFlagValue("positionRelativeDefault");
// RemoveDelete mega-op
ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction =
@@ -38,7 +38,9 @@ YogaStylableProps::YogaStylableProps(
/*static*/ const yoga::Style& YogaStylableProps::defaultStyle() {
static const auto defaultStyle = []() {
yoga::Style style;
style.setPositionType(yoga::PositionType::Static);
style.setPositionType(
CoreFeatures::positionRelativeDefault ? yoga::PositionType::Relative
: yoga::PositionType::Static);
return style;
}();
@@ -23,5 +23,6 @@ bool CoreFeatures::enableClonelessStateProgression = false;
bool CoreFeatures::excludeYogaFromRawProps = false;
bool CoreFeatures::enableMicrotasks = false;
bool CoreFeatures::enableReportEventPaintTime = false;
bool CoreFeatures::positionRelativeDefault = false;
} // namespace facebook::react
@@ -67,6 +67,9 @@ class CoreFeatures {
// Report paint time inside the Event Timing API implementation
// (PerformanceObserver).
static bool enableReportEventPaintTime;
// Sets the default position of nodes to be relative instead of static
static bool positionRelativeDefault;
};
} // namespace facebook::react