Bug 1873530 Part 3 - Unify continuation linking operations by removing SetPrevContinuation() and SetPrevInFlow(). r=jfkthame

SetNextContinuation() and SetPrevContinuation() are almost always called
together when setting up a continuation link, but the callers don't call them in
particular order. We should unify them as one method so that it's more
ergonomics and robust, especially when we do more complex work such as caching
continuations. Same reason for SetNextInFlow() and SetPrevInFlow().

We choose to merge the SetPrevContinuation() code into SetNextContinuation() for
the symmetry of SetNextSibling(). (Yes, we don't have SetPrevSibling().)

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D197966
This commit is contained in:
Ting-Yu Lin
2024-01-11 19:50:58 +00:00
parent fd8f769590
commit 1c5fd05aca
8 changed files with 142 additions and 157 deletions

View File

@@ -2224,7 +2224,6 @@ nsIFrame* nsCSSFrameConstructor::ConstructTableCol(
nsTableColFrame* newCol = NS_NewTableColFrame(mPresShell, computedStyle);
InitAndRestoreFrame(aState, content, aParentFrame, newCol, false);
aFrameList.LastChild()->SetNextContinuation(newCol);
newCol->SetPrevContinuation(aFrameList.LastChild());
aFrameList.AppendFrame(nullptr, newCol);
newCol->SetColType(eColAnonymousCol);
}
@@ -8030,10 +8029,10 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
}
// Init() set newFrame to be a fluid continuation of aFrame.
// If we want a non-fluid continuation, we need to call SetPrevContinuation()
// to reset NS_FRAME_IS_FLUID_CONTINUATION.
// If we want a non-fluid continuation, we need to call SetNextContinuation()
// to remove NS_FRAME_IS_FLUID_CONTINUATION bit from newFrame.
if (!aIsFluid) {
newFrame->SetPrevContinuation(aFrame);
aFrame->SetNextContinuation(newFrame);
}
// If a continuing frame needs to carry frame state bits from its previous
@@ -8041,10 +8040,8 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
// frame class's Init() if the bits are belong to specific group.
if (nextInFlow) {
nextInFlow->SetPrevInFlow(newFrame);
newFrame->SetNextInFlow(nextInFlow);
} else if (nextContinuation) {
nextContinuation->SetPrevContinuation(newFrame);
newFrame->SetNextContinuation(nextContinuation);
}