Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _ASDisplayLayer's delegateDidChangeBounds flag #1618

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,6 @@ - (void)_locked_loadViewOrLayer
_view = [self _locked_viewToLoad];
_view.asyncdisplaykit_node = self;
_layer = _view.layer;
// Needed to force `-[_ASDisplayLayer setDelegate:]` to evaluate
// It appears that UIKit might be setting the delegate ivar directly which
// bypasses establishing the `_delegateFlags` ivar on `ASDisplayLayer`
// This is critical for things like ASPagerNode, ASCollectionNode that depend
// on layer delegateFlags to forward bounds changes
if (_layer.delegate == _view) {
[_layer setDelegate:_view];
}
}
_layer.asyncdisplaykit_node = self;

Expand Down
13 changes: 1 addition & 12 deletions Source/Details/_ASDisplayLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,12 @@
@implementation _ASDisplayLayer
{
BOOL _attemptedDisplayWhileZeroSized;

struct {
BOOL delegateDidChangeBounds:1;
} _delegateFlags;
}

@dynamic displaysAsynchronously;

#pragma mark - Properties

- (void)setDelegate:(id)delegate
{
[super setDelegate:delegate];
_delegateFlags.delegateDidChangeBounds = [delegate respondsToSelector:@selector(layer:didChangeBoundsWithOldValue:newValue:)];
}

- (void)setDisplaySuspended:(BOOL)displaySuspended
{
ASDisplayNodeAssertMainThread();
Expand All @@ -59,12 +49,11 @@ - (void)setBounds:(CGRect)bounds
if (!valid) {
return;
}
if (_delegateFlags.delegateDidChangeBounds) {
if ([self.delegate respondsToSelector:@selector(layer:didChangeBoundsWithOldValue:newValue:)]) {
CGRect oldBounds = self.bounds;
[super setBounds:bounds];
self.asyncdisplaykit_node.threadSafeBounds = bounds;
[(id<ASCALayerExtendedDelegate>)self.delegate layer:self didChangeBoundsWithOldValue:oldBounds newValue:bounds];

} else {
[super setBounds:bounds];
self.asyncdisplaykit_node.threadSafeBounds = bounds;
Expand Down