From aee694bd1aa0595a5e141e074f94ff70d95d2bc8 Mon Sep 17 00:00:00 2001 From: Greg Bolsinga Date: Tue, 30 Apr 2019 15:56:03 -0700 Subject: [PATCH] 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. --- Source/ASDisplayNode.h | 5 ++++ Source/ASDisplayNode.mm | 36 ++++++++++++++++++++++++++ Source/Private/ASDisplayNodeInternal.h | 17 +++--------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 964ddc50d..3e3d34001 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -20,6 +20,9 @@ #import #import +#pragma clang diagnostic push +#pragma clang diagnostic error "-Wobjc-missing-property-synthesis" + NS_ASSUME_NONNULL_BEGIN #define ASDisplayNodeLoggingEnabled 0 @@ -987,3 +990,5 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) { @end NS_ASSUME_NONNULL_END + +#pragma clang diagnostic pop diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index 120282f18..c8115af49 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -2635,6 +2635,42 @@ - (BOOL)placeholderShouldPersist return NO; } +- (BOOL)placeholderEnabled +{ + MutexLocker l(__instanceLock__); + return _placeholderEnabled; +} + +- (void)setPlaceholderEnabled:(BOOL)placeholderEnabled +{ + MutexLocker l(__instanceLock__); + _placeholderEnabled = placeholderEnabled; +} + +- (NSTimeInterval)placeholderFadeDuration +{ + MutexLocker l(__instanceLock__); + return _placeholderFadeDuration; +} + +- (void)setPlaceholderFadeDuration:(NSTimeInterval)placeholderFadeDuration +{ + MutexLocker l(__instanceLock__); + _placeholderFadeDuration = placeholderFadeDuration; +} + +- (NSInteger)drawingPriority +{ + MutexLocker l(__instanceLock__); + return _drawingPriority; +} + +- (void)setDrawingPriority:(NSInteger)drawingPriority +{ + MutexLocker l(__instanceLock__); + _drawingPriority = drawingPriority; +} + #pragma mark - Hierarchy State - (BOOL)isInHierarchy diff --git a/Source/Private/ASDisplayNodeInternal.h b/Source/Private/ASDisplayNodeInternal.h index caf329ec7..b9b20cf8a 100644 --- a/Source/Private/ASDisplayNodeInternal.h +++ b/Source/Private/ASDisplayNodeInternal.h @@ -204,6 +204,9 @@ static constexpr CACornerMask kASCACornerAllCorners = UIImage *_placeholderImage; BOOL _placeholderEnabled; CALayer *_placeholderLayer; + NSTimeInterval _placeholderFadeDuration; + + NSInteger _drawingPriority; // keeps track of nodes/subnodes that have not finished display, used with placeholders ASWeakSet *_pendingDisplayNodes; @@ -351,20 +354,6 @@ static constexpr CACornerMask kASCACornerAllCorners = */ - (void)enumerateInterfaceStateDelegates:(void(NS_NOESCAPE ^)(id delegate))block; -/** - * // TODO: NOT YET IMPLEMENTED - * - * @abstract Prevents interface state changes from affecting the node, until disabled. - * - * @discussion Useful to avoid flashing after removing a node from the hierarchy and re-adding it. - * Removing a node from the hierarchy will cause it to exit the Display state, clearing its contents. - * For some animations, it's desirable to be able to remove a node without causing it to re-display. - * Once re-enabled, the interface state will be updated to the same value it would have been. - * - * @see ASInterfaceState - */ -@property (nonatomic) BOOL interfaceStateSuspended; - /** * This method has proven helpful in a few rare scenarios, similar to a category extension on UIView, * but it's considered private API for now and its use should not be encouraged.