Need some more locks for working with calculated yoga layouts (#1388)

This commit is contained in:
Kevin 2019-03-09 07:55:35 -08:00 committed by Adlai Holler
parent 510000ee85
commit 872e89b772

View File

@ -286,6 +286,7 @@
- (void)invalidateCalculatedYogaLayout - (void)invalidateCalculatedYogaLayout
{ {
ASLockScopeSelf();
YGNodeRef yogaNode = self.style.yogaNode; YGNodeRef yogaNode = self.style.yogaNode;
if (yogaNode && [self shouldHaveYogaMeasureFunc]) { if (yogaNode && [self shouldHaveYogaMeasureFunc]) {
// Yoga internally asserts that MarkDirty() may only be called on nodes with a measurement function. // Yoga internally asserts that MarkDirty() may only be called on nodes with a measurement function.
@ -338,6 +339,7 @@
- (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize - (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize
{ {
ASScopedLockSet lockSet = [self lockToRootIfNeededForLayout];
ASDisplayNode *yogaRoot = self.yogaRoot; ASDisplayNode *yogaRoot = self.yogaRoot;
if (self != yogaRoot) { if (self != yogaRoot) {
@ -358,7 +360,6 @@
} }
}]; }];
// Prepare all children for the layout pass with the current Yoga tree configuration. // Prepare all children for the layout pass with the current Yoga tree configuration.
ASDisplayNodePerformBlockOnEveryYogaChild(self, ^(ASDisplayNode *_Nonnull node) { ASDisplayNodePerformBlockOnEveryYogaChild(self, ^(ASDisplayNode *_Nonnull node) {
node.yogaLayoutInProgress = YES; node.yogaLayoutInProgress = YES;