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 draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 24 Feb 2017 08:38:31 -0800
changeset 489275 b21ef6a533cda52263f3f387210dbcb589af5623
parent 489034 395af43e7b9c68903f594698a9c3b6bc982ccb4b
child 489276 521313eac996947987876c5cbb89df61ef2f59cd
push id46784
push userdholbert@mozilla.com
push dateFri, 24 Feb 2017 16:39:08 +0000
reviewersmats
bugs1340309
milestone54.0a1
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 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) {