-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASDisplayNode] Add automatic measurement before layout #1725
[ASDisplayNode] Add automatic measurement before layout #1725
Conversation
AsyncDisplayKit/ASDisplayNode.mm
Outdated
| // with negative sizes after applying margins, which will cause | ||
| // measureWithSizeRange: on subnodes to assert. | ||
| if (!CGRectEqualToRect(bounds, CGRectZero)) { | ||
| _placeholderLayer.frame = bounds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maicki I think this change may be overwriting a recent fix that added the lines _shouldHavePlaceholderLayer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I adjusted the code based on the recent changes we did
|
I've got nothing to add to Scott's comments – 👌 |
| { | ||
| // Normally measure will be called before layout occurs. If this doesn't happen, nothing is going to call it at all. | ||
| // We simply call measureWithSizeRange: using a size range equal to whatever bounds were provided to that element | ||
| if (self.supernode == nil && !self.supportsRangeManagedInterfaceState && [self _hasDirtyLayout]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maicki what about ASViewController? I think there is a way to override the constrainedSize, but the .node has no supernode, is not range managed, etc. This may be handled by _hasDirtyLayout, not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to grab the lock here, at least while checking these three properties. If we don't, the value of one or more could change as the condition is being evaluated... There is also locking overhead in each method as it is re-acquired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleguy In ASViewController we pass in the overwritten constrained size in measureWithSizeRange: so this will calling through to the measure method and dirty layout is false
Will add acquiring a lock for supportsRangeManagedInterfaceState and check for has dirty layout. In [self supernode] we already grab a lock
Fix original PR ( #1673 ) that was reverted (#1717)
_hasDirtyLayoutcheck