Bug 1316051 part 5 - [css-grid] Subtract the caption size from the CB size that is used for stretching table items. r=dholbert

This commit is contained in:
Mats Palmgren 2016-11-18 19:08:31 +01:00
parent a8c4f0a7da
commit 74d08d3799

View File

@ -951,9 +951,12 @@ nsTableWrapperFrame::Reflow(nsPresContext* aPresContext,
captionRI->ComputedLogicalMargin().ConvertTo(wm, captionWM);
// Now that we know the bsize of the caption, reduce the available bsize
// for the table frame if we are bsize constrained and the caption is above
// or below the inner table.
if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize()) {
// or below the inner table. Also reduce the CB size that we store for
// our children in case we're a grid item, by the same amount.
LogicalSize* cbSize = Properties().Get(GridItemCBSizeProperty());
if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize() || cbSize) {
nscoord captionBSize = 0;
nscoord captionISize = 0;
switch (captionSide) {
case NS_STYLE_CAPTION_SIDE_TOP:
case NS_STYLE_CAPTION_SIDE_BOTTOM:
@ -961,9 +964,27 @@ nsTableWrapperFrame::Reflow(nsPresContext* aPresContext,
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE:
captionBSize = captionSize.BSize(wm) + captionMargin.BStartEnd(wm);
break;
case NS_STYLE_CAPTION_SIDE_LEFT:
case NS_STYLE_CAPTION_SIDE_RIGHT:
captionISize = captionSize.ISize(wm) + captionMargin.IStartEnd(wm);
break;
}
if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize()) {
innerRI->AvailableBSize() =
std::max(0, innerRI->AvailableBSize() - captionBSize);
}
if (cbSize) {
// Shrink the CB size by the size reserved for the caption.
LogicalSize oldCBSize = *cbSize;
cbSize->ISize(wm) = std::max(0, cbSize->ISize(wm) - captionISize);
cbSize->BSize(wm) = std::max(0, cbSize->BSize(wm) - captionBSize);
if (oldCBSize != *cbSize) {
// Reset the inner table's ReflowInput to stretch it to the new size.
innerRI.reset();
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRI,
innerRI, aOuterRI.ComputedSize(wm).ISize(wm));
}
}
innerRI->AvailableBSize() =
std::max(0, innerRI->AvailableBSize() - captionBSize);
}
}