commit e21dcc7bb55b2c6b5e5e5229c7be48a80121314e
parent 6b30f8318890a05dd0849e3355200ecbccbeefc6
Author: Ting-Yu Lin <tlin@mozilla.com>
Date: Thu, 1 Jan 2026 00:19:33 +0000
Bug 2007602 Part 2 - Create a helper method for moving child from pushed absolute child list to absolute child list. r=layout-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D277494
Diffstat:
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -110,6 +110,27 @@ nsFrameList AbsoluteContainingBlock::StealPushedChildList() {
return std::move(mPushedAbsoluteFrames);
}
+void AbsoluteContainingBlock::DrainPushedChildList(
+ const nsIFrame* aDelegatingFrame) {
+ MOZ_ASSERT(aDelegatingFrame->GetAbsoluteContainingBlock() == this,
+ "aDelegatingFrame's absCB should be us!");
+
+ // Our pushed absolute child list might be non-empty if our next-in-flow
+ // hasn't reflowed yet. Move any child in that list that is a first-in-flow,
+ // or whose prev-in-flow is not in our absolute child list, into our absolute
+ // child list.
+ for (auto iter = mPushedAbsoluteFrames.begin();
+ iter != mPushedAbsoluteFrames.end();) {
+ // Advance the iterator first, so it's safe to move |child|.
+ nsIFrame* const child = *iter++;
+ if (!child->GetPrevInFlow() ||
+ child->GetPrevInFlow()->GetParent() != aDelegatingFrame) {
+ mPushedAbsoluteFrames.RemoveFrame(child);
+ mAbsoluteFrames.AppendFrame(nullptr, child);
+ }
+ }
+}
+
bool AbsoluteContainingBlock::PrepareAbsoluteFrames(
nsContainerFrame* aDelegatingFrame) {
if (!aDelegatingFrame->PresContext()
@@ -133,20 +154,7 @@ bool AbsoluteContainingBlock::PrepareAbsoluteFrames(
}
}
- // Our pushed absolute child list might be non-empty if our next-in-flow
- // hasn't reflowed yet. Move any child in that list that is a first-in-flow,
- // or whose prev-in-flow is not in our absolute child list, into our absolute
- // child list.
- for (auto iter = mPushedAbsoluteFrames.begin();
- iter != mPushedAbsoluteFrames.end();) {
- // Advance the iterator first, so it's safe to move |child|.
- nsIFrame* const child = *iter++;
- if (!child->GetPrevInFlow() ||
- child->GetPrevInFlow()->GetParent() != aDelegatingFrame) {
- mPushedAbsoluteFrames.RemoveFrame(child);
- mAbsoluteFrames.AppendFrame(nullptr, child);
- }
- }
+ DrainPushedChildList(aDelegatingFrame);
// TODO (Bug 1994346 or Bug 1997696): Consider stealing absolute frames from
// our next-in-flow's absolute child list.
diff --git a/layout/generic/AbsoluteContainingBlock.h b/layout/generic/AbsoluteContainingBlock.h
@@ -194,6 +194,15 @@ class AbsoluteContainingBlock {
*/
void StealFrame(nsIFrame* aFrame);
+ /**
+ * Move any frame in our pushed absolute list into our absolute child list, if
+ * it is a first-in-flow, or if its prev-in-flow is not present in our
+ * absolute child list.
+ *
+ * @param aDelegatingFrame the frame that owns us.
+ */
+ void DrainPushedChildList(const nsIFrame* aDelegatingFrame);
+
// Stores the abspos frames that have been placed in this containing block.
nsFrameList mAbsoluteFrames;