mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[ASTextNode] Ensure that isTruncated computes the correct value when sizing fast-path is used. (#2550) (#2763)
* Fix fast-path isTruncated. * Clean up formatting; remove extra char.
This commit is contained in:
@@ -1163,7 +1163,7 @@ static NSAttributedString *DefaultTruncationAttributedString()
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
ASTextKitRenderer *renderer = [self _renderer];
|
||||
return renderer.firstVisibleRange.length < _attributedText.length;
|
||||
return renderer.isTruncated;
|
||||
}
|
||||
|
||||
- (void)setPointSizeScaleFactors:(NSArray *)pointSizeScaleFactors
|
||||
|
||||
@@ -85,6 +85,11 @@
|
||||
*/
|
||||
- (NSUInteger)lineCount;
|
||||
|
||||
/**
|
||||
Whether or not the text is truncated.
|
||||
*/
|
||||
- (BOOL)isTruncated;
|
||||
|
||||
@end
|
||||
|
||||
@interface ASTextKitRenderer (ASTextKitRendererConvenience)
|
||||
|
||||
@@ -261,6 +261,18 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
- (BOOL)isTruncated
|
||||
{
|
||||
if (self.canUseFastPath) {
|
||||
CGRect boundedRect = [_attributes.attributedString boundingRectWithSize:CGSizeMake(_constrainedSize.width, CGFLOAT_MAX)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine
|
||||
context:nil];
|
||||
return boundedRect.size.height > _constrainedSize.height;
|
||||
} else {
|
||||
return self.firstVisibleRange.length < _attributes.attributedString.length;
|
||||
}
|
||||
}
|
||||
|
||||
- (std::vector<NSRange>)visibleRanges
|
||||
{
|
||||
return _truncater.visibleRanges;
|
||||
|
||||
Reference in New Issue
Block a user