Fix test util to measure text properly based on flex direction

Summary: Depending on the flex direction text will either be capped to the measured size or to the longest word, so I added that functionality

Differential Revision: D67106199
This commit is contained in:
Joe Vilches
2024-12-11 13:37:42 -08:00
committed by Facebook GitHub Bot
parent 13f4adbbcd
commit 7ef49a9abe
11 changed files with 216 additions and 37 deletions

View File

@@ -90,14 +90,20 @@ YGSize IntrinsicSizeMeasure(
measuredHeight = std::min(
calculateHeight(
innerText,
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
? measuredWidth
: std::max(
longestWordWidth(innerText, widthPerChar), measuredWidth),
widthPerChar,
heightPerChar),
height);
} else {
measuredHeight = calculateHeight(
innerText,
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
? measuredWidth
: std::max(
longestWordWidth(innerText, widthPerChar), measuredWidth),
widthPerChar,
heightPerChar);
}