* [Optimization] Convert to type-generic math
* add std:: prefix in obj-c++ files
* more cleanup
* revert test changes
* convert min and max back to fmin/fmax
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
This reverts commit 6238e5edbde55fb82982ce4a19a0cbca7fe7eb9d.
We will re-apply this change, but there are some early signs of performance impacts that need to be investigated.
* 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.
The crash happens in the placeholderImage of ASTextNode. The node is not visible in the time it try to get the `placeholderImage` and so the `visibleRange` has count 0 and a crash happens while accessing the first object of an empty array.
Summary: Previously the first thing we did when calculating the size of text was to truncate it. This could lead to ASFontSizeAdjuster being sent a truncated string which, obviously, never needed to shrink. If we change the order then we first shrink, then truncate if still necessary.
Reviewers: scottg, levi, garrett
Differential Revision: https://phabricator.pinadmin.com/D89780
Summary: Looks like this isn't being locked when it should be.
Reviewers: ricky, levi, scottg, schneider
Reviewed By: scottg, schneider
Subscribers: jenkins
Differential Revision: https://phabricator.pinadmin.com/D84952
Previously I was multiplying the calculated height of the text by the scale factor. This fails in the case where we have a long string that doesn't fit, but it is shrunk so much that it now has more than enough room in the renderer's constrained size. In this case we fail to update the calculated size's width.
Also updated `lineCountForString` in `ASTextKitFontSizeAdjuster` to reuse a sizer layout manager and text container.
1) cache the scale in the font adjuster. The adjuster will be dealloc'ed when the renderer that owns it is dealloc'ed (or invalidated). Until that time we can trust the scale that the adjuster has computed.
2) When measuring line count, make sure that we are not bounding the height of the container's size. This will cause the wrong number of lines to be returned.
3) Instead of setting the ascender/descender on an ASTextNode when an attributed string is added, wait until after the renderer calculates size. This way, if there is any need to scale the font to fit we can apply that scale to the ascender/descender.
Was running into issues where the scale factor would get cleared when setting a new atributedString on a textNode.
I was clearing out the currentScaleFactor when setting an attributedString into a textNode. It appears that `_calculateSize` isn't always called when setting a new string into a ASTextNode. It can be the case that only `drawInContext:bounds:` is called. With _currentScaleFactor cleared out the renderer that calls`drawInContext...` was being called with a scaleFactor of 0.
It could be the case that the fix could be to remove the clearing of `currentScaleFactor` from `setAttributedString`, but this seems like a safer fix to me. It does, however, require an extra run through the font adjuster when enabled.