-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yoga integration improvements #1187
Conversation
maicki
commented
Oct 23, 2018
- Add thread safety for Yoga layout tree manipulation
- Support baseline alignments for ASYogaLayout
- Refactor ASLayoutElementYogaBaselineFunc to not require yogaParent (its parent style is set into a private var on ASLayoutElementStyle before layout instead)
- Only set the accessibility element to nil if the view is loaded
- Add nodeWillCalculateLayout callback to ASNodeController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to get @appleguy 's take since he knows the Yoga integration the best but this is a pretty great diff!
Source/ASDisplayNode+Yoga.mm
Outdated
- (ASDisplayNode *)yogaRoot { | ||
ASDisplayNode *yogaRoot = self; | ||
while(yogaRoot.yogaParent) { | ||
yogaRoot = yogaRoot.yogaParent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid calling yogaParent
twice per node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, also a space after "while ("
Source/ASDisplayNode+Yoga.mm
Outdated
node.yogaLayoutInProgress = YES; | ||
if (node.yogaParent) { | ||
node.style.parentAlignStyle = node.yogaParent.style.alignItems; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid getting parent twice?
Source/ASDisplayNode+Beta.h
Outdated
@@ -199,6 +199,7 @@ AS_EXTERN void ASDisplayNodePerformBlockOnEveryYogaChild(ASDisplayNode * _Nullab | |||
|
|||
@property BOOL yogaLayoutInProgress; | |||
@property (nullable, nonatomic) ASLayout *yogaCalculatedLayout; | |||
@property (weak, readonly) ASDisplayNode *yogaRoot; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might declare this a method, rather than an atomic weak property. Just to be more transparent.
Source/ASDisplayNode+Yoga.mm
Outdated
- (ASDisplayNode *)yogaRoot { | ||
ASDisplayNode *yogaRoot = self; | ||
while(yogaRoot.yogaParent) { | ||
yogaRoot = yogaRoot.yogaParent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, also a space after "while ("
- (void)setYogaChildren:(NSArray *)yogaChildren | ||
{ | ||
ASLockScope(self.yogaRoot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe? Can't the yogaRoot be changing at this time? I'm pretty sure we also need to lock self, before accessing this and also hold that lock for the duration of the method for it to be re-entrant safe.
…ts parent style is set into a private var on ASLayoutElementStyle before layout instead)
87f6e7e
to
f90a74b
Compare
* Thread safety for Yoga layout * Support baseline alignments for ASYogaLayout * Refactor ASLayoutElementYogaBaselineFunc to not require yogaParent (its parent style is set into a private var on ASLayoutElementStyle before layout instead) * Only set the accessibility element if the view is loaded * Add nodeWillCalculateLayout to ASNodeController * Update Changelog * Address first comments