Merge pull request #493 from facebook/LayerDrivenLayout

Remove -[_ASDisplayView layoutSubviews] and use only -[_ASDisplayLayer layoutSublayers]
This commit is contained in:
appleguy 2015-06-20 20:16:13 -07:00
commit c12cbdd21a
3 changed files with 20 additions and 17 deletions

View File

@ -7,6 +7,19 @@
*/
#import "ASScrollNode.h"
#import "_ASDisplayLayer.h"
@interface ASScrollView : UIScrollView
@end
@implementation ASScrollView
+ (Class)layerClass
{
return [_ASDisplayLayer class];
}
@end
@implementation ASScrollNode
@dynamic view;
@ -14,7 +27,7 @@
- (instancetype)init
{
return [super initWithViewBlock:^UIView *{
return [[UIScrollView alloc] init];
return [[ASScrollView alloc] init];
}];
}

View File

@ -93,10 +93,13 @@
[super layoutSublayers];
ASDisplayNode *node = self.asyncdisplaykit_node;
// If our associated node is layer-backed, we cannot rely on the view's -layoutSubviews calling the node's -layout implementation, so do it ourselves.
if (node.isLayerBacked) {
ASDisplayNodeAssertMainThread();
if (ASDisplayNodeThreadIsMain()) {
[node __layout];
} else {
ASDisplayNodeFailAssert(@"not reached assertion");
dispatch_async(dispatch_get_main_queue(), ^ {
[node __layout];
});
}
}

View File

@ -122,19 +122,6 @@
}
}
- (void)layoutSubviews
{
if (ASDisplayNodeThreadIsMain()) {
[_node __layout];
} else {
// FIXME: CRASH This should not be happening because of the way we gate -setNeedsLayout, but it has been seen.
ASDisplayNodeFailAssert(@"not reached assertion");
dispatch_async(dispatch_get_main_queue(), ^ {
[_node __layout];
});
}
}
- (UIViewContentMode)contentMode
{
return ASDisplayNodeUIContentModeFromCAContentsGravity(self.layer.contentsGravity);