Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
public static field enableMountHooks Z
public static field enableOnDemandReactChoreographer Z
public static field enableRemoveDeleteTreeInstruction Z
public static field enableSpannableBuildingUnification Z
public static field enableTextSpannableCache Z
public static field enableViewRecycling Z
public static field excludeYogaFromRawProps Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,4 @@ public class ReactFeatureFlags {
* when there is work to do.
*/
public static boolean enableOnDemandReactChoreographer = false;

/** Enables the new unified {@link android.text.Spannable} building logic. */
public static boolean enableSpannableBuildingUnification = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<<52367278b4d0fdf7f436bd8c511d4ffe>>
* @generated SignedSource<<82a7973a820b75c46977931a8b178493>>
*/

/**
Expand All @@ -31,23 +31,33 @@ object ReactNativeFeatureFlags {
/**
* Common flag for testing. Do NOT modify.
*/
@JvmStatic
fun commonTestFlag() = accessor.commonTestFlag()

/**
* When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.
*/
@JvmStatic
fun useModernRuntimeScheduler() = accessor.useModernRuntimeScheduler()

/**
* Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).
*/
@JvmStatic
fun enableMicrotasks() = accessor.enableMicrotasks()

/**
* When enabled, the RuntimeScheduler processing the event loop will batch all rendering updates and dispatch them together at the end of each iteration of the loop.
*/
@JvmStatic
fun batchRenderingUpdatesInEventLoop() = accessor.batchRenderingUpdatesInEventLoop()

/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
@JvmStatic
fun enableSpannableBuildingUnification() = accessor.enableSpannableBuildingUnification()

/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<920bb26d238f935f63a77943df7ef6e2>>
* @generated SignedSource<<881b7f9eb6b1765764b70719155a457c>>
*/

/**
Expand All @@ -24,6 +24,7 @@ class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
private var useModernRuntimeSchedulerCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null

override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
Expand Down Expand Up @@ -61,6 +62,15 @@ class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}

override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableSpannableBuildingUnification()
enableSpannableBuildingUnificationCache = cached
}
return cached
}

override fun override(provider: ReactNativeFeatureFlagsProvider) =
ReactNativeFeatureFlagsCxxInterop.override(provider as Any)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<19d0606854e3e34efe67acf9dc1d26b4>>
* @generated SignedSource<<c4908662a6c752ef8dc85f7eb86d1df4>>
*/

/**
Expand Down Expand Up @@ -36,6 +36,8 @@ object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic external fun batchRenderingUpdatesInEventLoop(): Boolean

@DoNotStrip @JvmStatic external fun enableSpannableBuildingUnification(): Boolean

@DoNotStrip @JvmStatic external fun override(provider: Any)

@DoNotStrip @JvmStatic external fun dangerouslyReset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<932fd2768c81d5a5f49929c89d6659ff>>
* @generated SignedSource<<44159bbcf15dc403e40656c71d84516a>>
*/

/**
Expand All @@ -30,4 +30,6 @@ open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvider {
override fun enableMicrotasks(): Boolean = false

override fun batchRenderingUpdatesInEventLoop(): Boolean = false

override fun enableSpannableBuildingUnification(): Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<<6254686d99a8bfd0531ed629655cf673>>
* @generated SignedSource<<85d0ebc43b7c390be7dd89c58f1b7a7a>>
*/

/**
Expand All @@ -28,6 +28,7 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
private var useModernRuntimeSchedulerCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null

override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
Expand Down Expand Up @@ -69,6 +70,16 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}

override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
cached = currentProvider.enableSpannableBuildingUnification()
accessedFeatureFlags.add("enableSpannableBuildingUnification")
enableSpannableBuildingUnificationCache = cached
}
return cached
}

override fun override(provider: ReactNativeFeatureFlagsProvider) {
if (accessedFeatureFlags.isNotEmpty()) {
val accessedFeatureFlagsStr = accessedFeatureFlags.joinToString(separator = ", ") { it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<c5c87368aae4df966b4b7971aadb79f2>>
* @generated SignedSource<<d5db40f4f25503513c4128892fd12e3f>>
*/

/**
Expand All @@ -30,4 +30,6 @@ interface ReactNativeFeatureFlagsProvider {
@DoNotStrip fun enableMicrotasks(): Boolean

@DoNotStrip fun batchRenderingUpdatesInEventLoop(): Boolean

@DoNotStrip fun enableSpannableBuildingUnification(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.NativeViewHierarchyOptimizer;
Expand Down Expand Up @@ -93,7 +93,7 @@ private static void buildSpannedFromShadowNode(
boolean supportsInlineViews,
@Nullable Map<Integer, ReactShadowNode> inlineViews,
int start) {
if (ReactFeatureFlags.enableSpannableBuildingUnification) {
if (ReactNativeFeatureFlags.enableSpannableBuildingUnification()) {
buildSpannedFromShadowNodeUnified(
textShadowNode, sb, ops, parentTextAttributes, supportsInlineViews, inlineViews, start);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole;
import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role;
Expand Down Expand Up @@ -118,7 +118,7 @@ private static void buildSpannableFromFragments(
ReadableArray fragments,
SpannableStringBuilder sb,
List<SetSpanOperation> ops) {
if (ReactFeatureFlags.enableSpannableBuildingUnification) {
if (ReactNativeFeatureFlags.enableSpannableBuildingUnification()) {
buildSpannableFromFragmentsUnified(context, fragments, sb, ops);
} else {
buildSpannableFromFragmentsDuplicated(context, fragments, sb, ops);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.common.mapbuffer.MapBuffer;
import com.facebook.react.common.mapbuffer.ReadableMapBuffer;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole;
import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role;
Expand Down Expand Up @@ -140,7 +140,7 @@ public static boolean isRTL(MapBuffer attributedString) {

private static void buildSpannableFromFragments(
Context context, MapBuffer fragments, SpannableStringBuilder sb, List<SetSpanOperation> ops) {
if (ReactFeatureFlags.enableSpannableBuildingUnification) {
if (ReactNativeFeatureFlags.enableSpannableBuildingUnification()) {
buildSpannableFromFragmentsUnified(context, fragments, sb, ops);
} else {
buildSpannableFromFragmentsDuplicated(context, fragments, sb, ops);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<bd4482119f1c4963aa4ad1e354f9107d>>
* @generated SignedSource<<36acddfcb6c038dbf523ad669bcedeba>>
*/

/**
Expand Down Expand Up @@ -43,6 +43,11 @@ bool JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop(
return ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop();
}

bool JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableSpannableBuildingUnification();
}

void JReactNativeFeatureFlagsCxxInterop::override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/,
jni::alias_ref<jobject> provider) {
Expand Down Expand Up @@ -72,6 +77,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"batchRenderingUpdatesInEventLoop",
JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop),
makeNativeMethod(
"enableSpannableBuildingUnification",
JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<b7304c29a002ce5a8a612d7a08d798ff>>
* @generated SignedSource<<b903dab48f817589883d7f41cc5674f0>>
*/

/**
Expand Down Expand Up @@ -42,6 +42,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool batchRenderingUpdatesInEventLoop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool enableSpannableBuildingUnification(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static void override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>,
jni::alias_ref<jobject> provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<91f988022fbff7eba632f2ba46056025>>
* @generated SignedSource<<5f99c47d357e45524b359e6517d1f2eb>>
*/

/**
Expand Down Expand Up @@ -51,4 +51,10 @@ bool ReactNativeFeatureFlagsProviderHolder::batchRenderingUpdatesInEventLoop() {
return method(javaProvider_);
}

bool ReactNativeFeatureFlagsProviderHolder::enableSpannableBuildingUnification() {
static const auto method =
getJClass()->getMethod<jboolean()>("enableSpannableBuildingUnification");
return method(javaProvider_);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -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<<3550f7ee28a53a4024a48301ee38ce7e>>
* @generated SignedSource<<6aaa06ae0c12de2f432374d0cd048460>>
*/

/**
Expand Down Expand Up @@ -39,6 +39,7 @@ class ReactNativeFeatureFlagsProviderHolder
bool useModernRuntimeScheduler() override;
bool enableMicrotasks() override;
bool batchRenderingUpdatesInEventLoop() override;
bool enableSpannableBuildingUnification() override;

private:
jni::global_ref<jobject> javaProvider_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<eb9bb346a84321197849de2dd8bf7dc3>>
* @generated SignedSource<<809c23db6d36e18d448554900e462aa0>>
*/

/**
Expand Down Expand Up @@ -37,6 +37,10 @@ bool ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop() {
return getAccessor().batchRenderingUpdatesInEventLoop();
}

bool ReactNativeFeatureFlags::enableSpannableBuildingUnification() {
return getAccessor().enableSpannableBuildingUnification();
}

void ReactNativeFeatureFlags::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
getAccessor().override(std::move(provider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<be203871f94ca134f75b803b7d79a5ab>>
* @generated SignedSource<<ea6c88fb2c3fcaa35b5886b8f8ceb769>>
*/

/**
Expand Down Expand Up @@ -52,6 +52,11 @@ class ReactNativeFeatureFlags {
*/
static bool batchRenderingUpdatesInEventLoop();

/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
static bool enableSpannableBuildingUnification();

/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<5df50987338c0541436b11cd5433013c>>
* @generated SignedSource<<15858c6ab96e90350aa5f29eb108b051>>
*/

/**
Expand Down Expand Up @@ -96,6 +96,23 @@ bool ReactNativeFeatureFlagsAccessor::batchRenderingUpdatesInEventLoop() {
return batchRenderingUpdatesInEventLoop_.value();
}

bool ReactNativeFeatureFlagsAccessor::enableSpannableBuildingUnification() {
if (!enableSpannableBuildingUnification_.has_value()) {
// Mark the flag as accessed.
static const char* flagName = "enableSpannableBuildingUnification";
if (std::find(
accessedFeatureFlags_.begin(),
accessedFeatureFlags_.end(),
flagName) == accessedFeatureFlags_.end()) {
accessedFeatureFlags_.push_back(flagName);
}

enableSpannableBuildingUnification_.emplace(currentProvider_->enableSpannableBuildingUnification());
}

return enableSpannableBuildingUnification_.value();
}

void ReactNativeFeatureFlagsAccessor::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
if (!accessedFeatureFlags_.empty()) {
Expand Down
Loading