Skip to content

Commit fb45877

Browse files
coadofacebook-github-bot
authored andcommitted
Move ReactNativeFeatureFlags to src/private (#52610)
Summary: Pull Request resolved: #52610 This diff removes `ReactNativeFeatureFlags` from `react-native/Libraries/ReactNative` and migrates `shouldPressibilityUseW3CPointerEventsForHover` to common `ReactNativeFeatureFlags` in `src/private/featureflags`. The `shouldEmitW3CPointerEvents is removed as it is used in `rn-tester` to hide some examples. Changelog: [General][Breaking] - Migrate `shouldPressibilityUseW3CPointerEventsForHover` to common private feature flags and remove `shouldEmitW3CPointerEvents` flag. Reviewed By: robhogan Differential Revision: D75448698 fbshipit-source-id: 03942c9504b855f2054c9a5948c0521ce17365b5
1 parent 730a0d5 commit fb45877

27 files changed

+167
-115
lines changed

packages/react-native/Libraries/Pressability/Pressability.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import type {
1616
MouseEvent,
1717
} from '../Types/CoreEventTypes';
1818

19+
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
1920
import SoundManager from '../Components/Sound/SoundManager';
20-
import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags';
2121
import UIManager from '../ReactNative/UIManager';
2222
import {type RectOrSize, normalizeRect} from '../StyleSheet/Rect';
2323
import {type PointerEvent} from '../Types/CoreEventTypes';

packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6f50c9b7a356260abf8afc022aba8fc2>>
7+
* @generated SignedSource<<ebfa5c471b394293aebdb37c6b679903>>
88
*/
99

1010
/**
@@ -324,6 +324,12 @@ public object ReactNativeFeatureFlags {
324324
@JvmStatic
325325
public fun releaseImageDataWhenConsumed(): Boolean = accessor.releaseImageDataWhenConsumed()
326326

327+
/**
328+
* Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks
329+
*/
330+
@JvmStatic
331+
public fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean = accessor.shouldPressibilityUseW3CPointerEventsForHover()
332+
327333
/**
328334
* Skip activity identity assertion in ReactHostImpl::onHostPause()
329335
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d442e14a9a0f7f5dd2cdbabac34c8415>>
7+
* @generated SignedSource<<e00a0a927d72346f532a561faa53f5d4>>
88
*/
99

1010
/**
@@ -69,6 +69,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
6969
private var preparedTextCacheSizeCache: Double? = null
7070
private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null
7171
private var releaseImageDataWhenConsumedCache: Boolean? = null
72+
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
7273
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
7374
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
7475
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
@@ -525,6 +526,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
525526
return cached
526527
}
527528

529+
override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean {
530+
var cached = shouldPressibilityUseW3CPointerEventsForHoverCache
531+
if (cached == null) {
532+
cached = ReactNativeFeatureFlagsCxxInterop.shouldPressibilityUseW3CPointerEventsForHover()
533+
shouldPressibilityUseW3CPointerEventsForHoverCache = cached
534+
}
535+
return cached
536+
}
537+
528538
override fun skipActivityIdentityAssertionOnHostPause(): Boolean {
529539
var cached = skipActivityIdentityAssertionOnHostPauseCache
530540
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<eb4ba3fd4ce8434f993793febcb8d481>>
7+
* @generated SignedSource<<cca36c1bf21945b7a44ff33e77fa1e50>>
88
*/
99

1010
/**
@@ -126,6 +126,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
126126

127127
@DoNotStrip @JvmStatic public external fun releaseImageDataWhenConsumed(): Boolean
128128

129+
@DoNotStrip @JvmStatic public external fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean
130+
129131
@DoNotStrip @JvmStatic public external fun skipActivityIdentityAssertionOnHostPause(): Boolean
130132

131133
@DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<ed1b41e080f0575aff6891aa4fadddce>>
7+
* @generated SignedSource<<1c1ae67a283926bd5da1c5ddad875810>>
88
*/
99

1010
/**
@@ -121,6 +121,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
121121

122122
override fun releaseImageDataWhenConsumed(): Boolean = false
123123

124+
override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean = false
125+
124126
override fun skipActivityIdentityAssertionOnHostPause(): Boolean = false
125127

126128
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1c4bee4de12fc3e38a09f2ddf9b39601>>
7+
* @generated SignedSource<<4c1cfcf144eb98e871358413340a7651>>
88
*/
99

1010
/**
@@ -73,6 +73,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
7373
private var preparedTextCacheSizeCache: Double? = null
7474
private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null
7575
private var releaseImageDataWhenConsumedCache: Boolean? = null
76+
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
7677
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
7778
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
7879
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
@@ -578,6 +579,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
578579
return cached
579580
}
580581

582+
override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean {
583+
var cached = shouldPressibilityUseW3CPointerEventsForHoverCache
584+
if (cached == null) {
585+
cached = currentProvider.shouldPressibilityUseW3CPointerEventsForHover()
586+
accessedFeatureFlags.add("shouldPressibilityUseW3CPointerEventsForHover")
587+
shouldPressibilityUseW3CPointerEventsForHoverCache = cached
588+
}
589+
return cached
590+
}
591+
581592
override fun skipActivityIdentityAssertionOnHostPause(): Boolean {
582593
var cached = skipActivityIdentityAssertionOnHostPauseCache
583594
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<366629baac4727e7db4042a8e9dcab93>>
7+
* @generated SignedSource<<02df7850c3578fb7d033038e517e7cef>>
88
*/
99

1010
/**
@@ -121,6 +121,8 @@ public interface ReactNativeFeatureFlagsProvider {
121121

122122
@DoNotStrip public fun releaseImageDataWhenConsumed(): Boolean
123123

124+
@DoNotStrip public fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean
125+
124126
@DoNotStrip public fun skipActivityIdentityAssertionOnHostPause(): Boolean
125127

126128
@DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1ec5b2dea32e6f318622cb24a9d66ef2>>
7+
* @generated SignedSource<<dd77d71fb46a3015fd6705b9a3520f1e>>
88
*/
99

1010
/**
@@ -333,6 +333,12 @@ class ReactNativeFeatureFlagsJavaProvider
333333
return method(javaProvider_);
334334
}
335335

336+
bool shouldPressibilityUseW3CPointerEventsForHover() override {
337+
static const auto method =
338+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("shouldPressibilityUseW3CPointerEventsForHover");
339+
return method(javaProvider_);
340+
}
341+
336342
bool skipActivityIdentityAssertionOnHostPause() override {
337343
static const auto method =
338344
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("skipActivityIdentityAssertionOnHostPause");
@@ -666,6 +672,11 @@ bool JReactNativeFeatureFlagsCxxInterop::releaseImageDataWhenConsumed(
666672
return ReactNativeFeatureFlags::releaseImageDataWhenConsumed();
667673
}
668674

675+
bool JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover(
676+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
677+
return ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover();
678+
}
679+
669680
bool JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause(
670681
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
671682
return ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause();
@@ -914,6 +925,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
914925
makeNativeMethod(
915926
"releaseImageDataWhenConsumed",
916927
JReactNativeFeatureFlagsCxxInterop::releaseImageDataWhenConsumed),
928+
makeNativeMethod(
929+
"shouldPressibilityUseW3CPointerEventsForHover",
930+
JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover),
917931
makeNativeMethod(
918932
"skipActivityIdentityAssertionOnHostPause",
919933
JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<3570d50c3ff20d976b7145c0c36fd6ac>>
7+
* @generated SignedSource<<956c5e2083b578aea5289299939d2e5c>>
88
*/
99

1010
/**
@@ -177,6 +177,9 @@ class JReactNativeFeatureFlagsCxxInterop
177177
static bool releaseImageDataWhenConsumed(
178178
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
179179

180+
static bool shouldPressibilityUseW3CPointerEventsForHover(
181+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
182+
180183
static bool skipActivityIdentityAssertionOnHostPause(
181184
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
182185

0 commit comments

Comments
 (0)