Fix parent height calculation in case of baseline alignment
Summary: Prior to this diff, if parents height was not set then the height of parent was deduced as max of childrens height(considering line ht, padding, margin etc. ), but it didn't consider the baseline scenario where the previous logic will fail as then the parents height will be determined by the space taken by children above and below the reference baseline. I added a test case for the same. Look at the diff D9088051 which shows the screenshot of the bug. It is solved to https://pxl.cl/gvVk Reviewed By: dsyang Differential Revision: D9219678 fbshipit-source-id: f4a0b9f1452c33e78bd8c6cf39f6fcf538a04074
This commit is contained in:
parent
f0631b11f5
commit
3770165f72
|
@ -3152,47 +3152,46 @@ static void YGNodelayoutImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
// STEP 8: MULTI-LINE CONTENT ALIGNMENT
|
// STEP 8: MULTI-LINE CONTENT ALIGNMENT
|
||||||
if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node)) &&
|
// currentLead stores the size of the cross dim
|
||||||
!YGFloatIsUndefined(availableInnerCrossDim)) {
|
float currentLead = leadingPaddingAndBorderCross;
|
||||||
const float remainingAlignContentDim =
|
if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node))) {
|
||||||
availableInnerCrossDim - totalLineCrossDim;
|
|
||||||
|
|
||||||
float crossDimLead = 0;
|
float crossDimLead = 0;
|
||||||
float currentLead = leadingPaddingAndBorderCross;
|
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
|
||||||
|
const float remainingAlignContentDim =
|
||||||
switch (node->getStyle().alignContent) {
|
availableInnerCrossDim - totalLineCrossDim;
|
||||||
case YGAlignFlexEnd:
|
switch (node->getStyle().alignContent) {
|
||||||
currentLead += remainingAlignContentDim;
|
case YGAlignFlexEnd:
|
||||||
break;
|
currentLead += remainingAlignContentDim;
|
||||||
case YGAlignCenter:
|
break;
|
||||||
currentLead += remainingAlignContentDim / 2;
|
case YGAlignCenter:
|
||||||
break;
|
currentLead += remainingAlignContentDim / 2;
|
||||||
case YGAlignStretch:
|
break;
|
||||||
if (availableInnerCrossDim > totalLineCrossDim) {
|
case YGAlignStretch:
|
||||||
crossDimLead = remainingAlignContentDim / lineCount;
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
||||||
}
|
|
||||||
break;
|
|
||||||
case YGAlignSpaceAround:
|
|
||||||
if (availableInnerCrossDim > totalLineCrossDim) {
|
|
||||||
currentLead += remainingAlignContentDim / (2 * lineCount);
|
|
||||||
if (lineCount > 1) {
|
|
||||||
crossDimLead = remainingAlignContentDim / lineCount;
|
crossDimLead = remainingAlignContentDim / lineCount;
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
currentLead += remainingAlignContentDim / 2;
|
case YGAlignSpaceAround:
|
||||||
}
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
||||||
break;
|
currentLead += remainingAlignContentDim / (2 * lineCount);
|
||||||
case YGAlignSpaceBetween:
|
if (lineCount > 1) {
|
||||||
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
|
crossDimLead = remainingAlignContentDim / lineCount;
|
||||||
crossDimLead = remainingAlignContentDim / (lineCount - 1);
|
}
|
||||||
}
|
} else {
|
||||||
break;
|
currentLead += remainingAlignContentDim / 2;
|
||||||
case YGAlignAuto:
|
}
|
||||||
case YGAlignFlexStart:
|
break;
|
||||||
case YGAlignBaseline:
|
case YGAlignSpaceBetween:
|
||||||
break;
|
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
|
||||||
|
crossDimLead = remainingAlignContentDim / (lineCount - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YGAlignAuto:
|
||||||
|
case YGAlignFlexStart:
|
||||||
|
case YGAlignBaseline:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t endIndex = 0;
|
uint32_t endIndex = 0;
|
||||||
for (uint32_t i = 0; i < lineCount; i++) {
|
for (uint32_t i = 0; i < lineCount; i++) {
|
||||||
const uint32_t startIndex = endIndex;
|
const uint32_t startIndex = endIndex;
|
||||||
|
@ -3394,7 +3393,6 @@ static void YGNodelayoutImpl(
|
||||||
measureModeCrossDim == YGMeasureModeAtMost)) {
|
measureModeCrossDim == YGMeasureModeAtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
|
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
YGNodeBoundAxis(
|
YGNodeBoundAxis(
|
||||||
node,
|
node,
|
||||||
|
@ -3420,6 +3418,18 @@ static void YGNodelayoutImpl(
|
||||||
dim[crossAxis]);
|
dim[crossAxis]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (performLayout &&
|
||||||
|
node->getStyle().dimensions[dim[crossAxis]].unit == YGUnitAuto &&
|
||||||
|
node->getStyle().alignItems == YGAlignBaseline) {
|
||||||
|
node->setLayoutMeasuredDimension(
|
||||||
|
YGNodeBoundAxis(
|
||||||
|
node,
|
||||||
|
crossAxis,
|
||||||
|
currentLead + paddingAndBorderAxisRow,
|
||||||
|
crossAxisownerSize,
|
||||||
|
ownerWidth),
|
||||||
|
dim[crossAxis]);
|
||||||
|
}
|
||||||
// As we only wrapped in normal direction yet, we need to reverse the
|
// As we only wrapped in normal direction yet, we need to reverse the
|
||||||
// positions on wrap-reverse.
|
// positions on wrap-reverse.
|
||||||
if (performLayout && node->getStyle().flexWrap == YGWrapWrapReverse) {
|
if (performLayout && node->getStyle().flexWrap == YGWrapWrapReverse) {
|
||||||
|
|
Loading…
Reference in New Issue