in yoga/Yoga.cpp [3673:3743]
YOGA_EXPORT bool YGNodeCanUseCachedMeasurement(
const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn,
const YGConfigRef config) {
if ((!YGFloatIsUndefined(lastComputedHeight) && lastComputedHeight < 0) ||
(!YGFloatIsUndefined(lastComputedWidth) && lastComputedWidth < 0)) {
return false;
}
bool useRoundedComparison =
config != nullptr && config->pointScaleFactor != 0;
const float effectiveWidth = useRoundedComparison
? YGRoundValueToPixelGrid(width, config->pointScaleFactor, false, false)
: width;
const float effectiveHeight = useRoundedComparison
? YGRoundValueToPixelGrid(height, config->pointScaleFactor, false, false)
: height;
const float effectiveLastWidth = useRoundedComparison
? YGRoundValueToPixelGrid(
lastWidth, config->pointScaleFactor, false, false)
: lastWidth;
const float effectiveLastHeight = useRoundedComparison
? YGRoundValueToPixelGrid(
lastHeight, config->pointScaleFactor, false, false)
: lastHeight;
const bool hasSameWidthSpec = lastWidthMode == widthMode &&
YGFloatsEqual(effectiveLastWidth, effectiveWidth);
const bool hasSameHeightSpec = lastHeightMode == heightMode &&
YGFloatsEqual(effectiveLastHeight, effectiveHeight);
const bool widthIsCompatible =
hasSameWidthSpec ||
YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(
widthMode, width - marginRow, lastComputedWidth) ||
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(
widthMode, width - marginRow, lastWidthMode, lastComputedWidth) ||
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
widthMode,
width - marginRow,
lastWidthMode,
lastWidth,
lastComputedWidth);
const bool heightIsCompatible =
hasSameHeightSpec ||
YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(
heightMode, height - marginColumn, lastComputedHeight) ||
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(
heightMode,
height - marginColumn,
lastHeightMode,
lastComputedHeight) ||
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
heightMode,
height - marginColumn,
lastHeightMode,
lastHeight,
lastComputedHeight);
return widthIsCompatible && heightIsCompatible;
}