Skip calculating a zero size for empty RSSingleLineView and RSSingleLineRenderer.

This commit is contained in:
Brent Simmons 2017-11-16 21:10:44 -08:00
parent c459bd1a4e
commit 828075454e
2 changed files with 12 additions and 3 deletions

View File

@ -120,7 +120,11 @@ static NSMutableDictionary *rendererCache = nil;
- (NSSize)size {
if (self.title.string.length < 1) {
return NSZeroSize;
}
if (NSEqualSizes(_size, NSZeroSize)) {
_size = [self calculatedSize];
}
@ -173,7 +177,7 @@ static const CGFloat kMaxHeight = 10000.0;
CGContextSetFillColorWithColor(context, self.backgroundColor.CGColor);
CGContextFillRect(context, r);
CGContextSetShouldSmoothFonts(context, true);
CTFrameDraw(self.frameref, context);

View File

@ -109,7 +109,12 @@ static NSAttributedString *emptyAttributedString = nil;
- (NSSize)intrinsicContentSize {
if (!self.intrinsicSizeIsValid) {
self.intrinsicSize = ((RSSingleLineRenderer *)(self.renderer)).size;
if (!self.attributedStringValue) {
self.intrinsicSize = NSZeroSize;
}
else {
self.intrinsicSize = ((RSSingleLineRenderer *)(self.renderer)).size;
}
self.intrinsicSizeIsValid = YES;
}