diff --git a/AsyncDisplayKit.xcodeproj/project.pbxproj b/AsyncDisplayKit.xcodeproj/project.pbxproj index bcc179653..3c6668706 100644 --- a/AsyncDisplayKit.xcodeproj/project.pbxproj +++ b/AsyncDisplayKit.xcodeproj/project.pbxproj @@ -134,6 +134,8 @@ 6900C5F41E8072DA00BCD75C /* ASImageNode+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6900C5F31E8072DA00BCD75C /* ASImageNode+Private.h */; }; 6907C2581DC4ECFE00374C66 /* ASObjectDescriptionHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 6907C2561DC4ECFE00374C66 /* ASObjectDescriptionHelpers.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6907C25A1DC4ECFE00374C66 /* ASObjectDescriptionHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 6907C2571DC4ECFE00374C66 /* ASObjectDescriptionHelpers.m */; }; + 690BC8C120F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 690BC8BF20F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 690BC8C220F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 690BC8C020F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.m */; }; 690C35621E055C5D00069B91 /* ASDimensionInternal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 690C35601E055C5D00069B91 /* ASDimensionInternal.mm */; }; 690C35641E055C7B00069B91 /* ASDimensionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 690C35631E055C7B00069B91 /* ASDimensionInternal.h */; settings = {ATTRIBUTES = (Public, ); }; }; 690ED58E1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 690ED58D1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -691,6 +693,8 @@ 6900C5F31E8072DA00BCD75C /* ASImageNode+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASImageNode+Private.h"; sourceTree = ""; }; 6907C2561DC4ECFE00374C66 /* ASObjectDescriptionHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASObjectDescriptionHelpers.h; sourceTree = ""; }; 6907C2571DC4ECFE00374C66 /* ASObjectDescriptionHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASObjectDescriptionHelpers.m; sourceTree = ""; }; + 690BC8BF20F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASDisplayNodeCornerLayerDelegate.h; sourceTree = ""; }; + 690BC8C020F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASDisplayNodeCornerLayerDelegate.m; sourceTree = ""; }; 690C35601E055C5D00069B91 /* ASDimensionInternal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDimensionInternal.mm; sourceTree = ""; }; 690C35631E055C7B00069B91 /* ASDimensionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDimensionInternal.h; sourceTree = ""; }; 690ED58D1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutElementStylePrivate.h; sourceTree = ""; }; @@ -1483,6 +1487,8 @@ 058D0A0A195D050800B7D73C /* ASDisplayNode+DebugTiming.mm */, DE6EA3211C14000600183B10 /* ASDisplayNode+FrameworkPrivate.h */, 058D0A0B195D050800B7D73C /* ASDisplayNode+UIViewBridge.mm */, + 690BC8BF20F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.h */, + 690BC8C020F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.m */, 058D0A0C195D050800B7D73C /* ASDisplayNodeInternal.h */, 6959433D1D70815300B0EE1F /* ASDisplayNodeLayout.h */, 6959433C1D70815300B0EE1F /* ASDisplayNodeLayout.mm */, @@ -1929,6 +1935,7 @@ 254C6B7E1BF94DF4003EC431 /* ASTextKitTailTruncater.h in Headers */, B35062491B010EFD0018CF92 /* _ASCoreAnimationExtras.h in Headers */, 683F563720E409D700CEB7A3 /* ASDisplayNode+InterfaceState.h in Headers */, + 690BC8C120F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.h in Headers */, 68EE0DBE1C1B4ED300BA1B99 /* ASMainSerialQueue.h in Headers */, CCCCCCE11EC3EF060087FE10 /* ASTextUtilities.h in Headers */, B350624B1B010EFD0018CF92 /* _ASPendingState.h in Headers */, @@ -2434,6 +2441,7 @@ 68355B401CB57A69001D4E68 /* ASImageContainerProtocolCategories.m in Sources */, E5855DEF1EBB4D83003639AE /* ASCollectionLayoutDefines.m in Sources */, B35062031B010EFD0018CF92 /* ASImageNode.mm in Sources */, + 690BC8C220F6D3490052A434 /* ASDisplayNodeCornerLayerDelegate.m in Sources */, 254C6B821BF94F8A003EC431 /* ASTextKitComponents.mm in Sources */, 34EFC7601B701C8B00AD841F /* ASInsetLayoutSpec.mm in Sources */, AC6145441D8AFD4F003D62A2 /* ASSection.m in Sources */, diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c132eba5..c952ef869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,20 +15,21 @@ - Optimize layout flattening, particularly reducing retain/release operations. [Adlai Holler](https://github.com/Adlai-Holler) - Create a method to transfer strong C-arrays into immutable NSArrays, reducing retain/release traffic. [Adlai Holler](https://github.com/Adlai-Holler) - Remove yoga layout spec, which has been superseded by tighter Yoga integration (`ASDisplayNode+Yoga.h`) -- Properly consider node for responder methods [Michael Schneider](https://github.com/maicki) -- [IGListKit] Adds missing UIScrollViewDelegate method to DataSource proxy [Sergey Pronin](https://github.com/wannabehero) +- Properly consider node for responder methods [Michael Schneider](https://github.com/maicki) +- [IGListKit] Adds missing UIScrollViewDelegate method to DataSource proxy [Sergey Pronin](https://github.com/wannabehero) - Fix misleading/scary stack trace shown when an assertion occurs during node measurement [Huy Nguyen](https://github.com/nguyenhuy) [#1022](https://github.com/TextureGroup/Texture/pull/1022) - Fix build on 32-bit simulator in Xcode 9.3 and later, caused by `Thread-local storage is not supported on this architecture.` [Adlai Holler](https://github.com/Adlai-Holler) - Enable locking assertions (and add some more) to improve and enforce locking safety within the framework [Huy Nguyen](https://github.com/nguyenhuy) [#1024](https://github.com/TextureGroup/Texture/pull/1024) - Split MapKit, Photos, and AssetsLibrary dependent code into separate subspecs to improve binary size and start time when they're not needed. The default subspec includes all three for backwards compatibility, but this **will change in 3.0**. When using non-Cocoapods build environments, define `AS_USE_PHOTOS, AS_USE_MAPKIT, AS_USE_ASSETS_LIBRARY` to 1 respectively to signal their use. [Adlai Holler](https://github.com/Adlai-Holler) - Optimization: Removed an NSMutableArray in flattened layouts. [Adlai Holler](https://github.com/Adlai-Holler) - Reduced binary size by disabling exception support (which we don't use.) [Adlai Holler](https://github.com/Adlai-Holler) +- Create and set delegate for clip corner layers within ASDisplayNode [Michael Schneider](https://github.com/maicki) [#1024](https://github.com/TextureGroup/Texture/pull/1029) ## 2.7 - Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877) - [ASTextNode2] Upgrade lock safety by protecting all ivars (including rarely-changed ones). - User FLT_EPSILON in ASCeilPixelValue and ASFloorPixelValue to help with floating point precision errors when computing layouts for 3x devices. [Ricky Cancro](https://github.com/rcancro) [#838](https://github.com/TextureGroup/Texture/pull/864) -- Disable interface colescing and match to pre-colescing interface update behavior [Max Wang](https://github.com/wsdwsd0829) [#862](https://github.com/TextureGroup/Texture/pull/862) +- Disable interface colescing and match to pre-colescing interface update behavior [Max Wang](https://github.com/wsdwsd0829) [#862](https://github.com/TextureGroup/Texture/pull/862) - [ASDisplayNode] Add safeAreaInsets, layoutMargins and related properties to ASDisplayNode, with full support for older OS versions [Yevgen Pogribnyi](https://github.com/ypogribnyi) [#685](https://github.com/TextureGroup/Texture/pull/685) - [ASPINRemoteImageDownloader] Allow cache to provide animated image. [Max Wang](https://github.com/wsdwsd0829) [#850](https://github.com/TextureGroup/Texture/pull/850) - [tvOS] Fixes errors when building against tvOS SDK [Alex Hill](https://github.com/alexhillc) [#728](https://github.com/TextureGroup/Texture/pull/728) @@ -63,7 +64,8 @@ - Optimized ASNetworkImageNode loading and resolved edge cases where the image provided to the delegate was not the image that was loaded. [Adlai Holler](https://github.com/Adlai-Holler) [#778](https://github.com/TextureGroup/Texture/pull/778/) - Make `ASCellNode` tint color apply to table view cell accessories. [Vladyslav Chapaev](https://github.com/ShogunPhyched) [#764](https://github.com/TextureGroup/Texture/pull/764) - Fix ASTextNode2 is accessing backgroundColor off main while sizing / layout is happening. [Michael Schneider](https://github.com/maicki) [#794](https://github.com/TextureGroup/Texture/pull/778/) -- Pass scrollViewWillEndDragging delegation through in ASIGListAdapterDataSource for IGListKit integration. [#796](https://github.com/TextureGroup/Texture/pull/796) +- Pass scrollViewWillEndDragging delegation through in ASIGListAdapterDataSource for IGListKit integration. [#796](https://github.com/TextureGro +- up/Texture/pull/796) - Fix UIResponder handling with view backing ASDisplayNode. [Michael Schneider](https://github.com/maicki) [#789](https://github.com/TextureGroup/Texture/pull/789/) - Optimized thread-local storage by replacing pthread_specific with C11 thread-local variables. [Adlai Holler](https://github.com/Adlai-Holler) [#811](https://github.com/TextureGroup/Texture/pull/811/) - Fixed a thread-sanitizer warning in ASTextNode. [Adlai Holler](https://github.com/Adlai-Holler) [#830](https://github.com/TextureGroup/Texture/pull/830/) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index dbe641e9b..9eb64cbb8 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -624,10 +624,10 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority; */ - (void)layoutIfNeeded; -@property CGRect frame; // default=CGRectZero -@property CGRect bounds; // default=CGRectZero -@property CGPoint position; // default=CGPointZero -@property CGFloat alpha; // default=1.0f +@property CGRect frame; // default=CGRectZero +@property CGRect bounds; // default=CGRectZero +@property CGPoint position; // default=CGPointZero +@property CGFloat alpha; // default=1.0f /* @abstract Sets the corner rounding method to use on the ASDisplayNode. * There are three types of corner rounding provided by Texture: CALayer, Precomposited, and Clipping. @@ -651,7 +651,7 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority; * * @default ASCornerRoundingTypeDefaultSlowCALayer */ -@property ASCornerRoundingType cornerRoundingType; // default=Slow CALayer .cornerRadius (offscreen rendering) +@property ASCornerRoundingType cornerRoundingType; // default=ASCornerRoundingTypeDefaultSlowCALayer .cornerRadius (offscreen rendering) /** @abstract The radius to use when rounding corners of the ASDisplayNode. * @@ -660,24 +660,24 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority; */ @property CGFloat cornerRadius; // default=0.0 -@property BOOL clipsToBounds; // default==NO -@property (getter=isHidden) BOOL hidden; // default==NO -@property (getter=isOpaque) BOOL opaque; // default==YES +@property BOOL clipsToBounds; // default==NO +@property (getter=isHidden) BOOL hidden; // default==NO +@property (getter=isOpaque) BOOL opaque; // default==YES -@property (nullable) id contents; // default=nil -@property CGRect contentsRect; // default={0,0,1,1}. @see CALayer.h for details. -@property CGRect contentsCenter; // default={0,0,1,1}. @see CALayer.h for details. -@property CGFloat contentsScale; // default=1.0f. See @contentsScaleForDisplay for details. -@property CGFloat rasterizationScale; // default=1.0f. +@property (nullable) id contents; // default=nil +@property CGRect contentsRect; // default={0,0,1,1}. @see CALayer.h for details. +@property CGRect contentsCenter; // default={0,0,1,1}. @see CALayer.h for details. +@property CGFloat contentsScale; // default=1.0f. See @contentsScaleForDisplay for details. +@property CGFloat rasterizationScale; // default=1.0f. -@property CGPoint anchorPoint; // default={0.5, 0.5} -@property CGFloat zPosition; // default=0.0 -@property CATransform3D transform; // default=CATransform3DIdentity -@property CATransform3D subnodeTransform; // default=CATransform3DIdentity +@property CGPoint anchorPoint; // default={0.5, 0.5} +@property CGFloat zPosition; // default=0.0 +@property CATransform3D transform; // default=CATransform3DIdentity +@property CATransform3D subnodeTransform; // default=CATransform3DIdentity @property (getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default=YES (NO for layer-backed nodes) #if TARGET_OS_IOS -@property (getter=isExclusiveTouch) BOOL exclusiveTouch; // default=NO +@property (getter=isExclusiveTouch) BOOL exclusiveTouch; // default=NO #endif /** @@ -686,10 +686,10 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority; * @discussion In contrast to UIView, setting a transparent color will not set opaque = NO. * This only affects nodes that implement +drawRect like ASTextNode. */ -@property (nullable, copy) UIColor *backgroundColor; // default=nil +@property (nullable, copy) UIColor *backgroundColor; // default=nil -@property (null_resettable, copy) UIColor *tintColor; // default=Blue -- (void)tintColorDidChange; // Notifies the node when the tintColor has changed. +@property (null_resettable, copy) UIColor *tintColor; // default=Blue +- (void)tintColorDidChange; // Notifies the node when the tintColor has changed. /** * @abstract A flag used to determine how a node lays out its content when its bounds change. @@ -699,24 +699,24 @@ AS_EXTERN NSInteger const ASDefaultDrawingPriority; * Thus, UIViewContentModeRedraw is not allowed; use needsDisplayOnBoundsChange = YES instead, and pick an appropriate * contentMode for your content while it's being re-rendered. */ -@property UIViewContentMode contentMode; // default=UIViewContentModeScaleToFill -@property (copy) NSString *contentsGravity; // Use .contentMode in preference when possible. -@property UISemanticContentAttribute semanticContentAttribute; +@property UIViewContentMode contentMode; // default=UIViewContentModeScaleToFill +@property (copy) NSString *contentsGravity; // Use .contentMode in preference when possible. +@property UISemanticContentAttribute semanticContentAttribute; -@property (nullable) CGColorRef shadowColor; // default=opaque rgb black -@property CGFloat shadowOpacity; // default=0.0 -@property CGSize shadowOffset; // default=(0, -3) -@property CGFloat shadowRadius; // default=3 -@property CGFloat borderWidth; // default=0 -@property (nullable) CGColorRef borderColor; // default=opaque rgb black +@property (nullable) CGColorRef shadowColor; // default=opaque rgb black +@property CGFloat shadowOpacity; // default=0.0 +@property CGSize shadowOffset; // default=(0, -3) +@property CGFloat shadowRadius; // default=3 +@property CGFloat borderWidth; // default=0 +@property (nullable) CGColorRef borderColor; // default=opaque rgb black -@property BOOL allowsGroupOpacity; -@property BOOL allowsEdgeAntialiasing; -@property unsigned int edgeAntialiasingMask; // default==all values from CAEdgeAntialiasingMask +@property BOOL allowsGroupOpacity; +@property BOOL allowsEdgeAntialiasing; +@property unsigned int edgeAntialiasingMask; // default==all values from CAEdgeAntialiasingMask -@property BOOL needsDisplayOnBoundsChange; // default==NO -@property BOOL autoresizesSubviews; // default==YES (undefined for layer-backed nodes) -@property UIViewAutoresizing autoresizingMask; // default==UIViewAutoresizingNone (undefined for layer-backed nodes) +@property BOOL needsDisplayOnBoundsChange; // default==NO +@property BOOL autoresizesSubviews; // default==YES (undefined for layer-backed nodes) +@property UIViewAutoresizing autoresizingMask; // default==UIViewAutoresizingNone (undefined for layer-backed nodes) /** * @abstract Content margins diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index 6272fa018..347d41c42 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -35,6 +35,7 @@ #import #import #import +#import #import #import #import @@ -1642,7 +1643,7 @@ - (void)_layoutClipCornersIfNeeded } CGSize boundsSize = self.bounds.size; - for (int idx = 0; idx < 4; idx++) { + for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { BOOL isTop = (idx == 0 || idx == 1); BOOL isRight = (idx == 1 || idx == 2); if (_clipCornerLayers[idx]) { @@ -1656,7 +1657,7 @@ - (void)_layoutClipCornersIfNeeded - (void)_updateClipCornerLayerContentsWithRadius:(CGFloat)radius backgroundColor:(UIColor *)backgroundColor { ASPerformBlockOnMainThread(^{ - for (int idx = 0; idx < 4; idx++) { + for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { // Layers are, in order: Top Left, Top Right, Bottom Right, Bottom Left. // anchorPoint is Bottom Left at 0,0 and Top Right at 1,1. BOOL isTop = (idx == 0 || idx == 1); @@ -1693,16 +1694,21 @@ - (void)_setClipCornerLayersVisible:(BOOL)visible ASPerformBlockOnMainThread(^{ ASDisplayNodeAssertMainThread(); if (visible) { - for (int idx = 0; idx < 4; idx++) { + for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { if (_clipCornerLayers[idx] == nil) { + static ASDisplayNodeCornerLayerDelegate *clipCornerLayers; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + clipCornerLayers = [[ASDisplayNodeCornerLayerDelegate alloc] init]; + }); _clipCornerLayers[idx] = [[CALayer alloc] init]; _clipCornerLayers[idx].zPosition = 99999; - _clipCornerLayers[idx].delegate = self; + _clipCornerLayers[idx].delegate = clipCornerLayers; } } [self _updateClipCornerLayerContentsWithRadius:_cornerRadius backgroundColor:self.backgroundColor]; } else { - for (int idx = 0; idx < 4; idx++) { + for (int idx = 0; idx < NUM_CLIP_CORNER_LAYERS; idx++) { [_clipCornerLayers[idx] removeFromSuperlayer]; _clipCornerLayers[idx] = nil; } diff --git a/Source/Private/ASDisplayNodeCornerLayerDelegate.h b/Source/Private/ASDisplayNodeCornerLayerDelegate.h new file mode 100644 index 000000000..f1f0fb9b3 --- /dev/null +++ b/Source/Private/ASDisplayNodeCornerLayerDelegate.h @@ -0,0 +1,21 @@ +// +// ASDisplayNodeCornerLayerDelegate.h +// Texture +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. +// +// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// + +#import + +@interface ASDisplayNodeCornerLayerDelegate : NSObject +@end diff --git a/Source/Private/ASDisplayNodeCornerLayerDelegate.m b/Source/Private/ASDisplayNodeCornerLayerDelegate.m new file mode 100644 index 000000000..b01723dd4 --- /dev/null +++ b/Source/Private/ASDisplayNodeCornerLayerDelegate.m @@ -0,0 +1,27 @@ +// +// ASDisplayNodeCornerLayerDelegate.m +// Texture +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional +// grant of patent rights can be found in the PATENTS file in the same directory. +// +// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present, +// Pinterest, Inc. Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// + +#import "ASDisplayNodeCornerLayerDelegate.h" + +@implementation ASDisplayNodeCornerLayerDelegate + +- (id)actionForLayer:(CALayer *)layer forKey:(NSString *)event +{ + return (id)kCFNull; +} + +@end diff --git a/Source/Private/ASDisplayNodeInternal.h b/Source/Private/ASDisplayNodeInternal.h index 4c668a3f3..3c7c2e887 100644 --- a/Source/Private/ASDisplayNodeInternal.h +++ b/Source/Private/ASDisplayNodeInternal.h @@ -81,6 +81,8 @@ AS_EXTERN NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimest #define TIME_DISPLAYNODE_OPS 0 // If you're using this information frequently, try: (DEBUG || PROFILE) +#define NUM_CLIP_CORNER_LAYERS 4 + @interface ASDisplayNode () <_ASTransitionContextCompletionDelegate> { @package @@ -186,7 +188,7 @@ AS_EXTERN NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimest CGFloat _cornerRadius; ASCornerRoundingType _cornerRoundingType; - CALayer *_clipCornerLayers[4]; + CALayer *_clipCornerLayers[NUM_CLIP_CORNER_LAYERS]; ASDisplayNodeContextModifier _willDisplayNodeContentWithRenderingContext; ASDisplayNodeContextModifier _didDisplayNodeContentWithRenderingContext; diff --git a/Tests/ASDisplayNodeTests.mm b/Tests/ASDisplayNodeTests.mm index ba7ee7b53..55585eec9 100644 --- a/Tests/ASDisplayNodeTests.mm +++ b/Tests/ASDisplayNodeTests.mm @@ -26,6 +26,7 @@ #import #import #import +#import #import "ASDisplayNodeTestsHelper.h" #import #import @@ -184,6 +185,11 @@ - (void)displayWillStartAsynchronously:(BOOL)asynchronously _displayWillStartCount++; } +- (CALayer *__strong (*)[NUM_CLIP_CORNER_LAYERS])clipCornerLayers +{ + return &self->_clipCornerLayers; +} + @end @interface ASSynchronousTestDisplayNodeViaViewClass : ASDisplayNode @@ -2688,4 +2694,16 @@ - (void)testThatIfLayerClassIsOverwrittenItsSynchronous XCTAssertTrue([node isSynchronous], @"Node should be synchronous if viewClass is ovewritten and not a subclass of _ASDisplayView"); } +- (void)testCornerRoundingTypeClippingRoundedCornersIsUsingASDisplayNodeCornerLayerDelegate +{ + ASTestDisplayNode *node = [[ASTestDisplayNode alloc] init]; + node.cornerRoundingType = ASCornerRoundingTypeClipping; + node.cornerRadius = 10.0; + auto l = node.clipCornerLayers; + for (int i = 0; i < NUM_CLIP_CORNER_LAYERS; i++) { + CALayer *cornerLayer = (*l)[i]; + XCTAssertTrue([cornerLayer.delegate isKindOfClass:[ASDisplayNodeCornerLayerDelegate class]], @""); + } +} + @end