Skip to content

Commit d6061f4

Browse files
author
Greg Bolsinga
authored
Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)
* Make sure all ASDisplayNodes have backing ivars for consistency. Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.
1 parent 15fb7e0 commit d6061f4

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

Source/ASDisplayNode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#import <AsyncDisplayKit/ASLayoutElement.h>
2121
#import <AsyncDisplayKit/ASLocking.h>
2222

23+
#pragma clang diagnostic push
24+
#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"
25+
2326
NS_ASSUME_NONNULL_BEGIN
2427

2528
#define ASDisplayNodeLoggingEnabled 0
@@ -987,3 +990,5 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) {
987990
@end
988991

989992
NS_ASSUME_NONNULL_END
993+
994+
#pragma clang diagnostic pop

Source/ASDisplayNode.mm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,42 @@ - (BOOL)placeholderShouldPersist
26352635
return NO;
26362636
}
26372637

2638+
- (BOOL)placeholderEnabled
2639+
{
2640+
MutexLocker l(__instanceLock__);
2641+
return _placeholderEnabled;
2642+
}
2643+
2644+
- (void)setPlaceholderEnabled:(BOOL)placeholderEnabled
2645+
{
2646+
MutexLocker l(__instanceLock__);
2647+
_placeholderEnabled = placeholderEnabled;
2648+
}
2649+
2650+
- (NSTimeInterval)placeholderFadeDuration
2651+
{
2652+
MutexLocker l(__instanceLock__);
2653+
return _placeholderFadeDuration;
2654+
}
2655+
2656+
- (void)setPlaceholderFadeDuration:(NSTimeInterval)placeholderFadeDuration
2657+
{
2658+
MutexLocker l(__instanceLock__);
2659+
_placeholderFadeDuration = placeholderFadeDuration;
2660+
}
2661+
2662+
- (NSInteger)drawingPriority
2663+
{
2664+
MutexLocker l(__instanceLock__);
2665+
return _drawingPriority;
2666+
}
2667+
2668+
- (void)setDrawingPriority:(NSInteger)drawingPriority
2669+
{
2670+
MutexLocker l(__instanceLock__);
2671+
_drawingPriority = drawingPriority;
2672+
}
2673+
26382674
#pragma mark - Hierarchy State
26392675

26402676
- (BOOL)isInHierarchy

Source/Private/ASDisplayNodeInternal.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ static constexpr CACornerMask kASCACornerAllCorners =
204204
UIImage *_placeholderImage;
205205
BOOL _placeholderEnabled;
206206
CALayer *_placeholderLayer;
207+
NSTimeInterval _placeholderFadeDuration;
208+
209+
NSInteger _drawingPriority;
207210

208211
// keeps track of nodes/subnodes that have not finished display, used with placeholders
209212
ASWeakSet *_pendingDisplayNodes;
@@ -351,20 +354,6 @@ static constexpr CACornerMask kASCACornerAllCorners =
351354
*/
352355
- (void)enumerateInterfaceStateDelegates:(void(NS_NOESCAPE ^)(id<ASInterfaceStateDelegate> delegate))block;
353356

354-
/**
355-
* // TODO: NOT YET IMPLEMENTED
356-
*
357-
* @abstract Prevents interface state changes from affecting the node, until disabled.
358-
*
359-
* @discussion Useful to avoid flashing after removing a node from the hierarchy and re-adding it.
360-
* Removing a node from the hierarchy will cause it to exit the Display state, clearing its contents.
361-
* For some animations, it's desirable to be able to remove a node without causing it to re-display.
362-
* Once re-enabled, the interface state will be updated to the same value it would have been.
363-
*
364-
* @see ASInterfaceState
365-
*/
366-
@property (nonatomic) BOOL interfaceStateSuspended;
367-
368357
/**
369358
* This method has proven helpful in a few rare scenarios, similar to a category extension on UIView,
370359
* but it's considered private API for now and its use should not be encouraged.

0 commit comments

Comments
 (0)