From 59157b87fdd53752d628ce19916c2da05f0f1eb7 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 27 Feb 2023 07:43:50 -0800 Subject: [PATCH] Back out "feat: Add iOS Paper implementation of inset logical properties" Summary: This backs out https://github.com/facebook/react-native/pull/36241 for causing screenshot failures in an app still using Paper. Changelog: [iOS][Removed] - Back out "[react-native][PR] feat: Add iOS Paper implementation of inset logical properties" Reviewed By: motiz88, rshest Differential Revision: D43621612 fbshipit-source-id: 0fc01d6c6ae5c5bfb2813bd60b25e9315e42e3c3 --- React/Views/RCTShadowView.h | 7 --- React/Views/RCTShadowView.m | 110 +++++++++++------------------------ React/Views/RCTViewManager.m | 7 --- 3 files changed, 34 insertions(+), 90 deletions(-) diff --git a/React/Views/RCTShadowView.h b/React/Views/RCTShadowView.h index 6f8a1dce219..4cf8323be55 100644 --- a/React/Views/RCTShadowView.h +++ b/React/Views/RCTShadowView.h @@ -86,13 +86,6 @@ typedef void (^RCTApplierBlock)(NSDictionary *viewRegistry @property (nonatomic, assign) YGValue right; @property (nonatomic, assign) YGValue start; @property (nonatomic, assign) YGValue end; -@property (nonatomic, assign) YGValue inset; -@property (nonatomic, assign) YGValue insetInline; -@property (nonatomic, assign) YGValue insetInlineEnd; -@property (nonatomic, assign) YGValue insetInlineStart; -@property (nonatomic, assign) YGValue insetBlock; -@property (nonatomic, assign) YGValue insetBlockEnd; -@property (nonatomic, assign) YGValue insetBlockStart; @property (nonatomic, assign) YGValue width; @property (nonatomic, assign) YGValue height; diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index e4fdf9ff739..baca3cef65e 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -29,12 +29,6 @@ typedef NS_ENUM(unsigned int, meta_prop_t) { META_PROP_HORIZONTAL, META_PROP_VERTICAL, META_PROP_ALL, - META_PROP_INLINE, - META_PROP_INLINE_END, - META_PROP_INLINE_START, - META_PROP_BLOCK, - META_PROP_BLOCK_END, - META_PROP_BLOCK_START, META_PROP_COUNT, }; @@ -44,11 +38,9 @@ typedef NS_ENUM(unsigned int, meta_prop_t) { BOOL _recomputePadding; BOOL _recomputeMargin; BOOL _recomputeBorder; - BOOL _recomputePosition; YGValue _paddingMetaProps[META_PROP_COUNT]; YGValue _marginMetaProps[META_PROP_COUNT]; YGValue _borderMetaProps[META_PROP_COUNT]; - YGValue _positionMetaProps[META_PROP_COUNT]; } + (YGConfigRef)yogaConfig @@ -170,47 +162,6 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT], YGNodeStyleSetBorder(node, YGEdgeAll, metaProps[META_PROP_ALL].value); } -static void RCTProcessMetaPropsPosition(const YGValue metaProps[META_PROP_COUNT], YGNodeRef node) -{ - YGNodeStyleSetPosition(node, YGEdgeTop, metaProps[META_PROP_TOP].value); - YGNodeStyleSetPosition(node, YGEdgeBottom, metaProps[META_PROP_BOTTOM].value); - YGNodeStyleSetPosition(node, YGEdgeStart, metaProps[META_PROP_START].value); - YGNodeStyleSetPosition(node, YGEdgeEnd, metaProps[META_PROP_END].value); - - if (![[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL]) { - YGNodeStyleSetPosition(node, YGEdgeLeft, metaProps[META_PROP_LEFT].value); - YGNodeStyleSetPosition(node, YGEdgeRight, metaProps[META_PROP_RIGHT].value); - } else { - YGNodeStyleSetPosition(node, YGEdgeStart, metaProps[META_PROP_LEFT].value); - YGNodeStyleSetPosition(node, YGEdgeEnd, metaProps[META_PROP_RIGHT].value); - } - - // Aliases with precedence - if (!YGFloatIsUndefined(metaProps[META_PROP_ALL].value)) { - YGNodeStyleSetPosition(node, YGEdgeAll, metaProps[META_PROP_ALL].value); - } - if (!YGFloatIsUndefined(metaProps[META_PROP_BLOCK].value)) { - YGNodeStyleSetPosition(node, YGEdgeVertical, metaProps[META_PROP_BLOCK].value); - } - if (!YGFloatIsUndefined(metaProps[META_PROP_INLINE].value)) { - YGNodeStyleSetPosition(node, YGEdgeHorizontal, metaProps[META_PROP_INLINE].value); - } - if (!YGFloatIsUndefined(metaProps[META_PROP_INLINE_END].value)) { - YGNodeStyleSetPosition(node, YGEdgeEnd, metaProps[META_PROP_INLINE_END].value); - } - if (!YGFloatIsUndefined(metaProps[META_PROP_INLINE_START].value)) { - YGNodeStyleSetPosition(node, YGEdgeStart, metaProps[META_PROP_INLINE_START].value); - } - - // Aliases without precedence - if (YGFloatIsUndefined(metaProps[META_PROP_BOTTOM].value)) { - YGNodeStyleSetPosition(node, YGEdgeBottom, metaProps[META_PROP_BLOCK_END].value); - } - if (YGFloatIsUndefined(metaProps[META_PROP_TOP].value)) { - YGNodeStyleSetPosition(node, YGEdgeTop, metaProps[META_PROP_BLOCK_START].value); - } -} - - (CGRect)measureLayoutRelativeToAncestor:(RCTShadowView *)ancestor { CGPoint offset = CGPointZero; @@ -242,7 +193,6 @@ static void RCTProcessMetaPropsPosition(const YGValue metaProps[META_PROP_COUNT] _paddingMetaProps[ii] = YGValueUndefined; _marginMetaProps[ii] = YGValueUndefined; _borderMetaProps[ii] = YGValueUndefined; - _positionMetaProps[ii] = YGValueUndefined; } _intrinsicContentSize = CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric); @@ -562,30 +512,42 @@ RCT_MIN_MAX_DIMENSION_PROPERTY(MaxHeight, maxHeight, MaxHeight) // Position -#define RCT_POSITION_PROPERTY(setProp, getProp, metaProp) \ - -(void)set##setProp : (YGValue)value \ - { \ - _positionMetaProps[META_PROP_##metaProp] = value; \ - _recomputePosition = YES; \ - } \ - -(YGValue)getProp \ - { \ - return _positionMetaProps[META_PROP_##metaProp]; \ +#define RCT_POSITION_PROPERTY(setProp, getProp, edge) \ + -(void)set##setProp : (YGValue)value \ + { \ + RCT_SET_YGVALUE(value, YGNodeStyleSetPosition, _yogaNode, edge); \ + } \ + -(YGValue)getProp \ + { \ + return YGNodeStyleGetPosition(_yogaNode, edge); \ } -RCT_POSITION_PROPERTY(Top, top, TOP) -RCT_POSITION_PROPERTY(Bottom, bottom, BOTTOM) -RCT_POSITION_PROPERTY(Left, left, LEFT) -RCT_POSITION_PROPERTY(Right, right, RIGHT) -RCT_POSITION_PROPERTY(Start, start, START) -RCT_POSITION_PROPERTY(End, end, END) -RCT_POSITION_PROPERTY(Inset, inset, ALL) -RCT_POSITION_PROPERTY(InsetInline, insetInline, INLINE) -RCT_POSITION_PROPERTY(InsetInlineEnd, insetInlineEnd, INLINE_END) -RCT_POSITION_PROPERTY(InsetInlineStart, insetInlineStart, INLINE_START) -RCT_POSITION_PROPERTY(InsetBlock, insetBlock, BLOCK) -RCT_POSITION_PROPERTY(InsetBlockEnd, insetBlockEnd, BLOCK_END) -RCT_POSITION_PROPERTY(InsetBlockStart, insetBlockStart, BLOCK_START) +RCT_POSITION_PROPERTY(Top, top, YGEdgeTop) +RCT_POSITION_PROPERTY(Bottom, bottom, YGEdgeBottom) +RCT_POSITION_PROPERTY(Start, start, YGEdgeStart) +RCT_POSITION_PROPERTY(End, end, YGEdgeEnd) + +- (void)setLeft:(YGValue)value +{ + YGEdge edge = [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL] ? YGEdgeStart : YGEdgeLeft; + RCT_SET_YGVALUE(value, YGNodeStyleSetPosition, _yogaNode, edge); +} +- (YGValue)left +{ + YGEdge edge = [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL] ? YGEdgeStart : YGEdgeLeft; + return YGNodeStyleGetPosition(_yogaNode, edge); +} + +- (void)setRight:(YGValue)value +{ + YGEdge edge = [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL] ? YGEdgeEnd : YGEdgeRight; + RCT_SET_YGVALUE(value, YGNodeStyleSetPosition, _yogaNode, edge); +} +- (YGValue)right +{ + YGEdge edge = [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL] ? YGEdgeEnd : YGEdgeRight; + return YGNodeStyleGetPosition(_yogaNode, edge); +} // Size @@ -735,13 +697,9 @@ RCT_STYLE_PROPERTY(AspectRatio, aspectRatio, AspectRatio, float) if (_recomputeBorder) { RCTProcessMetaPropsBorder(_borderMetaProps, _yogaNode); } - if (_recomputePosition) { - RCTProcessMetaPropsPosition(_positionMetaProps, _yogaNode); - } _recomputeMargin = NO; _recomputePadding = NO; _recomputeBorder = NO; - _recomputePosition = NO; } @end diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index bd1dde7c2e7..8c97b298879 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -394,13 +394,6 @@ RCT_EXPORT_SHADOW_PROPERTY(start, YGValue) RCT_EXPORT_SHADOW_PROPERTY(end, YGValue) RCT_EXPORT_SHADOW_PROPERTY(bottom, YGValue) RCT_EXPORT_SHADOW_PROPERTY(left, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(inset, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetInline, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetInlineEnd, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetInlineStart, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetBlock, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetBlockEnd, YGValue) -RCT_EXPORT_SHADOW_PROPERTY(insetBlockStart, YGValue) RCT_EXPORT_SHADOW_PROPERTY(width, YGValue) RCT_EXPORT_SHADOW_PROPERTY(height, YGValue)