Skip to content

Commit 8e5a034

Browse files
javachefacebook-github-bot
authored andcommitted
Fix ctor/setProp prop-name gaps surfaced by iterator-setter audit (#57330)
Summary: Auditing every Props .cpp file in the renderer surfaced six cases where a prop key parsed by the 3-arg constructor's `convertRawProp(...)` call had no matching `case` in the same class's `setProp` method. With the iterator-setter path now routing every prop through `setProp` (instead of re-running the parsing constructor), each gap silently drops the prop on the floor when the iterator-setter path is active. Fix each gap: - `BaseScrollViewProps::setProp` — add `RAW_SET_PROP_SWITCH_CASE_BASIC(automaticallyAdjustKeyboardInsets)`. Parsed in ctor, missing case. - `BaseTextProps::setProp` — add `REBUILD_FIELD_SWITCH_CASE(... dynamicTypeRamp, "dynamicTypeRamp")`. Parsed in ctor, missing case. - `BaseTextProps::setProp` — rename the `baseWritingDirection` switch case key to `writingDirection`. JS sends `writingDirection` (the C++ field is named `baseWritingDirection` internally, but JS / Flow / TS / codegen all use `writingDirection` — verified across `StyleSheetTypes.js`, `StyleSheetTypes.d.ts`, `ReactNativeStyleAttributes.js`, `RCTTextInputViewConfig.js`, and the `Text-itest.js` integration test mounts `<rn-paragraph writingDirection="rtl">`). The setProp case was keyed off the C++ field name and never fired for any real JS prop. `appendTextAttributesProps` still emits `baseWritingDirection` for the C++→JS diff path — that's a separate, out-of-scope inconsistency. - `AccessibilityProps::setProp` — rename the `accessibilityOrder` switch case key to `experimental_accessibilityOrder`. JS sends the prefixed name (verified in `ViewPropTypes.js`, `BaseViewConfig.android.js`, `BaseViewConfig.ios.js`, `ViewProps.kt`'s `ACCESSIBILITY_ORDER = "experimental_accessibilityOrder"` constant, and `HostPlatformViewProps::getDebugProps` which serializes back out as `experimental_accessibilityOrder`). The unprefixed case never fired. - `BaseViewProps::setProp` — add `RAW_SET_PROP_SWITCH_CASE_BASIC(transformOrigin)`. Parsed in ctor, missing case. - `BaseViewProps::setProp` — add `SET_CASCADED_RECTANGLE_CORNERS(borderCurves, "border", "Curve", value)`. The ctor parses the full 13-key cascaded set (`borderCurve`, `borderTopLeftCurve`, … `borderStartStartCurve`) via `CascadedRectangleCornersNames`, but `setProp` had `SET_CASCADED_RECTANGLE_CORNERS` for `borderRadii` and `SET_CASCADED_RECTANGLE_EDGES` for `borderColors`/`borderStyles` — the corresponding `borderCurves` invocation was missing. Same gaps in the `third-party/react-native-macos/.../BaseViewProps.cpp` mirror — applied the same fixes there. Out-of-scope but flagged by the audit (left for follow-ups): - `propsConversions.h`'s `ViewEvents` converter doesn't handle `onGotPointerCapture` / `onLostPointerCapture` (explicit `// TODO` at line 541). `BaseViewProps::setProp` does. Asymmetry runs the other direction — iterator-setter handles these, classic ctor doesn't. - android `HostPlatformViewProps.cpp` defines `VIEW_EVENT_CASE` macro but never invokes it in its switch — dead code (events live on `BaseViewProps::events`). Cleanup candidate. Changelog: [General][Fixed] - Several view, text, scrollview, and accessibility props that the iterator-setter path silently dropped now propagate correctly through `setProp`: `automaticallyAdjustKeyboardInsets`, `dynamicTypeRamp`, `writingDirection`, `experimental_accessibilityOrder`, `transformOrigin`, and the full `borderCurves` cascaded set. Differential Revision: D109584760
1 parent 19c11ba commit 8e5a034

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ void BaseScrollViewProps::setProp(
395395
RAW_SET_PROP_SWITCH_CASE_BASIC(centerContent);
396396
RAW_SET_PROP_SWITCH_CASE_BASIC(automaticallyAdjustContentInsets);
397397
RAW_SET_PROP_SWITCH_CASE_BASIC(automaticallyAdjustsScrollIndicatorInsets);
398+
RAW_SET_PROP_SWITCH_CASE_BASIC(automaticallyAdjustKeyboardInsets);
398399
RAW_SET_PROP_SWITCH_CASE_BASIC(decelerationRate);
399400
RAW_SET_PROP_SWITCH_CASE_BASIC(directionalLockEnabled);
400401
RAW_SET_PROP_SWITCH_CASE_BASIC(indicatorStyle);

packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ void BaseTextProps::setProp(
273273
textAttributes,
274274
maxFontSizeMultiplier,
275275
"maxFontSizeMultiplier");
276+
REBUILD_FIELD_SWITCH_CASE(
277+
defaults, value, textAttributes, dynamicTypeRamp, "dynamicTypeRamp");
276278
REBUILD_FIELD_SWITCH_CASE(
277279
defaults, value, textAttributes, letterSpacing, "letterSpacing");
278280
REBUILD_FIELD_SWITCH_CASE(
@@ -286,7 +288,7 @@ void BaseTextProps::setProp(
286288
value,
287289
textAttributes,
288290
baseWritingDirection,
289-
"baseWritingDirection");
291+
"writingDirection");
290292
REBUILD_FIELD_SWITCH_CASE(
291293
defaults,
292294
value,

packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ void AccessibilityProps::setProp(
267267
RAW_SET_PROP_SWITCH_CASE_BASIC(accessible);
268268
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityState);
269269
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLabel);
270-
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityOrder);
270+
RAW_SET_PROP_SWITCH_CASE(
271+
accessibilityOrder, "experimental_accessibilityOrder");
271272
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLabelledBy);
272273
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLiveRegion);
273274
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityHint);

packages/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ void BaseViewProps::setProp(
465465
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOpacity);
466466
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowRadius);
467467
RAW_SET_PROP_SWITCH_CASE_BASIC(transform);
468+
RAW_SET_PROP_SWITCH_CASE_BASIC(transformOrigin);
468469
RAW_SET_PROP_SWITCH_CASE_BASIC(backfaceVisibility);
469470
RAW_SET_PROP_SWITCH_CASE_BASIC(shouldRasterize);
470471
RAW_SET_PROP_SWITCH_CASE_BASIC(zIndex);
@@ -522,6 +523,7 @@ void BaseViewProps::setProp(
522523
// BorderRadii
523524
SET_CASCADED_RECTANGLE_CORNERS(borderRadii, "border", "Radius", value);
524525
SET_CASCADED_RECTANGLE_EDGES(borderColors, "border", "Color", value);
526+
SET_CASCADED_RECTANGLE_CORNERS(borderCurves, "border", "Curve", value);
525527
SET_CASCADED_RECTANGLE_EDGES(borderStyles, "border", "Style", value);
526528
}
527529
}

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ HostPlatformViewProps::HostPlatformViewProps(
143143
sourceProps.nextFocusUp,
144144
{})) {}
145145

146-
#define VIEW_EVENT_CASE(eventType) \
147-
case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \
148-
const auto offset = ViewEvents::Offset::eventType; \
149-
ViewEvents defaultViewEvents{}; \
150-
bool res = defaultViewEvents[offset]; \
151-
if (value.hasValue()) { \
152-
fromRawValue(context, value, res); \
153-
} \
154-
events[offset] = res; \
155-
return; \
156-
}
157-
158146
void HostPlatformViewProps::setProp(
159147
const PropsParserContext& context,
160148
RawPropsPropNameHash hash,

packages/react-native/ReactCommon/react/renderer/components/view/propsConversions.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,18 @@ static inline ViewEvents convertRawProp(
538538
"onPointerUpCapture",
539539
sourceValue[Offset::PointerUpCapture],
540540
defaultValue[Offset::PointerUpCapture]);
541-
// TODO: gotPointerCapture & lostPointerCapture
541+
result[Offset::GotPointerCapture] = convertRawProp(
542+
context,
543+
rawProps,
544+
"onGotPointerCapture",
545+
sourceValue[Offset::GotPointerCapture],
546+
defaultValue[Offset::GotPointerCapture]);
547+
result[Offset::LostPointerCapture] = convertRawProp(
548+
context,
549+
rawProps,
550+
"onLostPointerCapture",
551+
sourceValue[Offset::LostPointerCapture],
552+
defaultValue[Offset::LostPointerCapture]);
542553

543554
// PanResponder callbacks
544555
result[Offset::MoveShouldSetResponder] = convertRawProp(

0 commit comments

Comments
 (0)