[ASTextNode] Fix text node truncation (#1863)

* Before truncate a text storage in ASTextKitContext reset the text storage to original value

* Fix ASTextNode tests

We should pass in the constrained size in both cases and the sizes should be the same. We adjust the calculated size in ASTextNode to be a bit narrower in the second case if we truncate again with the calculated size as constrained size it will truncate more and the resulting size will shrink.
This commit is contained in:
Michael Schneider
2016-07-09 15:40:31 -07:00
committed by appleguy
parent 38fab7cd94
commit 6238e5edbd
5 changed files with 56 additions and 8 deletions

View File

@@ -129,8 +129,12 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
// If we're updating an existing context, make sure to use the same inset logic used during initialization.
// This codepath allows us to reuse the
CGSize shadowConstrainedSize = [[self shadower] insetSizeWithConstrainedSize:constrainedSize];
if (_context) _context.constrainedSize = shadowConstrainedSize;
if (_fontSizeAdjuster) _fontSizeAdjuster.constrainedSize = shadowConstrainedSize;
if (_context) {
_context.constrainedSize = shadowConstrainedSize;
}
if (_fontSizeAdjuster) {
_fontSizeAdjuster.constrainedSize = shadowConstrainedSize;
}
}
}
}