Skip to content

Commit 3ea6c42

Browse files
authored
Inherit text's role and accessibilityRole together (#60300)
Summary: Inheriting `role` and `accessibilityRole` independently leads to some links inheriting `role=heading` while setting their own `accessibilityRole=link`. This caused the former to overrule the latter, missing link detection. Changelog: [Internal] Reviewed By: javache Differential Revision: D116668886 Pull Request resolved: #60300
1 parent e361372 commit 3ea6c42

22 files changed

Lines changed: 340 additions & 111 deletions

‎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<<34bdbabf546b759301a91ae428fed6ec>>
7+
* @generated SignedSource<<dbc8dd1b5f401a0517830ef76e147839>>
88
*/
99

1010
/**
@@ -120,6 +120,12 @@ public object ReactNativeFeatureFlags {
120120
@JvmStatic
121121
public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = accessor.enableAccumulatedUpdatesInRawPropsAndroid()
122122

123+
/**
124+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) inherits neither.
125+
*/
126+
@JvmStatic
127+
public fun enableAliasedTextRoleInheritance(): Boolean = accessor.enableAliasedTextRoleInheritance()
128+
123129
/**
124130
* Enables various optimizations throughout the path of measuring text on Android.
125131
*/

‎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<<9726e5e1cd3145fea4b07a166f85660a>>
7+
* @generated SignedSource<<666ccc72b92cb71cee62acb9d338903f>>
88
*/
99

1010
/**
@@ -35,6 +35,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
3535
private var disableViewPreallocationAndroidCache: Boolean? = null
3636
private var enableAccessibilityOrderCache: Boolean? = null
3737
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
38+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
3839
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
3940
private var enableAsyncDiskCacheCheckInMultiSourceImageAndroidCache: Boolean? = null
4041
private var enableBridgelessArchitectureCache: Boolean? = null
@@ -258,6 +259,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
258259
return cached
259260
}
260261

262+
override fun enableAliasedTextRoleInheritance(): Boolean {
263+
var cached = enableAliasedTextRoleInheritanceCache
264+
if (cached == null) {
265+
cached = ReactNativeFeatureFlagsCxxInterop.enableAliasedTextRoleInheritance()
266+
enableAliasedTextRoleInheritanceCache = cached
267+
}
268+
return cached
269+
}
270+
261271
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
262272
var cached = enableAndroidTextMeasurementOptimizationsCache
263273
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<<a980a4686e0ec1da053ef504509c4314>>
7+
* @generated SignedSource<<62e104bae80f5d1b4bc66fbe5b1682aa>>
88
*/
99

1010
/**
@@ -58,6 +58,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
5858

5959
@DoNotStrip @JvmStatic public external fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
6060

61+
@DoNotStrip @JvmStatic public external fun enableAliasedTextRoleInheritance(): Boolean
62+
6163
@DoNotStrip @JvmStatic public external fun enableAndroidTextMeasurementOptimizations(): Boolean
6264

6365
@DoNotStrip @JvmStatic public external fun enableAsyncDiskCacheCheckInMultiSourceImageAndroid(): 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<<fd11ece2517442e70232346797b75cdf>>
7+
* @generated SignedSource<<aa0b238667f02be74c01551236c7ffbe>>
88
*/
99

1010
/**
@@ -53,6 +53,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
5353

5454
override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = false
5555

56+
override fun enableAliasedTextRoleInheritance(): Boolean = false
57+
5658
override fun enableAndroidTextMeasurementOptimizations(): Boolean = true
5759

5860
override fun enableAsyncDiskCacheCheckInMultiSourceImageAndroid(): 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<<7bb012133d3e7b2f565a6cce09f2101e>>
7+
* @generated SignedSource<<b74a60f5a53f535e7d93ded619b7bc77>>
88
*/
99

