Bug 1221565 Part 2: Make nsFlexContainerFrame map justify-content and align-content values of 'left' and 'right' to 'start' or 'end'. r=dholbert
MozReview-Commit-ID: 8sZyFwIlpr4
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -2600,16 +2600,33 @@ MainAxisPositionTracker::
if (mPackingSpaceRemaining < 0) {
if (mJustifyContent == NS_STYLE_JUSTIFY_SPACE_BETWEEN) {
mJustifyContent = NS_STYLE_JUSTIFY_FLEX_START;
} else if (mJustifyContent == NS_STYLE_JUSTIFY_SPACE_AROUND) {
mJustifyContent = NS_STYLE_JUSTIFY_CENTER;
}
}
+ // Map 'left'/'right' to 'start'/'end'
+ if (mJustifyContent == NS_STYLE_ALIGN_LEFT ||
+ mJustifyContent == NS_STYLE_ALIGN_RIGHT) {
+ if (aAxisTracker.IsColumnOriented()) {
+ // Container's alignment axis is not parallel to the inline axis,
+ // so we map both 'left' and 'right' to 'start'.
+ mJustifyContent = NS_STYLE_ALIGN_START;
+ } else {
+ // Row-oriented, so we map 'left' and 'right' to 'start' or 'end',
+ // depending on left-to-right writing mode.
+ const bool isLTR = aAxisTracker.GetWritingMode().IsBidiLTR();
+ const bool isAlignLeft = (mJustifyContent == NS_STYLE_ALIGN_LEFT);
+ mJustifyContent = (isAlignLeft == isLTR) ? NS_STYLE_ALIGN_START
+ : NS_STYLE_ALIGN_END;
+ }
+ }
+
// Map 'start'/'end' to 'flex-start'/'flex-end'.
if (mJustifyContent == NS_STYLE_JUSTIFY_START) {
mJustifyContent = NS_STYLE_JUSTIFY_FLEX_START;
} else if (mJustifyContent == NS_STYLE_JUSTIFY_END) {
mJustifyContent = NS_STYLE_JUSTIFY_FLEX_END;
}
// If our main axis is (internally) reversed, swap the justify-content
@@ -2623,18 +2640,16 @@ MainAxisPositionTracker::
}
// Figure out how much space we'll set aside for auto margins or
// packing spaces, and advance past any leading packing-space.
if (mNumAutoMarginsInMainAxis == 0 &&
mPackingSpaceRemaining != 0 &&
!aLine->IsEmpty()) {
switch (mJustifyContent) {
- case NS_STYLE_JUSTIFY_LEFT:
- case NS_STYLE_JUSTIFY_RIGHT:
case NS_STYLE_JUSTIFY_BASELINE:
case NS_STYLE_JUSTIFY_LAST_BASELINE:
case NS_STYLE_JUSTIFY_SPACE_EVENLY:
NS_WARNING("NYI: justify-content:left/right/baseline/last-baseline/space-evenly");
MOZ_FALLTHROUGH;
case NS_STYLE_JUSTIFY_FLEX_START:
// All packing space should go at the end --> nothing to do here.
break;
@@ -2800,16 +2815,33 @@ CrossAxisPositionTracker::
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) {
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()) {
+ // Container's alignment axis is not parallel to the inline axis,
+ // so we map both 'left' and 'right' to 'start'.
+ mAlignContent = NS_STYLE_ALIGN_START;
+ } else {
+ // Column-oriented, so we map 'left' and 'right' to 'start' or 'end',
+ // depending on left-to-right writing mode.
+ const bool isLTR = aAxisTracker.GetWritingMode().IsBidiLTR();
+ const bool isAlignLeft = (mAlignContent == NS_STYLE_ALIGN_LEFT);
+ mAlignContent = (isAlignLeft == isLTR) ? NS_STYLE_ALIGN_START
+ : NS_STYLE_ALIGN_END;
+ }
+ }
+
// Map 'start'/'end' to 'flex-start'/'flex-end'.
if (mAlignContent == NS_STYLE_ALIGN_START) {
mAlignContent = NS_STYLE_ALIGN_FLEX_START;
} else if (mAlignContent == NS_STYLE_ALIGN_END) {
mAlignContent = NS_STYLE_ALIGN_FLEX_END;
}
// If our cross axis is (internally) reversed, swap the align-content
@@ -2821,18 +2853,16 @@ CrossAxisPositionTracker::
mAlignContent = NS_STYLE_ALIGN_FLEX_START;
}
}
// 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_JUSTIFY_LEFT:
- case NS_STYLE_JUSTIFY_RIGHT:
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-self:left/right/self-start/self-end/space-evenly/baseline/last-baseline");
MOZ_FALLTHROUGH;
case NS_STYLE_ALIGN_FLEX_START: