Skip to content

Commit

Permalink
[Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. (#370)
Browse files Browse the repository at this point in the history
[Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. #trivial
  • Loading branch information
appleguy authored Jun 19, 2017
1 parent 486410d commit 8c33a61
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 42 deletions.
2 changes: 0 additions & 2 deletions Source/ASDisplayNode+Beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ extern void ASDisplayNodePerformBlockOnEveryYogaChild(ASDisplayNode * _Nullable

- (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute;

#if YOGA_TREE_CONTIGUOUS
@property (nonatomic, assign) BOOL yogaLayoutInProgress;
@property (nonatomic, strong, nullable) ASLayout *yogaCalculatedLayout;
// These methods should not normally be called directly.
- (void)invalidateCalculatedYogaLayout;
- (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize;
#endif

@end

Expand Down
25 changes: 0 additions & 25 deletions Source/ASDisplayNode+Yoga.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#pragma mark - ASDisplayNode+Yoga

#if YOGA_TREE_CONTIGUOUS

@interface ASDisplayNode (YogaInternal)
@property (nonatomic, weak) ASDisplayNode *yogaParent;
- (ASSizeRange)_locked_constrainedSizeForLayoutPass;
Expand All @@ -42,8 +40,6 @@ @interface ASLayout (YogaInternal)
@property (nonatomic, getter=isFlattened) BOOL flattened;
@end

#endif /* YOGA_TREE_CONTIGUOUS */

@implementation ASDisplayNode (Yoga)

- (void)setYogaChildren:(NSArray *)yogaChildren
Expand Down Expand Up @@ -80,23 +76,12 @@ - (void)addYogaChild:(ASDisplayNode *)child

[_yogaChildren addObject:child];

#if YOGA_TREE_CONTIGUOUS
// Ensure any measure function is removed before inserting the YGNodeRef child.
if (hadZeroChildren) {
[self updateYogaMeasureFuncIfNeeded];
}
// YGNodeRef insertion is done in setParent:
child.yogaParent = self;
#else
// When using non-contiguous Yoga layout, each level in the node hierarchy independently uses an ASYogaLayoutSpec
__weak ASDisplayNode *weakSelf = self;
self.layoutSpecBlock = ^ASLayoutSpec * _Nonnull(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
ASYogaLayoutSpec *spec = [[ASYogaLayoutSpec alloc] init];
spec.rootNode = weakSelf;
spec.children = weakSelf.yogaChildren;
return spec;
};
#endif
}

- (void)removeYogaChild:(ASDisplayNode *)child
Expand All @@ -108,18 +93,12 @@ - (void)removeYogaChild:(ASDisplayNode *)child
BOOL hadChildren = (_yogaChildren.count > 0);
[_yogaChildren removeObjectIdenticalTo:child];

#if YOGA_TREE_CONTIGUOUS
// YGNodeRef removal is done in setParent:
child.yogaParent = nil;
// Ensure any measure function is re-added after removing the YGNodeRef child.
if (hadChildren && _yogaChildren.count == 0) {
[self updateYogaMeasureFuncIfNeeded];
}
#else
if (_yogaChildren.count == 0) {
self.layoutSpecBlock = nil;
}
#endif
}

- (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute
Expand All @@ -132,8 +111,6 @@ - (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute
}
}

#if YOGA_TREE_CONTIGUOUS /* YOGA_TREE_CONTIGUOUS */

- (void)setYogaParent:(ASDisplayNode *)yogaParent
{
if (_yogaParent == yogaParent) {
Expand Down Expand Up @@ -292,8 +269,6 @@ - (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize
#endif /* YOGA_LAYOUT_LOGGING */
}

#endif /* YOGA_TREE_CONTIGUOUS */

@end

#endif /* YOGA */
4 changes: 2 additions & 2 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ - (void)invalidateCalculatedLayout

_unflattenedLayout = nil;

#if YOGA_TREE_CONTIGUOUS
#if YOGA
[self invalidateCalculatedYogaLayout];
#endif
}
Expand Down Expand Up @@ -968,7 +968,7 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize

ASDN::MutexLocker l(__instanceLock__);

#if YOGA_TREE_CONTIGUOUS /* YOGA */
#if YOGA
// There are several cases where Yoga could arrive here:
// - This node is not in a Yoga tree: it has neither a yogaParent nor yogaChildren.
// - This node is a Yoga tree root: it has no yogaParent, but has yogaChildren.
Expand Down
7 changes: 0 additions & 7 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
#define YOGA __has_include(YOGA_HEADER_PATH)
#endif

// Contiguous Yoga layout attempts to build a connected tree of YGNodeRef objects, across multiple levels
// in the ASDisplayNode tree (based on .yogaChildren). When disabled, ASYogaLayoutSpec is used, with a
// disjoint Yoga tree for each level in the hierarchy. Currently, both modes are experimental.
#ifndef YOGA_TREE_CONTIGUOUS
#define YOGA_TREE_CONTIGUOUS YOGA // To enable, set to YOGA, as the code depends on YOGA also being set.
#endif

#define AS_PIN_REMOTE_IMAGE __has_include(<PINRemoteImage/PINRemoteImage.h>)
#define AS_IG_LIST_KIT __has_include(<IGListKit/IGListKit.h>)

Expand Down
2 changes: 0 additions & 2 deletions Source/Layout/ASYogaLayoutSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#import <AsyncDisplayKit/ASAvailability.h>

#if YOGA /* YOGA */
#if !YOGA_TREE_CONTIGUOUS /* !YOGA_TREE_CONTIGUOUS */

#import <AsyncDisplayKit/ASDisplayNode.h>
#import <AsyncDisplayKit/ASLayoutSpec.h>
Expand All @@ -22,5 +21,4 @@
@property (nonatomic, strong, nonnull) ASDisplayNode *rootNode;
@end

#endif /* !YOGA_TREE_CONTIGUOUS */
#endif /* YOGA */
2 changes: 0 additions & 2 deletions Source/Layout/ASYogaLayoutSpec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#import <AsyncDisplayKit/ASAvailability.h>

#if YOGA /* YOGA */
#if !YOGA_TREE_CONTIGUOUS /* !YOGA_TREE_CONTIGUOUS */

#import <AsyncDisplayKit/ASYogaLayoutSpec.h>
#import <AsyncDisplayKit/ASYogaUtilities.h>
Expand Down Expand Up @@ -176,5 +175,4 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize

@end

#endif /* !YOGA_TREE_CONTIGUOUS */
#endif /* YOGA */
2 changes: 0 additions & 2 deletions Source/Private/ASDisplayNodeInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
// create ASDisplayNodes to make a stack layout when using Yoga.
// However, the implementation is mostly ready for id <ASLayoutElement>, with a few areas requiring updates.
NSMutableArray<ASDisplayNode *> *_yogaChildren;
#endif
#if YOGA_TREE_CONTIGUOUS
__weak ASDisplayNode *_yogaParent;
ASLayout *_yogaCalculatedLayout;
#endif
Expand Down

0 comments on commit 8c33a61

Please sign in to comment.