1010
/**
@@ -39,6 +39,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3939
private var disableViewPreallocationAndroidCache: Boolean? = null
4040
private var enableAccessibilityOrderCache: Boolean? = null
4141
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
42+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
4243
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
4344
private var enableAsyncDiskCacheCheckInMultiSourceImageAndroidCache: Boolean? = null
4445
private var enableBridgelessArchitectureCache: Boolean? = null
@@ -277,6 +278,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
277278
return cached
278279
}
279280

281+
override fun enableAliasedTextRoleInheritance(): Boolean {
282+
var cached = enableAliasedTextRoleInheritanceCache
283+
if (cached == null) {
284+
cached = currentProvider.enableAliasedTextRoleInheritance()
285+
accessedFeatureFlags.add("enableAliasedTextRoleInheritance")
286+
enableAliasedTextRoleInheritanceCache = cached
287+
}
288+
return cached
289+
}
290+
280291
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
281292
var cached = enableAndroidTextMeasurementOptimizationsCache
282293
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<<72dbf13d4f0e66503364e384a4d32ec9>>
7+
* @generated SignedSource<<ded38341408b1822c0ee29736c8d7309>>
88
*/
99

1010
/**
@@ -53,6 +53,8 @@ public interface ReactNativeFeatureFlagsProvider {
5353

5454
@DoNotStrip public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
5555

56+
@DoNotStrip public fun enableAliasedTextRoleInheritance(): Boolean
57+
5658
@DoNotStrip public fun enableAndroidTextMeasurementOptimizations(): Boolean
5759

5860
@DoNotStrip public fun enableAsyncDiskCacheCheckInMultiSourceImageAndroid(): 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<<04ec1a82d4d8a9f78fcb804be6189176>>
7+
* @generated SignedSource<<927c12777b5682e200477286b49fa8dd>>
88
*/
99

1010
/**
@@ -129,6 +129,12 @@ class ReactNativeFeatureFlagsJavaProvider
129129
return method(javaProvider_);
130130
}
131131

132+
bool enableAliasedTextRoleInheritance() override {
133+
static const auto method =
134+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAliasedTextRoleInheritance");
135+
return method(javaProvider_);
136+
}
137+
132138
bool enableAndroidTextMeasurementOptimizations() override {
133139
static const auto method =
134140
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAndroidTextMeasurementOptimizations");
@@ -730,6 +736,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndro
730736
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
731737
}
732738

739+
bool JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance(
740+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
741+
return ReactNativeFeatureFlags::enableAliasedTextRoleInheritance();
742+
}
743+
733744
bool JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations(
734745
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
735746
return ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations();
@@ -1241,6 +1252,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
12411252
makeNativeMethod(
12421253
"enableAccumulatedUpdatesInRawPropsAndroid",
12431254
JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndroid),
1255+
makeNativeMethod(
1256+
"enableAliasedTextRoleInheritance",
1257+
JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance),
12441258
makeNativeMethod(
12451259
"enableAndroidTextMeasurementOptimizations",
12461260
JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations),

‎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<<19f054d765a345d3768c075502177952>>
7+
* @generated SignedSource<<079a6bc867f6eeace870efaf80e20f75>>
88
*/
99

1010
/**
@@ -75,6 +75,9 @@ class JReactNativeFeatureFlagsCxxInterop
7575
static bool enableAccumulatedUpdatesInRawPropsAndroid(
7676
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
7777

78+
static bool enableAliasedTextRoleInheritance(
79+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
80+
7881
static bool enableAndroidTextMeasurementOptimizations(
7982
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
8083

‎packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp‎

Lines changed: 5 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<<abe454ca84cbfeb04b9720d7bf5cbb6d>>
7+
* @generated SignedSource<<7a02d21afc37beb9618eb31d5ae5a15c>>
88
*/
99

1010
/**
@@ -86,6 +86,10 @@ bool ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid() {
8686
return getAccessor().enableAccumulatedUpdatesInRawPropsAndroid();
8787
}
8888

89+
bool ReactNativeFeatureFlags::enableAliasedTextRoleInheritance() {
90+
return getAccessor().enableAliasedTextRoleInheritance();
91+
}
92+
8993
bool ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations() {
9094
return getAccessor().enableAndroidTextMeasurementOptimizations();
9195
}

‎packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h‎

Lines changed: 6 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<<095a2439c2db06e9ee161bdbde7498c1>>
7+
* @generated SignedSource<<61b669719ed341332652257d1353fbe6>>
88
*/
99

1010
/**
@@ -116,6 +116,11 @@ class ReactNativeFeatureFlags {
116116
*/
117117
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();
118118

119+
/**
120+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) inherits neither.
121+
*/
122+
RN_EXPORT static bool enableAliasedTextRoleInheritance();
123+
119124
/**
120125
* Enables various optimizations throughout the path of measuring text on Android.
121126
*/

0 commit comments

Comments
 (0)