[Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. (#370)

[Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. #trivial
This commit is contained in:
appleguy
2017-06-18 18:18:59 -07:00
committed by GitHub
parent 486410d7d6
commit 8c33a617ed
7 changed files with 2 additions and 42 deletions

View File

@@ -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

View File

@@ -31,8 +31,6 @@
#pragma mark - ASDisplayNode+Yoga
#if YOGA_TREE_CONTIGUOUS
@interface ASDisplayNode (YogaInternal)
@property (nonatomic, weak) ASDisplayNode *yogaParent;
- (ASSizeRange)_locked_constrainedSizeForLayoutPass;
@@ -42,8 +40,6 @@
@property (nonatomic, getter=isFlattened) BOOL flattened;
@end
#endif /* YOGA_TREE_CONTIGUOUS */
@implementation ASDisplayNode (Yoga)
- (void)setYogaChildren:(NSArray *)yogaChildren
@@ -80,23 +76,12 @@
[_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
@@ -108,18 +93,12 @@
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
@@ -132,8 +111,6 @@
}
}
#if YOGA_TREE_CONTIGUOUS /* YOGA_TREE_CONTIGUOUS */
- (void)setYogaParent:(ASDisplayNode *)yogaParent
{
if (_yogaParent == yogaParent) {
@@ -292,8 +269,6 @@
#endif /* YOGA_LAYOUT_LOGGING */
}
#endif /* YOGA_TREE_CONTIGUOUS */
@end
#endif /* YOGA */

View File

@@ -894,7 +894,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
_unflattenedLayout = nil;
#if YOGA_TREE_CONTIGUOUS
#if YOGA
[self invalidateCalculatedYogaLayout];
#endif
}
@@ -968,7 +968,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
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.

View File

@@ -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>)

View File

@@ -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>
@@ -22,5 +21,4 @@
@property (nonatomic, strong, nonnull) ASDisplayNode *rootNode;
@end
#endif /* !YOGA_TREE_CONTIGUOUS */
#endif /* YOGA */

View File

@@ -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>
@@ -176,5 +175,4 @@
@end
#endif /* !YOGA_TREE_CONTIGUOUS */
#endif /* YOGA */

View File

@@ -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