From 50b0c4bcfd78e9a67f2873149e3a2b035baf4073 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Wed, 27 Jul 2022 21:55:17 +0000 Subject: [PATCH] Bug 1464761 Part 2 - Remove IsTruncated() in nsTableRowFrame::ReflowCellFrame(). r=dholbert We call NS_FRAME_SET_TRUNCATION (via nsReflowStatus::UpdateTruncated) in the end of every frame's Reflow() to update nsReflowStatus::mTruncated bit. In the following patches, I'm going to rewrite all the callers of IsTruncated(), and ultimately remove the mTruncated bit. In this patch, I rewrite the callsite in ReflowCellFrame() by moving nsReflowStatus::UpdateTruncated logic [1] into it. Note that we use an assertion in ReflowCellFrame to make sure nsTableRowFrame and nsTableCellFrame have the same writing-mode. The only test covering the code path is `layout/reftests/bugs/409084-1a.html`. [1] https://searchfox.org/mozilla-central/rev/2946e9b450cb35afaf8dad927a8d187975dcd74d/layout/generic/nsIFrame.cpp#256-258 Differential Revision: https://phabricator.services.mozilla.com/D151459 --- layout/tables/nsTableRowFrame.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 2e0d550ce940..93122d3a5dc0 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -1073,6 +1073,8 @@ nscoord nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext, nsTableCellFrame* aCellFrame, nscoord aAvailableBSize, nsReflowStatus& aStatus) { + MOZ_ASSERT(aAvailableBSize != NS_UNCONSTRAINEDSIZE, + "Why split cell frame if available bsize is unconstrained?"); WritingMode wm = aReflowInput.GetWritingMode(); // Reflow the cell frame with the specified height. Use the existing width @@ -1096,8 +1098,11 @@ nscoord nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext, ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowInput, 0, 0, ReflowChildFlags::NoMoveFrame, aStatus); - bool fullyComplete = aStatus.IsComplete() && !aStatus.IsTruncated(); - if (fullyComplete) { + const bool isTruncated = + aAvailableBSize < desiredSize.BSize(wm) && + !aIsTopOfPage; // XXX Is !aIsTopOfPage check really necessary? + const bool isCompleteAndNotTruncated = aStatus.IsComplete() && !isTruncated; + if (isCompleteAndNotTruncated) { desiredSize.BSize(wm) = aAvailableBSize; } aCellFrame->SetSize( @@ -1106,7 +1111,7 @@ nscoord nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext, // Note: BlockDirAlignChild can affect the overflow rect. // XXX What happens if this cell has 'vertical-align: baseline' ? // XXX Why is it assumed that the cell's ascent hasn't changed ? - if (fullyComplete) { + if (isCompleteAndNotTruncated) { aCellFrame->BlockDirAlignChild(wm, mMaxCellAscent); }