Pass layout marker data along
Summary: pubic Passes layout marker data through the recursive calls of the layout algorithm, in order to allow for collecting metrics. Reviewed By: SidharthGuglani Differential Revision: D13819444 fbshipit-source-id: cdca04964fba6a03ca3eeaca4d169107019ba457
This commit is contained in:
committed by
Facebook Github Bot
parent
74dd627495
commit
b4b009c2d8
@@ -1021,7 +1021,8 @@ bool YGLayoutNodeInternal(
|
|||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const char* reason,
|
const char* reason,
|
||||||
const YGConfigRef config);
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData);
|
||||||
|
|
||||||
static void YGNodePrintInternal(
|
static void YGNodePrintInternal(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
@@ -1260,7 +1261,8 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const YGMeasureMode heightMode,
|
const YGMeasureMode heightMode,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
||||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
||||||
@@ -1433,7 +1435,8 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
ownerHeight,
|
ownerHeight,
|
||||||
false,
|
false,
|
||||||
"measure",
|
"measure",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
|
|
||||||
child->setLayoutComputedFlexBasis(YGFloatOptional(YGFloatMax(
|
child->setLayoutComputedFlexBasis(YGFloatOptional(YGFloatMax(
|
||||||
child->getLayout().measuredDimensions[dim[mainAxis]],
|
child->getLayout().measuredDimensions[dim[mainAxis]],
|
||||||
@@ -1449,7 +1452,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
const YGMeasureMode widthMode,
|
const YGMeasureMode widthMode,
|
||||||
const float height,
|
const float height,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
||||||
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
||||||
@@ -1553,7 +1557,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
childHeight,
|
childHeight,
|
||||||
false,
|
false,
|
||||||
"abs-measure",
|
"abs-measure",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
||||||
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
||||||
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
@@ -1571,7 +1576,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
childHeight,
|
childHeight,
|
||||||
true,
|
true,
|
||||||
"abs-layout",
|
"abs-layout",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
|
|
||||||
if (child->isTrailingPosDefined(mainAxis) &&
|
if (child->isTrailingPosDefined(mainAxis) &&
|
||||||
!child->isLeadingPositionDefined(mainAxis)) {
|
!child->isLeadingPositionDefined(mainAxis)) {
|
||||||
@@ -1867,7 +1873,8 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
YGDirection direction,
|
YGDirection direction,
|
||||||
YGFlexDirection mainAxis,
|
YGFlexDirection mainAxis,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
bool performLayout) {
|
bool performLayout,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
float totalOuterFlexBasis = 0.0f;
|
float totalOuterFlexBasis = 0.0f;
|
||||||
YGNodeRef singleFlexChild = nullptr;
|
YGNodeRef singleFlexChild = nullptr;
|
||||||
YGVector children = node->getChildren();
|
YGVector children = node->getChildren();
|
||||||
@@ -1931,7 +1938,8 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
heightMeasureMode,
|
heightMeasureMode,
|
||||||
direction,
|
direction,
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
totalOuterFlexBasis +=
|
totalOuterFlexBasis +=
|
||||||
@@ -2043,7 +2051,8 @@ static float YGDistributeFreeSpaceSecondPass(
|
|||||||
const bool flexBasisOverflows,
|
const bool flexBasisOverflows,
|
||||||
const YGMeasureMode measureModeCrossDim,
|
const YGMeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
float childFlexBasis = 0;
|
float childFlexBasis = 0;
|
||||||
float flexShrinkScaledFactor = 0;
|
float flexShrinkScaledFactor = 0;
|
||||||
float flexGrowFactor = 0;
|
float flexGrowFactor = 0;
|
||||||
@@ -2207,7 +2216,8 @@ static float YGDistributeFreeSpaceSecondPass(
|
|||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
performLayout && !requiresStretchLayout,
|
performLayout && !requiresStretchLayout,
|
||||||
"flex",
|
"flex",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
node->setLayoutHadOverflow(
|
node->setLayoutHadOverflow(
|
||||||
node->getLayout().hadOverflow |
|
node->getLayout().hadOverflow |
|
||||||
currentRelativeChild->getLayout().hadOverflow);
|
currentRelativeChild->getLayout().hadOverflow);
|
||||||
@@ -2336,7 +2346,8 @@ static void YGResolveFlexibleLength(
|
|||||||
const bool flexBasisOverflows,
|
const bool flexBasisOverflows,
|
||||||
const YGMeasureMode measureModeCrossDim,
|
const YGMeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace;
|
const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace;
|
||||||
// First pass: detect the flex items whose min/max constraints trigger
|
// First pass: detect the flex items whose min/max constraints trigger
|
||||||
YGDistributeFreeSpaceFirstPass(
|
YGDistributeFreeSpaceFirstPass(
|
||||||
@@ -2360,7 +2371,8 @@ static void YGResolveFlexibleLength(
|
|||||||
flexBasisOverflows,
|
flexBasisOverflows,
|
||||||
measureModeCrossDim,
|
measureModeCrossDim,
|
||||||
performLayout,
|
performLayout,
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
|
|
||||||
collectedFlexItemsValues.remainingFreeSpace =
|
collectedFlexItemsValues.remainingFreeSpace =
|
||||||
originalFreeSpace - distributedFreeSpace;
|
originalFreeSpace - distributedFreeSpace;
|
||||||
@@ -2656,7 +2668,8 @@ static void YGNodelayoutImpl(
|
|||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
YGAssertWithNode(
|
YGAssertWithNode(
|
||||||
node,
|
node,
|
||||||
YGFloatIsUndefined(availableWidth)
|
YGFloatIsUndefined(availableWidth)
|
||||||
@@ -2837,7 +2850,8 @@ static void YGNodelayoutImpl(
|
|||||||
direction,
|
direction,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
config,
|
config,
|
||||||
performLayout);
|
performLayout,
|
||||||
|
layoutMarkerData);
|
||||||
|
|
||||||
const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
|
const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
|
||||||
? false
|
? false
|
||||||
@@ -2943,7 +2957,8 @@ static void YGNodelayoutImpl(
|
|||||||
flexBasisOverflows,
|
flexBasisOverflows,
|
||||||
measureModeCrossDim,
|
measureModeCrossDim,
|
||||||
performLayout,
|
performLayout,
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
node->setLayoutHadOverflow(
|
node->setLayoutHadOverflow(
|
||||||
@@ -3108,7 +3123,8 @@ static void YGNodelayoutImpl(
|
|||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
true,
|
true,
|
||||||
"stretch",
|
"stretch",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const float remainingCrossDim = containerCrossAxis -
|
const float remainingCrossDim = containerCrossAxis -
|
||||||
@@ -3314,7 +3330,8 @@ static void YGNodelayoutImpl(
|
|||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
true,
|
true,
|
||||||
"multiline-stretch",
|
"multiline-stretch",
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3451,7 +3468,8 @@ static void YGNodelayoutImpl(
|
|||||||
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
direction,
|
direction,
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||||
@@ -3683,7 +3701,8 @@ bool YGLayoutNodeInternal(
|
|||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const char* reason,
|
const char* reason,
|
||||||
const YGConfigRef config) {
|
const YGConfigRef config,
|
||||||
|
YGMarkerLayoutData& layoutMarkerData) {
|
||||||
YGLayout* layout = &node->getLayout();
|
YGLayout* layout = &node->getLayout();
|
||||||
|
|
||||||
gDepth++;
|
gDepth++;
|
||||||
@@ -3837,7 +3856,8 @@ bool YGLayoutNodeInternal(
|
|||||||
ownerWidth,
|
ownerWidth,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
performLayout,
|
performLayout,
|
||||||
config);
|
config,
|
||||||
|
layoutMarkerData);
|
||||||
|
|
||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
YGLog(
|
YGLog(
|
||||||
@@ -4067,7 +4087,8 @@ void YGNodeCalculateLayout(
|
|||||||
ownerHeight,
|
ownerHeight,
|
||||||
true,
|
true,
|
||||||
"initial",
|
"initial",
|
||||||
node->getConfig())) {
|
node->getConfig(),
|
||||||
|
marker.data)) {
|
||||||
node->setPosition(
|
node->setPosition(
|
||||||
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
||||||
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
||||||
@@ -4097,6 +4118,7 @@ void YGNodeCalculateLayout(
|
|||||||
gCurrentGenerationCount++;
|
gCurrentGenerationCount++;
|
||||||
// Rerun the layout, and calculate the diff
|
// Rerun the layout, and calculate the diff
|
||||||
originalNode->setAndPropogateUseLegacyFlag(false);
|
originalNode->setAndPropogateUseLegacyFlag(false);
|
||||||
|
YGMarkerLayoutData layoutMarkerData;
|
||||||
if (YGLayoutNodeInternal(
|
if (YGLayoutNodeInternal(
|
||||||
originalNode,
|
originalNode,
|
||||||
width,
|
width,
|
||||||
@@ -4108,7 +4130,8 @@ void YGNodeCalculateLayout(
|
|||||||
ownerHeight,
|
ownerHeight,
|
||||||
true,
|
true,
|
||||||
"initial",
|
"initial",
|
||||||
originalNode->getConfig())) {
|
originalNode->getConfig(),
|
||||||
|
layoutMarkerData)) {
|
||||||
originalNode->setPosition(
|
originalNode->setPosition(
|
||||||
originalNode->getLayout().direction,
|
originalNode->getLayout().direction,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
|
Reference in New Issue
Block a user