added test for align-self: baseline
This commit is contained in:
20
yoga/Yoga.c
20
yoga/Yoga.c
@@ -1008,6 +1008,21 @@ static inline bool YGNodeIsFlex(const YGNodeRef node) {
|
||||
(YGNodeStyleGetFlexGrow(node) != 0 || YGNodeStyleGetFlexShrink(node) != 0));
|
||||
}
|
||||
|
||||
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
||||
if (node->style.alignItems == YGAlignBaseline) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < YGNodeGetChildCount(node); i++) {
|
||||
const YGNodeRef child = YGNodeGetChild(node, i);
|
||||
if (child->style.positionType == YGPositionTypeRelative &&
|
||||
child->style.alignSelf == YGAlignBaseline) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline float YGNodeDimWithMargin(const YGNodeRef node,
|
||||
const YGFlexDirection axis,
|
||||
const float widthSize) {
|
||||
@@ -2462,7 +2477,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
}
|
||||
|
||||
// STEP 8: MULTI-LINE CONTENT ALIGNMENT
|
||||
if ((node->style.alignItems == YGAlignBaseline || lineCount > 1) && performLayout &&
|
||||
if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node)) &&
|
||||
!YGFloatIsUndefined(availableInnerCrossDim)) {
|
||||
const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim;
|
||||
|
||||
@@ -2556,8 +2571,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
}
|
||||
case YGAlignBaseline: {
|
||||
child->layout.position[pos[crossAxis]] =
|
||||
currentLead + maxAscentForCurrentLine -
|
||||
YGBaseline(child, crossAxis) +
|
||||
currentLead + maxAscentForCurrentLine - YGBaseline(child, crossAxis) +
|
||||
YGNodeLeadingPosition(child, crossAxis, availableInnerCrossDim);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user