diff --git a/Source/Details/ASTraitCollection.h b/Source/Details/ASTraitCollection.h index ba11f0c07..010e44ae5 100644 --- a/Source/Details/ASTraitCollection.h +++ b/Source/Details/ASTraitCollection.h @@ -101,6 +101,16 @@ ASDISPLAYNODE_EXTERN_C_END @end +#define ASPrimitiveTraitCollectionDefaults \ +- (ASPrimitiveTraitCollection)primitiveTraitCollection\ +{\ + return _primitiveTraitCollection;\ +}\ +- (void)setPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traitCollection\ +{\ + _primitiveTraitCollection = traitCollection;\ +}\ + #define ASPrimitiveTraitCollectionDeprecatedImplementation \ - (ASEnvironmentTraitCollection)environmentTraitCollection\ {\ diff --git a/Source/Layout/ASLayoutElementPrivate.h b/Source/Layout/ASLayoutElementPrivate.h index d4e3f2066..a0855ed0b 100644 --- a/Source/Layout/ASLayoutElementPrivate.h +++ b/Source/Layout/ASLayoutElementPrivate.h @@ -49,18 +49,19 @@ extern void ASLayoutElementClearCurrentContext(); #define ASLayoutElementLayoutCalculationDefaults \ - (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize\ {\ - _Pragma("clang diagnostic push")\ - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")\ - /* For now we just call the deprecated measureWithSizeRange: method to not break old API */ \ - return [self measureWithSizeRange:constrainedSize]; \ - _Pragma("clang diagnostic pop")\ -} \ + return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max];\ +}\ \ - (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize\ {\ return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max];\ }\ \ +- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize\ +{\ + return [self calculateLayoutThatFits:constrainedSize restrictedToSize:self.style.size relativeToParentSize:parentSize];\ +}\ +\ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize\ restrictedToSize:(ASLayoutElementSize)size\ relativeToParentSize:(CGSize)parentSize\ @@ -69,7 +70,6 @@ extern void ASLayoutElementClearCurrentContext(); return [self calculateLayoutThatFits:resolvedRange];\ }\ - #pragma mark - ASLayoutElementFinalLayoutElement /** * The base protocol for ASLayoutElementFinalLayoutElement. Generally the methods/properties in this class do not need to be diff --git a/Source/Layout/ASLayoutSpec.mm b/Source/Layout/ASLayoutSpec.mm index 232d0e6fd..fd37f9e6d 100644 --- a/Source/Layout/ASLayoutSpec.mm +++ b/Source/Layout/ASLayoutSpec.mm @@ -94,23 +94,7 @@ - (instancetype)styledWithBlock:(AS_NOESCAPE void (^)(__kindof ASLayoutElementSt #pragma mark - Layout -- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize -{ - return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max]; -} - -- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize -{ - return [self calculateLayoutThatFits:constrainedSize restrictedToSize:self.style.size relativeToParentSize:parentSize]; -} - -- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutElementSize)size - relativeToParentSize:(CGSize)parentSize -{ - const ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutElementSizeResolve(self.style.size, parentSize)); - return [self calculateLayoutThatFits:resolvedRange]; -} +ASLayoutElementLayoutCalculationDefaults - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { @@ -178,22 +162,13 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object #pragma mark - ASTraitEnvironment -- (ASPrimitiveTraitCollection)primitiveTraitCollection -{ - return _primitiveTraitCollection; -} - -- (void)setPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traitCollection -{ - _primitiveTraitCollection = traitCollection; -} - - (ASTraitCollection *)asyncTraitCollection { ASDN::MutexLocker l(__instanceLock__); return [ASTraitCollection traitCollectionWithASPrimitiveTraitCollection:self.primitiveTraitCollection]; } +ASPrimitiveTraitCollectionDefaults ASPrimitiveTraitCollectionDeprecatedImplementation #pragma mark - ASLayoutElementStyleExtensibility @@ -261,13 +236,6 @@ - (void)setDebugName:(NSString *)debugName } } -#pragma mark - Deprecated - -- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize -{ - return [self layoutThatFits:constrainedSize]; -} - @end #pragma mark - ASWrapperLayoutSpec