Remove needsMeasure

This commit is contained in:
Adlai Holler
2015-10-09 21:13:00 -07:00
parent 0848aac186
commit 7f42b37dec
3 changed files with 4 additions and 11 deletions

View File

@@ -12,9 +12,7 @@
/** /**
* Generic cell node. Subclass this instead of `ASDisplayNode` to use with `ASTableView` and `ASCollectionView`. * Generic cell node. Subclass this instead of `ASDisplayNode` to use with `ASTableView` and `ASCollectionView`.
*/ */
@interface ASCellNode : ASDisplayNode { @interface ASCellNode : ASDisplayNode
BOOL _needsMeasure;
}
/** /**
* @abstract When enabled, ensures that the cell is completely displayed before allowed onscreen. * @abstract When enabled, ensures that the cell is completely displayed before allowed onscreen.

View File

@@ -27,7 +27,6 @@
// use UITableViewCell defaults // use UITableViewCell defaults
_selectionStyle = UITableViewCellSelectionStyleDefault; _selectionStyle = UITableViewCellSelectionStyleDefault;
self.clipsToBounds = YES; self.clipsToBounds = YES;
_needsMeasure = YES;
return self; return self;
} }

View File

@@ -15,7 +15,6 @@
#import "ASDisplayNode.h" #import "ASDisplayNode.h"
#import "ASMultidimensionalArrayUtils.h" #import "ASMultidimensionalArrayUtils.h"
#import "ASDisplayNodeInternal.h" #import "ASDisplayNodeInternal.h"
#import "ASCellNodeInternal.h"
//#define LOG(...) NSLog(__VA_ARGS__) //#define LOG(...) NSLog(__VA_ARGS__)
#define LOG(...) #define LOG(...)
@@ -106,11 +105,10 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
[indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, __unused BOOL * stop) { [indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, __unused BOOL * stop) {
ASCellNode *node = nodes[idx]; ASCellNode *node = nodes[idx];
if (node.isNodeLoaded && node.needsMeasure) { if (node.isNodeLoaded) {
ASSizeRange constrainedSize = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPath]; ASSizeRange constrainedSize = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPath];
[node measureWithSizeRange:constrainedSize]; [node measureWithSizeRange:constrainedSize];
node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height); node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height);
node.needsMeasure = NO;
} }
}]; }];
} }
@@ -130,7 +128,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
for (NSUInteger k = j; k < j + batchCount; k++) { for (NSUInteger k = j; k < j + batchCount; k++) {
ASCellNode *node = nodes[k]; ASCellNode *node = nodes[k];
if (node.needsMeasure) { if (!node.isNodeLoaded) {
nodeBoundSizes[k] = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPaths[k]]; nodeBoundSizes[k] = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPaths[k]];
} }
} }
@@ -138,12 +136,11 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
dispatch_group_async(layoutGroup, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_group_async(layoutGroup, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (NSUInteger k = j; k < j + batchCount; k++) { for (NSUInteger k = j; k < j + batchCount; k++) {
ASCellNode *node = nodes[k]; ASCellNode *node = nodes[k];
if (node.needsMeasure) { if (!node.isNodeLoaded) {
ASDisplayNodeAssert(!node.isNodeLoaded, @"Nodes that are loaded should already have been measured on the main thread."); ASDisplayNodeAssert(!node.isNodeLoaded, @"Nodes that are loaded should already have been measured on the main thread.");
ASSizeRange constrainedSize = nodeBoundSizes[k]; ASSizeRange constrainedSize = nodeBoundSizes[k];
[node measureWithSizeRange:constrainedSize]; [node measureWithSizeRange:constrainedSize];
node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height); node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height);
node.needsMeasure = NO;
} }
} }
}); });
@@ -616,7 +613,6 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
ASSizeRange constrainedSize = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPath]; ASSizeRange constrainedSize = [_dataSource dataController:self constrainedSizeForNodeAtIndexPath:indexPath];
[node measureWithSizeRange:constrainedSize]; [node measureWithSizeRange:constrainedSize];
node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height); node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height);
node.needsMeasure = NO;
}]; }];
}]; }];
}]; }];