diff --git a/AsyncDisplayKit/ASTextNode.mm b/AsyncDisplayKit/ASTextNode.mm index cbf731019f..25ff6cd86a 100644 --- a/AsyncDisplayKit/ASTextNode.mm +++ b/AsyncDisplayKit/ASTextNode.mm @@ -354,12 +354,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; // as this would essentially serve to set its constrainedSize to be its calculatedSize (unnecessary). ASLayout *layout = self.calculatedLayout; if (layout != nil && CGSizeEqualToSize(boundsSize, layout.size)) { - if (boundsSize.width != rendererConstrainedSize.width) { - // Don't bother changing _constrainedSize, as ASDisplayNode's -measure: method would have a cache miss - // and ask us to recalculate layout if it were called with the same calculatedSize that got us to this point! - _renderer.constrainedSize = boundsSize; - } - return NO; + return (boundsSize.width != rendererConstrainedSize.width); } else { return YES; } @@ -382,7 +377,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; if (CGSizeEqualToSize(_constrainedSize, layoutSize) == NO) { _constrainedSize = layoutSize; - _renderer.constrainedSize = layoutSize; + [self _invalidateRenderer]; } } } @@ -403,9 +398,9 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; _constrainedSize = constrainedSize; - // Instead of invalidating the renderer, in case this is a new call with a different constrained size, - // just update the size of the NSTextContainer that is owned by the renderer's internal context object. - [self _renderer].constrainedSize = _constrainedSize; + if (_renderer != nil && CGSizeEqualToSize(constrainedSize, _renderer.constrainedSize) == NO) { + [self _invalidateRenderer]; + } [self setNeedsDisplay]; diff --git a/AsyncDisplayKit/TextKit/ASTextKitRenderer.h b/AsyncDisplayKit/TextKit/ASTextKitRenderer.h index 17c9439e0a..d34ce0e1c5 100755 --- a/AsyncDisplayKit/TextKit/ASTextKitRenderer.h +++ b/AsyncDisplayKit/TextKit/ASTextKitRenderer.h @@ -53,7 +53,7 @@ @property (nonatomic, assign, readonly) ASTextKitAttributes attributes; -@property (nonatomic, assign, readwrite) CGSize constrainedSize; +@property (nonatomic, assign, readonly) CGSize constrainedSize; @property (nonatomic, assign, readonly) CGFloat currentScaleFactor; diff --git a/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm b/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm index 0eff3ff25c..4fab1a5273 100755 --- a/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm +++ b/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm @@ -140,27 +140,6 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet() return _calculatedSize; } -- (void)setConstrainedSize:(CGSize)constrainedSize -{ - if (!CGSizeEqualToSize(constrainedSize, _constrainedSize)) { - _sizeIsCalculated = NO; - _constrainedSize = constrainedSize; - _calculatedSize = CGSizeZero; - - // Throw away the all subcomponents to create them with the new constrained size new as well as let the - // truncater do it's job again for the new constrained size. This is necessary as after a truncation did happen - // the context would use the truncated string and not the original string to truncate based on the new - // constrained size - - ASPerformBackgroundDeallocation(_context); - ASPerformBackgroundDeallocation(_truncater); - ASPerformBackgroundDeallocation(_fontSizeAdjuster); - _context = nil; - _truncater = nil; - _fontSizeAdjuster = nil; - } -} - - (void)_calculateSize { // if we have no scale factors or an unconstrained width, there is no reason to try to adjust the font size