mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
.preventOrCancelDisplay -> .displaySuspended.
Rename the ASDisplayNode property to match its _ASDisplayLayer counterpart -- `displaySuspended` is more succinct and is a more plausible name for a Cocoa BOOL property.
This commit is contained in:
@@ -319,31 +319,31 @@
|
||||
* progress.
|
||||
*
|
||||
* Defaults to NO. Does not control display for any child or descendant nodes; for that, use
|
||||
* -recursiveSetPreventOrCancelDisplay:.
|
||||
* -recursivelySetDisplaySuspended:.
|
||||
*
|
||||
* If a setNeedsDisplay occurs while preventOrCancelDisplay is YES, and preventOrCancelDisplay is set to NO, then the
|
||||
* If a setNeedsDisplay occurs while displaySuspended is YES, and displaySuspended is set to NO, then the
|
||||
* layer will be automatically displayed.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL preventOrCancelDisplay;
|
||||
@property (nonatomic, assign) BOOL displaySuspended;
|
||||
|
||||
/**
|
||||
* @abstract Prevent the node and its descendants' layer from displaying.
|
||||
*
|
||||
* @param flag YES if display should be prevented or cancelled; NO otherwise.
|
||||
*
|
||||
* @see preventOrCancelDisplay
|
||||
* @see displaySuspended
|
||||
*/
|
||||
- (void)recursiveSetPreventOrCancelDisplay:(BOOL)flag;
|
||||
- (void)recursivelySetDisplaySuspended:(BOOL)flag;
|
||||
|
||||
/**
|
||||
* @abstract Calls -reclaimMemory on the receiver and its subnode hierarchy.
|
||||
*
|
||||
* @discussion Clears backing stores and other memory-intensive intermediates.
|
||||
* If the node is removed from a visible hierarchy and then re-added, it will automatically trigger a new asynchronous display,
|
||||
* as long as preventOrCancelDisplay is not set.
|
||||
* as long as displaySuspended is not set.
|
||||
* If the node remains in the hierarchy throughout, -setNeedsDisplay is required to trigger a new asynchronous display.
|
||||
*
|
||||
* @see preventOrCancelDisplay and setNeedsDisplay
|
||||
* @see displaySuspended and setNeedsDisplay
|
||||
*/
|
||||
|
||||
- (void)recursivelyReclaimMemory;
|
||||
|
||||
@@ -1326,7 +1326,7 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
_pendingViewState = nil;
|
||||
|
||||
// TODO: move this into real pending state
|
||||
if (_flags.preventOrCancelDisplay) {
|
||||
if (_flags.displaySuspended) {
|
||||
self.asyncLayer.displaySuspended = YES;
|
||||
}
|
||||
if (!_flags.displaysAsynchronously) {
|
||||
@@ -1359,12 +1359,12 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)recursiveSetPreventOrCancelDisplay:(BOOL)flag
|
||||
- (void)recursivelySetDisplaySuspended:(BOOL)flag
|
||||
{
|
||||
_recursiveSetPreventOrCancelDisplay(self, nil, flag);
|
||||
_recursivelySetDisplaySuspended(self, nil, flag);
|
||||
}
|
||||
|
||||
static void _recursiveSetPreventOrCancelDisplay(ASDisplayNode *node, CALayer *layer, BOOL flag)
|
||||
static void _recursivelySetDisplaySuspended(ASDisplayNode *node, CALayer *layer, BOOL flag)
|
||||
{
|
||||
// If there is no layer, but node whose its view is loaded, then we can traverse down its layer hierarchy. Otherwise we must stick to the node hierarchy to avoid loading views prematurely. Note that for nodes that haven't loaded their views, they can't possibly have subviews/sublayers, so we don't need to traverse the layer hierarchy for them.
|
||||
if (!layer && node && node.nodeLoaded) {
|
||||
@@ -1377,29 +1377,29 @@ static void _recursiveSetPreventOrCancelDisplay(ASDisplayNode *node, CALayer *la
|
||||
}
|
||||
|
||||
// Set the flag on the node. If this is a pure layer (no node) then this has no effect (plain layers don't support preventing/cancelling display).
|
||||
node.preventOrCancelDisplay = flag;
|
||||
node.displaySuspended = flag;
|
||||
|
||||
if (layer && !node.shouldRasterizeDescendants) {
|
||||
// If there is a layer, recurse down the layer hierarchy to set the flag on descendants. This will cover both layer-based and node-based children.
|
||||
for (CALayer *sublayer in layer.sublayers) {
|
||||
_recursiveSetPreventOrCancelDisplay(nil, sublayer, flag);
|
||||
_recursivelySetDisplaySuspended(nil, sublayer, flag);
|
||||
}
|
||||
} else {
|
||||
// If there is no layer (view not loaded yet) or this node rasterizes descendants (there won't be a layer tree to traverse), recurse down the subnode hierarchy to set the flag on descendants. This covers only node-based children, but for a node whose view is not loaded it can't possibly have nodeless children.
|
||||
for (ASDisplayNode *subnode in node.subnodes) {
|
||||
_recursiveSetPreventOrCancelDisplay(subnode, nil, flag);
|
||||
_recursivelySetDisplaySuspended(subnode, nil, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)preventOrCancelDisplay
|
||||
- (BOOL)displaySuspended
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
return _flags.preventOrCancelDisplay;
|
||||
return _flags.displaySuspended;
|
||||
}
|
||||
|
||||
- (void)setPreventOrCancelDisplay:(BOOL)flag
|
||||
- (void)setDisplaySuspended:(BOOL)flag
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
|
||||
@@ -1409,10 +1409,10 @@ static void _recursiveSetPreventOrCancelDisplay(ASDisplayNode *node, CALayer *la
|
||||
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
|
||||
if (_flags.preventOrCancelDisplay == flag)
|
||||
if (_flags.displaySuspended == flag)
|
||||
return;
|
||||
|
||||
_flags.preventOrCancelDisplay = flag;
|
||||
_flags.displaySuspended = flag;
|
||||
|
||||
self.asyncLayer.displaySuspended = flag;
|
||||
}
|
||||
|
||||
@@ -107,10 +107,10 @@ typedef UIImage *(^asimagenode_modification_block_t)(UIImage *image);
|
||||
*
|
||||
* @param displayCompletionBlock The block to be performed after display has
|
||||
* finished. Its `canceled` property will be YES if display was prevented or
|
||||
* canceled (via preventOrCancelDisplay); NO otherwise.
|
||||
* canceled (via displaySuspended); NO otherwise.
|
||||
*
|
||||
* @discussion displayCompletionBlock will be performed on the main-thread. If
|
||||
* `preventOrCancelDisplay` is YES, `displayCompletionBlock` is will be
|
||||
* `displaySuspended` is YES, `displayCompletionBlock` is will be
|
||||
* performed immediately and `YES` will be passed for `canceled`.
|
||||
*/
|
||||
- (void)setNeedsDisplayWithCompletion:(void (^)(BOOL canceled))displayCompletionBlock;
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
#pragma mark -
|
||||
- (void)setNeedsDisplayWithCompletion:(void (^)(BOOL canceled))displayCompletionBlock
|
||||
{
|
||||
if (self.preventOrCancelDisplay) {
|
||||
if (self.displaySuspended) {
|
||||
if (displayCompletionBlock)
|
||||
displayCompletionBlock(YES);
|
||||
return;
|
||||
|
||||
@@ -187,7 +187,7 @@ static BOOL ASRangeIsValid(NSRange range)
|
||||
ASDisplayNodeAssertMainThread();
|
||||
ASDisplayNodeAssert(node, @"invalid argument");
|
||||
|
||||
[node recursiveSetPreventOrCancelDisplay:YES];
|
||||
[node recursivelySetDisplaySuspended:YES];
|
||||
[node.view removeFromSuperview];
|
||||
|
||||
// since this class usually manages large or infinite data sets, the working range
|
||||
@@ -526,7 +526,7 @@ static NSRange ASCalculateWorkingRange(ASRangeTuningParameters params, ASScrollD
|
||||
ASCellNode *sizedNode = _nodes[[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]];
|
||||
ASDisplayNodeAssert(sizedNode, @"this node should be sized but doesn't even exist");
|
||||
ASDisplayNodeAssert([sizedNode.asyncdisplaykit_indexPath isEqual:indexPath], @"this node has the wrong index path");
|
||||
[sizedNode recursiveSetPreventOrCancelDisplay:NO];
|
||||
[sizedNode recursivelySetDisplaySuspended:NO];
|
||||
return sizedNode;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void ASDisplayNodePerformBlockOnMainThread(void (^block)());
|
||||
unsigned layerBacked:1;
|
||||
unsigned displaysAsynchronously:1;
|
||||
unsigned shouldRasterizeDescendants:1;
|
||||
unsigned preventOrCancelDisplay:1;
|
||||
unsigned displaySuspended:1;
|
||||
|
||||
// whether custom drawing is enabled
|
||||
unsigned implementsDrawRect:1;
|
||||
|
||||
@@ -149,7 +149,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
XCTAssertEqual(3.f, node.shadowRadius, @"default shadowRadius broken %@", hasLoadedView);
|
||||
XCTAssertEqual(0.0f, node.borderWidth, @"default borderWidth broken %@", hasLoadedView);
|
||||
XCTAssertEqualObjects(rgbBlackCGColorIdPtr, (id)node.borderColor, @"default borderColor broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.preventOrCancelDisplay, @"default preventOrCancelDisplay broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.displaySuspended, @"default displaySuspended broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.displaysAsynchronously, @"default displaysAsynchronously broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.asyncdisplaykit_asyncTransactionContainer, @"default asyncdisplaykit_asyncTransactionContainer broken %@", hasLoadedView);
|
||||
XCTAssertEqualObjects(nil, node.name, @"default name broken %@", hasLoadedView);
|
||||
@@ -245,8 +245,8 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
XCTAssertEqual(.5f, node.shadowRadius, @"shadowRadius broken %@", hasLoadedView);
|
||||
XCTAssertEqual(.5f, node.borderWidth, @"borderWidth broken %@", hasLoadedView);
|
||||
XCTAssertEqual([[UIColor orangeColor] CGColor], node.borderColor, @"borderColor broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.preventOrCancelDisplay, @"preventOrCancelDisplay broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.displaysAsynchronously, @"preventOrCancelDisplay broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.displaySuspended, @"displaySuspended broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.displaysAsynchronously, @"displaySuspended broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.asyncdisplaykit_asyncTransactionContainer, @"asyncTransactionContainer broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.userInteractionEnabled, @"userInteractionEnabled broken %@", hasLoadedView);
|
||||
XCTAssertEqual((BOOL)!isLayerBacked, node.exclusiveTouch, @"exclusiveTouch broken %@", hasLoadedView);
|
||||
@@ -298,7 +298,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
node.shadowRadius = .5f;
|
||||
node.borderWidth = .5f;
|
||||
node.borderColor = [[UIColor orangeColor] CGColor];
|
||||
node.preventOrCancelDisplay = YES;
|
||||
node.displaySuspended = YES;
|
||||
node.displaysAsynchronously = NO;
|
||||
node.asyncdisplaykit_asyncTransactionContainer = YES;
|
||||
node.userInteractionEnabled = NO;
|
||||
|
||||
Reference in New Issue
Block a user