Add assertion for ASDisplayNode is layer backed if using ASInterfaceStateForDisplayNode

This commit is contained in:
Michael Schneider
2016-03-16 16:27:08 -07:00
parent 41ca796ef4
commit e82118e72f
4 changed files with 19 additions and 18 deletions

View File

@@ -1137,7 +1137,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
[node __exitHierarchy];
}
// Updating the visible node index paths only for range managed nodes. Not range managed nodes will get their
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
// their update in the layout pass
if (![node supportsRangeManagedInterfaceState]) {
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];

View File

@@ -12,8 +12,11 @@
extern ASInterfaceState ASInterfaceStateForDisplayNode(ASDisplayNode *displayNode, UIWindow *window)
{
ASDisplayNodeCAssert(![displayNode isLayerBacked], @"displayNode must not be layer backed as it may have a nil window");
if (displayNode && [displayNode supportsRangeManagedInterfaceState]) {
// Only use the interfaceState of nodes that are range managed
// Directly clear the visible bit if we are not in a window. This means that the interface state is,
// if not already, about to be set to invisible as it is not possible for an element to be visible
// while outside of a window.
ASInterfaceState interfaceState = displayNode.interfaceState;
return (window == nil ? (interfaceState &= (~ASInterfaceStateVisible)) : interfaceState);
} else {

View File

@@ -1069,7 +1069,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
[node __exitHierarchy];
}
// Updating the visible node index paths only for range managed nodes. Not range managed nodes will get their
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
// their update in the layout pass
if (![node supportsRangeManagedInterfaceState]) {
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];

View File

@@ -12,20 +12,6 @@
#import "ASCollectionNode.h"
#import "ASTableNode.h"
/**
* Update the range mode for a range controller to a explicitly set range mode until the node that contains the range
* controller becomes visible again
*
* Logic for the automatic range mode:
* 1. If there are no visible node paths available nothing is to be done and no range update will happen
* 2. The initial range update if the range controller is visible always will be ASLayoutRangeModeCount
* (ASLayoutRangeModeMinimum) as it's the initial fetch
* 3. The range mode set explicitly via updateCurrentRangeWithMode: will last at least one range update. After that it
the range controller will use the explicit set range mode until it becomes visible and a new range update was
triggered or a new range mode via updateCurrentRangeWithMode: is set
* 4. If range mode is not explicitly set the range mode is variying based if the range controller is visible or not
*/
@protocol ASRangeControllerUpdateRangeProtocol <NSObject>
@@ -48,7 +34,19 @@
@interface ASRangeController (ASRangeControllerUpdateRangeProtocol) <ASRangeControllerUpdateRangeProtocol>
/// This is a way for a one way update of range with a given mode.
/**
* Update the range mode for a range controller to a explicitly set mode until the node that contains the range
* controller becomes visible again
*
* Logic for the automatic range mode:
* 1. If there are no visible node paths available nothing is to be done and no range update will happen
* 2. The initial range update if the range controller is visible always will be ASLayoutRangeModeCount
* (ASLayoutRangeModeMinimum) as it's the initial fetch
* 3. The range mode set explicitly via updateCurrentRangeWithMode: will last at least one range update. After that it
the range controller will use the explicit set range mode until it becomes visible and a new range update was
triggered or a new range mode via updateCurrentRangeWithMode: is set
* 4. If range mode is not explicitly set the range mode is variying based if the range controller is visible or not
*/
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
@end