Bug 1221565 Part 1: Make nsFlexContainerFrame map align-self values of 'left' and 'right' to either 'start' or 'end'. r=dholbert draft
authorBrad Werth <bwerth@mozilla.com>
Thu, 06 Oct 2016 15:55:39 -0700
changeset 421839 796dea9e9b81183ad9b87c1e14a10c780aba30dc
parent 421656 da986c9f1f723af1e0c44f4ccd4cddd5fb6084e8
child 421841 a8aede234b38b42d1b9018f5b9db312d2892cd17
child 422214 594f467df3f34021a363510d945ea87d2a82ba24
push id31611
push userbwerth@mozilla.com
push dateThu, 06 Oct 2016 22:57:24 +0000
reviewersdholbert
bugs1221565
milestone52.0a1
Bug 1221565 Part 1: Make nsFlexContainerFrame map align-self values of 'left' and 'right' to either 'start' or 'end'. r=dholbert MozReview-Commit-ID: 8Xv4BzZ3Okv
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -3092,16 +3092,32 @@ SingleLineCrossAxisPositionTracker::
 
   uint8_t alignSelf = aItem.GetAlignSelf();
   // NOTE: 'stretch' behaves like 'flex-start' once we've stretched any
   // auto-sized items (which we've already done).
   if (alignSelf == NS_STYLE_ALIGN_STRETCH) {
     alignSelf = NS_STYLE_ALIGN_FLEX_START;
   }
 
+  // Map 'left'/'right' to 'start'/'end'
+  if (alignSelf == NS_STYLE_ALIGN_LEFT || alignSelf == 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'.
+      alignSelf = 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 = (alignSelf == NS_STYLE_ALIGN_LEFT);
+      alignSelf = (isAlignLeft == isLTR) ? NS_STYLE_ALIGN_START
+                                         : NS_STYLE_ALIGN_END;
+    }
+  }
+
   // Map 'start'/'end' to 'flex-start'/'flex-end'.
   if (alignSelf == NS_STYLE_ALIGN_START) {
     alignSelf = NS_STYLE_ALIGN_FLEX_START;
   } else if (alignSelf == NS_STYLE_ALIGN_END) {
     alignSelf = NS_STYLE_ALIGN_FLEX_END;
   }
 
   // If our cross axis is (internally) reversed, swap the align-self
@@ -3110,18 +3126,16 @@ SingleLineCrossAxisPositionTracker::
     if (alignSelf == NS_STYLE_ALIGN_FLEX_START) {
       alignSelf = NS_STYLE_ALIGN_FLEX_END;
     } else if (alignSelf == NS_STYLE_ALIGN_FLEX_END) {
       alignSelf = NS_STYLE_ALIGN_FLEX_START;
     }
   }
 
   switch (alignSelf) {
-    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_LAST_BASELINE:
       NS_WARNING("NYI: align-self:left/right/self-start/self-end/last-baseline");
       MOZ_FALLTHROUGH;
     case NS_STYLE_ALIGN_FLEX_START:
       // No space to skip over -- we're done.
       break;