Bug 1269017 part 5 - [css-grid] Tag grid placeholder children as needing CSS Box Alignment, & consolidate their placement code. r=mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 07 Nov 2016 12:45:40 -0800
changeset 435077 1af7172db9edb6ecb5e66ca68ed15109cb383873
parent 435076 61c3677ace82a9265a55434aa0ad013838cdb8ec
child 435078 0109049b54144fdecf4707eb1b9b25a213adb9f1
child 435538 113b511b04887cdba1c772ca35bcba18e5dfa731
push id34928
push userdholbert@mozilla.com
push dateTue, 08 Nov 2016 00:57:02 +0000
reviewersmats
bugs1269017
milestone52.0a1
Bug 1269017 part 5 - [css-grid] Tag grid placeholder children as needing CSS Box Alignment, & consolidate their placement code. r=mats MozReview-Commit-ID: 5105oez3IO3
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -5201,17 +5201,27 @@ nsGridContainerFrame::ReflowInFlowChild(
         aChild->Properties().Delete(aProp);
       }
     };
     SetProp(eLogicalAxisBlock, isOrthogonal ? IBaselinePadProperty() :
                                               BBaselinePadProperty());
     SetProp(eLogicalAxisInline, isOrthogonal ? BBaselinePadProperty() :
                                                IBaselinePadProperty());
   } else {
-    cb = aContentArea;
+    // By convention, for frames that perform CSS Box Alignment, we position
+    // placeholder children at the start corner of their alignment container,
+    // and in this case that's usually the grid's padding box.
+    // ("Usually" - the exception is when the grid *also* forms the
+    // abs.pos. containing block. In that case, the alignment container isn't
+    // the padding box -- it's some grid area instead.  But that case doesn't
+    // require any special handling here, because we handle it later using a
+    // special flag (STATIC_POS_IS_CB_ORIGIN) which will make us ignore the
+    // placeholder's position entirely.)
+    cb = aContentArea - padStart;
+    aChild->AddStateBits(PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN);
   }
 
   LogicalSize reflowSize(cb.Size(wm));
   if (isConstrainedBSize) {
     reflowSize.BSize(wm) = toFragmentainerEnd;
   }
   LogicalSize childCBSize = reflowSize.ConvertTo(childWM, wm);
 
@@ -5287,20 +5297,18 @@ nsGridContainerFrame::ReflowInFlowChild(
     auto justify = childRI.mStylePosition->UsedJustifySelf(containerSC);
     auto state = aGridItemInfo->mState[eLogicalAxisInline];
     if (state & ItemState::eContentBaseline) {
       justify = (state & ItemState::eFirstBaseline) ? NS_STYLE_JUSTIFY_SELF_START
                                                     : NS_STYLE_JUSTIFY_SELF_END;
     }
     nscoord cbsz = cb.ISize(wm);
     JustifySelf(*aGridItemInfo, justify, cbsz, wm, childRI, size, &childPos);
-  } else {
-    // Put a placeholder at the padding edge, in case an ancestor is its CB.
-    childPos -= padStart;
-  }
+  } // else, nsAbsoluteContainingBlock.cpp will handle align/justify-self.
+
   childRI.ApplyRelativePositioning(&childPos, aContainerSize);
   FinishReflowChild(aChild, pc, childSize, &childRI, childWM, childPos,
                     aContainerSize, 0);
   ConsiderChildOverflow(aDesiredSize.mOverflowAreas, aChild);
 }
 
 nscoord
 nsGridContainerFrame::ReflowInFragmentainer(GridReflowInput&     aState,