Skip to content

Commit

Permalink
RCTShadowViews's cssNode property was renamed to yogaNode
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D4590104

fbshipit-source-id: 7767aaa62bcbdce2746c3a26543052dd46be63e0
  • Loading branch information
shergin authored and Gabor Wnuk committed Feb 28, 2017
1 parent a68aaf4 commit 471a9d7
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 66 deletions.
20 changes: 10 additions & 10 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ - (void)setUp
[super setUp];

self.parentView = [RCTRootShadowView new];
YGNodeStyleSetFlexDirection(self.parentView.cssNode, YGFlexDirectionColumn);
YGNodeStyleSetWidth(self.parentView.cssNode, 440);
YGNodeStyleSetHeight(self.parentView.cssNode, 440);
YGNodeStyleSetFlexDirection(self.parentView.yogaNode, YGFlexDirectionColumn);
YGNodeStyleSetWidth(self.parentView.yogaNode, 440);
YGNodeStyleSetHeight(self.parentView.yogaNode, 440);
self.parentView.reactTag = @1; // must be valid rootView tag
}

Expand Down Expand Up @@ -82,10 +82,10 @@ - (void)testApplyingLayoutRecursivelyToShadowView
YGNodeStyleSetFlex(node, 1);
}];

YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeLeft, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeTop, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeRight, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeBottom, 10);
YGNodeStyleSetPadding(self.parentView.yogaNode, YGEdgeLeft, 10);
YGNodeStyleSetPadding(self.parentView.yogaNode, YGEdgeTop, 10);
YGNodeStyleSetPadding(self.parentView.yogaNode, YGEdgeRight, 10);
YGNodeStyleSetPadding(self.parentView.yogaNode, YGEdgeBottom, 10);

[self.parentView insertReactSubview:headerView atIndex:0];
[self.parentView insertReactSubview:mainView atIndex:1];
Expand Down Expand Up @@ -167,8 +167,8 @@ - (void)testDoesNotOverrideDimensionStyleWithSuggestedDimensions

- (void)testDoesNotAssignSuggestedDimensionsWhenStyledWithFlexAttribute
{
float parentWidth = YGNodeStyleGetWidth(self.parentView.cssNode).value;
float parentHeight = YGNodeStyleGetHeight(self.parentView.cssNode).value;
float parentWidth = YGNodeStyleGetWidth(self.parentView.yogaNode).value;
float parentHeight = YGNodeStyleGetHeight(self.parentView.yogaNode).value;
[self _withShadowViewWithStyle:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}
Expand All @@ -194,7 +194,7 @@ - (void)_withShadowViewWithStyle:(void(^)(YGNodeRef node))configBlock
- (RCTShadowView *)_shadowViewWithConfig:(void(^)(YGNodeRef node))configBlock
{
RCTShadowView *shadowView = [RCTShadowView new];
configBlock(shadowView.cssNode);
configBlock(shadowView.yogaNode);
return shadowView;
}

Expand Down
14 changes: 7 additions & 7 deletions Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ - (instancetype)init
_writingDirection = NSWritingDirectionNatural;
_cachedEffectiveLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight;

YGNodeSetMeasureFunc(self.cssNode, RCTMeasure);
YGNodeSetMeasureFunc(self.yogaNode, RCTMeasure);

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeMultiplierDidChange:)
Expand All @@ -94,14 +94,14 @@ - (NSString *)description
return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", [self attributedString].string];
}

- (BOOL)isCSSLeafNode
- (BOOL)isYogaLeafNode
{
return YES;
}

- (void)contentSizeMultiplierDidChange:(NSNotification *)note
{
YGNodeMarkDirty(self.cssNode);
YGNodeMarkDirty(self.yogaNode);
[self dirtyText];
}

Expand Down Expand Up @@ -166,7 +166,7 @@ - (void)applyLayoutToChildren:(YGNodeRef)node
NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
[layoutManager.textStorage enumerateAttribute:RCTShadowViewAttributeName inRange:characterRange options:0 usingBlock:^(RCTShadowView *child, NSRange range, BOOL *_) {
if (child) {
YGNodeRef childNode = child.cssNode;
YGNodeRef childNode = child.yogaNode;
float width = YGNodeStyleGetWidth(childNode).value;
float height = YGNodeStyleGetHeight(childNode).value;
if (YGFloatIsUndefined(width) || YGFloatIsUndefined(height)) {
Expand Down Expand Up @@ -324,8 +324,8 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
[child setTextComputed];
} else {
float width = YGNodeStyleGetWidth(child.cssNode).value;
float height = YGNodeStyleGetHeight(child.cssNode).value;
float width = YGNodeStyleGetWidth(child.yogaNode).value;
float height = YGNodeStyleGetHeight(child.yogaNode).value;
if (YGFloatIsUndefined(width) || YGFloatIsUndefined(height)) {
RCTLogError(@"Views nested within a <Text> must have a width and height");
}
Expand Down Expand Up @@ -365,7 +365,7 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily

// create a non-mutable attributedString for use by the Text system which avoids copies down the line
_cachedAttributedString = [[NSAttributedString alloc] initWithAttributedString:attributedString];
YGNodeMarkDirty(self.cssNode);
YGNodeMarkDirty(self.yogaNode);

return _cachedAttributedString;
}
Expand Down
4 changes: 2 additions & 2 deletions React/Views/RCTRootShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ - (instancetype)init
float availableWidth = _availableSize.width == INFINITY ? YGUndefined : _availableSize.width;
float availableHeight = _availableSize.height == INFINITY ? YGUndefined : _availableSize.height;

YGNodeCalculateLayout(self.cssNode, availableWidth, availableHeight, _baseDirection);
YGNodeCalculateLayout(self.yogaNode, availableWidth, availableHeight, _baseDirection);

NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set];
[self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];
[self applyLayoutNode:self.yogaNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];
return viewsWithNewFrame;
}

Expand Down
20 changes: 15 additions & 5 deletions React/Views/RCTShadowView.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
- (void)removeReactSubview:(RCTShadowView *)subview NS_REQUIRES_SUPER;

@property (nonatomic, weak, readonly) RCTShadowView *superview;
@property (nonatomic, assign, readonly) YGNodeRef cssNode;
@property (nonatomic, assign, readonly) YGNodeRef yogaNode;
@property (nonatomic, copy) NSString *viewName;
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children
@property (nonatomic, copy) RCTDirectEventBlock onLayout;
Expand Down Expand Up @@ -211,11 +211,11 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
absolutePosition:(CGPoint)absolutePosition;

/**
* Return whether or not this node acts as a leaf node in the eyes of Yoga. For example
* RCTShadowText has children which it does not want Yoga to lay out so in the eyes of
* Yoga it is a leaf node.
* Return whether or not this node acts as a leaf node in the eyes of Yoga.
* For example `RCTShadowText` has children which it does not want Yoga
* to lay out so in the eyes of Yoga it is a leaf node.
*/
- (BOOL)isCSSLeafNode;
- (BOOL)isYogaLeafNode;

- (void)dirtyPropagation NS_REQUIRES_SUPER;
- (BOOL)isPropagationDirty;
Expand Down Expand Up @@ -246,3 +246,13 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
- (BOOL)viewIsDescendantOf:(RCTShadowView *)ancestor;

@end

@interface RCTShadowView (Deprecated)

@property (nonatomic, assign, readonly) YGNodeRef cssNode
__deprecated_msg("Use `yogaNode` instead.");

- (BOOL)isCSSLeafNode
__deprecated_msg("Use `isYogaLeafNode` instead.");

@end
Loading

0 comments on commit 471a9d7

Please sign in to comment.