|
46 | 46 | * and check ownership count of the mutex. |
47 | 47 | */ |
48 | 48 | #if CHECK_LOCKING_SAFETY |
49 | | - #define ASDisplayNodeAssertLockUnownedByCurrentThread(lock) ASDisplayNodeAssertFalse(lock.ownedByCurrentThread()); |
| 49 | + #define ASDisplayNodeAssertLockUnownedByCurrentThread(lock) ASDisplayNodeAssertFalse(lock.ownedByCurrentThread()) |
50 | 50 | #else |
51 | 51 | #define ASDisplayNodeAssertLockUnownedByCurrentThread(lock) |
52 | 52 | #endif |
@@ -924,29 +924,33 @@ - (void)invalidateCalculatedLayout |
924 | 924 | - (void)__layout |
925 | 925 | { |
926 | 926 | ASDisplayNodeAssertMainThread(); |
927 | | - ASDN::MutexLocker l(__instanceLock__); |
928 | | - CGRect bounds = _threadSafeBounds; |
929 | | - |
930 | | - if (CGRectEqualToRect(bounds, CGRectZero)) { |
931 | | - // Performing layout on a zero-bounds view often results in frame calculations |
932 | | - // with negative sizes after applying margins, which will cause |
933 | | - // measureWithSizeRange: on subnodes to assert. |
934 | | - LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self); |
935 | | - return; |
936 | | - } |
| 927 | + ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__); |
937 | 928 |
|
938 | | - // If a current layout transition is in progress there is no need to do a measurement and layout pass in here as |
939 | | - // this is supposed to happen within the layout transition process |
940 | | - if ([self _isTransitionInProgress]) { |
941 | | - return; |
942 | | - } |
| 929 | + { |
| 930 | + ASDN::MutexLocker l(__instanceLock__); |
| 931 | + CGRect bounds = _threadSafeBounds; |
943 | 932 |
|
944 | | - // This method will confirm that the layout is up to date (and update if needed). |
945 | | - // Importantly, it will also APPLY the layout to all of our subnodes if (unless parent is transitioning). |
946 | | - [self _locked_measureNodeWithBoundsIfNecessary:bounds]; |
947 | | - _pendingDisplayNodeLayout = nullptr; |
948 | | - |
949 | | - [self _locked_layoutPlaceholderIfNecessary]; |
| 933 | + if (CGRectEqualToRect(bounds, CGRectZero)) { |
| 934 | + // Performing layout on a zero-bounds view often results in frame calculations |
| 935 | + // with negative sizes after applying margins, which will cause |
| 936 | + // measureWithSizeRange: on subnodes to assert. |
| 937 | + LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self); |
| 938 | + return; |
| 939 | + } |
| 940 | + |
| 941 | + // If a current layout transition is in progress there is no need to do a measurement and layout pass in here as |
| 942 | + // this is supposed to happen within the layout transition process |
| 943 | + if (_transitionInProgress) { |
| 944 | + return; |
| 945 | + } |
| 946 | + |
| 947 | + // This method will confirm that the layout is up to date (and update if needed). |
| 948 | + // Importantly, it will also APPLY the layout to all of our subnodes if (unless parent is transitioning). |
| 949 | + [self _locked_measureNodeWithBoundsIfNecessary:bounds]; |
| 950 | + _pendingDisplayNodeLayout = nullptr; |
| 951 | + |
| 952 | + [self _locked_layoutPlaceholderIfNecessary]; |
| 953 | + } |
950 | 954 |
|
951 | 955 | [self layout]; |
952 | 956 | [self layoutDidFinish]; |
@@ -1062,6 +1066,8 @@ - (ASSizeRange)_locked_constrainedSizeForLayoutPass |
1062 | 1066 | - (void)layoutDidFinish |
1063 | 1067 | { |
1064 | 1068 | // Hook for subclasses |
| 1069 | + ASDisplayNodeAssertMainThread(); |
| 1070 | + ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__); |
1065 | 1071 | } |
1066 | 1072 |
|
1067 | 1073 | #pragma mark Calculation |
@@ -1316,6 +1322,7 @@ - (void)_locked_displayNodeDidInvalidateSizeNewSize:(CGSize)size |
1316 | 1322 | - (void)layout |
1317 | 1323 | { |
1318 | 1324 | ASDisplayNodeAssertMainThread(); |
| 1325 | + ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__); |
1319 | 1326 |
|
1320 | 1327 | __instanceLock__.lock(); |
1321 | 1328 | if (_calculatedDisplayNodeLayout->isDirty()) { |
@@ -1488,7 +1495,7 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize |
1488 | 1495 | - (void)cancelLayoutTransition |
1489 | 1496 | { |
1490 | 1497 | ASDN::MutexLocker l(__instanceLock__); |
1491 | | - if ([self _isTransitionInProgress]) { |
| 1498 | + if (_transitionInProgress) { |
1492 | 1499 | // Cancel transition in progress |
1493 | 1500 | [self _finishOrCancelTransition]; |
1494 | 1501 |
|
|
0 commit comments