mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use static_cast instead of static_pointer_cast where possible (#37932)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37932 `static_cast<Derived &>(*sharedBase)` is preferred over `*std::static_pointer_cast<Derived>(sharedBase)`, since we don't need to copy the underlying shared_ptr to do so. The same applies for `std::const_pointer_cast`. Changelog: [Internal] Reviewed By: rshest Differential Revision: D46766558 fbshipit-source-id: 5d0b660107b2a60340952e2b5ec2792e3ed1832a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa17aad24e
commit
a855013fc6
+2
-2
@@ -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<const ActivityIndicatorViewProps>(_props);
|
||||
const auto &newViewProps = *std::static_pointer_cast<const ActivityIndicatorViewProps>(props);
|
||||
const auto &oldViewProps = static_cast<ActivityIndicatorViewProps const &>(*_props);
|
||||
const auto &newViewProps = static_cast<ActivityIndicatorViewProps const &>(*props);
|
||||
|
||||
if (oldViewProps.animating != newViewProps.animating) {
|
||||
if (newViewProps.animating) {
|
||||
|
||||
+9
-9
@@ -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<ImageProps const>(_props);
|
||||
auto const &newImageProps = *std::static_pointer_cast<ImageProps const>(props);
|
||||
const auto &oldImageProps = static_cast<ImageProps const &>(*_props);
|
||||
const auto &newImageProps = static_cast<ImageProps const &>(*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<ImageEventEmitter const>(_eventEmitter)->onLoadStart();
|
||||
static_cast<ImageEventEmitter const &>(*_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<ImageEventEmitter const>(_eventEmitter)->onLoad();
|
||||
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onLoadEnd();
|
||||
static_cast<ImageEventEmitter const &>(*_eventEmitter).onLoad();
|
||||
static_cast<ImageEventEmitter const &>(*_eventEmitter).onLoadEnd();
|
||||
|
||||
const auto &imageProps = *std::static_pointer_cast<ImageProps const>(_props);
|
||||
const auto &imageProps = static_cast<ImageProps const &>(*_props);
|
||||
|
||||
if (imageProps.tintColor) {
|
||||
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
@@ -176,7 +176,7 @@ using namespace facebook::react;
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onProgress(progress);
|
||||
static_cast<ImageEventEmitter const &>(*_eventEmitter).onProgress(progress);
|
||||
}
|
||||
|
||||
- (void)didReceiveFailureFromObserver:(void const *)observer
|
||||
@@ -187,8 +187,8 @@ using namespace facebook::react;
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onError();
|
||||
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onLoadEnd();
|
||||
static_cast<ImageEventEmitter const &>(*_eventEmitter).onError();
|
||||
static_cast<ImageEventEmitter const &>(*_eventEmitter).onLoadEnd();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+2
-2
@@ -107,8 +107,8 @@ static UIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWithNat
|
||||
|
||||
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
||||
{
|
||||
auto const &oldInputAccessoryProps = *std::static_pointer_cast<InputAccessoryProps const>(_props);
|
||||
auto const &newInputAccessoryProps = *std::static_pointer_cast<InputAccessoryProps const>(props);
|
||||
const auto &oldInputAccessoryProps = static_cast<InputAccessoryProps const &>(*_props);
|
||||
const auto &newInputAccessoryProps = static_cast<InputAccessoryProps const &>(*props);
|
||||
|
||||
if (newInputAccessoryProps.backgroundColor != oldInputAccessoryProps.backgroundColor) {
|
||||
_contentView.backgroundColor = RCTUIColorFromSharedColor(newInputAccessoryProps.backgroundColor);
|
||||
|
||||
+4
-4
@@ -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<LegacyViewManagerInteropViewEventEmitter const>(strongSelf->_eventEmitter);
|
||||
eventEmitter->dispatchEvent(eventName, event);
|
||||
const auto &eventEmitter =
|
||||
static_cast<LegacyViewManagerInteropViewEventEmitter const &>(*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<const LegacyViewManagerInteropViewProps>(_props);
|
||||
const auto &newProps = static_cast<LegacyViewManagerInteropViewProps const &>(*_props);
|
||||
[_adapter setProps:newProps.otherProps];
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -182,12 +182,12 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
||||
|
||||
- (std::shared_ptr<const ModalHostViewEventEmitter>)modalEventEmitter
|
||||
{
|
||||
if (!self->_eventEmitter) {
|
||||
if (!_eventEmitter) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(self->_eventEmitter));
|
||||
return std::static_pointer_cast<ModalHostViewEventEmitter const>(self->_eventEmitter);
|
||||
assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter));
|
||||
return std::static_pointer_cast<ModalHostViewEventEmitter const>(_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<const ModalHostViewProps>(props);
|
||||
const auto &newProps = static_cast<ModalHostViewProps const &>(*props);
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
self.viewController.supportedInterfaceOrientations = supportedOrientationsMask(newProps.supportedOrientations);
|
||||
|
||||
+4
-4
@@ -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<PullToRefreshViewProps const>(_props);
|
||||
auto const &newConcreteProps = *std::static_pointer_cast<PullToRefreshViewProps const>(props);
|
||||
const auto &oldConcreteProps = static_cast<PullToRefreshViewProps const &>(*_props);
|
||||
const auto &newConcreteProps = static_cast<PullToRefreshViewProps const &>(*props);
|
||||
|
||||
if (newConcreteProps.refreshing != oldConcreteProps.refreshing) {
|
||||
if (newConcreteProps.refreshing) {
|
||||
@@ -89,12 +89,12 @@ using namespace facebook::react;
|
||||
|
||||
- (void)handleUIControlEventValueChanged
|
||||
{
|
||||
std::static_pointer_cast<PullToRefreshViewEventEmitter const>(_eventEmitter)->onRefresh({});
|
||||
static_cast<PullToRefreshViewEventEmitter const &>(*_eventEmitter).onRefresh({});
|
||||
}
|
||||
|
||||
- (void)_updateTitle
|
||||
{
|
||||
auto const &concreteProps = *std::static_pointer_cast<PullToRefreshViewProps const>(_props);
|
||||
const auto &concreteProps = static_cast<PullToRefreshViewProps const &>(*_props);
|
||||
|
||||
if (concreteProps.title.empty()) {
|
||||
_refreshControl.attributedTitle = nil;
|
||||
|
||||
+14
-15
@@ -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<const ScrollViewProps>(_props);
|
||||
const auto &newScrollViewProps = *std::static_pointer_cast<const ScrollViewProps>(props);
|
||||
const auto &oldScrollViewProps = static_cast<ScrollViewProps const &>(*_props);
|
||||
const auto &newScrollViewProps = static_cast<ScrollViewProps const &>(*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<const ScrollViewProps>(_props);
|
||||
const auto &props = static_cast<ScrollViewProps const &>(*_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<ScrollViewEventEmitter const>(_eventEmitter)->onScroll([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onScroll([self _scrollViewMetrics]);
|
||||
}
|
||||
|
||||
RCTSendScrollEventForNativeAnimations_DEPRECATED(scrollView, self.tag);
|
||||
@@ -479,7 +479,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onScrollBeginDrag([self _scrollViewMetrics]);
|
||||
_isUserTriggeredScrolling = YES;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onScrollEndDrag([self _scrollViewMetrics]);
|
||||
|
||||
[self _updateStateWithContentOffset];
|
||||
|
||||
@@ -510,8 +510,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)
|
||||
->onMomentumScrollBegin([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onMomentumScrollBegin([self _scrollViewMetrics]);
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||
@@ -522,7 +521,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onMomentumScrollEnd([self _scrollViewMetrics]);
|
||||
[self _updateStateWithContentOffset];
|
||||
_isUserTriggeredScrolling = NO;
|
||||
}
|
||||
@@ -541,7 +540,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_eventEmitter).onMomentumScrollEnd([self _scrollViewMetrics]);
|
||||
[self _updateStateWithContentOffset];
|
||||
}
|
||||
|
||||
@@ -553,7 +552,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
return;
|
||||
}
|
||||
|
||||
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_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<ScrollViewEventEmitter const>(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]);
|
||||
static_cast<ScrollViewEventEmitter const &>(*_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<const ScrollViewProps>(_props);
|
||||
const auto &props = static_cast<ScrollViewProps const &>(*_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<const ScrollViewProps>(_props);
|
||||
const auto &props = static_cast<ScrollViewProps const &>(*_props);
|
||||
if (!props.maintainVisibleContentPosition) {
|
||||
return;
|
||||
}
|
||||
@@ -740,7 +739,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
|
||||
|
||||
- (void)_adjustForMaintainVisibleContentPosition
|
||||
{
|
||||
const auto &props = *std::static_pointer_cast<const ScrollViewProps>(_props);
|
||||
const auto &props = static_cast<ScrollViewProps const &>(*_props);
|
||||
if (!props.maintainVisibleContentPosition) {
|
||||
return;
|
||||
}
|
||||
|
||||
+5
-5
@@ -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<const SwitchProps>(_props);
|
||||
const auto &newSwitchProps = *std::static_pointer_cast<const SwitchProps>(props);
|
||||
const auto &oldSwitchProps = static_cast<SwitchProps const &>(*_props);
|
||||
const auto &newSwitchProps = static_cast<SwitchProps const &>(*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<const SwitchProps>(_props);
|
||||
const auto &props = static_cast<SwitchProps const &>(*_props);
|
||||
if (props.value == sender.on) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::dynamic_pointer_cast<const SwitchEventEmitter>(_eventEmitter)
|
||||
->onChange(SwitchEventEmitter::OnChange{.value = static_cast<bool>(sender.on)});
|
||||
static_cast<const SwitchEventEmitter &>(*_eventEmitter)
|
||||
.onChange(SwitchEventEmitter::OnChange{.value = static_cast<bool>(sender.on)});
|
||||
}
|
||||
|
||||
#pragma mark - Native Commands
|
||||
|
||||
+5
-5
@@ -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<ParagraphProps const>(_props);
|
||||
auto const &newParagraphProps = *std::static_pointer_cast<ParagraphProps const>(props);
|
||||
const auto &oldParagraphProps = static_cast<ParagraphProps const &>(*_props);
|
||||
const auto &newParagraphProps = static_cast<ParagraphProps const &>(*props);
|
||||
|
||||
_paragraphAttributes = newParagraphProps.paragraphAttributes;
|
||||
|
||||
@@ -147,7 +147,7 @@ using namespace facebook::react;
|
||||
|
||||
- (NSArray *)accessibilityElements
|
||||
{
|
||||
auto const ¶graphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
|
||||
const auto ¶graphProps = static_cast<ParagraphProps const &>(*_props);
|
||||
|
||||
// If the component is not `accessible`, we return an empty array.
|
||||
// We do this because logically all nested <Text> components represent the content of the <Paragraph> component;
|
||||
@@ -241,13 +241,13 @@ using namespace facebook::react;
|
||||
|
||||
- (BOOL)canBecomeFirstResponder
|
||||
{
|
||||
auto const ¶graphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
|
||||
const auto ¶graphProps = static_cast<ParagraphProps const &>(*_props);
|
||||
return paragraphProps.isSelectable;
|
||||
}
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
||||
{
|
||||
auto const ¶graphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
|
||||
const auto ¶graphProps = static_cast<ParagraphProps const &>(*_props);
|
||||
|
||||
if (paragraphProps.isSelectable && action == @selector(copy:)) {
|
||||
return YES;
|
||||
|
||||
+18
-19
@@ -82,7 +82,7 @@ using namespace facebook::react;
|
||||
[super didMoveToWindow];
|
||||
|
||||
if (self.window && !_didMoveToWindow) {
|
||||
auto const &props = *std::static_pointer_cast<TextInputProps const>(_props);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_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<TextInputProps const>(_props);
|
||||
auto const &newTextInputProps = *std::static_pointer_cast<TextInputProps const>(props);
|
||||
const auto &oldTextInputProps = static_cast<TextInputProps const &>(*_props);
|
||||
const auto &newTextInputProps = static_cast<TextInputProps const &>(*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<TextInputEventEmitter const>(_eventEmitter);
|
||||
textInputEventEmitter.onContentSizeChange([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_eventEmitter).onContentSizeChange([self _textInputMetrics]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +277,7 @@ using namespace facebook::react;
|
||||
|
||||
- (void)textInputDidBeginEditing
|
||||
{
|
||||
auto const &props = *std::static_pointer_cast<TextInputProps const>(_props);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_props);
|
||||
|
||||
if (props.traits.clearTextOnFocus) {
|
||||
_backedTextInputView.attributedText = nil;
|
||||
@@ -291,7 +290,7 @@ using namespace facebook::react;
|
||||
}
|
||||
|
||||
if (_eventEmitter) {
|
||||
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onFocus([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_eventEmitter).onFocus([self _textInputMetrics]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,8 +302,8 @@ using namespace facebook::react;
|
||||
- (void)textInputDidEndEditing
|
||||
{
|
||||
if (_eventEmitter) {
|
||||
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onEndEditing([self _textInputMetrics]);
|
||||
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onBlur([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_eventEmitter).onEndEditing([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_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<TextInputEventEmitter const>(_eventEmitter)->onSubmitEditing([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_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<TextInputProps const>(_props);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_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<TextInputEventEmitter const>(_eventEmitter);
|
||||
auto const &textInputEventEmitter = static_cast<TextInputEventEmitter const &>(*_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<TextInputEventEmitter const>(_eventEmitter);
|
||||
auto const &props = *std::static_pointer_cast<TextInputProps const>(_props);
|
||||
auto const &textInputEventEmitter = static_cast<TextInputEventEmitter const &>(*_eventEmitter);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_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<TextInputProps const>(_props);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_props);
|
||||
if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
|
||||
[self textInputDidChange];
|
||||
_ignoreNextTextInputCall = YES;
|
||||
}
|
||||
|
||||
if (_eventEmitter) {
|
||||
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onSelectionChange([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_eventEmitter).onSelectionChange([self _textInputMetrics]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,7 +424,7 @@ using namespace facebook::react;
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if (_eventEmitter) {
|
||||
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onScroll([self _textInputMetrics]);
|
||||
static_cast<TextInputEventEmitter const &>(*_eventEmitter).onScroll([self _textInputMetrics]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +578,7 @@ using namespace facebook::react;
|
||||
|
||||
- (void)_restoreTextSelection
|
||||
{
|
||||
auto const selection = std::dynamic_pointer_cast<TextInputProps const>(_props)->selection;
|
||||
const auto &selection = static_cast<TextInputProps const &>(*_props).selection;
|
||||
if (!selection.has_value()) {
|
||||
return;
|
||||
}
|
||||
@@ -659,7 +658,7 @@ using namespace facebook::react;
|
||||
|
||||
- (SubmitBehavior)getSubmitBehavior
|
||||
{
|
||||
auto const &props = *std::static_pointer_cast<TextInputProps const>(_props);
|
||||
const auto &props = static_cast<TextInputProps const &>(*_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.
|
||||
|
||||
+2
-2
@@ -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<const UnimplementedNativeViewProps>(_props);
|
||||
const auto &newViewProps = *std::static_pointer_cast<const UnimplementedNativeViewProps>(props);
|
||||
const auto &oldViewProps = static_cast<UnimplementedNativeViewProps const &>(*_props);
|
||||
const auto &newViewProps = static_cast<UnimplementedNativeViewProps const &>(*props);
|
||||
|
||||
if (oldViewProps.name != newViewProps.name) {
|
||||
_label.text = [NSString stringWithFormat:@"'%s' is not Fabric compatible yet.", newViewProps.name.c_str()];
|
||||
|
||||
+2
-2
@@ -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<UnimplementedViewProps const>(_props);
|
||||
auto const &newUnimplementedViewProps = *std::static_pointer_cast<UnimplementedViewProps const>(props);
|
||||
const auto &oldUnimplementedViewProps = static_cast<UnimplementedViewProps const &>(*_props);
|
||||
const auto &newUnimplementedViewProps = static_cast<UnimplementedViewProps const &>(*props);
|
||||
|
||||
if (oldUnimplementedViewProps.getComponentName() != newUnimplementedViewProps.getComponentName()) {
|
||||
_label.text =
|
||||
|
||||
+4
-4
@@ -193,8 +193,8 @@ using namespace facebook::react;
|
||||
NSStringFromClass([self class]));
|
||||
#endif
|
||||
|
||||
auto const &oldViewProps = *std::static_pointer_cast<ViewProps const>(_props);
|
||||
auto const &newViewProps = *std::static_pointer_cast<ViewProps const>(props);
|
||||
const auto &oldViewProps = static_cast<ViewProps const &>(*_props);
|
||||
const auto &newViewProps = static_cast<ViewProps const &>(*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<ViewProps const>(_props);
|
||||
const auto &props = static_cast<ViewProps const &>(*_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<ViewProps const>(_props);
|
||||
const auto &props = static_cast<ViewProps const &>(*_props);
|
||||
|
||||
// Handle Switch.
|
||||
if ((self.accessibilityTraits & AccessibilityTraitSwitch) == AccessibilityTraitSwitch) {
|
||||
|
||||
@@ -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<const ViewProps>(newProps);
|
||||
const auto &newViewProps = static_cast<ViewProps const &>(*newProps);
|
||||
|
||||
if (props[@"transform"] &&
|
||||
!CATransform3DEqualToTransform(
|
||||
|
||||
+3
-3
@@ -88,9 +88,9 @@ CoreComponentsRegistry::initHybrid(
|
||||
auto registry = CoreComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(
|
||||
{eventDispatcher, contextContainer});
|
||||
auto mutableRegistry =
|
||||
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
|
||||
mutableRegistry->setFallbackComponentDescriptor(
|
||||
auto &mutableRegistry =
|
||||
const_cast<ComponentDescriptorRegistry &>(*registry);
|
||||
mutableRegistry.setFallbackComponentDescriptor(
|
||||
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
|
||||
ComponentDescriptorParameters{
|
||||
eventDispatcher, contextContainer, nullptr}));
|
||||
|
||||
+5
-10
@@ -201,19 +201,14 @@ static inline void writeIntBufferTypePreamble(
|
||||
// TODO: this method will be removed when binding for components are code-gen
|
||||
jni::local_ref<jstring> getPlatformComponentName(ShadowView const &shadowView) {
|
||||
static std::string scrollViewComponentName = std::string("ScrollView");
|
||||
|
||||
jni::local_ref<jstring> componentName;
|
||||
if (scrollViewComponentName == shadowView.componentName) {
|
||||
auto newViewProps =
|
||||
std::static_pointer_cast<const ScrollViewProps>(shadowView.props);
|
||||
if (newViewProps->getProbablyMoreHorizontalThanVertical_DEPRECATED()) {
|
||||
componentName = jni::make_jstring("AndroidHorizontalScrollView");
|
||||
return componentName;
|
||||
const auto &newViewProps =
|
||||
static_cast<const ScrollViewProps &>(*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) {
|
||||
|
||||
+3
-4
@@ -44,10 +44,9 @@ DefaultComponentsRegistry::initHybrid(
|
||||
->createComponentDescriptorRegistry(
|
||||
{eventDispatcher, contextContainer});
|
||||
|
||||
auto mutableRegistry =
|
||||
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
|
||||
|
||||
mutableRegistry->setFallbackComponentDescriptor(
|
||||
auto &mutableRegistry =
|
||||
const_cast<ComponentDescriptorRegistry &>(*registry);
|
||||
mutableRegistry.setFallbackComponentDescriptor(
|
||||
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
|
||||
ComponentDescriptorParameters{
|
||||
eventDispatcher, contextContainer, nullptr}));
|
||||
|
||||
+6
-8
@@ -467,8 +467,7 @@ LayoutAnimationKeyFrameManager::pullTransaction(
|
||||
|
||||
if (baselineShadowView.traits.check(
|
||||
ShadowNodeTraits::Trait::ViewKind)) {
|
||||
auto const &viewProps =
|
||||
*std::static_pointer_cast<ViewProps const>(props);
|
||||
const auto &viewProps = static_cast<ViewProps const &>(*props);
|
||||
const_cast<ViewProps &>(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<ViewProps const>(props);
|
||||
const auto &viewProps = static_cast<ViewProps const &>(*props);
|
||||
const_cast<ViewProps &>(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<ViewProps const>(props);
|
||||
const auto &viewProps =
|
||||
static_cast<ViewProps const &>(*props);
|
||||
const_cast<ViewProps &>(viewProps).opacity = 0;
|
||||
}
|
||||
|
||||
@@ -615,8 +613,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
|
||||
|
||||
if (baselineShadowView.traits.check(
|
||||
ShadowNodeTraits::Trait::ViewKind)) {
|
||||
auto const &viewProps =
|
||||
*std::static_pointer_cast<ViewProps const>(props);
|
||||
const auto &viewProps =
|
||||
static_cast<ViewProps const &>(*props);
|
||||
const_cast<ViewProps &>(viewProps).transform =
|
||||
Transform::Scale(isScaleX ? 0 : 1, isScaleY ? 0 : 1, 1);
|
||||
}
|
||||
|
||||
+2
-3
@@ -27,12 +27,11 @@ class ImageComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
auto imageShadowNode =
|
||||
std::static_pointer_cast<ImageShadowNode>(shadowNode);
|
||||
auto &imageShadowNode = static_cast<ImageShadowNode &>(*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:
|
||||
|
||||
+8
-11
@@ -22,20 +22,17 @@ class InputAccessoryComponentDescriptor final
|
||||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
||||
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
auto concreteShadowNode =
|
||||
std::static_pointer_cast<InputAccessoryShadowNode>(shadowNode);
|
||||
auto &layoutableShadowNode =
|
||||
static_cast<YogaLayoutableShadowNode &>(*shadowNode);
|
||||
|
||||
auto layoutableShadowNode =
|
||||
std::static_pointer_cast<YogaLayoutableShadowNode>(concreteShadowNode);
|
||||
auto &stateData =
|
||||
static_cast<const InputAccessoryShadowNode::ConcreteState &>(
|
||||
*shadowNode->getState())
|
||||
.getData();
|
||||
|
||||
auto state =
|
||||
std::static_pointer_cast<const InputAccessoryShadowNode::ConcreteState>(
|
||||
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);
|
||||
}
|
||||
|
||||
+4
-4
@@ -57,7 +57,7 @@ static std::shared_ptr<void> const constructCoordinator(
|
||||
ContextContainer::Shared const &contextContainer,
|
||||
ComponentDescriptor::Flavor const &flavor)
|
||||
{
|
||||
auto componentName = *std::static_pointer_cast<std::string const>(flavor);
|
||||
auto &componentName = *static_cast<std::string const *>(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<std::string const>(this->flavor_)->c_str();
|
||||
return static_cast<std::string const *>(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<LegacyViewManagerInteropShadowNode>(shadowNode));
|
||||
auto legacyViewManagerInteropShadowNode = std::static_pointer_cast<LegacyViewManagerInteropShadowNode>(shadowNode);
|
||||
auto &legacyViewManagerInteropShadowNode = static_cast<LegacyViewManagerInteropShadowNode &>(*shadowNode);
|
||||
|
||||
auto state = LegacyViewManagerInteropState{};
|
||||
state.coordinator = _coordinator;
|
||||
|
||||
legacyViewManagerInteropShadowNode->setStateData(std::move(state));
|
||||
legacyViewManagerInteropShadowNode.setStateData(std::move(state));
|
||||
}
|
||||
} // namespace facebook::react
|
||||
|
||||
+8
-12
@@ -23,20 +23,16 @@ class ModalHostViewComponentDescriptor final
|
||||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
||||
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
auto modalShadowNode =
|
||||
std::static_pointer_cast<ModalHostViewShadowNode>(shadowNode);
|
||||
auto &layoutableShadowNode =
|
||||
static_cast<YogaLayoutableShadowNode &>(*shadowNode);
|
||||
auto &stateData =
|
||||
static_cast<const ModalHostViewShadowNode::ConcreteState &>(
|
||||
*shadowNode->getState())
|
||||
.getData();
|
||||
|
||||
auto layoutableShadowNode =
|
||||
std::static_pointer_cast<YogaLayoutableShadowNode>(modalShadowNode);
|
||||
|
||||
auto state =
|
||||
std::static_pointer_cast<const ModalHostViewShadowNode::ConcreteState>(
|
||||
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);
|
||||
}
|
||||
|
||||
+4
-4
@@ -29,17 +29,17 @@ class AndroidProgressBarComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
auto androidProgressBarShadowNode =
|
||||
std::static_pointer_cast<AndroidProgressBarShadowNode>(shadowNode);
|
||||
auto &androidProgressBarShadowNode =
|
||||
static_cast<AndroidProgressBarShadowNode &>(*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:
|
||||
|
||||
+7
-15
@@ -22,21 +22,13 @@ class SafeAreaViewComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
react_native_assert(
|
||||
std::dynamic_pointer_cast<SafeAreaViewShadowNode>(shadowNode));
|
||||
auto safeAreaViewShadowNode =
|
||||
std::static_pointer_cast<SafeAreaViewShadowNode>(shadowNode);
|
||||
|
||||
react_native_assert(std::dynamic_pointer_cast<YogaLayoutableShadowNode>(
|
||||
safeAreaViewShadowNode));
|
||||
auto layoutableShadowNode =
|
||||
std::static_pointer_cast<YogaLayoutableShadowNode>(
|
||||
safeAreaViewShadowNode);
|
||||
|
||||
auto state =
|
||||
std::static_pointer_cast<const SafeAreaViewShadowNode::ConcreteState>(
|
||||
shadowNode->getState());
|
||||
auto stateData = state->getData();
|
||||
|
||||
layoutableShadowNode->setPadding(stateData.padding);
|
||||
auto &layoutableShadowNode =
|
||||
static_cast<YogaLayoutableShadowNode &>(*shadowNode);
|
||||
auto &stateData =
|
||||
static_cast<const SafeAreaViewShadowNode::ConcreteState &>(
|
||||
*shadowNode->getState())
|
||||
.getData();
|
||||
layoutableShadowNode.setPadding(stateData.padding);
|
||||
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
}
|
||||
|
||||
+4
-4
@@ -29,17 +29,17 @@ class AndroidSwitchComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
auto androidSwitchShadowNode =
|
||||
std::static_pointer_cast<AndroidSwitchShadowNode>(shadowNode);
|
||||
auto &androidSwitchShadowNode =
|
||||
static_cast<AndroidSwitchShadowNode &>(*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:
|
||||
|
||||
+2
-3
@@ -31,12 +31,11 @@ class ParagraphComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
auto paragraphShadowNode =
|
||||
std::static_pointer_cast<ParagraphShadowNode>(shadowNode);
|
||||
auto ¶graphShadowNode = static_cast<ParagraphShadowNode &>(*shadowNode);
|
||||
|
||||
// `ParagraphShadowNode` uses `TextLayoutManager` to measure text content
|
||||
// and communicate text rendering metrics to mounting layer.
|
||||
paragraphShadowNode->setTextLayoutManager(textLayoutManager_);
|
||||
paragraphShadowNode.setTextLayoutManager(textLayoutManager_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+28
-34
@@ -84,52 +84,49 @@ class AndroidTextInputComponentDescriptor final
|
||||
|
||||
protected:
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
auto textInputShadowNode =
|
||||
std::static_pointer_cast<AndroidTextInputShadowNode>(shadowNode);
|
||||
auto &textInputShadowNode =
|
||||
static_cast<AndroidTextInputShadowNode &>(*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<ContextContainer *>(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<AndroidTextInputProps &>(
|
||||
textInputShadowNode->getConcreteProps())
|
||||
const_cast<AndroidTextInputProps &>(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);
|
||||
}
|
||||
|
||||
+2
-4
@@ -28,10 +28,8 @@ class TextInputComponentDescriptor final
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
auto concreteShadowNode =
|
||||
std::static_pointer_cast<TextInputShadowNode>(shadowNode);
|
||||
|
||||
concreteShadowNode->setTextLayoutManager(textLayoutManager_);
|
||||
auto &concreteShadowNode = static_cast<TextInputShadowNode &>(*shadowNode);
|
||||
concreteShadowNode.setTextLayoutManager(textLayoutManager_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ ComponentHandle UnimplementedViewComponentDescriptor::getComponentHandle()
|
||||
}
|
||||
|
||||
ComponentName UnimplementedViewComponentDescriptor::getComponentName() const {
|
||||
return std::static_pointer_cast<std::string const>(this->flavor_)->c_str();
|
||||
return static_cast<std::string const *>(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<UnimplementedViewProps>(
|
||||
context,
|
||||
*std::static_pointer_cast<UnimplementedViewProps const>(clonedProps),
|
||||
static_cast<UnimplementedViewProps const &>(*clonedProps),
|
||||
emptyRawProps);
|
||||
|
||||
unimplementedViewProps->setComponentName(getComponentName());
|
||||
|
||||
+1
-1
@@ -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),
|
||||
};
|
||||
|
||||
@@ -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<const ShadowNodeT>(parentShadowNode);
|
||||
auto concreteNonConstParentShadowNode =
|
||||
std::const_pointer_cast<ShadowNodeT>(concreteParentShadowNode);
|
||||
concreteNonConstParentShadowNode->appendChild(childShadowNode);
|
||||
auto &concreteParentShadowNode =
|
||||
static_cast<const ShadowNodeT &>(*parentShadowNode);
|
||||
const_cast<ShadowNodeT &>(concreteParentShadowNode)
|
||||
.appendChild(childShadowNode);
|
||||
}
|
||||
|
||||
virtual Props::Shared cloneProps(
|
||||
|
||||
@@ -49,7 +49,7 @@ class ConcreteState : public State {
|
||||
* Returns stored data.
|
||||
*/
|
||||
Data const &getData() const {
|
||||
return *std::static_pointer_cast<Data const>(data_);
|
||||
return *static_cast<Data const *>(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<Data const>(oldData));
|
||||
return callback(*static_cast<Data const *>(oldData.get()));
|
||||
}};
|
||||
|
||||
family->dispatchRawState(std::move(stateUpdate), priority);
|
||||
|
||||
@@ -227,9 +227,8 @@ void ShadowNode::appendChild(const ShadowNode::Shared &child) {
|
||||
ensureUnsealed();
|
||||
|
||||
cloneChildrenIfShared();
|
||||
auto nonConstChildren =
|
||||
std::const_pointer_cast<ShadowNode::ListOfShared>(children_);
|
||||
nonConstChildren->push_back(child);
|
||||
auto &children = const_cast<ShadowNode::ListOfShared &>(*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<ShadowNode::ListOfShared>(children_);
|
||||
auto &children = const_cast<ShadowNode::ListOfShared &>(*children_);
|
||||
auto size = children.size();
|
||||
|
||||
if (suggestedIndex != -1 && suggestedIndex < size) {
|
||||
|
||||
@@ -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<ViewProps const &>(*viewShadowNode.getProps());
|
||||
if (!viewProps.onLayout) {
|
||||
continue;
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<T>(instances_.at(key));
|
||||
return *static_cast<T *>(instances_.at(key).get());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -99,7 +99,7 @@ class ContextContainer final {
|
||||
return {};
|
||||
}
|
||||
|
||||
return *std::static_pointer_cast<T>(iterator->second);
|
||||
return *static_cast<T *>(iterator->second.get());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user