diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm index 3f233578412..eb0d5682f5d 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm @@ -64,8 +64,8 @@ static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const Acti - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - const auto &oldViewProps = *std::static_pointer_cast(_props); - const auto &newViewProps = *std::static_pointer_cast(props); + const auto &oldViewProps = static_cast(*_props); + const auto &newViewProps = static_cast(*props); if (oldViewProps.animating != newViewProps.animating) { if (newViewProps.animating) { diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 8b5b3d1b22a..043d31f604c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -54,8 +54,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldImageProps = *std::static_pointer_cast(_props); - auto const &newImageProps = *std::static_pointer_cast(props); + const auto &oldImageProps = static_cast(*_props); + const auto &newImageProps = static_cast(*props); // `resizeMode` if (oldImageProps.resizeMode != newImageProps.resizeMode) { @@ -88,7 +88,7 @@ using namespace facebook::react; (newImageState && newImageState->getData().getImageSource() != oldImageState->getData().getImageSource())) { // Loading actually starts a little before this, but this is the first time we know // the image is loading and can fire an event from this component - std::static_pointer_cast(_eventEmitter)->onLoadStart(); + static_cast(*_eventEmitter).onLoadStart(); // TODO (T58941612): Tracking for visibility should be done directly on this class. // For now, we consolidate instrumentation logic in the image loader, so that pre-Fabric gets the same treatment. @@ -138,10 +138,10 @@ using namespace facebook::react; return; } - std::static_pointer_cast(_eventEmitter)->onLoad(); - std::static_pointer_cast(_eventEmitter)->onLoadEnd(); + static_cast(*_eventEmitter).onLoad(); + static_cast(*_eventEmitter).onLoadEnd(); - const auto &imageProps = *std::static_pointer_cast(_props); + const auto &imageProps = static_cast(*_props); if (imageProps.tintColor) { image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; @@ -176,7 +176,7 @@ using namespace facebook::react; return; } - std::static_pointer_cast(_eventEmitter)->onProgress(progress); + static_cast(*_eventEmitter).onProgress(progress); } - (void)didReceiveFailureFromObserver:(void const *)observer @@ -187,8 +187,8 @@ using namespace facebook::react; return; } - std::static_pointer_cast(_eventEmitter)->onError(); - std::static_pointer_cast(_eventEmitter)->onLoadEnd(); + static_cast(*_eventEmitter).onError(); + static_cast(*_eventEmitter).onLoadEnd(); } @end diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm index f78c2797f0e..f00cc30d211 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm @@ -107,8 +107,8 @@ static UIView *_Nullable RCTFindTextInputWithNat - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldInputAccessoryProps = *std::static_pointer_cast(_props); - auto const &newInputAccessoryProps = *std::static_pointer_cast(props); + const auto &oldInputAccessoryProps = static_cast(*_props); + const auto &newInputAccessoryProps = static_cast(*props); if (newInputAccessoryProps.backgroundColor != oldInputAccessoryProps.backgroundColor) { _contentView.backgroundColor = RCTUIColorFromSharedColor(newInputAccessoryProps.backgroundColor); diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm index 5324963ea01..81181588130 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm @@ -187,9 +187,9 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index"; _adapter.eventInterceptor = ^(std::string eventName, folly::dynamic event) { if (weakSelf) { __typeof(self) strongSelf = weakSelf; - auto eventEmitter = - std::static_pointer_cast(strongSelf->_eventEmitter); - eventEmitter->dispatchEvent(eventName, event); + const auto &eventEmitter = + static_cast(*strongSelf->_eventEmitter); + eventEmitter.dispatchEvent(eventName, event); } }; self.contentView = _adapter.paperView; @@ -217,7 +217,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index"; [_adapter.paperView didUpdateReactSubviews]; if (updateMask & RNComponentViewUpdateMaskProps) { - const auto &newProps = *std::static_pointer_cast(_props); + const auto &newProps = static_cast(*_props); [_adapter setProps:newProps.otherProps]; } } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 28c4bd227b7..b91e44bb15b 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -182,12 +182,12 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( - (std::shared_ptr)modalEventEmitter { - if (!self->_eventEmitter) { + if (!_eventEmitter) { return nullptr; } - assert(std::dynamic_pointer_cast(self->_eventEmitter)); - return std::static_pointer_cast(self->_eventEmitter); + assert(std::dynamic_pointer_cast(_eventEmitter)); + return std::static_pointer_cast(_eventEmitter); } #pragma mark - RCTMountingTransactionObserving @@ -245,7 +245,7 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - const auto &newProps = *std::static_pointer_cast(props); + const auto &newProps = static_cast(*props); #if !TARGET_OS_TV self.viewController.supportedInterfaceOrientations = supportedOrientationsMask(newProps.supportedOrientations); diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 9480239051e..23de45a9471 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -57,8 +57,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldConcreteProps = *std::static_pointer_cast(_props); - auto const &newConcreteProps = *std::static_pointer_cast(props); + const auto &oldConcreteProps = static_cast(*_props); + const auto &newConcreteProps = static_cast(*props); if (newConcreteProps.refreshing != oldConcreteProps.refreshing) { if (newConcreteProps.refreshing) { @@ -89,12 +89,12 @@ using namespace facebook::react; - (void)handleUIControlEventValueChanged { - std::static_pointer_cast(_eventEmitter)->onRefresh({}); + static_cast(*_eventEmitter).onRefresh({}); } - (void)_updateTitle { - auto const &concreteProps = *std::static_pointer_cast(_props); + const auto &concreteProps = static_cast(*_props); if (concreteProps.title.empty()) { _refreshControl.attributedTitle = nil; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index fde373ba822..94c82ad08ad 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -190,8 +190,8 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - const auto &oldScrollViewProps = *std::static_pointer_cast(_props); - const auto &newScrollViewProps = *std::static_pointer_cast(props); + const auto &oldScrollViewProps = static_cast(*_props); + const auto &newScrollViewProps = static_cast(*props); #define REMAP_PROP(reactName, localName, target) \ if (oldScrollViewProps.reactName != newScrollViewProps.reactName) { \ @@ -408,7 +408,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol - (void)prepareForRecycle { - const auto &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); _scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset); // We set the default behavior to "never" so that iOS // doesn't do weird things to UIScrollView insets automatically @@ -445,7 +445,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol if ((_lastScrollEventDispatchTime == 0) || (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) { _lastScrollEventDispatchTime = now; if (_eventEmitter) { - std::static_pointer_cast(_eventEmitter)->onScroll([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onScroll([self _scrollViewMetrics]); } RCTSendScrollEventForNativeAnimations_DEPRECATED(scrollView, self.tag); @@ -479,7 +479,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onScrollBeginDrag([self _scrollViewMetrics]); _isUserTriggeredScrolling = YES; } @@ -491,7 +491,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onScrollEndDrag([self _scrollViewMetrics]); [self _updateStateWithContentOffset]; @@ -510,8 +510,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter) - ->onMomentumScrollBegin([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onMomentumScrollBegin([self _scrollViewMetrics]); } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView @@ -522,7 +521,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onMomentumScrollEnd([self _scrollViewMetrics]); [self _updateStateWithContentOffset]; _isUserTriggeredScrolling = NO; } @@ -541,7 +540,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onMomentumScrollEnd([self _scrollViewMetrics]); [self _updateStateWithContentOffset]; } @@ -553,7 +552,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onScrollBeginDrag([self _scrollViewMetrics]); } - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale @@ -564,7 +563,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol return; } - std::static_pointer_cast(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]); + static_cast(*_eventEmitter).onScrollEndDrag([self _scrollViewMetrics]); [self _updateStateWithContentOffset]; } @@ -607,7 +606,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol fmax(_scrollView.contentInset.top, 0), 0.01)); // Make width and height greater than 0 - const auto &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (!CGRectContainsPoint(maxRect, offset) && !props.scrollToOverflowEnabled) { CGFloat localX = fmax(offset.x, CGRectGetMinX(maxRect)); localX = fmin(localX, CGRectGetMaxX(maxRect)); @@ -714,7 +713,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol - (void)_prepareForMaintainVisibleScrollPosition { - const auto &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (!props.maintainVisibleContentPosition) { return; } @@ -740,7 +739,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol - (void)_adjustForMaintainVisibleContentPosition { - const auto &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (!props.maintainVisibleContentPosition) { return; } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm index 844b60c120e..bf95785588c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm @@ -57,8 +57,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - const auto &oldSwitchProps = *std::static_pointer_cast(_props); - const auto &newSwitchProps = *std::static_pointer_cast(props); + const auto &oldSwitchProps = static_cast(*_props); + const auto &newSwitchProps = static_cast(*props); // `value` if (oldSwitchProps.value != newSwitchProps.value) { @@ -92,13 +92,13 @@ using namespace facebook::react; - (void)onChange:(UISwitch *)sender { - const auto &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (props.value == sender.on) { return; } - std::dynamic_pointer_cast(_eventEmitter) - ->onChange(SwitchEventEmitter::OnChange{.value = static_cast(sender.on)}); + static_cast(*_eventEmitter) + .onChange(SwitchEventEmitter::OnChange{.value = static_cast(sender.on)}); } #pragma mark - Native Commands diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm index ac45711c97b..95f3ab56934 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm @@ -81,8 +81,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldParagraphProps = *std::static_pointer_cast(_props); - auto const &newParagraphProps = *std::static_pointer_cast(props); + const auto &oldParagraphProps = static_cast(*_props); + const auto &newParagraphProps = static_cast(*props); _paragraphAttributes = newParagraphProps.paragraphAttributes; @@ -147,7 +147,7 @@ using namespace facebook::react; - (NSArray *)accessibilityElements { - auto const ¶graphProps = *std::static_pointer_cast(_props); + const auto ¶graphProps = static_cast(*_props); // If the component is not `accessible`, we return an empty array. // We do this because logically all nested components represent the content of the component; @@ -241,13 +241,13 @@ using namespace facebook::react; - (BOOL)canBecomeFirstResponder { - auto const ¶graphProps = *std::static_pointer_cast(_props); + const auto ¶graphProps = static_cast(*_props); return paragraphProps.isSelectable; } - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { - auto const ¶graphProps = *std::static_pointer_cast(_props); + const auto ¶graphProps = static_cast(*_props); if (paragraphProps.isSelectable && action == @selector(copy:)) { return YES; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 17a38ca7858..54f9bbf0e2c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -82,7 +82,7 @@ using namespace facebook::react; [super didMoveToWindow]; if (self.window && !_didMoveToWindow) { - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (props.autoFocus) { [_backedTextInputView becomeFirstResponder]; } @@ -107,8 +107,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldTextInputProps = *std::static_pointer_cast(_props); - auto const &newTextInputProps = *std::static_pointer_cast(props); + const auto &oldTextInputProps = static_cast(*_props); + const auto &newTextInputProps = static_cast(*props); // Traits: if (newTextInputProps.traits.multiline != oldTextInputProps.traits.multiline) { @@ -251,8 +251,7 @@ using namespace facebook::react; RCTUIEdgeInsetsFromEdgeInsets(layoutMetrics.contentInsets - layoutMetrics.borderWidth); if (_eventEmitter) { - auto const &textInputEventEmitter = *std::static_pointer_cast(_eventEmitter); - textInputEventEmitter.onContentSizeChange([self _textInputMetrics]); + static_cast(*_eventEmitter).onContentSizeChange([self _textInputMetrics]); } } @@ -278,7 +277,7 @@ using namespace facebook::react; - (void)textInputDidBeginEditing { - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (props.traits.clearTextOnFocus) { _backedTextInputView.attributedText = nil; @@ -291,7 +290,7 @@ using namespace facebook::react; } if (_eventEmitter) { - std::static_pointer_cast(_eventEmitter)->onFocus([self _textInputMetrics]); + static_cast(*_eventEmitter).onFocus([self _textInputMetrics]); } } @@ -303,8 +302,8 @@ using namespace facebook::react; - (void)textInputDidEndEditing { if (_eventEmitter) { - std::static_pointer_cast(_eventEmitter)->onEndEditing([self _textInputMetrics]); - std::static_pointer_cast(_eventEmitter)->onBlur([self _textInputMetrics]); + static_cast(*_eventEmitter).onEndEditing([self _textInputMetrics]); + static_cast(*_eventEmitter).onBlur([self _textInputMetrics]); } } @@ -319,7 +318,7 @@ using namespace facebook::react; // (no connection to any specific "submitting" process). if (_eventEmitter && shouldSubmit) { - std::static_pointer_cast(_eventEmitter)->onSubmitEditing([self _textInputMetrics]); + static_cast(*_eventEmitter).onSubmitEditing([self _textInputMetrics]); } return shouldSubmit; } @@ -336,7 +335,7 @@ using namespace facebook::react; - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range { - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (!_backedTextInputView.textWasPasted) { if (_eventEmitter) { @@ -344,7 +343,7 @@ using namespace facebook::react; keyPressMetrics.text = RCTStringFromNSString(text); keyPressMetrics.eventCount = _mostRecentEventCount; - auto const &textInputEventEmitter = *std::static_pointer_cast(_eventEmitter); + auto const &textInputEventEmitter = static_cast(*_eventEmitter); if (props.onKeyPressSync) { textInputEventEmitter.onKeyPressSync(keyPressMetrics); } else { @@ -394,8 +393,8 @@ using namespace facebook::react; [self _updateState]; if (_eventEmitter) { - auto const &textInputEventEmitter = *std::static_pointer_cast(_eventEmitter); - auto const &props = *std::static_pointer_cast(_props); + auto const &textInputEventEmitter = static_cast(*_eventEmitter); + const auto &props = static_cast(*_props); if (props.onChangeSync) { textInputEventEmitter.onChangeSync([self _textInputMetrics]); } else { @@ -409,14 +408,14 @@ using namespace facebook::react; if (_comingFromJS) { return; } - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { [self textInputDidChange]; _ignoreNextTextInputCall = YES; } if (_eventEmitter) { - std::static_pointer_cast(_eventEmitter)->onSelectionChange([self _textInputMetrics]); + static_cast(*_eventEmitter).onSelectionChange([self _textInputMetrics]); } } @@ -425,7 +424,7 @@ using namespace facebook::react; - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (_eventEmitter) { - std::static_pointer_cast(_eventEmitter)->onScroll([self _textInputMetrics]); + static_cast(*_eventEmitter).onScroll([self _textInputMetrics]); } } @@ -579,7 +578,7 @@ using namespace facebook::react; - (void)_restoreTextSelection { - auto const selection = std::dynamic_pointer_cast(_props)->selection; + const auto &selection = static_cast(*_props).selection; if (!selection.has_value()) { return; } @@ -659,7 +658,7 @@ using namespace facebook::react; - (SubmitBehavior)getSubmitBehavior { - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); const SubmitBehavior submitBehaviorDefaultable = props.traits.submitBehavior; // We should always have a non-default `submitBehavior`, but in case we don't, set it based on multiline. diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm index 6c38b8bda68..0a55451e61a 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm @@ -47,8 +47,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - const auto &oldViewProps = *std::static_pointer_cast(_props); - const auto &newViewProps = *std::static_pointer_cast(props); + const auto &oldViewProps = static_cast(*_props); + const auto &newViewProps = static_cast(*props); if (oldViewProps.name != newViewProps.name) { _label.text = [NSString stringWithFormat:@"'%s' is not Fabric compatible yet.", newViewProps.name.c_str()]; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm index 1112c5a9895..e4481787772 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm @@ -54,8 +54,8 @@ using namespace facebook::react; - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps { - auto const &oldUnimplementedViewProps = *std::static_pointer_cast(_props); - auto const &newUnimplementedViewProps = *std::static_pointer_cast(props); + const auto &oldUnimplementedViewProps = static_cast(*_props); + const auto &newUnimplementedViewProps = static_cast(*props); if (oldUnimplementedViewProps.getComponentName() != newUnimplementedViewProps.getComponentName()) { _label.text = diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 33da37d1f0a..b15f9dfb1be 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -193,8 +193,8 @@ using namespace facebook::react; NSStringFromClass([self class])); #endif - auto const &oldViewProps = *std::static_pointer_cast(_props); - auto const &newViewProps = *std::static_pointer_cast(props); + const auto &oldViewProps = static_cast(*_props); + const auto &newViewProps = static_cast(*props); BOOL needsInvalidateLayer = NO; @@ -425,7 +425,7 @@ using namespace facebook::react; [super prepareForRecycle]; // If view was managed by animated, its props need to align with UIView's properties. - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); if ([_propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN containsObject:@"transform"]) { self.layer.transform = RCTCATransform3DFromTransformMatrix(props.transform); } @@ -712,7 +712,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) - (NSString *)accessibilityValue { - auto const &props = *std::static_pointer_cast(_props); + const auto &props = static_cast(*_props); // Handle Switch. if ((self.accessibilityTraits & AccessibilityTraitSwitch) == AccessibilityTraitSwitch) { diff --git a/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm b/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm index 0e7cc3f383c..2cb3779169f 100644 --- a/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm +++ b/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm @@ -316,7 +316,7 @@ static void RCTPerformMountInstructions( [componentView updateProps:newProps oldProps:oldProps]; componentView.propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN = propKeys; - const auto &newViewProps = *std::static_pointer_cast(newProps); + const auto &newViewProps = static_cast(*newProps); if (props[@"transform"] && !CATransform3DEqualToTransform( diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp index b82a561a074..49cca5270a5 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp @@ -88,9 +88,9 @@ CoreComponentsRegistry::initHybrid( auto registry = CoreComponentsRegistry::sharedProviderRegistry() ->createComponentDescriptorRegistry( {eventDispatcher, contextContainer}); - auto mutableRegistry = - std::const_pointer_cast(registry); - mutableRegistry->setFallbackComponentDescriptor( + auto &mutableRegistry = + const_cast(*registry); + mutableRegistry.setFallbackComponentDescriptor( std::make_shared( ComponentDescriptorParameters{ eventDispatcher, contextContainer, nullptr})); diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp index e39091a6a57..8e8c94747f0 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp @@ -201,19 +201,14 @@ static inline void writeIntBufferTypePreamble( // TODO: this method will be removed when binding for components are code-gen jni::local_ref getPlatformComponentName(ShadowView const &shadowView) { static std::string scrollViewComponentName = std::string("ScrollView"); - - jni::local_ref componentName; if (scrollViewComponentName == shadowView.componentName) { - auto newViewProps = - std::static_pointer_cast(shadowView.props); - if (newViewProps->getProbablyMoreHorizontalThanVertical_DEPRECATED()) { - componentName = jni::make_jstring("AndroidHorizontalScrollView"); - return componentName; + const auto &newViewProps = + static_cast(*shadowView.props); + if (newViewProps.getProbablyMoreHorizontalThanVertical_DEPRECATED()) { + return jni::make_jstring("AndroidHorizontalScrollView"); } } - - componentName = jni::make_jstring(shadowView.componentName); - return componentName; + return jni::make_jstring(shadowView.componentName); } static inline float scale(Float value, Float pointScaleFactor) { diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp index 8273e31777a..a291c22f915 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp @@ -44,10 +44,9 @@ DefaultComponentsRegistry::initHybrid( ->createComponentDescriptorRegistry( {eventDispatcher, contextContainer}); - auto mutableRegistry = - std::const_pointer_cast(registry); - - mutableRegistry->setFallbackComponentDescriptor( + auto &mutableRegistry = + const_cast(*registry); + mutableRegistry.setFallbackComponentDescriptor( std::make_shared( ComponentDescriptorParameters{ eventDispatcher, contextContainer, nullptr})); diff --git a/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 34aed3a6760..71df612c864 100644 --- a/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -467,8 +467,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( if (baselineShadowView.traits.check( ShadowNodeTraits::Trait::ViewKind)) { - auto const &viewProps = - *std::static_pointer_cast(props); + const auto &viewProps = static_cast(*props); const_cast(viewProps).opacity = 0; } @@ -489,8 +488,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( .cloneProps(propsParserContext, viewStart.props, {}); if (baselineShadowView.traits.check( ShadowNodeTraits::Trait::ViewKind)) { - auto const &viewProps = - *std::static_pointer_cast(props); + const auto &viewProps = static_cast(*props); const_cast(viewProps).transform = Transform::Scale(isScaleX ? 0 : 1, isScaleY ? 0 : 1, 1); } @@ -590,8 +588,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( if (baselineShadowView.traits.check( ShadowNodeTraits::Trait::ViewKind)) { - auto const &viewProps = - *std::static_pointer_cast(props); + const auto &viewProps = + static_cast(*props); const_cast(viewProps).opacity = 0; } @@ -615,8 +613,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( if (baselineShadowView.traits.check( ShadowNodeTraits::Trait::ViewKind)) { - auto const &viewProps = - *std::static_pointer_cast(props); + const auto &viewProps = + static_cast(*props); const_cast(viewProps).transform = Transform::Scale(isScaleX ? 0 : 1, isScaleY ? 0 : 1, 1); } diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h index ae8040185ef..2feb6c9719b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h @@ -27,12 +27,11 @@ class ImageComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto imageShadowNode = - std::static_pointer_cast(shadowNode); + auto &imageShadowNode = static_cast(*shadowNode); // `ImageShadowNode` uses `ImageManager` to initiate image loading and // communicate the loading state and results to mounting layer. - imageShadowNode->setImageManager(imageManager_); + imageShadowNode.setImageManager(imageManager_); } private: diff --git a/packages/react-native/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h index 5f2117fbc90..695fe7bcbd5 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h @@ -22,20 +22,17 @@ class InputAccessoryComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(ShadowNode::Unshared const &shadowNode) const override { - auto concreteShadowNode = - std::static_pointer_cast(shadowNode); + auto &layoutableShadowNode = + static_cast(*shadowNode); - auto layoutableShadowNode = - std::static_pointer_cast(concreteShadowNode); + auto &stateData = + static_cast( + *shadowNode->getState()) + .getData(); - auto state = - std::static_pointer_cast( - shadowNode->getState()); - auto stateData = state->getData(); - - layoutableShadowNode->setSize( + layoutableShadowNode.setSize( Size{stateData.viewportSize.width, stateData.viewportSize.height}); - layoutableShadowNode->setPositionType(YGPositionTypeAbsolute); + layoutableShadowNode.setPositionType(YGPositionTypeAbsolute); ConcreteComponentDescriptor::adopt(shadowNode); } diff --git a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm index 67846a66342..4df8893ba2f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +++ b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm @@ -57,7 +57,7 @@ static std::shared_ptr const constructCoordinator( ContextContainer::Shared const &contextContainer, ComponentDescriptor::Flavor const &flavor) { - auto componentName = *std::static_pointer_cast(flavor); + auto &componentName = *static_cast(flavor.get()); auto moduleName = moduleNameFromComponentName(componentName); Class module = NSClassFromString(RCTNSStringFromString(moduleName)); assert(module); @@ -101,7 +101,7 @@ ComponentHandle LegacyViewManagerInteropComponentDescriptor::getComponentHandle( ComponentName LegacyViewManagerInteropComponentDescriptor::getComponentName() const { - return std::static_pointer_cast(this->flavor_)->c_str(); + return static_cast(flavor_.get())->c_str(); } void LegacyViewManagerInteropComponentDescriptor::adopt(ShadowNode::Unshared const &shadowNode) const @@ -109,11 +109,11 @@ void LegacyViewManagerInteropComponentDescriptor::adopt(ShadowNode::Unshared con ConcreteComponentDescriptor::adopt(shadowNode); assert(std::dynamic_pointer_cast(shadowNode)); - auto legacyViewManagerInteropShadowNode = std::static_pointer_cast(shadowNode); + auto &legacyViewManagerInteropShadowNode = static_cast(*shadowNode); auto state = LegacyViewManagerInteropState{}; state.coordinator = _coordinator; - legacyViewManagerInteropShadowNode->setStateData(std::move(state)); + legacyViewManagerInteropShadowNode.setStateData(std::move(state)); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h index dbb7c40a964..49300366e52 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h @@ -23,20 +23,16 @@ class ModalHostViewComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(ShadowNode::Unshared const &shadowNode) const override { - auto modalShadowNode = - std::static_pointer_cast(shadowNode); + auto &layoutableShadowNode = + static_cast(*shadowNode); + auto &stateData = + static_cast( + *shadowNode->getState()) + .getData(); - auto layoutableShadowNode = - std::static_pointer_cast(modalShadowNode); - - auto state = - std::static_pointer_cast( - shadowNode->getState()); - auto stateData = state->getData(); - - layoutableShadowNode->setSize( + layoutableShadowNode.setSize( Size{stateData.screenSize.width, stateData.screenSize.height}); - layoutableShadowNode->setPositionType(YGPositionTypeAbsolute); + layoutableShadowNode.setPositionType(YGPositionTypeAbsolute); ConcreteComponentDescriptor::adopt(shadowNode); } diff --git a/packages/react-native/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h index 6dc1ce41a1a..1f3fc051432 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h @@ -29,17 +29,17 @@ class AndroidProgressBarComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto androidProgressBarShadowNode = - std::static_pointer_cast(shadowNode); + auto &androidProgressBarShadowNode = + static_cast(*shadowNode); // `AndroidProgressBarShadowNode` uses // `AndroidProgressBarMeasurementsManager` to provide measurements to Yoga. - androidProgressBarShadowNode->setAndroidProgressBarMeasurementsManager( + androidProgressBarShadowNode.setAndroidProgressBarMeasurementsManager( measurementsManager_); // All `AndroidProgressBarShadowNode`s must have leaf Yoga nodes with // properly setup measure function. - androidProgressBarShadowNode->enableMeasurement(); + androidProgressBarShadowNode.enableMeasurement(); } private: diff --git a/packages/react-native/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h index 09134eb9abd..b0b916b853b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h @@ -22,21 +22,13 @@ class SafeAreaViewComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { react_native_assert( std::dynamic_pointer_cast(shadowNode)); - auto safeAreaViewShadowNode = - std::static_pointer_cast(shadowNode); - - react_native_assert(std::dynamic_pointer_cast( - safeAreaViewShadowNode)); - auto layoutableShadowNode = - std::static_pointer_cast( - safeAreaViewShadowNode); - - auto state = - std::static_pointer_cast( - shadowNode->getState()); - auto stateData = state->getData(); - - layoutableShadowNode->setPadding(stateData.padding); + auto &layoutableShadowNode = + static_cast(*shadowNode); + auto &stateData = + static_cast( + *shadowNode->getState()) + .getData(); + layoutableShadowNode.setPadding(stateData.padding); ConcreteComponentDescriptor::adopt(shadowNode); } diff --git a/packages/react-native/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h index 5ce046bebe5..a2694a68dc9 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h @@ -29,17 +29,17 @@ class AndroidSwitchComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto androidSwitchShadowNode = - std::static_pointer_cast(shadowNode); + auto &androidSwitchShadowNode = + static_cast(*shadowNode); // `AndroidSwitchShadowNode` uses `AndroidSwitchMeasurementsManager` to // provide measurements to Yoga. - androidSwitchShadowNode->setAndroidSwitchMeasurementsManager( + androidSwitchShadowNode.setAndroidSwitchMeasurementsManager( measurementsManager_); // All `AndroidSwitchShadowNode`s must have leaf Yoga nodes with properly // setup measure function. - androidSwitchShadowNode->enableMeasurement(); + androidSwitchShadowNode.enableMeasurement(); } private: diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h index 3d76dc9306c..85576b0f56c 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h @@ -31,12 +31,11 @@ class ParagraphComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto paragraphShadowNode = - std::static_pointer_cast(shadowNode); + auto ¶graphShadowNode = static_cast(*shadowNode); // `ParagraphShadowNode` uses `TextLayoutManager` to measure text content // and communicate text rendering metrics to mounting layer. - paragraphShadowNode->setTextLayoutManager(textLayoutManager_); + paragraphShadowNode.setTextLayoutManager(textLayoutManager_); } private: diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h index 33f183d58e3..7ea08be94c9 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h @@ -84,52 +84,49 @@ class AndroidTextInputComponentDescriptor final protected: void adopt(ShadowNode::Unshared const &shadowNode) const override { - auto textInputShadowNode = - std::static_pointer_cast(shadowNode); + auto &textInputShadowNode = + static_cast(*shadowNode); // `ParagraphShadowNode` uses `TextLayoutManager` to measure text content // and communicate text rendering metrics to mounting layer. - textInputShadowNode->setTextLayoutManager(textLayoutManager_); + textInputShadowNode.setTextLayoutManager(textLayoutManager_); - textInputShadowNode->setContextContainer( + textInputShadowNode.setContextContainer( const_cast(getContextContainer().get())); - int surfaceId = textInputShadowNode->getSurfaceId(); + int surfaceId = textInputShadowNode.getSurfaceId(); if (surfaceIdToThemePaddingMap_.find(surfaceId) != surfaceIdToThemePaddingMap_.end()) { YGStyle::Edges theme = surfaceIdToThemePaddingMap_[surfaceId]; + auto &textInputProps = textInputShadowNode.getConcreteProps(); + // Override padding // Node is still unsealed during adoption, before layout is complete // TODO: T62959168 account for RTL and paddingLeft when setting default // paddingStart, and vice-versa with paddingRight/paddingEnd. // For now this assumes no RTL. - YGStyle::Edges result = - textInputShadowNode->getConcreteProps().yogaStyle.padding(); + YGStyle::Edges result = textInputProps.yogaStyle.padding(); bool changedPadding = false; - if (!textInputShadowNode->getConcreteProps().hasPadding && - !textInputShadowNode->getConcreteProps().hasPaddingStart && - !textInputShadowNode->getConcreteProps().hasPaddingLeft && - !textInputShadowNode->getConcreteProps().hasPaddingHorizontal) { + if (!textInputProps.hasPadding && !textInputProps.hasPaddingStart && + !textInputProps.hasPaddingLeft && + !textInputProps.hasPaddingHorizontal) { changedPadding = true; result[YGEdgeStart] = theme[YGEdgeStart]; } - if (!textInputShadowNode->getConcreteProps().hasPadding && - !textInputShadowNode->getConcreteProps().hasPaddingEnd && - !textInputShadowNode->getConcreteProps().hasPaddingRight && - !textInputShadowNode->getConcreteProps().hasPaddingHorizontal) { + if (!textInputProps.hasPadding && !textInputProps.hasPaddingEnd && + !textInputProps.hasPaddingRight && + !textInputProps.hasPaddingHorizontal) { changedPadding = true; result[YGEdgeEnd] = theme[YGEdgeEnd]; } - if (!textInputShadowNode->getConcreteProps().hasPadding && - !textInputShadowNode->getConcreteProps().hasPaddingTop && - !textInputShadowNode->getConcreteProps().hasPaddingVertical) { + if (!textInputProps.hasPadding && !textInputProps.hasPaddingTop && + !textInputProps.hasPaddingVertical) { changedPadding = true; result[YGEdgeTop] = theme[YGEdgeTop]; } - if (!textInputShadowNode->getConcreteProps().hasPadding && - !textInputShadowNode->getConcreteProps().hasPaddingBottom && - !textInputShadowNode->getConcreteProps().hasPaddingVertical) { + if (!textInputProps.hasPadding && !textInputProps.hasPaddingBottom && + !textInputProps.hasPaddingVertical) { changedPadding = true; result[YGEdgeBottom] = theme[YGEdgeBottom]; } @@ -139,16 +136,14 @@ class AndroidTextInputComponentDescriptor final // paddingLeft update, we must explicitly unset paddingStart... (same with // paddingEnd) // TODO: support RTL - if ((textInputShadowNode->getConcreteProps().hasPadding || - textInputShadowNode->getConcreteProps().hasPaddingLeft || - textInputShadowNode->getConcreteProps().hasPaddingHorizontal) && - !textInputShadowNode->getConcreteProps().hasPaddingStart) { + if ((textInputProps.hasPadding || textInputProps.hasPaddingLeft || + textInputProps.hasPaddingHorizontal) && + !textInputProps.hasPaddingStart) { result[YGEdgeStart] = YGValueUndefined; } - if ((textInputShadowNode->getConcreteProps().hasPadding || - textInputShadowNode->getConcreteProps().hasPaddingRight || - textInputShadowNode->getConcreteProps().hasPaddingHorizontal) && - !textInputShadowNode->getConcreteProps().hasPaddingEnd) { + if ((textInputProps.hasPadding || textInputProps.hasPaddingRight || + textInputProps.hasPaddingHorizontal) && + !textInputProps.hasPaddingEnd) { result[YGEdgeEnd] = YGValueUndefined; } @@ -157,16 +152,15 @@ class AndroidTextInputComponentDescriptor final // commit, state update, etc, will incur this cost. if (changedPadding) { // Set new props on node - const_cast( - textInputShadowNode->getConcreteProps()) + const_cast(textInputProps) .yogaStyle.padding() = result; // Communicate new props to Yoga part of the node - textInputShadowNode->updateYogaProps(); + textInputShadowNode.updateYogaProps(); } } - textInputShadowNode->dirtyLayout(); - textInputShadowNode->enableMeasurement(); + textInputShadowNode.dirtyLayout(); + textInputShadowNode.enableMeasurement(); ConcreteComponentDescriptor::adopt(shadowNode); } diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputComponentDescriptor.h index c1a900be843..224c7703fe7 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputComponentDescriptor.h @@ -28,10 +28,8 @@ class TextInputComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto concreteShadowNode = - std::static_pointer_cast(shadowNode); - - concreteShadowNode->setTextLayoutManager(textLayoutManager_); + auto &concreteShadowNode = static_cast(*shadowNode); + concreteShadowNode.setTextLayoutManager(textLayoutManager_); } private: diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp index 5fd1a4ba9cb..b0420504ef4 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp @@ -15,7 +15,7 @@ ComponentHandle UnimplementedViewComponentDescriptor::getComponentHandle() } ComponentName UnimplementedViewComponentDescriptor::getComponentName() const { - return std::static_pointer_cast(this->flavor_)->c_str(); + return static_cast(flavor_.get())->c_str(); } Props::Shared UnimplementedViewComponentDescriptor::cloneProps( @@ -32,7 +32,7 @@ Props::Shared UnimplementedViewComponentDescriptor::cloneProps( emptyRawProps.parse(rawPropsParser_, context); auto unimplementedViewProps = std::make_shared( context, - *std::static_pointer_cast(clonedProps), + static_cast(*clonedProps), emptyRawProps); unimplementedViewProps->setComponentName(getComponentName()); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index d9ebf62e9b5..5d42331e70d 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -260,7 +260,7 @@ void AccessibilityProps::setProp( #if RN_DEBUG_STRING_CONVERTIBLE SharedDebugStringConvertibleList AccessibilityProps::getDebugProps() const { - auto const &defaultProps = AccessibilityProps(); + const auto &defaultProps = AccessibilityProps(); return SharedDebugStringConvertibleList{ debugStringConvertibleItem("testId", testId, defaultProps.testId), }; diff --git a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 3315e745ab8..93fe429330c 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -87,11 +87,10 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { void appendChild( const ShadowNode::Shared &parentShadowNode, const ShadowNode::Shared &childShadowNode) const override { - auto concreteParentShadowNode = - std::static_pointer_cast(parentShadowNode); - auto concreteNonConstParentShadowNode = - std::const_pointer_cast(concreteParentShadowNode); - concreteNonConstParentShadowNode->appendChild(childShadowNode); + auto &concreteParentShadowNode = + static_cast(*parentShadowNode); + const_cast(concreteParentShadowNode) + .appendChild(childShadowNode); } virtual Props::Shared cloneProps( diff --git a/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h b/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h index 640342d1965..61fb3299cf7 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h @@ -49,7 +49,7 @@ class ConcreteState : public State { * Returns stored data. */ Data const &getData() const { - return *std::static_pointer_cast(data_); + return *static_cast(data_.get()); } /* @@ -90,7 +90,7 @@ class ConcreteState : public State { auto stateUpdate = StateUpdate{ family, [=](StateData::Shared const &oldData) -> StateData::Shared { react_native_assert(oldData); - return callback(*std::static_pointer_cast(oldData)); + return callback(*static_cast(oldData.get())); }}; family->dispatchRawState(std::move(stateUpdate), priority); diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp index ba8da5d6f1e..f8782c879f0 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp @@ -227,9 +227,8 @@ void ShadowNode::appendChild(const ShadowNode::Shared &child) { ensureUnsealed(); cloneChildrenIfShared(); - auto nonConstChildren = - std::const_pointer_cast(children_); - nonConstChildren->push_back(child); + auto &children = const_cast(*children_); + children.push_back(child); child->family_->setParent(family_); } @@ -241,11 +240,9 @@ void ShadowNode::replaceChild( ensureUnsealed(); cloneChildrenIfShared(); - newChild->family_->setParent(family_); - auto &children = - *std::const_pointer_cast(children_); + auto &children = const_cast(*children_); auto size = children.size(); if (suggestedIndex != -1 && suggestedIndex < size) { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp index f504c986b5c..1ded30dcfda 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -446,7 +446,7 @@ void ShadowTree::emitLayoutEvents( // Checking if the `onLayout` event was requested for the particular Shadow // Node. - auto const &viewProps = + const auto &viewProps = static_cast(*viewShadowNode.getProps()); if (!viewProps.onLayout) { continue; diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 2e4db8f6e19..9d8daa8fd4d 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -332,7 +332,7 @@ jsi::Value UIManagerBinding::get( size_t count) -> jsi::Value { validateArgumentCount(runtime, methodName, paramCount, count); - auto const &rawProps = RawProps(runtime, arguments[1]); + const auto &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, uiManager->cloneNode( @@ -356,7 +356,7 @@ jsi::Value UIManagerBinding::get( size_t count) -> jsi::Value { validateArgumentCount(runtime, methodName, paramCount, count); - auto const &rawProps = RawProps(runtime, arguments[1]); + const auto &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, uiManager->cloneNode( diff --git a/packages/react-native/ReactCommon/react/utils/ContextContainer.h b/packages/react-native/ReactCommon/react/utils/ContextContainer.h index f71fb759493..d9b602240de 100644 --- a/packages/react-native/ReactCommon/react/utils/ContextContainer.h +++ b/packages/react-native/ReactCommon/react/utils/ContextContainer.h @@ -82,7 +82,7 @@ class ContextContainer final { react_native_assert( instances_.find(key) != instances_.end() && "ContextContainer doesn't have an instance for given key."); - return *std::static_pointer_cast(instances_.at(key)); + return *static_cast(instances_.at(key).get()); } /* @@ -99,7 +99,7 @@ class ContextContainer final { return {}; } - return *std::static_pointer_cast(iterator->second); + return *static_cast(iterator->second.get()); } private: