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,14 +3152,13 @@ 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;
|
||||||
|
if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node))) {
|
||||||
|
float crossDimLead = 0;
|
||||||
|
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
|
||||||
const float remainingAlignContentDim =
|
const float remainingAlignContentDim =
|
||||||
availableInnerCrossDim - totalLineCrossDim;
|
availableInnerCrossDim - totalLineCrossDim;
|
||||||
|
|
||||||
float crossDimLead = 0;
|
|
||||||
float currentLead = leadingPaddingAndBorderCross;
|
|
||||||
|
|
||||||
switch (node->getStyle().alignContent) {
|
switch (node->getStyle().alignContent) {
|
||||||
case YGAlignFlexEnd:
|
case YGAlignFlexEnd:
|
||||||
currentLead += remainingAlignContentDim;
|
currentLead += remainingAlignContentDim;
|
||||||
|
@ -3192,7 +3191,7 @@ static void YGNodelayoutImpl(
|
||||||
case YGAlignBaseline:
|
case YGAlignBaseline:
|
||||||
break;
|
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