Bug 1758757 - Remove two ReflowInput::ApplyRelativePositioning methods that require ReflowInput instance. r=emilio

See bug 1758757 comment 0 for the rationale.

Note: the old code in nsTableRowGroupFrame::SlideChild() is bogus because it
calls ApplyRelativePositioning() via the nsTableRowGroupFrame's ReflowInput
instance. That is, it applies relative positioning to nsTableRowGroupFrame, but
not to the aKidFrame (nsTableRowFrame).

While I'm here, I expand `SlideChild` in its only caller, and simplify it.

Differential Revision: https://phabricator.services.mozilla.com/D150323
This commit is contained in:
Ting-Yu Lin 2022-06-27 20:49:59 +00:00
parent 726a4f50bb
commit 8274aa5608
3 changed files with 11 additions and 35 deletions

View File

@ -869,22 +869,11 @@ struct ReflowInput : public SizeComputationInput {
const nsMargin& aComputedOffsets,
nsPoint* aPosition);
void ApplyRelativePositioning(nsPoint* aPosition) const {
ApplyRelativePositioning(mFrame, ComputedPhysicalOffsets(), aPosition);
}
static void ApplyRelativePositioning(
nsIFrame* aFrame, mozilla::WritingMode aWritingMode,
const mozilla::LogicalMargin& aComputedOffsets,
mozilla::LogicalPoint* aPosition, const nsSize& aContainerSize);
void ApplyRelativePositioning(mozilla::LogicalPoint* aPosition,
const nsSize& aContainerSize) const {
ApplyRelativePositioning(mFrame, mWritingMode,
ComputedLogicalOffsets(mWritingMode), aPosition,
aContainerSize);
}
// Resolve any block-axis 'auto' margins (if any) for an absolutely positioned
// frame. aMargin and aOffsets are both outparams (though we only touch
// aOffsets if the position is overconstrained)

View File

@ -442,7 +442,17 @@ void nsTableRowGroupFrame::ReflowChildren(
}
}
} else {
SlideChild(aReflowInput, kidFrame);
// Move a child that was skipped during a reflow.
const LogicalPoint oldPosition =
kidFrame->GetLogicalNormalPosition(wm, containerSize);
if (oldPosition.B(wm) != aReflowInput.bCoord) {
kidFrame->InvalidateFrameSubtree();
const LogicalPoint offset(wm, 0,
aReflowInput.bCoord - oldPosition.B(wm));
kidFrame->MovePositionBy(wm, offset);
nsTableFrame::RePositionViews(kidFrame);
kidFrame->InvalidateFrameSubtree();
}
// Adjust the running b-offset so we know where the next row should be
// placed
@ -917,27 +927,6 @@ nscoord nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset,
return bGroupOffset;
}
// Move a child that was skipped during a reflow.
void nsTableRowGroupFrame::SlideChild(TableRowGroupReflowInput& aReflowInput,
nsIFrame* aKidFrame) {
// Move the frame if we need to.
WritingMode wm = aReflowInput.reflowInput.GetWritingMode();
const nsSize containerSize =
aReflowInput.reflowInput.ComputedSizeAsContainerIfConstrained();
LogicalPoint oldPosition =
aKidFrame->GetLogicalNormalPosition(wm, containerSize);
LogicalPoint newPosition = oldPosition;
newPosition.B(wm) = aReflowInput.bCoord;
if (oldPosition.B(wm) != newPosition.B(wm)) {
aKidFrame->InvalidateFrameSubtree();
aReflowInput.reflowInput.ApplyRelativePositioning(&newPosition,
containerSize);
aKidFrame->SetPosition(wm, newPosition, containerSize);
nsTableFrame::RePositionViews(aKidFrame);
aKidFrame->InvalidateFrameSubtree();
}
}
// Create a continuing frame, add it to the child list, and then push it
// and the frames that follow
void nsTableRowGroupFrame::CreateContinuingRowFrame(nsIFrame& aRowFrame,

View File

@ -334,8 +334,6 @@ class nsTableRowGroupFrame final : public nsContainerFrame,
void DidResizeRows(ReflowOutput& aDesiredSize);
void SlideChild(TableRowGroupReflowInput& aReflowInput, nsIFrame* aKidFrame);
/**
* Reflow the frames we've already created
*