Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/ASDisplayNode+Beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ extern void ASDisplayNodePerformBlockOnEveryYogaChild(ASDisplayNode * _Nullable

@interface ASDisplayNode (Yoga)

@property (nonatomic, strong) NSArray *yogaChildren;
@property (nonatomic, strong) ASLayout *yogaCalculatedLayout;
@property (nonatomic, strong, nullable) NSArray *yogaChildren;
@property (nonatomic, strong, nullable) ASLayout *yogaCalculatedLayout;

- (void)addYogaChild:(ASDisplayNode *)child;
- (void)removeYogaChild:(ASDisplayNode *)child;
Expand Down
3 changes: 2 additions & 1 deletion Source/ASDisplayNode+Yoga.mm
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ - (void)invalidateCalculatedYogaLayout
if (YGNodeGetMeasureFunc(yogaNode)) {
YGNodeMarkDirty(yogaNode);
}
self.yogaCalculatedLayout = nil;
}

- (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute
Expand All @@ -350,7 +351,7 @@ - (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute
- (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize
{
if (self.yogaParent) {
if (ASHierarchyStateIncludesYogaLayoutMeasuring(self.hierarchyState) == NO) {
if (self.yogaCalculatedLayout == nil) {
[self _setNeedsLayoutFromAbove];
}
return;
Expand Down
18 changes: 10 additions & 8 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1166,17 +1166,19 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
ASDN::MutexLocker l(__instanceLock__);

#if YOGA /* YOGA */
if (ASHierarchyStateIncludesYogaLayoutEnabled(_hierarchyState) == YES &&
ASHierarchyStateIncludesYogaLayoutMeasuring(_hierarchyState) == NO) {
ASDN::MutexUnlocker ul(__instanceLock__);
[self calculateLayoutFromYogaRoot:constrainedSize];
}
if (ASHierarchyStateIncludesYogaLayoutEnabled(_hierarchyState) == YES) {
if (ASHierarchyStateIncludesYogaLayoutMeasuring(_hierarchyState) == NO && self.yogaCalculatedLayout == nil) {
ASDN::MutexUnlocker ul(__instanceLock__);
[self calculateLayoutFromYogaRoot:constrainedSize];
}

if (ASHierarchyStateIncludesYogaLayoutEnabled(_hierarchyState) == YES && self.yogaCalculatedLayout) {
return self.yogaCalculatedLayout;
// The call above may set yogaCalculatedLayout, even if it tested as nil to enter it.
if (self.yogaCalculatedLayout && self.yogaChildren.count > 0) {
return self.yogaCalculatedLayout;
}
}
#endif /* YOGA */

// Manual size calculation via calculateSizeThatFits:
if (((_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) ||
(_layoutSpecBlock != NULL)) == NO) {
Expand Down