From de113987f528da8cb15c8f06cb2624cf7dc82018 Mon Sep 17 00:00:00 2001 From: Max Wang Date: Mon, 10 Dec 2018 14:29:43 -0800 Subject: [PATCH] Yoga debug info (#1253) * fix SIMULATE_WEB_RESPONSE not imported #449 * Fix to make rangeMode update in right time * remove uncessary assert * Fix collection cell editing bug for iOS 9 & 10 * Revert "Fix collection cell editing bug for iOS 9 & 10" This reverts commit 06e18a10596622ff8a68835c95a23986d7bf61ea. * Add description method for yoga. * Fix comment --- Source/ASDisplayNode+Beta.h | 6 ++++++ Source/ASDisplayNode+Yoga.mm | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Source/ASDisplayNode+Beta.h b/Source/ASDisplayNode+Beta.h index 01c08609e..7adaf5e16 100644 --- a/Source/ASDisplayNode+Beta.h +++ b/Source/ASDisplayNode+Beta.h @@ -210,6 +210,12 @@ AS_EXTERN void ASDisplayNodePerformBlockOnEveryYogaChild(ASDisplayNode * _Nullab @end +@interface ASDisplayNode (YogaDebugging) + +- (NSString *)yogaTreeDescription; + +@end + @interface ASLayoutElementStyle (Yoga) - (YGNodeRef)yogaNodeCreateIfNeeded; diff --git a/Source/ASDisplayNode+Yoga.mm b/Source/ASDisplayNode+Yoga.mm index 8bea5d551..6dc1e8a8e 100644 --- a/Source/ASDisplayNode+Yoga.mm +++ b/Source/ASDisplayNode+Yoga.mm @@ -351,4 +351,20 @@ - (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize @end +@implementation ASDisplayNode (YogaDebugging) + +- (NSString *)yogaTreeDescription { + return [self _yogaTreeDescription:@""]; +} + +- (NSString *)_yogaTreeDescription:(NSString *)indent { + auto subtree = [NSMutableString stringWithFormat:@"%@%@\n", indent, self.description]; + for (ASDisplayNode *n in self.yogaChildren) { + [subtree appendString:[n _yogaTreeDescription:[indent stringByAppendingString:@"| "]]]; + } + return subtree; +} + +@end + #endif /* YOGA */