Skip to content

Commit

Permalink
Merge branch 'master' of github.com:TextureGroup/Texture
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdwsd0829 committed Aug 21, 2018
2 parents 0b886de + 2e95f55 commit a63d438
Show file tree
Hide file tree
Showing 29 changed files with 375 additions and 319 deletions.
16 changes: 10 additions & 6 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
697796611D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6977965E1D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm */; };
697B315A1CFE4B410049936F /* ASEditableTextNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 697B31591CFE4B410049936F /* ASEditableTextNodeTests.m */; };
698371DB1E4379CD00437585 /* ASNodeController+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 698371D91E4379CD00437585 /* ASNodeController+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; };
698371DC1E4379CD00437585 /* ASNodeController+Beta.m in Sources */ = {isa = PBXBuildFile; fileRef = 698371DA1E4379CD00437585 /* ASNodeController+Beta.m */; };
698371DC1E4379CD00437585 /* ASNodeController+Beta.mm in Sources */ = {isa = PBXBuildFile; fileRef = 698371DA1E4379CD00437585 /* ASNodeController+Beta.mm */; };
698C8B621CAB49FC0052DC3F /* ASLayoutElementExtensibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */; settings = {ATTRIBUTES = (Public, ); }; };
698DFF441E36B6C9002891F1 /* ASStackLayoutSpecUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 698DFF431E36B6C9002891F1 /* ASStackLayoutSpecUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
698DFF471E36B7E9002891F1 /* ASLayoutSpecUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 698DFF461E36B7E9002891F1 /* ASLayoutSpecUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -228,6 +228,7 @@
ACF6ED611B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED591B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm */; };
ACF6ED621B178DC700DA7C62 /* ASRatioLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED5A1B178DC700DA7C62 /* ASRatioLayoutSpecSnapshotTests.mm */; };
ACF6ED631B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED5B1B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm */; };
AE440175210FB7CF00B36DA2 /* ASTextKitFontSizeAdjusterTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE440174210FB7CF00B36DA2 /* ASTextKitFontSizeAdjusterTests.mm */; };
AE6987C11DD04E1000B9E458 /* ASPagerNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AE6987C01DD04E1000B9E458 /* ASPagerNodeTests.m */; };
AEEC47E41C21D3D200EC1693 /* ASVideoNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEC47E31C21D3D200EC1693 /* ASVideoNodeTests.m */; };
B13CA0F81C519EBA00E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0F61C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -716,7 +717,7 @@
6977965E1D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "ASLayoutSpec+Subclasses.mm"; sourceTree = "<group>"; };
697B31591CFE4B410049936F /* ASEditableTextNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASEditableTextNodeTests.m; sourceTree = "<group>"; };
698371D91E4379CD00437585 /* ASNodeController+Beta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASNodeController+Beta.h"; sourceTree = "<group>"; };
698371DA1E4379CD00437585 /* ASNodeController+Beta.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASNodeController+Beta.m"; sourceTree = "<group>"; };
698371DA1E4379CD00437585 /* ASNodeController+Beta.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "ASNodeController+Beta.mm"; sourceTree = "<group>"; };
698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutElementExtensibility.h; sourceTree = "<group>"; };
698DFF431E36B6C9002891F1 /* ASStackLayoutSpecUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASStackLayoutSpecUtilities.h; sourceTree = "<group>"; };
698DFF461E36B7E9002891F1 /* ASLayoutSpecUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutSpecUtilities.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -814,6 +815,7 @@
ACF6ED591B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASOverlayLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED5A1B178DC700DA7C62 /* ASRatioLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASRatioLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED5B1B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
AE440174210FB7CF00B36DA2 /* ASTextKitFontSizeAdjusterTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ASTextKitFontSizeAdjusterTests.mm; sourceTree = "<group>"; };
AE6987C01DD04E1000B9E458 /* ASPagerNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPagerNodeTests.m; sourceTree = "<group>"; };
AEB7B0181C5962EA00662EF4 /* ASDefaultPlayButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDefaultPlayButton.h; sourceTree = "<group>"; };
AEB7B0191C5962EA00662EF4 /* ASDefaultPlayButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDefaultPlayButton.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1197,7 +1199,7 @@
055B9FA61A1C154B00035D6D /* ASNetworkImageNode.h */,
055B9FA71A1C154B00035D6D /* ASNetworkImageNode.mm */,
698371D91E4379CD00437585 /* ASNodeController+Beta.h */,
698371DA1E4379CD00437585 /* ASNodeController+Beta.m */,
698371DA1E4379CD00437585 /* ASNodeController+Beta.mm */,
DBDB83921C6E879900D0098C /* ASPagerFlowLayout.h */,
DBDB83931C6E879900D0098C /* ASPagerFlowLayout.m */,
25E327541C16819500A2170C /* ASPagerNode.h */,
Expand Down Expand Up @@ -1253,7 +1255,6 @@
058D09C5195D04C000B7D73C /* Tests */ = {
isa = PBXGroup;
children = (
CC35CEC520DD87280006448D /* ASCollectionsTests.m */,
DBC452DD1C5C6A6A00B16017 /* ArrayDiffingTests.m */,
AC026B571BD3F61800BBC17E /* ASAbsoluteLayoutSpecSnapshotTests.m */,
696FCB301D6E46050093471E /* ASBackgroundLayoutSpecSnapshotTests.mm */,
Expand All @@ -1264,6 +1265,7 @@
CC051F1E1D7A286A006434CB /* ASCALayerTests.m */,
ACF6ED531B178DC700DA7C62 /* ASCenterLayoutSpecSnapshotTests.mm */,
CCDD148A1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m */,
CC35CEC520DD87280006448D /* ASCollectionsTests.m */,
2538B6F21BC5D2A2003CA0B4 /* ASCollectionViewFlowLayoutInspectorTests.m */,
9F06E5CC1B4CAF4200F015D8 /* ASCollectionViewTests.mm */,
CCEDDDD8200C518800FFCD0A /* ASConfigurationTests.m */,
Expand Down Expand Up @@ -1314,8 +1316,10 @@
3C9C128419E616EF00E942A0 /* ASTableViewTests.mm */,
CC4981B21D1A02BE004E13CC /* ASTableViewThrashTests.m */,
058D0A33195D057000B7D73C /* ASTextKitCoreTextAdditionsTests.m */,
AE440174210FB7CF00B36DA2 /* ASTextKitFontSizeAdjusterTests.mm */,
254C6B531BF8FF2A003EC431 /* ASTextKitTests.mm */,
254C6B511BF8FE6D003EC431 /* ASTextKitTruncationTests.mm */,
C057D9BC20B5453D00FC9112 /* ASTextNode2SnapshotTests.m */,
CC8B05D71D73979700F54286 /* ASTextNodePerformanceTests.m */,
81E95C131D62639600336598 /* ASTextNodeSnapshotTests.m */,
058D0A36195D057000B7D73C /* ASTextNodeTests.m */,
Expand All @@ -1325,7 +1329,6 @@
4496D0721FA9EA6B001CC8D5 /* ASTraitCollectionTests.m */,
CC0AEEA31D66316E005D1C78 /* ASUICollectionViewTests.m */,
AEEC47E31C21D3D200EC1693 /* ASVideoNodeTests.m */,
C057D9BC20B5453D00FC9112 /* ASTextNode2SnapshotTests.m */,
CCA221D21D6FA7EF00AF6A0F /* ASViewControllerTests.m */,
83A7D95D1D446A6E00BF333E /* ASWeakMapTests.m */,
CC3B208D1C3F7D0A00798563 /* ASWeakSetTests.m */,
Expand Down Expand Up @@ -2265,6 +2268,7 @@
buildActionMask = 2147483647;
files = (
CCEDDDD9200C518800FFCD0A /* ASConfigurationTests.m in Sources */,
AE440175210FB7CF00B36DA2 /* ASTextKitFontSizeAdjusterTests.mm in Sources */,
E51B78BF1F028ABF00E32604 /* ASLayoutFlatteningTests.m in Sources */,
4496D0731FA9EA6B001CC8D5 /* ASTraitCollectionTests.m in Sources */,
29CDC2E21AAE70D000833CA4 /* ASBasicImageDownloaderContextTests.m in Sources */,
Expand Down Expand Up @@ -2374,7 +2378,7 @@
DEFAD8131CC48914000527C4 /* ASVideoNode.mm in Sources */,
CCA282C11E9EAE010037E8B7 /* ASTip.m in Sources */,
B350624C1B010EFD0018CF92 /* _ASPendingState.mm in Sources */,
698371DC1E4379CD00437585 /* ASNodeController+Beta.m in Sources */,
698371DC1E4379CD00437585 /* ASNodeController+Beta.mm in Sources */,
CC6AA2DB1E9F03B900978E87 /* ASDisplayNode+Ancestry.m in Sources */,
509E68621B3AEDA5009B9150 /* ASAbstractLayoutController.mm in Sources */,
254C6B861BF94F8A003EC431 /* ASTextKitContext.mm in Sources */,
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
- 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) [#1029](https://github.com/TextureGroup/Texture/pull/1029)
- Improve locking situation in ASVideoPlayerNode [Michael Schneider](https://github.com/maicki) [#1042](https://github.com/TextureGroup/Texture/pull/1042)

- Optimize ASDisplayNode -> ASNodeController reference by removing weak proxy and objc associated objects. [Adlai Holler](https://github.com/Adlai-Holler)
- Remove CA transaction signpost injection because it causes more transactions and is too chatty. [Adlai Holler](https://github.com/Adlai-Holler)
- Optimize display node accessibility by not creating attributed & non-attributed copies of hint, label, and value. [Adlai Holler](https://github.com/Adlai-Holler)
- Add an experimental feature that reuses CTFramesetter objects in ASTextNode2 to improve performance. [Adlai Holler](https://github.com/Adlai-Holler)
- Add NS_DESIGNATED_INITIALIZER to ASViewController initWithNode: [Michael Schneider](https://github.com/maicki) [#1054](https://github.com/TextureGroup/Texture/pull/1054)
- Optimize text stack by removing unneeded copying. [Adlai Holler](https://github.com/Adlai-Holler)
- Remove double scaling of lineHeightMultiple & paragraphSpacing attributes in ASTextKitFontSizeAdjuster. [Eric Jensen](https://github.com/ejensen)

## 2.7
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
Expand Down
1 change: 1 addition & 0 deletions Schemas/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"exp_network_image_queue",
"exp_dealloc_queue_v2",
"exp_collection_teardown",
"exp_framesetter_cache"
]
}
}
Expand Down
13 changes: 13 additions & 0 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#import <AsyncDisplayKit/ASLayoutSpecPrivate.h>
#import <AsyncDisplayKit/ASLog.h>
#import <AsyncDisplayKit/ASMainThreadDeallocation.h>
#import <AsyncDisplayKit/ASNodeController+Beta.h>
#import <AsyncDisplayKit/ASRunLoopQueue.h>
#import <AsyncDisplayKit/ASSignpost.h>
#import <AsyncDisplayKit/ASTraitCollection.h>
Expand Down Expand Up @@ -876,6 +877,18 @@ - (void)setAutomaticallyRelayoutOnLayoutMarginsChanges:(BOOL)flag
_automaticallyRelayoutOnLayoutMarginsChanges = flag;
}

- (void)__setNodeController:(ASNodeController *)controller
{
// See docs for why we don't lock.
if (controller.shouldInvertStrongReference) {
_strongNodeController = controller;
_weakNodeController = nil;
} else {
_weakNodeController = controller;
_strongNodeController = nil;
}
}

#pragma mark - UIResponder

#define HANDLE_NODE_RESPONDER_METHOD(__sel) \
Expand Down
1 change: 1 addition & 0 deletions Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalNetworkImageQueue = 1 << 5, // exp_network_image_queue
ASExperimentalDeallocQueue = 1 << 6, // exp_dealloc_queue_v2
ASExperimentalCollectionTeardown = 1 << 7, // exp_collection_teardown
ASExperimentalFramesetterCache = 1 << 8, // exp_framesetter_cache
ASExperimentalFeatureAll = 0xFFFFFFFF
};

Expand Down
3 changes: 2 additions & 1 deletion Source/ASExperimentalFeatures.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
@"exp_infer_layer_defaults",
@"exp_network_image_queue",
@"exp_dealloc_queue_v2",
@"exp_collection_teardown"]));
@"exp_collection_teardown",
@"exp_framesetter_cache"]));

if (flags == ASExperimentalFeatureAll) {
return allNames;
Expand Down
57 changes: 3 additions & 54 deletions Source/ASNodeController+Beta.m → Source/ASNodeController+Beta.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,18 @@
//

#import <AsyncDisplayKit/ASInternalHelpers.h>
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
#import <AsyncDisplayKit/ASNodeController+Beta.h>
#import <AsyncDisplayKit/ASWeakProxy.h>

#define _node (_shouldInvertStrongReference ? _weakNode : _strongNode)

@interface ASDisplayNode (ASNodeControllerOwnership)

// This property exists for debugging purposes. Don't use __nodeController in production code.
@property (nonatomic, readonly) ASNodeController *__nodeController;

// These setters are mutually exclusive. Setting one will clear the relationship of the other.
- (void)__setNodeControllerStrong:(ASNodeController *)nodeController;
- (void)__setNodeControllerWeak:(ASNodeController *)nodeController;

@end

@implementation ASNodeController
{
ASDisplayNode *_strongNode;
__weak ASDisplayNode *_weakNode;
}

- (instancetype)init
{
self = [super init];
if (self) {

}
return self;
}

- (void)loadNode
{
self.node = [[ASDisplayNode alloc] init];
Expand All @@ -66,15 +46,14 @@ - (void)setupReferencesWithNode:(ASDisplayNode *)node
if (_shouldInvertStrongReference) {
// The node should own the controller; weak reference from controller to node.
_weakNode = node;
[node __setNodeControllerStrong:self];
_strongNode = nil;
} else {
// The controller should own the node; weak reference from node to controller.
_strongNode = node;
[node __setNodeControllerWeak:self];
_weakNode = nil;
}

[node __setNodeController:self];
[node addInterfaceStateDelegate:self];
}

Expand Down Expand Up @@ -111,40 +90,10 @@ - (void)interfaceStateDidChange:(ASInterfaceState)newState

@end

@implementation ASDisplayNode (ASNodeControllerOwnership)

- (ASNodeController *)__nodeController
{
ASNodeController *nodeController = nil;
id object = objc_getAssociatedObject(self, @selector(__nodeController));

if ([object isKindOfClass:[ASWeakProxy class]]) {
nodeController = (ASNodeController *)[(ASWeakProxy *)object target];
} else {
nodeController = (ASNodeController *)object;
}

return nodeController;
}

- (void)__setNodeControllerStrong:(ASNodeController *)nodeController
{
objc_setAssociatedObject(self, @selector(__nodeController), nodeController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)__setNodeControllerWeak:(ASNodeController *)nodeController
{
// Associated objects don't support weak references. Since assign can become a dangling pointer, use ASWeakProxy.
ASWeakProxy *nodeControllerProxy = [ASWeakProxy weakProxyWithTarget:nodeController];
objc_setAssociatedObject(self, @selector(__nodeController), nodeControllerProxy, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

@end

@implementation ASDisplayNode (ASNodeController)

- (ASNodeController *)nodeController {
return self.__nodeController;
return _weakNodeController ?: _strongNodeController;
}

@end
68 changes: 0 additions & 68 deletions Source/ASRunLoopQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -254,29 +254,6 @@ - (void)drain

@end

#if AS_KDEBUG_ENABLE
/**
* This is real, private CA API. Valid as of iOS 10.
*/
typedef enum {
kCATransactionPhasePreLayout,
kCATransactionPhasePreCommit,
kCATransactionPhasePostCommit,
} CATransactionPhase;

@interface CATransaction (Private)
+ (void)addCommitHandler:(void(^)(void))block forPhase:(CATransactionPhase)phase;
+ (int)currentState;
@end
#endif

#pragma mark - ASAbstractRunLoopQueue

@interface ASAbstractRunLoopQueue (Private)
+ (void)load;
+ (void)registerCATransactionObservers;
@end

@implementation ASAbstractRunLoopQueue

- (instancetype)init
Expand All @@ -289,51 +266,6 @@ - (instancetype)init
return self;
}

#if AS_KDEBUG_ENABLE
+ (void)load
{
[self registerCATransactionObservers];
}

+ (void)registerCATransactionObservers
{
static BOOL privateCAMethodsExist;
static dispatch_block_t preLayoutHandler;
static dispatch_block_t preCommitHandler;
static dispatch_block_t postCommitHandler;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
privateCAMethodsExist = [CATransaction respondsToSelector:@selector(addCommitHandler:forPhase:)];
privateCAMethodsExist &= [CATransaction respondsToSelector:@selector(currentState)];
if (!privateCAMethodsExist) {
NSLog(@"Private CA methods are gone.");
}
preLayoutHandler = ^{
ASSignpostStartCustom(ASSignpostCATransactionLayout, 0, [CATransaction currentState]);
};
preCommitHandler = ^{
int state = [CATransaction currentState];
ASSignpostEndCustom(ASSignpostCATransactionLayout, 0, state, ASSignpostColorDefault);
ASSignpostStartCustom(ASSignpostCATransactionCommit, 0, state);
};
postCommitHandler = ^{
ASSignpostEndCustom(ASSignpostCATransactionCommit, 0, [CATransaction currentState], ASSignpostColorDefault);
// Can't add new observers inside an observer. rdar://problem/31253952
dispatch_async(dispatch_get_main_queue(), ^{
[self registerCATransactionObservers];
});
};
});

if (privateCAMethodsExist) {
[CATransaction addCommitHandler:preLayoutHandler forPhase:kCATransactionPhasePreLayout];
[CATransaction addCommitHandler:preCommitHandler forPhase:kCATransactionPhasePreCommit];
[CATransaction addCommitHandler:postCommitHandler forPhase:kCATransactionPhasePostCommit];
}
}

#endif // AS_KDEBUG_ENABLE

@end

#pragma mark - ASRunLoopQueue
Expand Down
Loading

0 comments on commit a63d438

Please sign in to comment.