tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9eddd6cafcab999967709d9ec3e5a6e4e40b8397
parent 2ade44471efb1e2d65ee81c5c112bee7547c823c
Author: Ting-Yu Lin <tlin@mozilla.com>
Date:   Mon, 15 Dec 2025 18:21:48 +0000

Bug 2005918 - Correct reflow flag and remove an overflow area special case when reflowing fixed pos children in PageContentFrame. r=layout-reviewers,emilio

* Remove the special case at the beginning of
  `AbsoluteContainingBlock::Reflow()`. `PageContentFrame` now calls
  `AbsoluteContainingBlock::Reflow()` directly with a null overflow-area pointer
  so that replicated fixed-pos children do not contribute to page overflow.

* We also stop using `AbsPosReflowFlag::AllowFragmentation`, since fixed pos children
  is replicated rather than fragmented. This does not change
  behavior with the current code, but becomes important once bug 1994346 starts
  adjusting the available block-size based on that flag.

Differential Revision: https://phabricator.services.mozilla.com/D276361

Diffstat:
Mlayout/generic/AbsoluteContainingBlock.cpp | 8--------
Mlayout/generic/nsPageContentFrame.cpp | 27+++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp @@ -252,14 +252,6 @@ void AbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame, const nsRect& aContainingBlock, AbsPosReflowFlags aFlags, OverflowAreas* aOverflowAreas) { - // PageContentFrame replicates fixed pos children so we really don't want - // them contributing to overflow areas because that means we'll create new - // pages ad infinitum if one of them overflows the page. - if (aDelegatingFrame->IsPageContentFrame()) { - MOZ_ASSERT(mChildListID == FrameChildListID::Fixed); - aOverflowAreas = nullptr; - } - const auto scrollableContainingBlock = [&]() -> nsRect { switch (aDelegatingFrame->Style()->GetPseudoType()) { case PseudoStyleType::scrolledContent: diff --git a/layout/generic/nsPageContentFrame.cpp b/layout/generic/nsPageContentFrame.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsPageContentFrame.h" +#include "mozilla/AbsoluteContainingBlock.h" #include "mozilla/PresShell.h" #include "mozilla/PresShellInlines.h" #include "mozilla/StaticPrefs_layout.h" @@ -135,9 +136,31 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext, FinishAndStoreOverflow(&aReflowOutput); - // Reflow our fixed frames + // Reflow any fixed-pos children. Note that we don't need to call + // PrepareAbsoluteFrames() because the fixed pos frames cannot split. nsReflowStatus fixedStatus; - ReflowAbsoluteFrames(aPresContext, aReflowOutput, aReflowInput, fixedStatus); + if (auto* absCB = GetAbsoluteContainingBlock(); + absCB && absCB->HasAbsoluteFrames()) { + // The containing block for the fixed-pos children is formed by our padding + // edge. + const auto wm = GetWritingMode(); + LogicalRect cbRect(wm, LogicalPoint(wm), aReflowOutput.Size(wm)); + cbRect.Deflate(wm, GetLogicalUsedBorder(wm).ApplySkipSides( + PreReflowBlockLevelLogicalSkipSides())); + + // XXX: To optimize the performance, set the flags only when the CB width or + // height actually changes. + AbsPosReflowFlags flags{AbsPosReflowFlag::CBWidthChanged, + AbsPosReflowFlag::CBHeightChanged}; + + // PageContentFrame replicates fixed-pos children, so we really don't want + // them contributing to overflow areas; otherwise we'll create new pages ad + // infinitum if one of them overflows the page. + absCB->Reflow(this, aPresContext, aReflowInput, fixedStatus, + cbRect.GetPhysicalRect(wm, aReflowOutput.PhysicalSize()), + flags, + /* aOverflowAreas */ nullptr); + } NS_ASSERTION(fixedStatus.IsComplete(), "fixed frames can be truncated, but not incomplete");