Overflow detection in Yoga

Reviewed By: gkassabli

Differential Revision: D5336645

fbshipit-source-id: c4f87d1754d7bac848e8d347b31d619393b94d2c
This commit is contained in:
Andrey Mishanin 2017-06-30 09:19:33 -07:00 committed by Facebook Github Bot
parent 12ab236629
commit ecd5829bf8
2 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,7 @@ typedef struct YGLayout {
uint32_t computedFlexBasisGeneration;
float computedFlexBasis;
bool hadOverflow;
// Instead of recomputing the entire layout every single time, we
// cache some information to break early when nothing changed
@ -192,6 +193,7 @@ static YGNode gYGNodeDefaults = {
.lastParentDirection = (YGDirection) -1,
.nextCachedMeasurementsIndex = 0,
.computedFlexBasis = YGUndefined,
.hadOverflow = false,
.measuredDimensions = YG_DEFAULT_DIMENSION_VALUES,
.cachedLayout =
@ -782,6 +784,7 @@ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow);
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
@ -2574,12 +2577,14 @@ static void YGNodelayoutImpl(const YGNodeRef node,
performLayout && !requiresStretchLayout,
"flex",
config);
node->layout.hadOverflow = node->layout.hadOverflow || currentRelativeChild->layout.hadOverflow;
currentRelativeChild = currentRelativeChild->nextChild;
}
}
remainingFreeSpace = originalRemainingFreeSpace + deltaFreeSpace;
node->layout.hadOverflow = node->layout.hadOverflow || (remainingFreeSpace < 0);
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION

View File

@ -215,6 +215,7 @@ YG_NODE_LAYOUT_PROPERTY(float, Bottom);
YG_NODE_LAYOUT_PROPERTY(float, Width);
YG_NODE_LAYOUT_PROPERTY(float, Height);
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow);
// Get the computed values for these nodes after performing layout. If they were set using
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if