mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Fix deadlock calling trailingRect on a ASTextNode
This commit is contained in:
parent
402c5fe25a
commit
91b6995987
@ -333,6 +333,8 @@ static const CGFloat ASTextKitRendererTextCapHeightPadding = 1.3;
|
|||||||
- (CGRect)trailingRect
|
- (CGRect)trailingRect
|
||||||
{
|
{
|
||||||
__block CGRect trailingRect = CGRectNull;
|
__block CGRect trailingRect = CGRectNull;
|
||||||
|
__block CGSize calculatedSize = CGSizeZero;
|
||||||
|
__block NSRange textRange = NSMakeRange(0, 0);
|
||||||
[self.context performBlockWithLockedTextKitComponents:^(NSLayoutManager *layoutManager, NSTextStorage *textStorage, NSTextContainer *textContainer) {
|
[self.context performBlockWithLockedTextKitComponents:^(NSLayoutManager *layoutManager, NSTextStorage *textStorage, NSTextContainer *textContainer) {
|
||||||
CGSize calculatedSize = textContainer.size;
|
CGSize calculatedSize = textContainer.size;
|
||||||
// If have an empty string, then our whole bounds constitute trailing space.
|
// If have an empty string, then our whole bounds constitute trailing space.
|
||||||
@ -340,15 +342,16 @@ static const CGFloat ASTextKitRendererTextCapHeightPadding = 1.3;
|
|||||||
trailingRect = CGRectMake(0, 0, calculatedSize.width, calculatedSize.height);
|
trailingRect = CGRectMake(0, 0, calculatedSize.width, calculatedSize.height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take everything after our final character as trailing space.
|
textRange = NSMakeRange([textStorage length] - 1, 1);
|
||||||
NSArray *finalRects = [self rectsForTextRange:NSMakeRange([textStorage length] - 1, 1) measureOption:ASTextKitRendererMeasureOptionLineHeight];
|
|
||||||
CGRect finalGlyphRect = [[finalRects lastObject] CGRectValue];
|
|
||||||
CGPoint origin = CGPointMake(CGRectGetMaxX(finalGlyphRect), CGRectGetMinY(finalGlyphRect));
|
|
||||||
CGSize size = CGSizeMake(calculatedSize.width - origin.x, calculatedSize.height - origin.y);
|
|
||||||
trailingRect = (CGRect){origin, size};
|
|
||||||
}];
|
}];
|
||||||
return trailingRect;
|
|
||||||
|
// Take everything after our final character as trailing space.
|
||||||
|
NSArray *finalRects = [self rectsForTextRange:textRange measureOption:ASTextKitRendererMeasureOptionLineHeight];
|
||||||
|
CGRect finalGlyphRect = [[finalRects lastObject] CGRectValue];
|
||||||
|
CGPoint origin = CGPointMake(CGRectGetMaxX(finalGlyphRect), CGRectGetMinY(finalGlyphRect));
|
||||||
|
CGSize size = CGSizeMake(calculatedSize.width - origin.x, calculatedSize.height - origin.y);
|
||||||
|
return (CGRect){origin, size};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)frameForTextRange:(NSRange)textRange
|
- (CGRect)frameForTextRange:(NSRange)textRange
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user