tor-browser

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

commit f36ac04143f4e2299c9be5ab99ac74c425103e0e
parent 1c62271c70f3cf3552ad0a190f61dcb27c0e5a08
Author: Ting-Yu Lin <tlin@mozilla.com>
Date:   Mon, 13 Oct 2025 21:36:15 +0000

Bug 1983345 Part 9 - Remove ViewportFrame::AdjustReflowInputAsContainingBlock(). r=firefox-style-system-reviewers,layout-reviewers,emilio

`AdjustReflowInputAsContainingBlock` and
`GetContainingBlockAdjustedForScrollbars()` does the same thing, except the
former adjusts the `ReflowInput` parameter.

I assume the adjustment of `ReflowInput` is not really needed if we pass the
testcase `layout/reftests/bugs/844178.html` added in bug 844178.

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

Diffstat:
Mlayout/generic/ReflowInput.cpp | 2+-
Mlayout/generic/ViewportFrame.cpp | 34----------------------------------
Mlayout/generic/ViewportFrame.h | 22+++-------------------
Mlayout/style/RestyleManager.cpp | 7++++---
4 files changed, 8 insertions(+), 57 deletions(-)

diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp @@ -1553,7 +1553,7 @@ void ReflowInput::CalculateHypotheticalPosition( // When the containing block is the ViewportFrame, i.e. we are calculating // the static position for a fixed-positioned frame, we need to adjust the // origin to exclude the scrollbar or scrollbar-gutter area. The - // ViewportFrame's containing block rect is passed into + // ViewportFrame's containing block rect is adjusted in // AbsoluteContainingBlock::ReflowAbsoluteFrame(), and it will add the // rect's origin to the fixed-positioned frame's final position if needed. // diff --git a/layout/generic/ViewportFrame.cpp b/layout/generic/ViewportFrame.cpp @@ -344,40 +344,6 @@ nscoord ViewportFrame::IntrinsicISize(const IntrinsicSizeInput& aInput, : mFrames.FirstChild()->IntrinsicISize(aInput, aType); } -nsPoint ViewportFrame::AdjustReflowInputForScrollbars( - ReflowInput& aReflowInput) const { - // Get our prinicpal child frame and see if we're scrollable - nsIFrame* kidFrame = mFrames.FirstChild(); - - if (ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(kidFrame)) { - // Note: In ReflowInput::CalculateHypotheticalPosition(), we exclude the - // scrollbar or scrollbar-gutter area when computing the offset to - // ViewportFrame. Ensure the code there remains in sync with the logic here. - WritingMode wm = aReflowInput.GetWritingMode(); - LogicalMargin scrollbars(wm, - scrollContainerFrame->GetActualScrollbarSizes()); - aReflowInput.SetComputedISize( - aReflowInput.ComputedISize() - scrollbars.IStartEnd(wm), - ReflowInput::ResetResizeFlags::No); - aReflowInput.SetAvailableISize(aReflowInput.AvailableISize() - - scrollbars.IStartEnd(wm)); - aReflowInput.SetComputedBSize( - aReflowInput.ComputedBSize() - scrollbars.BStartEnd(wm), - ReflowInput::ResetResizeFlags::No); - return nsPoint(scrollbars.Left(wm), scrollbars.Top(wm)); - } - return nsPoint(0, 0); -} - -nsRect ViewportFrame::AdjustReflowInputAsContainingBlock( - ReflowInput& aReflowInput) const { - const nsPoint origin = AdjustReflowInputForScrollbars(aReflowInput); - nsRect rect(origin, aReflowInput.ComputedPhysicalSize()); - rect.SizeTo(AdjustViewportSizeForFixedPosition(rect)); - - return rect; -} - nsRect ViewportFrame::GetContainingBlockAdjustedForScrollbars( const ReflowInput& aReflowInput) const { const WritingMode wm = aReflowInput.GetWritingMode(); diff --git a/layout/generic/ViewportFrame.h b/layout/generic/ViewportFrame.h @@ -68,16 +68,9 @@ class ViewportFrame : public nsContainerFrame { bool ComputeCustomOverflow(mozilla::OverflowAreas&) override { return false; } /** - * Adjust aReflowInput to account for scrollbars and pres shell - * GetVisualViewportSizeSet and - * GetContentDocumentFixedPositionMargins adjustments. - * @return the rect to use as containing block rect - */ - nsRect AdjustReflowInputAsContainingBlock(ReflowInput& aReflowInput) const; - - /* - * This is similar to AdjustReflowInputAsContainingBlock, but it doesn't - * change the input ReflowInput. Only return the containing block rect. + * Get the containing block rect when ViewportFrame serves as a containing + * block. This method accounts for scrollbars, visual viewport, and dynamic + * toolbar sizes. */ nsRect GetContainingBlockAdjustedForScrollbars( const ReflowInput& aReflowInput) const; @@ -101,15 +94,6 @@ class ViewportFrame : public nsContainerFrame { virtual nsresult GetFrameName(nsAString& aResult) const override; #endif - /** - * Calculate how much room is available for fixed frames. That means - * determining if the viewport is scrollable and whether the vertical and/or - * horizontal scrollbars are visible. Adjust the computed isize/bsize and - * available isize for aReflowInput accordingly. - * @return the current scroll position, or (0,0) if not scrollable. - */ - nsPoint AdjustReflowInputForScrollbars(ReflowInput& aReflowInput) const; - protected: ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID) : nsContainerFrame(aStyle, aPresContext, aID), mView(nullptr) {} diff --git a/layout/style/RestyleManager.cpp b/layout/style/RestyleManager.cpp @@ -985,9 +985,10 @@ static bool RecomputePosition(nsIFrame* aFrame) { ViewportFrame* viewport = do_QueryFrame(parentFrame); nsSize cbSize = - viewport ? viewport->AdjustReflowInputAsContainingBlock(parentReflowInput) - .Size() - : aFrame->GetContainingBlock()->GetSize(); + viewport + ? viewport->GetContainingBlockAdjustedForScrollbars(parentReflowInput) + .Size() + : aFrame->GetContainingBlock()->GetSize(); const nsMargin& parentBorder = parentReflowInput.mStyleBorder->GetComputedBorder(); cbSize -= nsSize(parentBorder.LeftRight(), parentBorder.TopBottom());