diff --git a/AsyncDisplayKit/ASImageNode.h b/AsyncDisplayKit/ASImageNode.h index c733a66459..35cbb068d6 100644 --- a/AsyncDisplayKit/ASImageNode.h +++ b/AsyncDisplayKit/ASImageNode.h @@ -83,7 +83,7 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image); * * @discussion This value defines a rectangle that is to be featured by the * receiver. The rectangle is specified as a "unit rectangle," using - * percentages of the source image's width and height, e.g. CGRectMake(0.5, 0, + * fractions of the source image's width and height, e.g. CGRectMake(0.5, 0, * 0.5, 1.0) will feature the full right half a photo. If the cropRect is * empty, the content mode of the receiver will be used to determine its * dimensions, and only the cropRect's origin will be used for positioning. The diff --git a/AsyncDisplayKit/Layout/ASDimension.h b/AsyncDisplayKit/Layout/ASDimension.h index 822a1c1963..79e7e2f64b 100644 --- a/AsyncDisplayKit/Layout/ASDimension.h +++ b/AsyncDisplayKit/Layout/ASDimension.h @@ -17,7 +17,7 @@ typedef NS_ENUM(NSInteger, ASRelativeDimensionType) { /** Just a number. It will always resolve to exactly this amount. This is the default type. */ ASRelativeDimensionTypePoints, /** Multiplied to a provided parent amount to resolve a final amount. */ - ASRelativeDimensionTypePercent, + ASRelativeDimensionTypeFraction, }; typedef struct { @@ -44,7 +44,7 @@ extern ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type, extern ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points); -extern ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent); +extern ASRelativeDimension ASRelativeDimensionMakeWithFraction(CGFloat fraction); extern ASRelativeDimension ASRelativeDimensionCopy(ASRelativeDimension aDimension); diff --git a/AsyncDisplayKit/Layout/ASDimension.mm b/AsyncDisplayKit/Layout/ASDimension.mm index d7309d7370..5859830c56 100644 --- a/AsyncDisplayKit/Layout/ASDimension.mm +++ b/AsyncDisplayKit/Layout/ASDimension.mm @@ -32,10 +32,10 @@ ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points) return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points); } -ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent) +ASRelativeDimension ASRelativeDimensionMakeWithFraction(CGFloat fraction) { - // ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent); - return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent); + // ASDisplayNodeCAssert( 0 <= fraction && fraction <= 1.0, @"ASRelativeDimension fraction value (%f) must be between 0 and 1.", fraction); + return ASRelativeDimensionMake(ASRelativeDimensionTypeFraction, fraction); } ASRelativeDimension ASRelativeDimensionCopy(ASRelativeDimension aDimension) @@ -53,7 +53,7 @@ NSString *NSStringFromASRelativeDimension(ASRelativeDimension dimension) switch (dimension.type) { case ASRelativeDimensionTypePoints: return [NSString stringWithFormat:@"%.0fpt", dimension.value]; - case ASRelativeDimensionTypePercent: + case ASRelativeDimensionTypeFraction: return [NSString stringWithFormat:@"%.0f%%", dimension.value * 100.0]; } } @@ -63,7 +63,7 @@ CGFloat ASRelativeDimensionResolve(ASRelativeDimension dimension, CGFloat parent switch (dimension.type) { case ASRelativeDimensionTypePoints: return dimension.value; - case ASRelativeDimensionTypePercent: + case ASRelativeDimensionTypeFraction: return dimension.value * parent; } } diff --git a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h index 9584094226..b41e66fb5f 100644 --- a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN /** A layout spec that wraps another layoutable child, applying insets around it. - If the child has a size specified as a percentage, the percentage is resolved against this spec's parent + If the child has a size specified as a fraction, the fraction is resolved against this spec's parent size **after** applying insets. @example ASOuterLayoutSpec contains an ASInsetLayoutSpec with an ASInnerLayoutSpec. Suppose that: diff --git a/AsyncDisplayKit/Layout/ASLayoutable.h b/AsyncDisplayKit/Layout/ASLayoutable.h index 0f68d5e2dd..ad1d1f8b92 100644 --- a/AsyncDisplayKit/Layout/ASLayoutable.h +++ b/AsyncDisplayKit/Layout/ASLayoutable.h @@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - ASStaticLayoutable /** - If specified, the child's size is restricted according to this size. Percentages are resolved relative to the static layout spec. + If specified, the child's size is restricted according to this size. Fractions are resolved relative to the static layout spec. */ @property (nonatomic, assign) ASRelativeSizeRange sizeRange; diff --git a/AsyncDisplayKit/Layout/ASStaticLayoutable.h b/AsyncDisplayKit/Layout/ASStaticLayoutable.h index 825b6ac40e..d1c3f74806 100644 --- a/AsyncDisplayKit/Layout/ASStaticLayoutable.h +++ b/AsyncDisplayKit/Layout/ASStaticLayoutable.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol ASStaticLayoutable /** - If specified, the child's size is restricted according to this size. Percentages are resolved relative to the static layout spec. + If specified, the child's size is restricted according to this size. Fractions are resolved relative to the static layout spec. */ @property (nonatomic, assign) ASRelativeSizeRange sizeRange; diff --git a/AsyncDisplayKit/Private/ASImageNode+CGExtras.h b/AsyncDisplayKit/Private/ASImageNode+CGExtras.h index 74471ad62d..52b2109c50 100644 --- a/AsyncDisplayKit/Private/ASImageNode+CGExtras.h +++ b/AsyncDisplayKit/Private/ASImageNode+CGExtras.h @@ -20,7 +20,7 @@ ASDISPLAYNODE_EXTERN_C_BEGIN @param sourceImageSize The size of the encoded image. @param boundsSize The bounds in which the image will be displayed. @param contentMode The mode that defines how image will be scaled and cropped to fit. Supported values are UIViewContentModeScaleToAspectFill and UIViewContentModeScaleToAspectFit. - @param cropRect A rectangle that is to be featured by the cropped image. The rectangle is specified as a "unit rectangle," using percentages of the source image's width and height, e.g. CGRectMake(0.5, 0, 0.5, 1.0) will feature the full right half a photo. If the cropRect is empty, the contentMode will be used to determine the drawRect's size, and only the cropRect's origin will be used for positioning. + @param cropRect A rectangle that is to be featured by the cropped image. The rectangle is specified as a "unit rectangle," using fractions of the source image's width and height, e.g. CGRectMake(0.5, 0, 0.5, 1.0) will feature the full right half a photo. If the cropRect is empty, the contentMode will be used to determine the drawRect's size, and only the cropRect's origin will be used for positioning. @param forceUpscaling A boolean that indicates you would *not* like the backing size to be downscaled if the image is smaller than the destination size. Setting this to YES will result in higher memory usage when images are smaller than their destination. @discussion If the image is smaller than the size and UIViewContentModeScaleToAspectFill is specified, we suggest the input size so it will be efficiently upscaled on the GPU by the displaying layer at composite time. */ diff --git a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm index bf40f61133..3b30272d45 100644 --- a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm +++ b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm @@ -330,7 +330,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex) subnode2.staticSize = {50, 50}; ASRatioLayoutSpec *child1 = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.5 child:subnode1]; - child1.flexBasis = ASRelativeDimensionMakeWithPercent(1); + child1.flexBasis = ASRelativeDimensionMakeWithFraction(1); child1.flexGrow = YES; child1.flexShrink = YES; @@ -508,7 +508,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex) [self testStackLayoutSpecWithStyle:style sizeRange:kOverflowSize subnodes:subnodes identifier:@"overflow"]; } -- (void)testPercentageFlexBasisResolvesAgainstParentSize +- (void)testFractionalFlexBasisResolvesAgainstParentSize { ASStackLayoutSpecStyle style = {.direction = ASStackLayoutDirectionHorizontal}; @@ -520,7 +520,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex) // This should override the intrinsic size of 50pts and instead compute to 50% = 100pts. // The result should be that the red box is twice as wide as the blue and gree boxes after flexing. - ((ASStaticSizeDisplayNode *)subnodes[0]).flexBasis = ASRelativeDimensionMakeWithPercent(0.5); + ((ASStaticSizeDisplayNode *)subnodes[0]).flexBasis = ASRelativeDimensionMakeWithFraction(0.5); static ASSizeRange kSize = {{200, 0}, {200, INFINITY}}; [self testStackLayoutSpecWithStyle:style sizeRange:kSize subnodes:subnodes identifier:nil];