mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 17:43:18 +00:00
Merge pull request #493 from facebook/LayerDrivenLayout
Remove -[_ASDisplayView layoutSubviews] and use only -[_ASDisplayLayer layoutSublayers]
This commit is contained in:
commit
c12cbdd21a
@ -7,6 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "ASScrollNode.h"
|
#import "ASScrollNode.h"
|
||||||
|
#import "_ASDisplayLayer.h"
|
||||||
|
|
||||||
|
@interface ASScrollView : UIScrollView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ASScrollView
|
||||||
|
|
||||||
|
+ (Class)layerClass
|
||||||
|
{
|
||||||
|
return [_ASDisplayLayer class];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation ASScrollNode
|
@implementation ASScrollNode
|
||||||
@dynamic view;
|
@dynamic view;
|
||||||
@ -14,7 +27,7 @@
|
|||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
return [super initWithViewBlock:^UIView *{
|
return [super initWithViewBlock:^UIView *{
|
||||||
return [[UIScrollView alloc] init];
|
return [[ASScrollView alloc] init];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,10 +93,13 @@
|
|||||||
[super layoutSublayers];
|
[super layoutSublayers];
|
||||||
|
|
||||||
ASDisplayNode *node = self.asyncdisplaykit_node;
|
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 (ASDisplayNodeThreadIsMain()) {
|
||||||
if (node.isLayerBacked) {
|
|
||||||
ASDisplayNodeAssertMainThread();
|
|
||||||
[node __layout];
|
[node __layout];
|
||||||
|
} else {
|
||||||
|
ASDisplayNodeFailAssert(@"not reached assertion");
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^ {
|
||||||
|
[node __layout];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
- (UIViewContentMode)contentMode
|
||||||
{
|
{
|
||||||
return ASDisplayNodeUIContentModeFromCAContentsGravity(self.layer.contentsGravity);
|
return ASDisplayNodeUIContentModeFromCAContentsGravity(self.layer.contentsGravity);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user