|
|
|
@@ -935,7 +935,7 @@ bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node) {
|
|
|
|
|
return node->getLayout().doesLegacyStretchFlagAffectsLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t gCurrentGenerationCount = 0;
|
|
|
|
|
uint8_t gCurrentGenerationCount = 0;
|
|
|
|
|
|
|
|
|
|
bool YGLayoutNodeInternal(
|
|
|
|
|
const YGNodeRef node,
|
|
|
|
@@ -950,7 +950,9 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
const char* reason,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext);
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
static void YGNodePrintInternal(
|
|
|
|
@@ -1194,7 +1196,9 @@ static void YGNodeComputeFlexBasisForChild(
|
|
|
|
|
const YGDirection direction,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
const YGFlexDirection mainAxis =
|
|
|
|
|
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
|
|
|
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
|
|
|
@@ -1217,8 +1221,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|
|
|
|
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
|
|
|
|
(YGConfigIsExperimentalFeatureEnabled(
|
|
|
|
|
child->getConfig(), YGExperimentalFeatureWebFlexBasis) &&
|
|
|
|
|
child->getLayout().computedFlexBasisGeneration !=
|
|
|
|
|
gCurrentGenerationCount)) {
|
|
|
|
|
child->getLayout().computedFlexBasisGeneration != generationCount)) {
|
|
|
|
|
const YGFloatOptional paddingAndBorder = YGFloatOptional(
|
|
|
|
|
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth));
|
|
|
|
|
child->setLayoutComputedFlexBasis(
|
|
|
|
@@ -1369,13 +1372,16 @@ static void YGNodeComputeFlexBasisForChild(
|
|
|
|
|
"measure",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
child->setLayoutComputedFlexBasis(YGFloatOptional(YGFloatMax(
|
|
|
|
|
child->getLayout().measuredDimensions[dim[mainAxis]],
|
|
|
|
|
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth))));
|
|
|
|
|
}
|
|
|
|
|
child->setLayoutComputedFlexBasisGeneration(gCurrentGenerationCount);
|
|
|
|
|
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void YGNodeAbsoluteLayoutChild(
|
|
|
|
@@ -1387,7 +1393,9 @@ static void YGNodeAbsoluteLayoutChild(
|
|
|
|
|
const YGDirection direction,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
const YGFlexDirection mainAxis =
|
|
|
|
|
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
|
|
|
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
|
|
|
@@ -1493,7 +1501,9 @@ static void YGNodeAbsoluteLayoutChild(
|
|
|
|
|
"abs-measure",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
|
|
|
|
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
|
|
|
|
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
|
|
|
@@ -1513,7 +1523,9 @@ static void YGNodeAbsoluteLayoutChild(
|
|
|
|
|
"abs-layout",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
|
|
|
|
|
if (child->isTrailingPosDefined(mainAxis) &&
|
|
|
|
|
!child->isLeadingPositionDefined(mainAxis)) {
|
|
|
|
@@ -1817,7 +1829,9 @@ static float YGNodeComputeFlexBasisForChildren(
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
bool performLayout,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
float totalOuterFlexBasis = 0.0f;
|
|
|
|
|
YGNodeRef singleFlexChild = nullptr;
|
|
|
|
|
YGVector children = node->getChildren();
|
|
|
|
@@ -1868,7 +1882,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (child == singleFlexChild) {
|
|
|
|
|
child->setLayoutComputedFlexBasisGeneration(gCurrentGenerationCount);
|
|
|
|
|
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
|
|
|
|
child->setLayoutComputedFlexBasis(YGFloatOptional(0));
|
|
|
|
|
} else {
|
|
|
|
|
YGNodeComputeFlexBasisForChild(
|
|
|
|
@@ -1883,7 +1897,9 @@ static float YGNodeComputeFlexBasisForChildren(
|
|
|
|
|
direction,
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
totalOuterFlexBasis +=
|
|
|
|
@@ -1997,7 +2013,9 @@ static float YGDistributeFreeSpaceSecondPass(
|
|
|
|
|
const bool performLayout,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
float childFlexBasis = 0;
|
|
|
|
|
float flexShrinkScaledFactor = 0;
|
|
|
|
|
float flexGrowFactor = 0;
|
|
|
|
@@ -2163,7 +2181,9 @@ static float YGDistributeFreeSpaceSecondPass(
|
|
|
|
|
"flex",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
node->setLayoutHadOverflow(
|
|
|
|
|
node->getLayout().hadOverflow |
|
|
|
|
|
currentRelativeChild->getLayout().hadOverflow);
|
|
|
|
@@ -2294,7 +2314,9 @@ static void YGResolveFlexibleLength(
|
|
|
|
|
const bool performLayout,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace;
|
|
|
|
|
// First pass: detect the flex items whose min/max constraints trigger
|
|
|
|
|
YGDistributeFreeSpaceFirstPass(
|
|
|
|
@@ -2320,7 +2342,9 @@ static void YGResolveFlexibleLength(
|
|
|
|
|
performLayout,
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
|
|
|
|
|
collectedFlexItemsValues.remainingFreeSpace =
|
|
|
|
|
originalFreeSpace - distributedFreeSpace;
|
|
|
|
@@ -2620,7 +2644,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
const bool performLayout,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
const uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
YGAssertWithNode(
|
|
|
|
|
node,
|
|
|
|
|
YGFloatIsUndefined(availableWidth)
|
|
|
|
@@ -2800,7 +2826,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
config,
|
|
|
|
|
performLayout,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
|
|
|
|
|
const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
|
|
|
|
|
? false
|
|
|
|
@@ -2905,7 +2933,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
performLayout,
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node->setLayoutHadOverflow(
|
|
|
|
@@ -3079,7 +3109,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
"stretch",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const float remainingCrossDim = containerCrossAxis -
|
|
|
|
@@ -3287,7 +3319,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
"multiline-stretch",
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@@ -3427,7 +3461,9 @@ static void YGNodelayoutImpl(
|
|
|
|
|
direction,
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
|
|
|
@@ -3455,7 +3491,6 @@ static void YGNodelayoutImpl(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t gDepth = 0;
|
|
|
|
|
bool gPrintChanges = false;
|
|
|
|
|
bool gPrintSkips = false;
|
|
|
|
|
|
|
|
|
@@ -3661,16 +3696,18 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
const char* reason,
|
|
|
|
|
const YGConfigRef config,
|
|
|
|
|
YGMarkerLayoutData& layoutMarkerData,
|
|
|
|
|
void* const layoutContext) {
|
|
|
|
|
void* const layoutContext,
|
|
|
|
|
uint32_t depth,
|
|
|
|
|
const uint8_t generationCount) {
|
|
|
|
|
#ifdef YG_ENABLE_EVENTS
|
|
|
|
|
Event::publish<Event::NodeLayout>(node);
|
|
|
|
|
#endif
|
|
|
|
|
YGLayout* layout = &node->getLayout();
|
|
|
|
|
|
|
|
|
|
gDepth++;
|
|
|
|
|
depth++;
|
|
|
|
|
|
|
|
|
|
const bool needToVisitNode =
|
|
|
|
|
(node->isDirty() && layout->generationCount != gCurrentGenerationCount) ||
|
|
|
|
|
(node->isDirty() && layout->generationCount != generationCount) ||
|
|
|
|
|
layout->lastOwnerDirection != ownerDirection;
|
|
|
|
|
|
|
|
|
|
if (needToVisitNode) {
|
|
|
|
@@ -3760,8 +3797,7 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
|
|
|
|
|
if (!needToVisitNode && cachedResults != nullptr) {
|
|
|
|
|
layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth;
|
|
|
|
|
layout->measuredDimensions[YGDimensionHeight] =
|
|
|
|
|
cachedResults->computedHeight;
|
|
|
|
|
layout->measuredDimensions[YGDimensionHeight] = cachedResults->computedHeight;
|
|
|
|
|
|
|
|
|
|
(performLayout ? layoutMarkerData.cachedLayouts
|
|
|
|
|
: layoutMarkerData.cachedMeasures) += 1;
|
|
|
|
@@ -3772,8 +3808,8 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
YGLogLevelVerbose,
|
|
|
|
|
nullptr,
|
|
|
|
|
"%s%d.{[skipped] ",
|
|
|
|
|
YGSpacer(gDepth),
|
|
|
|
|
gDepth);
|
|
|
|
|
YGSpacer(depth),
|
|
|
|
|
depth);
|
|
|
|
|
node->print(layoutContext);
|
|
|
|
|
Log::log(
|
|
|
|
|
node,
|
|
|
|
@@ -3795,8 +3831,8 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
YGLogLevelVerbose,
|
|
|
|
|
nullptr,
|
|
|
|
|
"%s%d.{%s",
|
|
|
|
|
YGSpacer(gDepth),
|
|
|
|
|
gDepth,
|
|
|
|
|
YGSpacer(depth),
|
|
|
|
|
depth,
|
|
|
|
|
needToVisitNode ? "*" : "");
|
|
|
|
|
node->print(layoutContext);
|
|
|
|
|
Log::log(
|
|
|
|
@@ -3823,7 +3859,9 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
performLayout,
|
|
|
|
|
config,
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext);
|
|
|
|
|
layoutContext,
|
|
|
|
|
depth,
|
|
|
|
|
generationCount);
|
|
|
|
|
|
|
|
|
|
if (gPrintChanges) {
|
|
|
|
|
Log::log(
|
|
|
|
@@ -3831,8 +3869,8 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
YGLogLevelVerbose,
|
|
|
|
|
nullptr,
|
|
|
|
|
"%s%d.}%s",
|
|
|
|
|
YGSpacer(gDepth),
|
|
|
|
|
gDepth,
|
|
|
|
|
YGSpacer(depth),
|
|
|
|
|
depth,
|
|
|
|
|
needToVisitNode ? "*" : "");
|
|
|
|
|
node->print(layoutContext);
|
|
|
|
|
Log::log(
|
|
|
|
@@ -3896,8 +3934,7 @@ bool YGLayoutNodeInternal(
|
|
|
|
|
node->setDirty(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gDepth--;
|
|
|
|
|
layout->generationCount = gCurrentGenerationCount;
|
|
|
|
|
layout->generationCount = generationCount;
|
|
|
|
|
return (needToVisitNode || cachedResults == nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -4070,7 +4107,9 @@ void YGNodeCalculateLayoutWithContext(
|
|
|
|
|
"initial",
|
|
|
|
|
node->getConfig(),
|
|
|
|
|
marker->data,
|
|
|
|
|
layoutContext)) {
|
|
|
|
|
layoutContext,
|
|
|
|
|
0, // tree root
|
|
|
|
|
gCurrentGenerationCount)) {
|
|
|
|
|
node->setPosition(
|
|
|
|
|
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
|
|
|
|
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
|
|
|
@@ -4123,7 +4162,9 @@ void YGNodeCalculateLayoutWithContext(
|
|
|
|
|
"initial",
|
|
|
|
|
nodeWithoutLegacyFlag->getConfig(),
|
|
|
|
|
layoutMarkerData,
|
|
|
|
|
layoutContext)) {
|
|
|
|
|
layoutContext,
|
|
|
|
|
0, // tree root
|
|
|
|
|
gCurrentGenerationCount)) {
|
|
|
|
|
nodeWithoutLegacyFlag->setPosition(
|
|
|
|
|
nodeWithoutLegacyFlag->getLayout().direction,
|
|
|
|
|
ownerWidth,
|
|
|
|
|
What was the motivation for this change? Due to alignment requirements, this won’t even save memory without reordering data members.
The motivation is to save heap: there are many bits left over from alignment of the bitfields above it, so you could combine
computedFlexBasisGeneration
with it. I suspect you can get away with just one bit, so long as the generation counter is the same width (or is truncated with a logical AND mask when the generation is incremented).