Skip to content
Open
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
154 changes: 74 additions & 80 deletions packages/react-native/Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import type {ViewProps} from './ViewPropTypes';

import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
import TextAncestorContext from '../../Text/TextAncestorContext';
import ViewNativeComponent from './ViewNativeComponent';
import * as React from 'react';
Expand All @@ -29,93 +28,88 @@ component View(
) {
const hasTextAncestor = use(TextAncestorContext);

let resolvedProps = props;
if (!ReactNativeFeatureFlags.enableNativeViewPropTransformations()) {
const {
accessibilityState,
accessibilityValue,
'aria-busy': ariaBusy,
'aria-checked': ariaChecked,
'aria-disabled': ariaDisabled,
'aria-expanded': ariaExpanded,
'aria-hidden': ariaHidden,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
'aria-live': ariaLive,
'aria-selected': ariaSelected,
'aria-valuemax': ariaValueMax,
'aria-valuemin': ariaValueMin,
'aria-valuenow': ariaValueNow,
'aria-valuetext': ariaValueText,
id,
tabIndex,
...otherProps
} = props;

const processedProps = otherProps as {...ViewProps};

const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
if (parsedAriaLabelledBy !== undefined) {
processedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
}

if (ariaLabel !== undefined) {
processedProps.accessibilityLabel = ariaLabel;
}
const {
accessibilityState,
accessibilityValue,
'aria-busy': ariaBusy,
'aria-checked': ariaChecked,
'aria-disabled': ariaDisabled,
'aria-expanded': ariaExpanded,
'aria-hidden': ariaHidden,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
'aria-live': ariaLive,
'aria-selected': ariaSelected,
'aria-valuemax': ariaValueMax,
'aria-valuemin': ariaValueMin,
'aria-valuenow': ariaValueNow,
'aria-valuetext': ariaValueText,
id,
tabIndex,
...otherProps
} = props;

const resolvedProps = otherProps as {...ViewProps};

const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
if (parsedAriaLabelledBy !== undefined) {
resolvedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
}

if (ariaLive !== undefined) {
processedProps.accessibilityLiveRegion =
ariaLive === 'off' ? 'none' : ariaLive;
}
if (ariaLabel !== undefined) {
resolvedProps.accessibilityLabel = ariaLabel;
}

if (ariaHidden !== undefined) {
processedProps.accessibilityElementsHidden = ariaHidden;
if (ariaHidden === true) {
processedProps.importantForAccessibility = 'no-hide-descendants';
}
}
if (ariaLive !== undefined) {
resolvedProps.accessibilityLiveRegion =
ariaLive === 'off' ? 'none' : ariaLive;
}

if (id !== undefined) {
processedProps.nativeID = id;
if (ariaHidden !== undefined) {
resolvedProps.accessibilityElementsHidden = ariaHidden;
if (ariaHidden === true) {
resolvedProps.importantForAccessibility = 'no-hide-descendants';
}
}

if (tabIndex !== undefined) {
processedProps.focusable = !tabIndex;
}
if (id !== undefined) {
resolvedProps.nativeID = id;
}

if (
accessibilityState != null ||
ariaBusy != null ||
ariaChecked != null ||
ariaDisabled != null ||
ariaExpanded != null ||
ariaSelected != null
) {
processedProps.accessibilityState = {
busy: ariaBusy ?? accessibilityState?.busy,
checked: ariaChecked ?? accessibilityState?.checked,
disabled: ariaDisabled ?? accessibilityState?.disabled,
expanded: ariaExpanded ?? accessibilityState?.expanded,
selected: ariaSelected ?? accessibilityState?.selected,
};
}
if (tabIndex !== undefined) {
resolvedProps.focusable = !tabIndex;
}

if (
accessibilityValue != null ||
ariaValueMax != null ||
ariaValueMin != null ||
ariaValueNow != null ||
ariaValueText != null
) {
processedProps.accessibilityValue = {
max: ariaValueMax ?? accessibilityValue?.max,
min: ariaValueMin ?? accessibilityValue?.min,
now: ariaValueNow ?? accessibilityValue?.now,
text: ariaValueText ?? accessibilityValue?.text,
};
}
if (
accessibilityState != null ||
ariaBusy != null ||
ariaChecked != null ||
ariaDisabled != null ||
ariaExpanded != null ||
ariaSelected != null
) {
resolvedProps.accessibilityState = {
busy: ariaBusy ?? accessibilityState?.busy,
checked: ariaChecked ?? accessibilityState?.checked,
disabled: ariaDisabled ?? accessibilityState?.disabled,
expanded: ariaExpanded ?? accessibilityState?.expanded,
selected: ariaSelected ?? accessibilityState?.selected,
};
}

resolvedProps = processedProps;
if (
accessibilityValue != null ||
ariaValueMax != null ||
ariaValueMin != null ||
ariaValueNow != null ||
ariaValueText != null
) {
resolvedProps.accessibilityValue = {
max: ariaValueMax ?? accessibilityValue?.max,
min: ariaValueMin ?? accessibilityValue?.min,
now: ariaValueNow ?? accessibilityValue?.now,
text: ariaValueText ?? accessibilityValue?.text,
};
}

const actualView =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @fantom_flags enableNativeCSSParsing:* enableNativeViewPropTransformations:*
* @fantom_flags enableNativeCSSParsing:*
* @format
*/

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<<1eca66b21554b00725f2a9be894a0db9>>
* @generated SignedSource<<2c364dcadc5b346d3bb13cde2e5a060a>>
*/

/**
Expand Down Expand Up @@ -270,12 +270,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableNativeCSSParsing(): Boolean = accessor.enableNativeCSSParsing()

/**
* When enabled, View.js passes aria-*, id, and tabIndex props directly to native, relying on C++ prop parsing instead of JS-side transformations.
*/
@JvmStatic
public fun enableNativeViewPropTransformations(): Boolean = accessor.enableNativeViewPropTransformations()

/**
* Enable network event reporting hooks in each native platform through `NetworkReporter` (Web Perf APIs + CDP). This flag should be combined with `fuseboxNetworkInspectionEnabled` to enable Network CDP debugging.
*/
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<<76d977ea53cb2a37fc2ea8549e31cebd>>
* @generated SignedSource<<c140db6c6b9cf48a018c723c08220e20>>
*/

/**
Expand Down Expand Up @@ -60,7 +60,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableModuleArgumentNSNullConversionIOSCache: Boolean? = null
private var enableMutationObserverByDefaultCache: Boolean? = null
private var enableNativeCSSParsingCache: Boolean? = null
private var enableNativeViewPropTransformationsCache: Boolean? = null
private var enableNetworkEventReportingCache: Boolean? = null
private var enablePreparedTextLayoutCache: Boolean? = null
private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null
Expand Down Expand Up @@ -473,15 +472,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun enableNetworkEventReporting(): Boolean {
var cached = enableNetworkEventReportingCache
if (cached == null) {
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<<a737810bf0211590401c2afb464aaf37>>
* @generated SignedSource<<53cb8cbc9588ede52d45c3dc611b55c6>>
*/

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

@DoNotStrip @JvmStatic public external fun enableNativeCSSParsing(): Boolean

@DoNotStrip @JvmStatic public external fun enableNativeViewPropTransformations(): Boolean

@DoNotStrip @JvmStatic public external fun enableNetworkEventReporting(): Boolean

@DoNotStrip @JvmStatic public external fun enablePreparedTextLayout(): Boolean
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<<9e5b3192d1bec953c116d959ad63283d>>
* @generated SignedSource<<8195238186a41519d277391e2295deb1>>
*/

/**
Expand Down Expand Up @@ -103,8 +103,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableNativeCSSParsing(): Boolean = false

override fun enableNativeViewPropTransformations(): Boolean = false

override fun enableNetworkEventReporting(): Boolean = true

override fun enablePreparedTextLayout(): Boolean = false
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<<378d6a8de497d26ebbbf55885be27a21>>
* @generated SignedSource<<85bd7b360d4ee759c77bfb15878e77aa>>
*/

/**
Expand Down Expand Up @@ -64,7 +64,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableModuleArgumentNSNullConversionIOSCache: Boolean? = null
private var enableMutationObserverByDefaultCache: Boolean? = null
private var enableNativeCSSParsingCache: Boolean? = null
private var enableNativeViewPropTransformationsCache: Boolean? = null
private var enableNetworkEventReportingCache: Boolean? = null
private var enablePreparedTextLayoutCache: Boolean? = null
private var enablePropsUpdateReconciliationAndroidCache: Boolean? = null
Expand Down Expand Up @@ -517,16 +516,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

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

override fun enableNetworkEventReporting(): Boolean {
var cached = enableNetworkEventReportingCache
if (cached == null) {
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<<42e555a40da280b24f84e3ee5b45051d>>
* @generated SignedSource<<5783380c1b3c870a38c6ee3dd732f451>>
*/

/**
Expand Down Expand Up @@ -103,8 +103,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableNativeCSSParsing(): Boolean

@DoNotStrip public fun enableNativeViewPropTransformations(): Boolean

@DoNotStrip public fun enableNetworkEventReporting(): Boolean

@DoNotStrip public fun enablePreparedTextLayout(): Boolean
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<<d9ed25122f1ff64122bfc83f8e5e9545>>
* @generated SignedSource<<11d00fb61dfb4cb468fe4aaba1a0736a>>
*/

/**
Expand Down Expand Up @@ -279,12 +279,6 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}

bool enableNativeViewPropTransformations() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableNativeViewPropTransformations");
return method(javaProvider_);
}

bool enableNetworkEventReporting() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableNetworkEventReporting");
Expand Down Expand Up @@ -795,11 +789,6 @@ bool JReactNativeFeatureFlagsCxxInterop::enableNativeCSSParsing(
return ReactNativeFeatureFlags::enableNativeCSSParsing();
}

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

bool JReactNativeFeatureFlagsCxxInterop::enableNetworkEventReporting(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableNetworkEventReporting();
Expand Down Expand Up @@ -1206,9 +1195,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableNativeCSSParsing",
JReactNativeFeatureFlagsCxxInterop::enableNativeCSSParsing),
makeNativeMethod(
"enableNativeViewPropTransformations",
JReactNativeFeatureFlagsCxxInterop::enableNativeViewPropTransformations),
makeNativeMethod(
"enableNetworkEventReporting",
JReactNativeFeatureFlagsCxxInterop::enableNetworkEventReporting),
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<<d87a80a2a88acb2187ea20b8181a7588>>
* @generated SignedSource<<0259578fbf209e84eb04078189c9db41>>
*/

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

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

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

Expand Down
Loading
Loading