Skip to content

Commit

Permalink
Factor out feature flags for RN Fabric core
Browse files Browse the repository at this point in the history
Summary:
A follow up to D38708718 (403fea2) review, this factors feature flags for Fabric core code into a separate file, `CoreFeatures`.

Keeping them together is arguably better for maintenance and makes code easier to reason about.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D40007784

fbshipit-source-id: 1885d5d6200575c6015f063d8b05813b18b47ffb
  • Loading branch information
rshest authored and facebook-github-bot committed Oct 3, 2022
1 parent 9d08d55 commit 9864586
Show file tree
Hide file tree
Showing 15 changed files with 563 additions and 483 deletions.
3 changes: 2 additions & 1 deletion React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import <react/config/ReactNativeConfig.h>
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#import <react/renderer/components/text/BaseTextProps.h>
#import <react/renderer/core/CoreFeatures.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import <react/renderer/scheduler/AsynchronousEventBeat.h>
#import <react/renderer/scheduler/SchedulerToolbox.h>
Expand Down Expand Up @@ -271,7 +272,7 @@ - (RCTScheduler *)_createScheduler
}

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_cpp_props_iterator_setter_ios")) {
Props::enablePropIteratorSetter = true;
CoreFeatures::enablePropIteratorSetter = true;
AccessibilityProps::enablePropIteratorSetter = true;
BaseTextProps::enablePropIteratorSetter = true;
}
Expand Down
8 changes: 5 additions & 3 deletions ReactAndroid/src/main/jni/react/fabric/Binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <react/renderer/animations/LayoutAnimationDriver.h>
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/components/scrollview/ScrollViewProps.h>
#include <react/renderer/core/CoreFeatures.h>
#include <react/renderer/core/EventBeat.h>
#include <react/renderer/core/EventEmitter.h>
#include <react/renderer/core/conversions.h>
Expand Down Expand Up @@ -455,11 +456,12 @@ void Binding::installFabricUIManager(
getFeatureFlagValue("enableLargeTextMeasureCache"));

// Props setter pattern feature
Props::enablePropIteratorSetter =
CoreFeatures::enablePropIteratorSetter =
getFeatureFlagValue("enableCppPropsIteratorSetter");
AccessibilityProps::enablePropIteratorSetter =
Props::enablePropIteratorSetter;
BaseTextProps::enablePropIteratorSetter = Props::enablePropIteratorSetter;
CoreFeatures::enablePropIteratorSetter;
BaseTextProps::enablePropIteratorSetter =
CoreFeatures::enablePropIteratorSetter;

// RemoveDelete mega-op
ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <react/jni/ReadableNativeMap.h>
#include <react/renderer/components/scrollview/ScrollViewProps.h>
#include <react/renderer/core/CoreFeatures.h>
#include <react/renderer/core/conversions.h>
#include <react/renderer/debug/SystraceSection.h>
#include <react/renderer/mounting/ShadowViewMutation.h>
Expand Down Expand Up @@ -51,7 +52,7 @@ FabricMountingManager::FabricMountingManager(
useOverflowInset_(getFeatureFlagValue("useOverflowInset")),
shouldRememberAllocatedViews_(
getFeatureFlagValue("shouldRememberAllocatedViews")) {
Props::enableMapBuffer = getFeatureFlagValue("useMapBufferProps");
CoreFeatures::enableMapBuffer = getFeatureFlagValue("useMapBufferProps");
}

void FabricMountingManager::onSurfaceStart(SurfaceId surfaceId) {
Expand Down Expand Up @@ -257,7 +258,7 @@ static inline float scale(Float value, Float pointScaleFactor) {
local_ref<jobject> FabricMountingManager::getProps(
ShadowView const &oldShadowView,
ShadowView const &newShadowView) {
if (Props::enableMapBuffer &&
if (CoreFeatures::enableMapBuffer &&
newShadowView.traits.check(
ShadowNodeTraits::Trait::AndroidMapBufferPropsSupported)) {
react_native_assert(
Expand Down
89 changes: 46 additions & 43 deletions ReactCommon/react/renderer/components/image/ImageProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <react/renderer/components/image/ImageProps.h>
#include <react/renderer/components/image/conversions.h>
#include <react/renderer/core/CoreFeatures.h>
#include <react/renderer/core/propsConversions.h>

namespace facebook {
Expand All @@ -18,55 +19,57 @@ ImageProps::ImageProps(
const RawProps &rawProps)
: ViewProps(context, sourceProps, rawProps),
sources(
Props::enablePropIteratorSetter ? sourceProps.sources
: convertRawProp(
context,
rawProps,
"source",
sourceProps.sources,
{})),
CoreFeatures::enablePropIteratorSetter ? sourceProps.sources
: convertRawProp(
context,
rawProps,
"source",
sourceProps.sources,
{})),
defaultSources(
Props::enablePropIteratorSetter ? sourceProps.defaultSources
: convertRawProp(
context,
rawProps,
"defaultSource",
sourceProps.defaultSources,
{})),
CoreFeatures::enablePropIteratorSetter
? sourceProps.defaultSources
: convertRawProp(
context,
rawProps,
"defaultSource",
sourceProps.defaultSources,
{})),
resizeMode(
Props::enablePropIteratorSetter ? sourceProps.resizeMode
: convertRawProp(
context,
rawProps,
"resizeMode",
sourceProps.resizeMode,
ImageResizeMode::Stretch)),
CoreFeatures::enablePropIteratorSetter
? sourceProps.resizeMode
: convertRawProp(
context,
rawProps,
"resizeMode",
sourceProps.resizeMode,
ImageResizeMode::Stretch)),
blurRadius(
Props::enablePropIteratorSetter ? sourceProps.blurRadius
: convertRawProp(
context,
rawProps,
"blurRadius",
sourceProps.blurRadius,
{})),
CoreFeatures::enablePropIteratorSetter ? sourceProps.blurRadius
: convertRawProp(
context,
rawProps,
"blurRadius",
sourceProps.blurRadius,
{})),
capInsets(
Props::enablePropIteratorSetter ? sourceProps.capInsets
: convertRawProp(
context,
rawProps,
"capInsets",
sourceProps.capInsets,
{})),
CoreFeatures::enablePropIteratorSetter ? sourceProps.capInsets
: convertRawProp(
context,
rawProps,
"capInsets",
sourceProps.capInsets,
{})),
tintColor(
Props::enablePropIteratorSetter ? sourceProps.tintColor
: convertRawProp(
context,
rawProps,
"tintColor",
sourceProps.tintColor,
{})),
CoreFeatures::enablePropIteratorSetter ? sourceProps.tintColor
: convertRawProp(
context,
rawProps,
"tintColor",
sourceProps.tintColor,
{})),
internal_analyticTag(
Props::enablePropIteratorSetter
CoreFeatures::enablePropIteratorSetter
? sourceProps.internal_analyticTag
: convertRawProp(
context,
Expand Down
Loading

0 comments on commit 9864586

Please sign in to comment.