tor-browser

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

commit d77d42c8dec1e97c3500802f2aee86aca69b5aea
parent 8c8ff247383692eba8341760c220180ebb860fc7
Author: Ting-Yu Lin <tlin@mozilla.com>
Date:   Mon, 13 Oct 2025 21:36:14 +0000

Bug 1983345 Part 6 - Revise the computation of containing block border-box size. r=layout-reviewers,emilio

Previously, when the block container was in reflow, we get the size from
absolute containing block's reflow input. That works in most cases (because the
two often coincide) but is conceptually wrong when they differ.

This patch computes the border-box size from the information returned from
`GetHypotheticalBoxContainer()` instead.

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

Diffstat:
Mlayout/generic/ReflowInput.cpp | 33++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp @@ -405,19 +405,28 @@ WritingMode ReflowInput::GetCBWritingMode() const { : mFrame->GetContainingBlock()->GetWritingMode(); } -nsSize ReflowInput::ComputedSizeAsContainerIfConstrained() const { - LogicalSize size = ComputedSize(); - if (size.ISize(mWritingMode) == NS_UNCONSTRAINEDSIZE) { - size.ISize(mWritingMode) = 0; +// Return the physical border-box size by combining aContentBoxSize and +// aBorderPadding, with unconstrained dimensions replaced by zero. +static nsSize BorderBoxSizeAsContainerIfConstrained( + WritingMode aWM, const LogicalSize& aContentBoxSize, + const LogicalMargin& aBorderPadding) { + LogicalSize size = aContentBoxSize; + if (size.ISize(aWM) == NS_UNCONSTRAINEDSIZE) { + size.ISize(aWM) = 0; } else { - size.ISize(mWritingMode) += mComputedBorderPadding.IStartEnd(mWritingMode); + size.ISize(aWM) += aBorderPadding.IStartEnd(aWM); } - if (size.BSize(mWritingMode) == NS_UNCONSTRAINEDSIZE) { - size.BSize(mWritingMode) = 0; + if (size.BSize(aWM) == NS_UNCONSTRAINEDSIZE) { + size.BSize(aWM) = 0; } else { - size.BSize(mWritingMode) += mComputedBorderPadding.BStartEnd(mWritingMode); + size.BSize(aWM) += aBorderPadding.BStartEnd(aWM); } - return size.GetPhysicalSize(mWritingMode); + return size.GetPhysicalSize(aWM); +} + +nsSize ReflowInput::ComputedSizeAsContainerIfConstrained() const { + return BorderBoxSizeAsContainerIfConstrained(mWritingMode, ComputedSize(), + mComputedBorderPadding); } bool ReflowInput::ShouldReflowAllKids() const { @@ -1423,10 +1432,8 @@ void ReflowInput::CalculateHypotheticalPosition( // Get the placeholder offset in the coordinate space of its block container. // XXXbz the placeholder is not fully reflowed yet if our containing block is // relatively positioned... - nsSize blockContainerSize = - blockContainer->HasAnyStateBits(NS_FRAME_IN_REFLOW) - ? aCBReflowInput->ComputedSizeAsContainerIfConstrained() - : blockContainer->GetSize(); + const nsSize blockContainerSize = BorderBoxSizeAsContainerIfConstrained( + wm, blockContainerContentBoxSize, blockContainerBP); LogicalPoint placeholderOffset( wm, aPlaceholderFrame->GetOffsetToIgnoringScrolling(blockContainer), blockContainerSize);