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
--- 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,