Bug 1235922 Part 4: Add support for "align-content: space-evenly" to flexbox layout. r?mats
MozReview-Commit-ID: 3ETuPrIURJ3
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -2801,24 +2801,25 @@ CrossAxisPositionTracker::
mPackingSpaceRemaining = aContentBoxCrossSize;
uint32_t numLines = 0;
for (FlexLine* line = aFirstLine; line; line = line->getNext()) {
mPackingSpaceRemaining -= line->GetLineCrossSize();
numLines++;
}
// If packing space is negative, 'space-between' and 'stretch' behave like
- // 'flex-start', and 'space-around' behaves like 'center'. In those cases,
- // it's simplest to just pretend we have a different 'align-content' value
- // and share code.
+ // 'flex-start', and 'space-around' and 'space-evenly' behave like 'center'.
+ // In those cases, it's simplest to just pretend we have a different
+ // 'align-content' value and share code.
if (mPackingSpaceRemaining < 0) {
if (mAlignContent == NS_STYLE_ALIGN_SPACE_BETWEEN ||
mAlignContent == NS_STYLE_ALIGN_STRETCH) {
mAlignContent = NS_STYLE_ALIGN_FLEX_START;
- } else if (mAlignContent == NS_STYLE_ALIGN_SPACE_AROUND) {
+ } else if (mAlignContent == NS_STYLE_ALIGN_SPACE_AROUND ||
+ mAlignContent == NS_STYLE_ALIGN_SPACE_EVENLY) {
mAlignContent = NS_STYLE_ALIGN_CENTER;
}
}
// Map 'left'/'right' to 'start'/'end'
if (mAlignContent == NS_STYLE_ALIGN_LEFT ||
mAlignContent == NS_STYLE_ALIGN_RIGHT) {
if (aAxisTracker.IsRowOriented()) {
@@ -2853,34 +2854,34 @@ CrossAxisPositionTracker::
}
// Figure out how much space we'll set aside for packing spaces, and advance
// past any leading packing-space.
if (mPackingSpaceRemaining != 0) {
switch (mAlignContent) {
case NS_STYLE_ALIGN_SELF_START:
case NS_STYLE_ALIGN_SELF_END:
- case NS_STYLE_ALIGN_SPACE_EVENLY:
case NS_STYLE_ALIGN_BASELINE:
case NS_STYLE_ALIGN_LAST_BASELINE:
- NS_WARNING("NYI: align-items/align-self:left/right/self-start/self-end/space-evenly/baseline/last-baseline");
+ NS_WARNING("NYI: align-items/align-self:left/right/self-start/self-end/baseline/last-baseline");
MOZ_FALLTHROUGH;
case NS_STYLE_ALIGN_FLEX_START:
// All packing space should go at the end --> nothing to do here.
break;
case NS_STYLE_ALIGN_FLEX_END:
// All packing space goes at the beginning
mPosition += mPackingSpaceRemaining;
break;
case NS_STYLE_ALIGN_CENTER:
// Half the packing space goes at the beginning
mPosition += mPackingSpaceRemaining / 2;
break;
case NS_STYLE_ALIGN_SPACE_BETWEEN:
case NS_STYLE_ALIGN_SPACE_AROUND:
+ case NS_STYLE_ALIGN_SPACE_EVENLY:
nsFlexContainerFrame::CalculatePackingSpace(numLines,
mAlignContent,
&mPosition,
&mNumPackingSpacesRemaining,
&mPackingSpaceRemaining);
break;
case NS_STYLE_ALIGN_STRETCH: {
// Split space equally between the lines:
@@ -2910,19 +2911,20 @@ CrossAxisPositionTracker::
}
}
void
CrossAxisPositionTracker::TraversePackingSpace()
{
if (mNumPackingSpacesRemaining) {
MOZ_ASSERT(mAlignContent == NS_STYLE_ALIGN_SPACE_BETWEEN ||
- mAlignContent == NS_STYLE_ALIGN_SPACE_AROUND,
+ mAlignContent == NS_STYLE_ALIGN_SPACE_AROUND ||
+ mAlignContent == NS_STYLE_ALIGN_SPACE_EVENLY,
"mNumPackingSpacesRemaining only applies for "
- "space-between/space-around");
+ "space-between/space-around/space-evenly");
MOZ_ASSERT(mPackingSpaceRemaining >= 0,
"ran out of packing space earlier than we expected");
// NOTE: This integer math will skew the distribution of remainder
// app-units towards the end, which is fine.
nscoord curPackingSpace =
mPackingSpaceRemaining / mNumPackingSpacesRemaining;