mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-03-18 21:38:18 +00:00
Address further comments
This commit is contained in:
@@ -306,7 +306,6 @@ extern NSInteger const ASDefaultDrawingPriority;
|
||||
*/
|
||||
@property (nonatomic, readonly, assign) ASSizeRange constrainedSizeForCalculatedLayout;
|
||||
|
||||
|
||||
/** @name Managing the nodes hierarchy */
|
||||
|
||||
|
||||
@@ -632,13 +631,18 @@ extern NSInteger const ASDefaultDrawingPriority;
|
||||
@interface ASDisplayNode (UIViewBridge)
|
||||
|
||||
/**
|
||||
* Marks the view as needing display. Convenience for use whether the view / layer is loaded or not. Safe to call
|
||||
* from a background thread.
|
||||
* Marks the view as needing display. Convenience for use whether the view / layer is loaded or not. Safe to call from a background thread.
|
||||
*/
|
||||
- (void)setNeedsDisplay;
|
||||
|
||||
/**
|
||||
* Marks the node as needing layout. Convenience for use whether the view / layer is loaded or not. Safe to call from a background thread.
|
||||
*
|
||||
* If the node determines its own desired layout size will change in the next layout pass, it will propagate this
|
||||
* information up the tree so its parents can have a chance to consider and apply if necessary the new size onto the node.
|
||||
*
|
||||
* Note: ASCellNode has special behavior in that calling this method will automatically notify
|
||||
* the containing ASTableView / ASCollectionView that the cell should be resized, if necessary.
|
||||
*/
|
||||
- (void)setNeedsLayout;
|
||||
|
||||
|
||||
@@ -704,7 +704,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)invalidateSize
|
||||
- (void)setNeedsLayoutFromAbove
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
|
||||
@@ -718,7 +718,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
__instanceLock__.unlock();
|
||||
// Cause supernode's layout to be invalidated
|
||||
// We need to release the lock to prevent a deadlock
|
||||
[supernode invalidateSize];
|
||||
[supernode setNeedsLayoutFromAbove];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -733,8 +733,13 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
constrainedSize = _calculatedDisplayNodeLayout->constrainedSize;
|
||||
}
|
||||
|
||||
// Check if the returned layout has a different size as the current bounds
|
||||
// Perform a measurement pass to get the current layout
|
||||
// It's important to differentiate between layout and measure pass here. Calling `layoutThatFits:` just perform a
|
||||
// measure pass and no layout pass immediately. If a layout pass wold be forced via `layoutIfNeeded` it could cause an
|
||||
// infinite loop as in `__layout` we check if the size changed and we are just to inform the node that the size changed
|
||||
ASLayout *layout = [self layoutThatFits:constrainedSize];
|
||||
|
||||
// Check if the returned layout has a different size as the current bounds
|
||||
if (CGSizeEqualToSize(oldSize, layout.size) == NO) {
|
||||
// If the size of the layout changes inform our container (e.g ASTableView, ASCollectionView, ASViewController, ...)
|
||||
// that we need it to change our bounds size.
|
||||
@@ -1415,11 +1420,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
[self invalidateCalculatedLayout];
|
||||
}
|
||||
|
||||
- (void)__layoutIfNeeded
|
||||
{
|
||||
// For now this is a no op.
|
||||
}
|
||||
|
||||
- (void)__setNeedsDisplay
|
||||
{
|
||||
BOOL nowDisplay = ASInterfaceStateIncludesDisplay(_interfaceState);
|
||||
@@ -1540,7 +1540,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
// If the size of the new layout to apply did change from the current bounds, invalidate the whole tree up
|
||||
// so the root node can handle a resizing if necessary
|
||||
if (CGSizeEqualToSize(ASCeilSizeValues(bounds.size), pendingLayout->layout.size) == NO) {
|
||||
[self invalidateSize];
|
||||
[self setNeedsLayoutFromAbove];
|
||||
}
|
||||
|
||||
if (didCreateNewContext) {
|
||||
@@ -1570,7 +1570,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
CGRect bounds = self.threadSafeBounds;
|
||||
|
||||
// Checkout if constrained size of pending or calculated display node layout can be used
|
||||
if (_pendingDisplayNodeLayout != nullptr && CGSizeEqualToSize(_pendingDisplayNodeLayout->layout.size, ASCeilSizeValues(bounds.size))) {
|
||||
if (_pendingDisplayNodeLayout != nullptr &&
|
||||
CGSizeEqualToSize(_pendingDisplayNodeLayout->layout.size, ASCeilSizeValues(bounds.size))) {
|
||||
// We assume the size from the last returned layoutThatFits: layout was applied so use the pending display node
|
||||
// layout constrained size
|
||||
return _pendingDisplayNodeLayout->constrainedSize;
|
||||
|
||||
@@ -1567,11 +1567,6 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
}
|
||||
}
|
||||
|
||||
- (ASSizeRange)constrainedSizeForNode:(ASCellNode *)node
|
||||
{
|
||||
return [self dataController:self.dataController constrainedSizeForNodeAtIndexPath:[self indexPathForNode:node]];
|
||||
}
|
||||
|
||||
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -181,7 +181,7 @@ __unused static NSString * _Nonnull NSStringFromASHierarchyState(ASHierarchyStat
|
||||
* @discussion The size of a root node is determined by each subnode. Calling invalidateSize will let the root node know
|
||||
* that the intrinsic size of the receiver node is no longer valid and a resizing of the root node needs to happen.
|
||||
*/
|
||||
- (void)invalidateSize;
|
||||
- (void)setNeedsLayoutFromAbove;
|
||||
|
||||
/**
|
||||
* @abstract Subclass hook for nodes that are acting as root nodes. This method is called if one of the subnodes
|
||||
|
||||
Reference in New Issue
Block a user