From 67aec97523a62ba2d9bb1b4cc92c2d7c1927c359 Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Sat, 5 Dec 2015 22:41:40 -0800 Subject: [PATCH] Adopt ASHierarchyState to replace manual checking for ASCellNode parent. --- AsyncDisplayKit/ASDisplayNode.mm | 18 ++++++------------ AsyncDisplayKit/TextKit/ASTextNodeWordKerner.m | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 0edc15136a..e7d266836c 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -1585,7 +1585,7 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer) ASDisplayNodeAssert(_flags.isEnteringHierarchy, @"You should never call -willEnterHierarchy directly. Appearance is automatically managed by ASDisplayNode"); ASDisplayNodeAssert(!_flags.isExitingHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); - if (![self supportsInterfaceState]) { + if (![self supportsRangeManagedInterfaceState]) { self.interfaceState = ASInterfaceStateInHierarchy; } } @@ -1596,7 +1596,7 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer) ASDisplayNodeAssert(_flags.isExitingHierarchy, @"You should never call -didExitHierarchy directly. Appearance is automatically managed by ASDisplayNode"); ASDisplayNodeAssert(!_flags.isEnteringHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); - if (![self supportsInterfaceState]) { + if (![self supportsRangeManagedInterfaceState]) { self.interfaceState = ASInterfaceStateNone; } } @@ -1647,18 +1647,12 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer) } /** - * We currently only set interface state on nodes - * in table/collection views. For other nodes, if they are - * in the hierarchy we return `Unknown`, otherwise we return `None`. - * - * TODO: Avoid traversing up node hierarchy due to possible deadlock. - * @see https://github.com/facebook/AsyncDisplayKit/issues/900 - * Possible solution is to push `isInCellNode` state downward on `addSubnode`/`removeFromSupernode`. + * We currently only set interface state on nodes in table/collection views. For other nodes, if they are + * in the hierarchy we enable all ASInterfaceState types with `ASInterfaceStateInHierarchy`, otherwise `None`. */ -- (BOOL)supportsInterfaceState +- (BOOL)supportsRangeManagedInterfaceState { - return ([self isKindOfClass:ASCellNode.class] - || [self _supernodeWithClass:ASCellNode.class checkViewHierarchy:NO] != nil); + return (_hierarchyState & ASHierarchyStateRangeManaged); } - (ASInterfaceState)interfaceState diff --git a/AsyncDisplayKit/TextKit/ASTextNodeWordKerner.m b/AsyncDisplayKit/TextKit/ASTextNodeWordKerner.m index f0ae6eea7f..ffd9655a91 100644 --- a/AsyncDisplayKit/TextKit/ASTextNodeWordKerner.m +++ b/AsyncDisplayKit/TextKit/ASTextNodeWordKerner.m @@ -68,7 +68,7 @@ { // If it's a space character and we have custom word kerning, use the whitespace action control character. if ([layoutManager.textStorage.string characterAtIndex:characterIndex] == ' ') - return NSControlCharacterActionWhitespace; + return NSControlCharacterWhitespaceAction; return defaultAction; }