mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Some commit
This commit is contained in:
@@ -254,6 +254,8 @@ extern NSInteger const ASDefaultDrawingPriority;
|
||||
|
||||
/** @name Managing dimensions */
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size;
|
||||
|
||||
/**
|
||||
* @abstract Asks the node to return a layout based on given size range.
|
||||
*
|
||||
|
||||
@@ -703,6 +703,11 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size
|
||||
{
|
||||
return [self layoutThatFits:ASSizeRangeMake(CGSizeZero, size)].size;
|
||||
}
|
||||
|
||||
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
@@ -1495,15 +1500,11 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
// If no measure pass happened or the bounds changed between layout passes we manually trigger a measurement pass
|
||||
// for the node using a size range equal to whatever bounds were provided to the node
|
||||
if (hasDirtyLayout) {
|
||||
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
||||
LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self);
|
||||
} else {
|
||||
if (CGSizeEqualToSize(calculatedLayoutSize, bounds.size) == NO) {
|
||||
[self layoutThatFits:ASSizeRangeMake(bounds.size)];
|
||||
} else {
|
||||
[self layoutThatFits:_calculatedDisplayNodeLayout->constrainedSize];
|
||||
}
|
||||
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
||||
LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self);
|
||||
} else {
|
||||
if (CGSizeEqualToSize(calculatedLayoutSize, bounds.size) == NO) {
|
||||
[self layoutThatFits:ASSizeRangeMake(bounds.size)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,17 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
return [self _rendererWithBounds:self.threadSafeBounds];
|
||||
}
|
||||
|
||||
- (ASTextKitRenderer *)_rendererWithBoundsSlow:(CGRect)bounds
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
CGSize constrainedSize = bounds.size;
|
||||
constrainedSize.width -= (_textContainerInset.left + _textContainerInset.right);
|
||||
constrainedSize.height -= (_textContainerInset.top + _textContainerInset.bottom);
|
||||
return [[ASTextKitRenderer alloc] initWithTextKitAttributes:[self _rendererAttributes]
|
||||
constrainedSize:constrainedSize];
|
||||
}
|
||||
|
||||
- (ASTextKitRenderer *)_rendererWithBounds:(CGRect)bounds
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
@@ -404,7 +415,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
|
||||
CGSize size = [self _renderer].size;
|
||||
CGSize size = [self _rendererWithBoundsSlow:{.size=constrainedSize}].size;
|
||||
if (_attributedText.length > 0) {
|
||||
self.style.ascender = [[self class] ascenderWithAttributedString:_attributedText];
|
||||
self.style.descender = [[_attributedText attribute:NSFontAttributeName atIndex:_attributedText.length - 1 effectiveRange:NULL] descender];
|
||||
@@ -537,7 +548,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
|
||||
CGContextTranslateCTM(context, _textContainerInset.left, _textContainerInset.top);
|
||||
|
||||
ASTextKitRenderer *renderer = [self _rendererWithBounds:drawParameterBounds];
|
||||
ASTextKitRenderer *renderer = [self _rendererWithBoundsSlow:drawParameterBounds];
|
||||
|
||||
// Fill background
|
||||
if (backgroundColor != nil) {
|
||||
|
||||
Reference in New Issue
Block a user