From edd9f55543ad287f8b10eb648265daf458abec5a Mon Sep 17 00:00:00 2001 From: Fedor Date: Fri, 30 Oct 2020 21:53:14 +0300 Subject: [PATCH] [layout] Avoid negative availSize.BSizes in paginated table reflow. --- layout/tables/nsTableFrame.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 1d47da584..3e7607e4f 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -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)); } }