Decouple clipping logic from border drawing (#46191)

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

Borders should not have to deal with clipping logic, that is fairly independent.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D61418470

fbshipit-source-id: 762dbf30d50b5ce9b2b73720e58625447d8bf00e
This commit is contained in:
Joe Vilches
2024-08-30 02:00:19 -07:00
committed by Facebook GitHub Bot
parent 7653f7600e
commit 4f50aca247
20 changed files with 218 additions and 92 deletions
@@ -16,6 +16,7 @@
#import <React/RCTBoxShadow.h>
#import <React/RCTConversions.h>
#import <React/RCTLocalizedString.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/renderer/components/view/ViewComponentDescriptor.h>
#import <react/renderer/components/view/ViewEventEmitter.h>
#import <react/renderer/components/view/ViewProps.h>
@@ -308,7 +309,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
// `overflow`
if (oldViewProps.getClipsContentToBounds() != newViewProps.getClipsContentToBounds()) {
self.clipsToBounds = newViewProps.getClipsContentToBounds();
self.currentContainerView.clipsToBounds = newViewProps.getClipsContentToBounds();
needsInvalidateLayer = YES;
}
@@ -577,7 +578,6 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
_eventEmitter.reset();
_isJSResponder = NO;
_removeClippedSubviews = NO;
_useCustomContainerView = NO;
_reactSubviews = [NSMutableArray new];
}
@@ -605,7 +605,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
BOOL isPointInside = [self pointInside:point withEvent:event];
BOOL clipsToBounds = self.clipsToBounds;
BOOL clipsToBounds = self.currentContainerView.clipsToBounds;
clipsToBounds = clipsToBounds || _layoutMetrics.overflowInset == EdgeInsets{};
@@ -696,7 +696,8 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
{
const auto borderMetrics = _props->resolveBorderMetrics(_layoutMetrics);
BOOL nonZeroBorderWidth = !(borderMetrics.borderWidths.isUniform() && borderMetrics.borderWidths.left == 0);
return _props->getClipsContentToBounds() && (!_props->boxShadow.empty() || nonZeroBorderWidth);
BOOL clipToPaddingBox = ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
return _props->getClipsContentToBounds() && (!_props->boxShadow.empty() || (clipToPaddingBox && nonZeroBorderWidth));
}
// This UIView is the UIView that holds all subviews. It is sometimes not self
@@ -710,6 +711,10 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
for (UIView *subview in self.subviews) {
[_containerView addSubview:subview];
}
_containerView.clipsToBounds = self.clipsToBounds;
self.clipsToBounds = NO;
_containerView.layer.mask = self.layer.mask;
self.layer.mask = nil;
[self addSubview:_containerView];
}
@@ -719,6 +724,8 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
for (UIView *subview in _containerView.subviews) {
[self addSubview:subview];
}
self.clipsToBounds = _containerView.clipsToBounds;
self.layer.mask = _containerView.layer.mask;
[_containerView removeFromSuperview];
_containerView = nil;
}
@@ -788,7 +795,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
// iOS draws borders in front of the content whereas CSS draws them behind
// the content. For this reason, only use iOS border drawing when clipping
// or when the border is hidden.
borderMetrics.borderWidths.left == 0 || self.clipsToBounds ||
borderMetrics.borderWidths.left == 0 || self.currentContainerView.clipsToBounds ||
(colorComponentsFromColor(borderMetrics.borderColors.left).alpha == 0 &&
(*borderMetrics.borderColors.left).getUIColor() != nullptr));
@@ -813,17 +820,25 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
[self.layer addSublayer:_backgroundColorLayer];
}
CAShapeLayer *maskLayer = [self
createMaskLayer:self.bounds
cornerInsets:RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero)];
_backgroundColorLayer.backgroundColor = backgroundColor;
_backgroundColorLayer.mask = maskLayer;
if (borderMetrics.borderRadii.isUniform()) {
_backgroundColorLayer.mask = nil;
_backgroundColorLayer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
_backgroundColorLayer.cornerCurve = CornerCurveFromBorderCurve(borderMetrics.borderCurves.topLeft);
} else {
CAShapeLayer *maskLayer =
[self createMaskLayer:self.bounds
cornerInsets:RCTGetCornerInsets(
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero)];
_backgroundColorLayer.mask = maskLayer;
_backgroundColorLayer.cornerRadius = 0;
}
}
// Stage 2. Border Rendering
// borders
if (useCoreAnimationBorderRendering) {
layer.mask = nil;
[_borderLayer removeFromSuperlayer];
_borderLayer = nil;
layer.borderWidth = (CGFloat)borderMetrics.borderWidths.left;
CGColorRef borderColor = RCTCreateCGColorRefFromSharedColor(borderMetrics.borderColors.left);
@@ -880,37 +895,9 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
// If mutations are applied inside of Animation block, it may cause _borderLayer to be animated.
// To stop that, imperatively remove all animations from _borderLayer.
[_borderLayer removeAllAnimations];
// Stage 2.5. Custom Clipping Mask
CAShapeLayer *maskLayer = nil;
CGFloat cornerRadius = 0;
if (self.clipsToBounds) {
if (borderMetrics.borderRadii.isUniform()) {
// In this case we can simply use `cornerRadius` exclusively.
cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
} else {
RCTCornerInsets cornerInsets =
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
maskLayer = [self createMaskLayer:self.bounds cornerInsets:cornerInsets];
}
}
layer.cornerRadius = cornerRadius;
layer.mask = maskLayer;
for (UIView *subview in self.currentContainerView.subviews) {
if ([subview isKindOfClass:[UIImageView class]]) {
RCTCornerInsets cornerInsets = RCTGetCornerInsets(
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths));
// If the subview is an image view, we have to apply the mask directly to the image view's layer,
// otherwise the image might overflow with the border radius.
subview.layer.mask = [self createMaskLayer:subview.bounds cornerInsets:cornerInsets];
}
}
}
// filter
[_filterLayer removeFromSuperlayer];
_filterLayer = nil;
self.layer.opacity = (float)_props->opacity;
@@ -947,6 +934,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
[self.layer addSublayer:_filterLayer];
}
// background image
[self clearExistingGradientLayers];
if (!_props->backgroundImage.empty()) {
for (const auto &gradient : _props->backgroundImage) {
@@ -994,6 +982,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
}
}
// box shadow
[_boxShadowLayer removeFromSuperlayer];
_boxShadowLayer = nil;
if (!_props->boxShadow.empty()) {
@@ -1010,6 +999,42 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
_boxShadowLayer.contents = (id)boxShadowImage.CGImage;
}
// clipping
if (self.currentContainerView.clipsToBounds) {
BOOL clipToPaddingBox = ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
if (clipToPaddingBox) {
CALayer *maskLayer = [self createMaskLayer:RCTCGRectFromRect(_layoutMetrics.getPaddingFrame())
cornerInsets:RCTGetCornerInsets(
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths))];
self.currentContainerView.layer.mask = maskLayer;
} else {
if (borderMetrics.borderRadii.isUniform()) {
self.currentContainerView.layer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
} else {
CALayer *maskLayer =
[self createMaskLayer:self.bounds
cornerInsets:RCTGetCornerInsets(
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero)];
self.currentContainerView.layer.mask = maskLayer;
}
for (UIView *subview in self.currentContainerView.subviews) {
if ([subview isKindOfClass:[UIImageView class]]) {
RCTCornerInsets cornerInsets = RCTGetCornerInsets(
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths));
// If the subview is an image view, we have to apply the mask directly to the image view's layer,
// otherwise the image might overflow with the border radius.
subview.layer.mask = [self createMaskLayer:subview.bounds cornerInsets:cornerInsets];
}
}
}
} else {
self.currentContainerView.layer.mask = nil;
}
}
- (CAShapeLayer *)createMaskLayer:(CGRect)bounds cornerInsets:(RCTCornerInsets)cornerInsets
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<cd8b6b6fdb11377c119f6bb979560b0e>>
* @generated SignedSource<<6cc52570dd571ddc792a0fd842c05dd9>>
*/
/**
@@ -112,6 +112,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableGranularShadowTreeStateReconciliation(): Boolean = accessor.enableGranularShadowTreeStateReconciliation()
/**
* iOS Views will clip to their padding box vs border box
*/
@JvmStatic
public fun enableIOSViewClipToPaddingBox(): Boolean = accessor.enableIOSViewClipToPaddingBox()
/**
* When enabled, LayoutAnimations API will animate state changes on iOS.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<47dbdb6ffcd04bb7b2d2d01c4c1e7ace>>
* @generated SignedSource<<eca842a1b1c823b72136c625b3bfd16e>>
*/
/**
@@ -34,6 +34,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
@@ -194,6 +195,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun enableIOSViewClipToPaddingBox(): Boolean {
var cached = enableIOSViewClipToPaddingBoxCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableIOSViewClipToPaddingBox()
enableIOSViewClipToPaddingBoxCache = cached
}
return cached
}
override fun enableLayoutAnimationsOnIOS(): Boolean {
var cached = enableLayoutAnimationsOnIOSCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<93ce8e0026e125192af1ad86730941c0>>
* @generated SignedSource<<ad54375c4ae3be2f377260887ae5aaf9>>
*/
/**
@@ -56,6 +56,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableGranularShadowTreeStateReconciliation(): Boolean
@DoNotStrip @JvmStatic public external fun enableIOSViewClipToPaddingBox(): Boolean
@DoNotStrip @JvmStatic public external fun enableLayoutAnimationsOnIOS(): Boolean
@DoNotStrip @JvmStatic public external fun enableLongTaskAPI(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<be36697a6f863c364f858112767399f8>>
* @generated SignedSource<<2a0cd5a4875a54bb724e5765ffe7753e>>
*/
/**
@@ -51,6 +51,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableGranularShadowTreeStateReconciliation(): Boolean = false
override fun enableIOSViewClipToPaddingBox(): Boolean = false
override fun enableLayoutAnimationsOnIOS(): Boolean = true
override fun enableLongTaskAPI(): Boolean = false
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7727737ae31a239d6b68397fafadbfea>>
* @generated SignedSource<<d02af2a8ef015c57d45aba8280539606>>
*/
/**
@@ -38,6 +38,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
@@ -212,6 +213,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableIOSViewClipToPaddingBox(): Boolean {
var cached = enableIOSViewClipToPaddingBoxCache
if (cached == null) {
cached = currentProvider.enableIOSViewClipToPaddingBox()
accessedFeatureFlags.add("enableIOSViewClipToPaddingBox")
enableIOSViewClipToPaddingBoxCache = cached
}
return cached
}
override fun enableLayoutAnimationsOnIOS(): Boolean {
var cached = enableLayoutAnimationsOnIOSCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d9975558a8a9981b4f43e7c5d4473231>>
* @generated SignedSource<<92b1214e3a526d7c67dcc7b0c2a131de>>
*/
/**
@@ -51,6 +51,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean
@DoNotStrip public fun enableIOSViewClipToPaddingBox(): Boolean
@DoNotStrip public fun enableLayoutAnimationsOnIOS(): Boolean
@DoNotStrip public fun enableLongTaskAPI(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c01d216f03d56fed027117e78dc590ab>>
* @generated SignedSource<<c23b21fca18699470580e54b99de1126>>
*/
/**
@@ -123,6 +123,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool enableIOSViewClipToPaddingBox() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableIOSViewClipToPaddingBox");
return method(javaProvider_);
}
bool enableLayoutAnimationsOnIOS() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableLayoutAnimationsOnIOS");
@@ -395,6 +401,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconcilia
return ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation();
}
bool JReactNativeFeatureFlagsCxxInterop::enableIOSViewClipToPaddingBox(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
}
bool JReactNativeFeatureFlagsCxxInterop::enableLayoutAnimationsOnIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS();
@@ -619,6 +630,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableGranularShadowTreeStateReconciliation",
JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconciliation),
makeNativeMethod(
"enableIOSViewClipToPaddingBox",
JReactNativeFeatureFlagsCxxInterop::enableIOSViewClipToPaddingBox),
makeNativeMethod(
"enableLayoutAnimationsOnIOS",
JReactNativeFeatureFlagsCxxInterop::enableLayoutAnimationsOnIOS),
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0e82efb1fac0a62802f5f09e96de31d0>>
* @generated SignedSource<<89d0da3b2bb56a4ee3c887e6c57491b2>>
*/
/**
@@ -72,6 +72,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableGranularShadowTreeStateReconciliation(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableIOSViewClipToPaddingBox(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableLayoutAnimationsOnIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<31c0fac0172a6d3f9ab84a77d4967f5e>>
* @generated SignedSource<<6139aa47aac3e5682a453a416bc10236>>
*/
/**
@@ -77,6 +77,10 @@ bool ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation() {
return getAccessor().enableGranularShadowTreeStateReconciliation();
}
bool ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox() {
return getAccessor().enableIOSViewClipToPaddingBox();
}
bool ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS() {
return getAccessor().enableLayoutAnimationsOnIOS();
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<56c3d93945f6c320e268c9ba32cbde0f>>
* @generated SignedSource<<c8266eb27ec23aaa856fa95275503a81>>
*/
/**
@@ -107,6 +107,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableGranularShadowTreeStateReconciliation();
/**
* iOS Views will clip to their padding box vs border box
*/
RN_EXPORT static bool enableIOSViewClipToPaddingBox();
/**
* When enabled, LayoutAnimations API will animate state changes on iOS.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<73c8cf1d23aa58b4b60e4018c0ddc12e>>
* @generated SignedSource<<dadda9bba46220975852baddb41e7dc9>>
*/
/**
@@ -281,6 +281,24 @@ bool ReactNativeFeatureFlagsAccessor::enableGranularShadowTreeStateReconciliatio
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableIOSViewClipToPaddingBox() {
auto flagValue = enableIOSViewClipToPaddingBox_.load();
if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(14, "enableIOSViewClipToPaddingBox");
flagValue = currentProvider_->enableIOSViewClipToPaddingBox();
enableIOSViewClipToPaddingBox_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() {
auto flagValue = enableLayoutAnimationsOnIOS_.load();
@@ -290,7 +308,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(14, "enableLayoutAnimationsOnIOS");
markFlagAsAccessed(15, "enableLayoutAnimationsOnIOS");
flagValue = currentProvider_->enableLayoutAnimationsOnIOS();
enableLayoutAnimationsOnIOS_ = flagValue;
@@ -308,7 +326,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLongTaskAPI() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(15, "enableLongTaskAPI");
markFlagAsAccessed(16, "enableLongTaskAPI");
flagValue = currentProvider_->enableLongTaskAPI();
enableLongTaskAPI_ = flagValue;
@@ -326,7 +344,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMicrotasks() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(16, "enableMicrotasks");
markFlagAsAccessed(17, "enableMicrotasks");
flagValue = currentProvider_->enableMicrotasks();
enableMicrotasks_ = flagValue;
@@ -344,7 +362,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(17, "enablePropsUpdateReconciliationAndroid");
markFlagAsAccessed(18, "enablePropsUpdateReconciliationAndroid");
flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid();
enablePropsUpdateReconciliationAndroid_ = flagValue;
@@ -362,7 +380,7 @@ bool ReactNativeFeatureFlagsAccessor::enableReportEventPaintTime() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(18, "enableReportEventPaintTime");
markFlagAsAccessed(19, "enableReportEventPaintTime");
flagValue = currentProvider_->enableReportEventPaintTime();
enableReportEventPaintTime_ = flagValue;
@@ -380,7 +398,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSynchronousStateUpdates() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(19, "enableSynchronousStateUpdates");
markFlagAsAccessed(20, "enableSynchronousStateUpdates");
flagValue = currentProvider_->enableSynchronousStateUpdates();
enableSynchronousStateUpdates_ = flagValue;
@@ -398,7 +416,7 @@ bool ReactNativeFeatureFlagsAccessor::enableUIConsistency() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(20, "enableUIConsistency");
markFlagAsAccessed(21, "enableUIConsistency");
flagValue = currentProvider_->enableUIConsistency();
enableUIConsistency_ = flagValue;
@@ -416,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(21, "enableViewRecycling");
markFlagAsAccessed(22, "enableViewRecycling");
flagValue = currentProvider_->enableViewRecycling();
enableViewRecycling_ = flagValue;
@@ -434,7 +452,7 @@ bool ReactNativeFeatureFlagsAccessor::excludeYogaFromRawProps() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(22, "excludeYogaFromRawProps");
markFlagAsAccessed(23, "excludeYogaFromRawProps");
flagValue = currentProvider_->excludeYogaFromRawProps();
excludeYogaFromRawProps_ = flagValue;
@@ -452,7 +470,7 @@ bool ReactNativeFeatureFlagsAccessor::fetchImagesInViewPreallocation() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(23, "fetchImagesInViewPreallocation");
markFlagAsAccessed(24, "fetchImagesInViewPreallocation");
flagValue = currentProvider_->fetchImagesInViewPreallocation();
fetchImagesInViewPreallocation_ = flagValue;
@@ -470,7 +488,7 @@ bool ReactNativeFeatureFlagsAccessor::fixIncorrectScrollViewStateUpdateOnAndroid
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(24, "fixIncorrectScrollViewStateUpdateOnAndroid");
markFlagAsAccessed(25, "fixIncorrectScrollViewStateUpdateOnAndroid");
flagValue = currentProvider_->fixIncorrectScrollViewStateUpdateOnAndroid();
fixIncorrectScrollViewStateUpdateOnAndroid_ = flagValue;
@@ -488,7 +506,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(25, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
markFlagAsAccessed(26, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact();
fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue;
@@ -506,7 +524,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMissedFabricStateUpdatesOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(26, "fixMissedFabricStateUpdatesOnAndroid");
markFlagAsAccessed(27, "fixMissedFabricStateUpdatesOnAndroid");
flagValue = currentProvider_->fixMissedFabricStateUpdatesOnAndroid();
fixMissedFabricStateUpdatesOnAndroid_ = flagValue;
@@ -524,7 +542,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMountingCoordinatorReportedPendingTrans
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(27, "fixMountingCoordinatorReportedPendingTransactionsOnAndroid");
markFlagAsAccessed(28, "fixMountingCoordinatorReportedPendingTransactionsOnAndroid");
flagValue = currentProvider_->fixMountingCoordinatorReportedPendingTransactionsOnAndroid();
fixMountingCoordinatorReportedPendingTransactionsOnAndroid_ = flagValue;
@@ -542,7 +560,7 @@ bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(28, "forceBatchingMountItemsOnAndroid");
markFlagAsAccessed(29, "forceBatchingMountItemsOnAndroid");
flagValue = currentProvider_->forceBatchingMountItemsOnAndroid();
forceBatchingMountItemsOnAndroid_ = flagValue;
@@ -560,7 +578,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledDebug() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(29, "fuseboxEnabledDebug");
markFlagAsAccessed(30, "fuseboxEnabledDebug");
flagValue = currentProvider_->fuseboxEnabledDebug();
fuseboxEnabledDebug_ = flagValue;
@@ -578,7 +596,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(30, "fuseboxEnabledRelease");
markFlagAsAccessed(31, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -596,7 +614,7 @@ bool ReactNativeFeatureFlagsAccessor::initEagerTurboModulesOnNativeModulesQueueA
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(31, "initEagerTurboModulesOnNativeModulesQueueAndroid");
markFlagAsAccessed(32, "initEagerTurboModulesOnNativeModulesQueueAndroid");
flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid();
initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue;
@@ -614,7 +632,7 @@ bool ReactNativeFeatureFlagsAccessor::lazyAnimationCallbacks() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(32, "lazyAnimationCallbacks");
markFlagAsAccessed(33, "lazyAnimationCallbacks");
flagValue = currentProvider_->lazyAnimationCallbacks();
lazyAnimationCallbacks_ = flagValue;
@@ -632,7 +650,7 @@ bool ReactNativeFeatureFlagsAccessor::loadVectorDrawablesOnImages() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(33, "loadVectorDrawablesOnImages");
markFlagAsAccessed(34, "loadVectorDrawablesOnImages");
flagValue = currentProvider_->loadVectorDrawablesOnImages();
loadVectorDrawablesOnImages_ = flagValue;
@@ -650,7 +668,7 @@ bool ReactNativeFeatureFlagsAccessor::setAndroidLayoutDirection() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(34, "setAndroidLayoutDirection");
markFlagAsAccessed(35, "setAndroidLayoutDirection");
flagValue = currentProvider_->setAndroidLayoutDirection();
setAndroidLayoutDirection_ = flagValue;
@@ -668,7 +686,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(35, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(36, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -686,7 +704,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(36, "useFabricInterop");
markFlagAsAccessed(37, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -704,7 +722,7 @@ bool ReactNativeFeatureFlagsAccessor::useImmediateExecutorInAndroidBridgeless()
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(37, "useImmediateExecutorInAndroidBridgeless");
markFlagAsAccessed(38, "useImmediateExecutorInAndroidBridgeless");
flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless();
useImmediateExecutorInAndroidBridgeless_ = flagValue;
@@ -722,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::useModernRuntimeScheduler() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(38, "useModernRuntimeScheduler");
markFlagAsAccessed(39, "useModernRuntimeScheduler");
flagValue = currentProvider_->useModernRuntimeScheduler();
useModernRuntimeScheduler_ = flagValue;
@@ -740,7 +758,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(39, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(40, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -758,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::useNewReactImageViewBackgroundDrawing() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(40, "useNewReactImageViewBackgroundDrawing");
markFlagAsAccessed(41, "useNewReactImageViewBackgroundDrawing");
flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing();
useNewReactImageViewBackgroundDrawing_ = flagValue;
@@ -776,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimisedViewPreallocationOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(41, "useOptimisedViewPreallocationOnAndroid");
markFlagAsAccessed(42, "useOptimisedViewPreallocationOnAndroid");
flagValue = currentProvider_->useOptimisedViewPreallocationOnAndroid();
useOptimisedViewPreallocationOnAndroid_ = flagValue;
@@ -794,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedEventBatchingOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(42, "useOptimizedEventBatchingOnAndroid");
markFlagAsAccessed(43, "useOptimizedEventBatchingOnAndroid");
flagValue = currentProvider_->useOptimizedEventBatchingOnAndroid();
useOptimizedEventBatchingOnAndroid_ = flagValue;
@@ -812,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdate() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(43, "useRuntimeShadowNodeReferenceUpdate");
markFlagAsAccessed(44, "useRuntimeShadowNodeReferenceUpdate");
flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate();
useRuntimeShadowNodeReferenceUpdate_ = flagValue;
@@ -830,7 +848,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdateOnLayou
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(44, "useRuntimeShadowNodeReferenceUpdateOnLayout");
markFlagAsAccessed(45, "useRuntimeShadowNodeReferenceUpdateOnLayout");
flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout();
useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue;
@@ -848,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(45, "useStateAlignmentMechanism");
markFlagAsAccessed(46, "useStateAlignmentMechanism");
flagValue = currentProvider_->useStateAlignmentMechanism();
useStateAlignmentMechanism_ = flagValue;
@@ -866,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(46, "useTurboModuleInterop");
markFlagAsAccessed(47, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<94a2acd88ff16cfe528e0ec9baf6a383>>
* @generated SignedSource<<ef12745c7462250933c3198115418393>>
*/
/**
@@ -45,6 +45,7 @@ class ReactNativeFeatureFlagsAccessor {
bool enableFabricLogs();
bool enableFabricRendererExclusively();
bool enableGranularShadowTreeStateReconciliation();
bool enableIOSViewClipToPaddingBox();
bool enableLayoutAnimationsOnIOS();
bool enableLongTaskAPI();
bool enableMicrotasks();
@@ -88,7 +89,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 47> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 48> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> allowRecursiveCommitsWithSynchronousMountOnAndroid_;
@@ -104,6 +105,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableFabricLogs_;
std::atomic<std::optional<bool>> enableFabricRendererExclusively_;
std::atomic<std::optional<bool>> enableGranularShadowTreeStateReconciliation_;
std::atomic<std::optional<bool>> enableIOSViewClipToPaddingBox_;
std::atomic<std::optional<bool>> enableLayoutAnimationsOnIOS_;
std::atomic<std::optional<bool>> enableLongTaskAPI_;
std::atomic<std::optional<bool>> enableMicrotasks_;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<602c539c5cf438a04a1fb4b6ce05cd3a>>
* @generated SignedSource<<2a078848517574213e02b42dff1af8e8>>
*/
/**
@@ -83,6 +83,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool enableIOSViewClipToPaddingBox() override {
return false;
}
bool enableLayoutAnimationsOnIOS() override {
return true;
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ea07dfe758e8d6f5eada26850dc492a0>>
* @generated SignedSource<<4adf3f21c8c7e370aa59bc79937e91a2>>
*/
/**
@@ -39,6 +39,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableFabricLogs() = 0;
virtual bool enableFabricRendererExclusively() = 0;
virtual bool enableGranularShadowTreeStateReconciliation() = 0;
virtual bool enableIOSViewClipToPaddingBox() = 0;
virtual bool enableLayoutAnimationsOnIOS() = 0;
virtual bool enableLongTaskAPI() = 0;
virtual bool enableMicrotasks() = 0;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1461fc4acff2a28056df4faa4d622a16>>
* @generated SignedSource<<1307630df6aff0acdb4f587465785a09>>
*/
/**
@@ -107,6 +107,11 @@ bool NativeReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation(
return ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation();
}
bool NativeReactNativeFeatureFlags::enableIOSViewClipToPaddingBox(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
}
bool NativeReactNativeFeatureFlags::enableLayoutAnimationsOnIOS(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS();
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9f06e832566c4c1271eaf9bb5cfdf886>>
* @generated SignedSource<<7e65025b9bdd8b515b31f02d2a1489b1>>
*/
/**
@@ -63,6 +63,8 @@ class NativeReactNativeFeatureFlags
bool enableGranularShadowTreeStateReconciliation(jsi::Runtime& runtime);
bool enableIOSViewClipToPaddingBox(jsi::Runtime& runtime);
bool enableLayoutAnimationsOnIOS(jsi::Runtime& runtime);
bool enableLongTaskAPI(jsi::Runtime& runtime);
@@ -101,6 +101,10 @@ const definitions: FeatureFlagDefinitions = {
description:
'When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing.',
},
enableIOSViewClipToPaddingBox: {
defaultValue: false,
description: 'iOS Views will clip to their padding box vs border box',
},
enableLayoutAnimationsOnIOS: {
defaultValue: true,
description:
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1f82c87c0c011c0bf2e76a6e46bb1d3e>>
* @generated SignedSource<<3693bce1a6719ef03c1c3148230771b4>>
* @flow strict-local
*/
@@ -60,6 +60,7 @@ export type ReactNativeFeatureFlags = {
enableFabricLogs: Getter<boolean>,
enableFabricRendererExclusively: Getter<boolean>,
enableGranularShadowTreeStateReconciliation: Getter<boolean>,
enableIOSViewClipToPaddingBox: Getter<boolean>,
enableLayoutAnimationsOnIOS: Getter<boolean>,
enableLongTaskAPI: Getter<boolean>,
enableMicrotasks: Getter<boolean>,
@@ -221,6 +222,10 @@ export const enableFabricRendererExclusively: Getter<boolean> = createNativeFlag
* When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing.
*/
export const enableGranularShadowTreeStateReconciliation: Getter<boolean> = createNativeFlagGetter('enableGranularShadowTreeStateReconciliation', false);
/**
* iOS Views will clip to their padding box vs border box
*/
export const enableIOSViewClipToPaddingBox: Getter<boolean> = createNativeFlagGetter('enableIOSViewClipToPaddingBox', false);
/**
* When enabled, LayoutAnimations API will animate state changes on iOS.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8370ce5bfcfa27bfdaab6549ae54b6d4>>
* @generated SignedSource<<6d4aa48dfdd3b78ac5f0f8e70eb3895f>>
* @flow strict-local
*/
@@ -37,6 +37,7 @@ export interface Spec extends TurboModule {
+enableFabricLogs?: () => boolean;
+enableFabricRendererExclusively?: () => boolean;
+enableGranularShadowTreeStateReconciliation?: () => boolean;
+enableIOSViewClipToPaddingBox?: () => boolean;
+enableLayoutAnimationsOnIOS?: () => boolean;
+enableLongTaskAPI?: () => boolean;
+enableMicrotasks?: () => boolean;