Bug 1221524 Part 1: Map align-self:"baseline" to "flex-start" when FlexItem writing mode is orthogonal to container main axis. r?dholbert draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 31 Oct 2016 14:46:52 -0700
changeset 434858 90dd3a597a23c944c44a88272210a706e23c774e
parent 434838 060f80b690b8aaa5d927e03578673a3eff3b4c64
child 434859 a733340601ecb80592d38e049feabff400a5f318
push id34857
push userbwerth@mozilla.com
push dateMon, 07 Nov 2016 18:02:05 +0000
reviewersdholbert
bugs1221524
milestone52.0a1
Bug 1221524 Part 1: Map align-self:"baseline" to "flex-start" when FlexItem writing mode is orthogonal to container main axis. r?dholbert MozReview-Commit-ID: 2IlkVDWNirG
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1886,29 +1886,26 @@ FlexItem::FlexItem(ReflowInput& aFlexIte
       if (styleMargin.GetUnit(side) == eStyleUnit_Auto) {
         MOZ_ASSERT(GetMarginComponentForSide(side) == 0,
                    "Someone else tried to resolve our auto margin");
       }
     }
   }
 #endif // DEBUG
 
-  // If the flex item's inline axis is the same as the cross axis, then
-  // 'align-self:baseline' is identical to 'flex-start'. If that's the case, we
-  // just directly convert our align-self value here, so that we don't have to
-  // handle this with special cases elsewhere.
-  // Moreover: for the time being (until we support writing-modes),
-  // all inline axes are horizontal -- so we can just check if the cross axis
-  // is horizontal.
-  // FIXME: Once we support writing-mode (vertical text), this
-  // IsCrossAxisHorizontal check won't be sufficient anymore -- we'll actually
-  // need to compare our inline axis vs. the cross axis.
-  if (mAlignSelf == NS_STYLE_ALIGN_BASELINE &&
-      aAxisTracker.IsCrossAxisHorizontal()) {
-    mAlignSelf = NS_STYLE_ALIGN_FLEX_START;
+  // Map align-self 'baseline' value to 'start' when baseline alignment
+  // is not possible because the FlexItem's writing mode is orthogonal to
+  // the main axis of the container. If that's the case, we just directly
+  // convert our align-self value here, so that we don't have to handle this
+  // with special cases elsewhere.
+  if (aAxisTracker.IsRowOriented() ==
+      aAxisTracker.GetWritingMode().IsOrthogonalTo(mWM)) {
+    if (mAlignSelf == NS_STYLE_ALIGN_BASELINE) {
+      mAlignSelf = NS_STYLE_ALIGN_FLEX_START;
+    }
   }
 }
 
 // Simplified constructor for creating a special "strut" FlexItem, for a child
 // with visibility:collapse. The strut has 0 main-size, and it only exists to
 // impose a minimum cross size on whichever FlexLine it ends up in.
 FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize,
                    WritingMode aContainerWM)