mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Revert "Revert "Make ASDisplayNode.name Thread Safe""
This reverts commit 906d7c759b.
This commit is contained in:
@@ -1544,7 +1544,6 @@
|
|||||||
205F0E221B376416007741D0 /* CGRect+ASConvenience.m in Sources */,
|
205F0E221B376416007741D0 /* CGRect+ASConvenience.m in Sources */,
|
||||||
058D0A21195D050800B7D73C /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
|
058D0A21195D050800B7D73C /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
|
||||||
205F0E101B371875007741D0 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
205F0E101B371875007741D0 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
||||||
058D0A25195D050800B7D73C /* UIView+ASConvenience.m in Sources */,
|
|
||||||
CC7FD9DF1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m in Sources */,
|
CC7FD9DF1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -1660,7 +1659,6 @@
|
|||||||
34566CB31BC1213700715E6B /* ASPhotosFrameworkImageRequest.m in Sources */,
|
34566CB31BC1213700715E6B /* ASPhotosFrameworkImageRequest.m in Sources */,
|
||||||
B350623B1B010EFD0018CF92 /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
|
B350623B1B010EFD0018CF92 /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
|
||||||
044284FD1BAA365100D16268 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
044284FD1BAA365100D16268 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
||||||
B35062441B010EFD0018CF92 /* UIView+ASConvenience.m in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
|
|||||||
|
|
||||||
/** @name Properties */
|
/** @name Properties */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract The name of this node, which will be displayed in `description`. The default value is nil.
|
||||||
|
*/
|
||||||
|
@property (atomic, copy) NSString *name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract Returns whether the node is synchronous.
|
* @abstract Returns whether the node is synchronous.
|
||||||
@@ -539,7 +543,7 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
|
|||||||
* Using them will not cause the actual view/layer to be created, and will be applied when it is created (when the view
|
* Using them will not cause the actual view/layer to be created, and will be applied when it is created (when the view
|
||||||
* or layer property is accessed).
|
* or layer property is accessed).
|
||||||
*
|
*
|
||||||
* After the view is created, the properties pass through to the view directly as if called on the main thread.
|
* - NOTE: After the view or layer is created, the properties pass through to the view or layer directly and must be called on the main thread.
|
||||||
*
|
*
|
||||||
* See UIView and CALayer for documentation on these common properties.
|
* See UIView and CALayer for documentation on these common properties.
|
||||||
*/
|
*/
|
||||||
@@ -583,7 +587,6 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
|
|||||||
@property (atomic, assign) CGFloat contentsScale; // default=1.0f. See @contentsScaleForDisplay for more info
|
@property (atomic, assign) CGFloat contentsScale; // default=1.0f. See @contentsScaleForDisplay for more info
|
||||||
@property (atomic, assign) CATransform3D transform; // default=CATransform3DIdentity
|
@property (atomic, assign) CATransform3D transform; // default=CATransform3DIdentity
|
||||||
@property (atomic, assign) CATransform3D subnodeTransform; // default=CATransform3DIdentity
|
@property (atomic, assign) CATransform3D subnodeTransform; // default=CATransform3DIdentity
|
||||||
@property (atomic, copy) NSString *name; // default=nil. Use this to tag your layers in the server-recurse-description / pca or for your own purposes
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract The node view's background color.
|
* @abstract The node view's background color.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#import "_ASDisplayView.h"
|
#import "_ASDisplayView.h"
|
||||||
#import "_ASScopeTimer.h"
|
#import "_ASScopeTimer.h"
|
||||||
#import "ASDisplayNodeExtras.h"
|
#import "ASDisplayNodeExtras.h"
|
||||||
|
#import "ASEqualityHelpers.h"
|
||||||
|
|
||||||
#import "ASInternalHelpers.h"
|
#import "ASInternalHelpers.h"
|
||||||
#import "ASLayout.h"
|
#import "ASLayout.h"
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
|
|
||||||
// these dynamic properties all defined in ASLayoutOptionsPrivate.m
|
// these dynamic properties all defined in ASLayoutOptionsPrivate.m
|
||||||
@dynamic spacingAfter, spacingBefore, flexGrow, flexShrink, flexBasis, alignSelf, ascender, descender, sizeRange, layoutPosition, layoutOptions;
|
@dynamic spacingAfter, spacingBefore, flexGrow, flexShrink, flexBasis, alignSelf, ascender, descender, sizeRange, layoutPosition, layoutOptions;
|
||||||
|
@synthesize name = _name;
|
||||||
@synthesize preferredFrameSize = _preferredFrameSize;
|
@synthesize preferredFrameSize = _preferredFrameSize;
|
||||||
@synthesize isFinalLayoutable = _isFinalLayoutable;
|
@synthesize isFinalLayoutable = _isFinalLayoutable;
|
||||||
|
|
||||||
@@ -526,6 +528,20 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
|||||||
return (_view != nil || (_flags.layerBacked && _layer != nil));
|
return (_view != nil || (_flags.layerBacked && _layer != nil));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)name
|
||||||
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setName:(NSString *)name
|
||||||
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
if (!ASObjectIsEqual(_name, name)) {
|
||||||
|
_name = [name copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isSynchronous
|
- (BOOL)isSynchronous
|
||||||
{
|
{
|
||||||
return _flags.synchronous;
|
return _flags.synchronous;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
@property (nonatomic, assign) CGFloat borderWidth;
|
@property (nonatomic, assign) CGFloat borderWidth;
|
||||||
@property (nonatomic, assign, getter = isOpaque) BOOL opaque;
|
@property (nonatomic, assign, getter = isOpaque) BOOL opaque;
|
||||||
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef borderColor;
|
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef borderColor;
|
||||||
@property (nonatomic, copy) NSString *asyncdisplaykit_name;
|
|
||||||
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef backgroundColor;
|
@property (nonatomic, retain) __attribute__((NSObject)) CGColorRef backgroundColor;
|
||||||
@property (nonatomic, assign) BOOL allowsEdgeAntialiasing;
|
@property (nonatomic, assign) BOOL allowsEdgeAntialiasing;
|
||||||
@property (nonatomic, assign) unsigned int edgeAntialiasingMask;
|
@property (nonatomic, assign) unsigned int edgeAntialiasingMask;
|
||||||
@@ -79,7 +78,3 @@
|
|||||||
@property (nonatomic, copy) NSString *accessibilityIdentifier;
|
@property (nonatomic, copy) NSString *accessibilityIdentifier;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CALayer (ASDisplayNodeLayer)
|
|
||||||
@property (atomic, copy) NSString *asyncdisplaykit_name;
|
|
||||||
@end
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
/* 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 root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "UIView+ASConvenience.h"
|
|
||||||
|
|
||||||
@implementation CALayer (ASDisplayNodeLayer)
|
|
||||||
@dynamic asyncdisplaykit_name;
|
|
||||||
@end
|
|
||||||
@@ -496,18 +496,6 @@
|
|||||||
_setToLayer(edgeAntialiasingMask, edgeAntialiasingMask);
|
_setToLayer(edgeAntialiasingMask, edgeAntialiasingMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)name
|
|
||||||
{
|
|
||||||
_bridge_prologue;
|
|
||||||
return _getFromLayer(asyncdisplaykit_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setName:(NSString *)name
|
|
||||||
{
|
|
||||||
_bridge_prologue;
|
|
||||||
_setToLayer(asyncdisplaykit_name, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isAccessibilityElement
|
- (BOOL)isAccessibilityElement
|
||||||
{
|
{
|
||||||
_bridge_prologue;
|
_bridge_prologue;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
CGFloat borderWidth;
|
CGFloat borderWidth;
|
||||||
CGColorRef borderColor;
|
CGColorRef borderColor;
|
||||||
BOOL asyncTransactionContainer;
|
BOOL asyncTransactionContainer;
|
||||||
NSString *name;
|
|
||||||
BOOL isAccessibilityElement;
|
BOOL isAccessibilityElement;
|
||||||
NSString *accessibilityLabel;
|
NSString *accessibilityLabel;
|
||||||
NSString *accessibilityHint;
|
NSString *accessibilityHint;
|
||||||
@@ -85,7 +84,6 @@
|
|||||||
int setBorderWidth:1;
|
int setBorderWidth:1;
|
||||||
int setBorderColor:1;
|
int setBorderColor:1;
|
||||||
int setAsyncTransactionContainer:1;
|
int setAsyncTransactionContainer:1;
|
||||||
int setName:1;
|
|
||||||
int setAllowsEdgeAntialiasing:1;
|
int setAllowsEdgeAntialiasing:1;
|
||||||
int setEdgeAntialiasingMask:1;
|
int setEdgeAntialiasingMask:1;
|
||||||
int setIsAccessibilityElement:1;
|
int setIsAccessibilityElement:1;
|
||||||
@@ -133,7 +131,6 @@
|
|||||||
@synthesize borderWidth=borderWidth;
|
@synthesize borderWidth=borderWidth;
|
||||||
@synthesize borderColor=borderColor;
|
@synthesize borderColor=borderColor;
|
||||||
@synthesize asyncdisplaykit_asyncTransactionContainer=asyncTransactionContainer;
|
@synthesize asyncdisplaykit_asyncTransactionContainer=asyncTransactionContainer;
|
||||||
@synthesize asyncdisplaykit_name=name;
|
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
@@ -419,20 +416,6 @@
|
|||||||
_flags.setAsyncTransactionContainer = YES;
|
_flags.setAsyncTransactionContainer = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is named this way, since I'm not sure we can change the setter for the CA version
|
|
||||||
- (void)setAsyncdisplaykit_name:(NSString *)newName
|
|
||||||
{
|
|
||||||
_flags.setName = YES;
|
|
||||||
if (name != newName) {
|
|
||||||
name = [newName copy];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)asyncdisplaykit_name
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isAccessibilityElement
|
- (BOOL)isAccessibilityElement
|
||||||
{
|
{
|
||||||
return isAccessibilityElement;
|
return isAccessibilityElement;
|
||||||
@@ -641,9 +624,6 @@
|
|||||||
if (_flags.setAsyncTransactionContainer)
|
if (_flags.setAsyncTransactionContainer)
|
||||||
layer.asyncdisplaykit_asyncTransactionContainer = asyncTransactionContainer;
|
layer.asyncdisplaykit_asyncTransactionContainer = asyncTransactionContainer;
|
||||||
|
|
||||||
if (_flags.setName)
|
|
||||||
layer.asyncdisplaykit_name = name;
|
|
||||||
|
|
||||||
if (_flags.setOpaque)
|
if (_flags.setOpaque)
|
||||||
ASDisplayNodeAssert(layer.opaque == opaque, @"Didn't set opaque as desired");
|
ASDisplayNodeAssert(layer.opaque == opaque, @"Didn't set opaque as desired");
|
||||||
}
|
}
|
||||||
@@ -756,9 +736,6 @@
|
|||||||
if (_flags.setAsyncTransactionContainer)
|
if (_flags.setAsyncTransactionContainer)
|
||||||
view.asyncdisplaykit_asyncTransactionContainer = asyncTransactionContainer;
|
view.asyncdisplaykit_asyncTransactionContainer = asyncTransactionContainer;
|
||||||
|
|
||||||
if (_flags.setName)
|
|
||||||
layer.asyncdisplaykit_name = name;
|
|
||||||
|
|
||||||
if (_flags.setOpaque)
|
if (_flags.setOpaque)
|
||||||
ASDisplayNodeAssert(view.layer.opaque == opaque, @"Didn't set opaque as desired");
|
ASDisplayNodeAssert(view.layer.opaque == opaque, @"Didn't set opaque as desired");
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,11 @@ static dispatch_block_t modifyMethodByAddingPrologueBlockAndReturnCleanupBlock(C
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
#define DeclareNodeNamed(n) ASDisplayNode *n = [[ASDisplayNode alloc] init]; n.name = @#n
|
#define DeclareNodeNamed(n) ASDisplayNode *n = [[ASDisplayNode alloc] init]; n.name = @#n
|
||||||
#define DeclareViewNamed(v) UIView *v = [[UIView alloc] init]; v.layer.asyncdisplaykit_name = @#v
|
|
||||||
#define DeclareLayerNamed(l) CALayer *l = [[CALayer alloc] init]; l.asyncdisplaykit_name = @#l
|
// FIXME: It's goofy to use `setValue:forKey:` here but importing ASDisplayNodeInternal.h
|
||||||
|
// in this file causes build to fail (compiler chokes at ASDN::RecursiveMutex)
|
||||||
|
#define DeclareViewNamed(v) UIView *v = [[UIView alloc] init]; [v.layer setValue:@#v forKey:@"asyncdisplaykit_node.name"]
|
||||||
|
#define DeclareLayerNamed(l) CALayer *l = [[CALayer alloc] init]; [l setValue:@#l forKey:@"asyncdisplaykit_node.name"]
|
||||||
|
|
||||||
@implementation ASDisplayNodeAppearanceTests
|
@implementation ASDisplayNodeAppearanceTests
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,19 +19,22 @@
|
|||||||
// Conveniences for making nodes named a certain way
|
// Conveniences for making nodes named a certain way
|
||||||
|
|
||||||
#define DeclareNodeNamed(n) ASDisplayNode *n = [[ASDisplayNode alloc] init]; n.name = @#n
|
#define DeclareNodeNamed(n) ASDisplayNode *n = [[ASDisplayNode alloc] init]; n.name = @#n
|
||||||
#define DeclareViewNamed(v) UIView *v = [[UIView alloc] init]; v.layer.asyncdisplaykit_name = @#v
|
|
||||||
#define DeclareLayerNamed(l) CALayer *l = [[CALayer alloc] init]; l.asyncdisplaykit_name = @#l
|
// FIXME: It's goofy to use `setValue:forKey:` here but importing ASDisplayNodeInternal.h
|
||||||
|
// in this file causes build to fail (compiler chokes at ASDN::RecursiveMutex)
|
||||||
|
#define DeclareViewNamed(v) UIView *v = [[UIView alloc] init]; [v.layer setValue:@#v forKey:@"asyncdisplaykit_node.name"]
|
||||||
|
#define DeclareLayerNamed(l) CALayer *l = [[CALayer alloc] init]; [l setValue:@#l forKey:@"asyncdisplaykit_node.name"]
|
||||||
|
|
||||||
static NSString *orderStringFromSublayers(CALayer *l) {
|
static NSString *orderStringFromSublayers(CALayer *l) {
|
||||||
return [[[l.sublayers valueForKey:@"asyncdisplaykit_name"] allObjects] componentsJoinedByString:@","];
|
return [[l.sublayers valueForKey:@"asyncdisplaykit_node.name"] componentsJoinedByString:@","];
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSString *orderStringFromSubviews(UIView *v) {
|
static NSString *orderStringFromSubviews(UIView *v) {
|
||||||
return [[[v.subviews valueForKeyPath:@"layer.asyncdisplaykit_name"] allObjects] componentsJoinedByString:@","];
|
return [[v.subviews valueForKeyPath:@"layer.asyncdisplaykit_node.name"] componentsJoinedByString:@","];
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSString *orderStringFromSubnodes(ASDisplayNode *n) {
|
static NSString *orderStringFromSubnodes(ASDisplayNode *n) {
|
||||||
return [[[n.subnodes valueForKey:@"name"] allObjects] componentsJoinedByString:@","];
|
return [[n.subnodes valueForKey:@"name"] componentsJoinedByString:@","];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asserts subnode, subview, sublayer order match what you provide here
|
// Asserts subnode, subview, sublayer order match what you provide here
|
||||||
|
|||||||
Reference in New Issue
Block a user