Fixed issue with measuring text with NaN width

Summary:
Looks like `-[NSLayoutManager ensureLayoutForTextContainer:textContainer]` has a bug that cause infinite loop inside this method
during measuring some special characters AND when specified `width` equals NaN (which is useless anyways).

So, we cover this case in this diff.

Reviewed By: javache

Differential Revision: D5859767

fbshipit-source-id: 58a5910f21f282bf5b82494916b5b02ad72d357f
This commit is contained in:
Valentin Shergin 2017-09-19 14:15:11 -07:00 committed by Facebook Github Bot
parent a43a988128
commit 6b11259c46
1 changed files with 4 additions and 1 deletions

View File

@ -220,7 +220,10 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
}
textContainer.maximumNumberOfLines = _numberOfLines;
textContainer.size = (CGSize){widthMode == YGMeasureModeUndefined ? CGFLOAT_MAX : width, CGFLOAT_MAX};
textContainer.size = (CGSize){
widthMode == YGMeasureModeUndefined || isnan(width) ? CGFLOAT_MAX : width,
CGFLOAT_MAX
};
[layoutManager addTextContainer:textContainer];
[layoutManager ensureLayoutForTextContainer:textContainer];