From 8c33a617ed5c44559cd2a267e2f12d26d64ebcba Mon Sep 17 00:00:00 2001 From: appleguy Date: Sun, 18 Jun 2017 18:18:59 -0700 Subject: [PATCH] [Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. (#370) [Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. #trivial --- Source/ASDisplayNode+Beta.h | 2 -- Source/ASDisplayNode+Yoga.mm | 25 ------------------------- Source/ASDisplayNode.mm | 4 ++-- Source/Base/ASAvailability.h | 7 ------- Source/Layout/ASYogaLayoutSpec.h | 2 -- Source/Layout/ASYogaLayoutSpec.mm | 2 -- Source/Private/ASDisplayNodeInternal.h | 2 -- 7 files changed, 2 insertions(+), 42 deletions(-) diff --git a/Source/ASDisplayNode+Beta.h b/Source/ASDisplayNode+Beta.h index 84f3df166..8235c24c9 100644 --- a/Source/ASDisplayNode+Beta.h +++ b/Source/ASDisplayNode+Beta.h @@ -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 diff --git a/Source/ASDisplayNode+Yoga.mm b/Source/ASDisplayNode+Yoga.mm index ab31bfa1d..dcfadaf51 100644 --- a/Source/ASDisplayNode+Yoga.mm +++ b/Source/ASDisplayNode+Yoga.mm @@ -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 @@ @interface ASLayout (YogaInternal) @property (nonatomic, getter=isFlattened) BOOL flattened; @end -#endif /* YOGA_TREE_CONTIGUOUS */ - @implementation ASDisplayNode (Yoga) - (void)setYogaChildren:(NSArray *)yogaChildren @@ -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 @@ -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 @@ -132,8 +111,6 @@ - (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute } } -#if YOGA_TREE_CONTIGUOUS /* YOGA_TREE_CONTIGUOUS */ - - (void)setYogaParent:(ASDisplayNode *)yogaParent { if (_yogaParent == yogaParent) { @@ -292,8 +269,6 @@ - (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize #endif /* YOGA_LAYOUT_LOGGING */ } -#endif /* YOGA_TREE_CONTIGUOUS */ - @end #endif /* YOGA */ diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index b3dc7e9a5..e866548d5 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -894,7 +894,7 @@ - (void)invalidateCalculatedLayout _unflattenedLayout = nil; -#if YOGA_TREE_CONTIGUOUS +#if YOGA [self invalidateCalculatedYogaLayout]; #endif } @@ -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. diff --git a/Source/Base/ASAvailability.h b/Source/Base/ASAvailability.h index 0a9737512..bb2defe24 100644 --- a/Source/Base/ASAvailability.h +++ b/Source/Base/ASAvailability.h @@ -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() #define AS_IG_LIST_KIT __has_include() diff --git a/Source/Layout/ASYogaLayoutSpec.h b/Source/Layout/ASYogaLayoutSpec.h index 4323b484c..f2e13a67c 100644 --- a/Source/Layout/ASYogaLayoutSpec.h +++ b/Source/Layout/ASYogaLayoutSpec.h @@ -13,7 +13,6 @@ #import #if YOGA /* YOGA */ -#if !YOGA_TREE_CONTIGUOUS /* !YOGA_TREE_CONTIGUOUS */ #import #import @@ -22,5 +21,4 @@ @property (nonatomic, strong, nonnull) ASDisplayNode *rootNode; @end -#endif /* !YOGA_TREE_CONTIGUOUS */ #endif /* YOGA */ diff --git a/Source/Layout/ASYogaLayoutSpec.mm b/Source/Layout/ASYogaLayoutSpec.mm index a5c34294b..2da6ed92d 100644 --- a/Source/Layout/ASYogaLayoutSpec.mm +++ b/Source/Layout/ASYogaLayoutSpec.mm @@ -13,7 +13,6 @@ #import #if YOGA /* YOGA */ -#if !YOGA_TREE_CONTIGUOUS /* !YOGA_TREE_CONTIGUOUS */ #import #import @@ -176,5 +175,4 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize @end -#endif /* !YOGA_TREE_CONTIGUOUS */ #endif /* YOGA */ diff --git a/Source/Private/ASDisplayNodeInternal.h b/Source/Private/ASDisplayNodeInternal.h index e857e6665..10f48bced 100644 --- a/Source/Private/ASDisplayNodeInternal.h +++ b/Source/Private/ASDisplayNodeInternal.h @@ -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 , with a few areas requiring updates. NSMutableArray *_yogaChildren; -#endif -#if YOGA_TREE_CONTIGUOUS __weak ASDisplayNode *_yogaParent; ASLayout *_yogaCalculatedLayout; #endif