Invalidate TextNode Renderer Instead of Changing constrainedSize (#2516)

* Instead of changing its constrained size, just invalidate renderer. It's virtually the same.

* Check constrained size before invalidating renderer
This commit is contained in:
Adlai Holler
2016-10-31 14:14:21 -07:00
committed by GitHub
parent 7ecce6b677
commit f09b92641c
3 changed files with 6 additions and 32 deletions

View File

@@ -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