[ASTextNode] Fix edge case where text truncator may not run (manually hosted nodes that are lacking the expected call to -measure).

This fixes the scenario described in https://github.com/facebook/AsyncDisplayKit/issues/1295
This commit is contained in:
Scott Goodson
2016-03-26 18:19:02 -07:00
parent a36cf79300
commit daf41ebb43
4 changed files with 764 additions and 348 deletions

View File

@@ -189,9 +189,10 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
// We add an assertion so we can track the rare conditions where a graphics context is not present
ASDisplayNodeAssertNotNil(context, @"This is no good without a context.");
// This renderer may not be the one that did the sizing. If that is the case its _currentScaleFactor will not be set, so we should compute it now
if (_sizeIsCalculated == NO && isinf(_constrainedSize.width) == NO && [_attributes.pointSizeScaleFactors count] > 0) {
_currentScaleFactor = [[self fontSizeAdjuster] scaleFactor];
// This renderer may not be the one that did the sizing. If that is the case its truncation and currentScaleFactor may not have been evaluated.
// If there's any possibility we need to truncate or scale (e.g. width is not infinite, perform the size calculation.
if (_sizeIsCalculated == NO && isinf(_constrainedSize.width) == NO) {
[self _calculateSize];
}
CGRect shadowInsetBounds = [[self shadower] insetRectWithConstrainedRect:bounds];