[layout] Avoid negative availSize.BSizes in paginated table reflow.

This commit is contained in:
Fedor 2020-10-30 21:53:14 +03:00
parent 4e0e2a7193
commit edd9f55543
1 changed files with 11 additions and 9 deletions

View File

@ -103,6 +103,14 @@ struct TableReflowInput {
availSize.BSize(wm) = std::max(0, availSize.BSize(wm));
}
}
void ReduceAvailableBSizeBy(WritingMode aWM, nscoord aAmount) {
if (availSize.BSize(aWM) == NS_UNCONSTRAINEDSIZE) {
return;
}
availSize.BSize(aWM) -= aAmount;
availSize.BSize(aWM) = std::max(0, availSize.BSize(aWM));
}
};
} // namespace mozilla
@ -2681,9 +2689,7 @@ nsTableFrame::PlaceChild(TableReflowInput& aReflowInput,
aReflowInput.bCoord += aKidDesiredSize.BSize(wm);
// If our bsize is constrained, then update the available bsize
if (NS_UNCONSTRAINEDSIZE != aReflowInput.availSize.BSize(wm)) {
aReflowInput.availSize.BSize(wm) -= aKidDesiredSize.BSize(wm);
}
aReflowInput.ReduceAvailableBSizeBy(wm, aKidDesiredSize.BSize(wm));
}
void
@ -3003,9 +3009,7 @@ nsTableFrame::ReflowChildren(TableReflowInput& aReflowInput,
kidReflowInput.mFlags.mIsTopOfPage = false;
}
aReflowInput.bCoord += cellSpacingB;
if (NS_UNCONSTRAINEDSIZE != aReflowInput.availSize.BSize(wm)) {
aReflowInput.availSize.BSize(wm) -= cellSpacingB;
}
aReflowInput.ReduceAvailableBSizeBy(wm, cellSpacingB);
// record the presence of a next in flow, it might get destroyed so we
// need to reorder the row group array
bool reorder = false;
@ -3170,9 +3174,7 @@ nsTableFrame::ReflowChildren(TableReflowInput& aReflowInput,
aReflowInput.bCoord += kidRect.BSize(wm);
// If our bsize is constrained then update the available bsize.
if (NS_UNCONSTRAINEDSIZE != aReflowInput.availSize.BSize(wm)) {
aReflowInput.availSize.BSize(wm) -= cellSpacingB + kidRect.BSize(wm);
}
aReflowInput.ReduceAvailableBSizeBy(wm, cellSpacingB + kidRect.BSize(wm));
}
}