Bug 1340309 - Part 1: Resolve "align-self:auto"/"justify-self:auto" to flex/grid parent's *-items value, when resolving static pos of abspos children. r=mats, a=jcristau
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 24 Feb 2017 08:38:31 -0800
changeset 378767 e4f35a45184ce760f88c9d6572fb9b9542c4bcfb
parent 378766 984adcec5b2e720c5f1257f136eaa5dfb3a21fd8
child 378768 deb6668fecd71e2f8e5d84e9b591586b6f1858f5
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, jcristau
bugs1340309
milestone53.0a2
Bug 1340309 - Part 1: Resolve "align-self:auto"/"justify-self:auto" to flex/grid parent's *-items value, when resolving static pos of abspos children. r=mats, a=jcristau MozReview-Commit-ID: 6fSmo1WGqow
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1284,17 +1284,17 @@ nsFlexContainerFrame::CSSAlignmentForAbs
     if (NS_STYLE_FLEX_WRAP_NOWRAP != containerStylePos->mFlexWrap &&
         alignContent != NS_STYLE_ALIGN_STRETCH) {
       // Multi-line, align-content isn't stretch --> align-content determines
       // this child's alignment in the cross axis.
       alignment = alignContent;
     } else {
       // Single-line, or multi-line but the (one) line stretches to fill
       // container. Respect align-self.
-      alignment = aChildRI.mStylePosition->UsedAlignSelf(nullptr);
+      alignment = aChildRI.mStylePosition->UsedAlignSelf(StyleContext());
       // XXX strip off <overflow-position> bits until we implement it
       // (bug 1311892)
       alignment &= ~NS_STYLE_ALIGN_FLAG_BITS;
 
       if (alignment == NS_STYLE_ALIGN_NORMAL) {
         // "the 'normal' keyword behaves as 'start' on replaced
         // absolutely-positioned boxes, and behaves as 'stretch' on all other
         // absolutely-positioned boxes."
@@ -1305,18 +1305,16 @@ nsFlexContainerFrame::CSSAlignmentForAbs
     }
   }
 
   // Resolve flex-start, flex-end, auto, left, right, baseline, last baseline;
   if (alignment == NS_STYLE_ALIGN_FLEX_START) {
     alignment = isAxisReversed ? NS_STYLE_ALIGN_END : NS_STYLE_ALIGN_START;
   } else if (alignment == NS_STYLE_ALIGN_FLEX_END) {
     alignment = isAxisReversed ? NS_STYLE_ALIGN_START : NS_STYLE_ALIGN_END;
-  } else if (alignment == NS_STYLE_ALIGN_AUTO) {
-    alignment = NS_STYLE_ALIGN_START;
   } else if (alignment == NS_STYLE_ALIGN_LEFT ||
              alignment == NS_STYLE_ALIGN_RIGHT) {
     if (aLogicalAxis == eLogicalAxisInline) {
       const bool isLeft = (alignment == NS_STYLE_ALIGN_LEFT);
       alignment = (isLeft == wm.IsBidiLTR()) ? NS_STYLE_ALIGN_START
                                              : NS_STYLE_ALIGN_END;
     } else {
       alignment = NS_STYLE_ALIGN_START;
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -6652,30 +6652,24 @@ nsGridContainerFrame::RemoveFrame(ChildL
 uint16_t
 nsGridContainerFrame::CSSAlignmentForAbsPosChild(const ReflowInput& aChildRI,
                                                  LogicalAxis aLogicalAxis) const
 {
   MOZ_ASSERT(aChildRI.mFrame->IsAbsolutelyPositioned(),
              "This method should only be called for abspos children");
 
   uint16_t alignment = (aLogicalAxis == eLogicalAxisInline) ?
-    aChildRI.mStylePosition->UsedJustifySelf(nullptr) :
-    aChildRI.mStylePosition->UsedAlignSelf(nullptr);
+    aChildRI.mStylePosition->UsedJustifySelf(StyleContext()) :
+    aChildRI.mStylePosition->UsedAlignSelf(StyleContext());
 
   // XXX strip off <overflow-position> bits until we implement it
   // (bug 1311892)
   alignment &= ~NS_STYLE_ALIGN_FLAG_BITS;
 
-  // We group 'auto' with 'normal', because the spec says:
-  //    "The 'auto' keyword is interpreted as 'normal'
-  //     if the box is absolutely positioned [...]"
-  // https://drafts.csswg.org/css-align-3/#valdef-align-self-auto
-  // https://drafts.csswg.org/css-align-3/#valdef-justify-self-auto
-  if (alignment == NS_STYLE_ALIGN_AUTO ||
-      alignment == NS_STYLE_ALIGN_NORMAL) {
+  if (alignment == NS_STYLE_ALIGN_NORMAL) {
     // "the 'normal' keyword behaves as 'start' on replaced
     // absolutely-positioned boxes, and behaves as 'stretch' on all other
     // absolutely-positioned boxes."
     // https://drafts.csswg.org/css-align/#align-abspos
     // https://drafts.csswg.org/css-align/#justify-abspos
     alignment = aChildRI.mFrame->IsFrameOfType(nsIFrame::eReplaced) ?
       NS_STYLE_ALIGN_START : NS_STYLE_ALIGN_STRETCH;
   } else if (alignment == NS_STYLE_ALIGN_FLEX_START) {