tor-browser

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

commit b1abbd349f0b67efffa2d7fbeaaaf590869f9bc2
parent c66676ce8f63cfed777b4369b51bf4a43ff747bb
Author: David Shin <dshin@mozilla.com>
Date:   Thu, 18 Dec 2025 18:44:12 +0000

Bug 2006402: Remove anchor-center flags in reflowinput. r=layout-anchor-positioning-reviewers,layout-reviewers,emilio

Most of the deleted code was to handle the fact that `FromUnresolved`
returned `auto` which got mapped afterwards. Now we just return zero.

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

Diffstat:
Mlayout/generic/AbsoluteContainingBlock.cpp | 30+++++++++++++-----------------
Mlayout/generic/ReflowInput.cpp | 40++--------------------------------------
Mlayout/generic/ReflowInput.h | 7-------
3 files changed, 15 insertions(+), 62 deletions(-)

diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp @@ -971,7 +971,7 @@ void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout( const auto anchorResolutionParams = AnchorPosResolutionParams::From(&aKidReflowInput); - auto ResolveMarginsInAxis = [&](LogicalAxis aAxis, bool aAnchorCenter) { + auto ResolveMarginsInAxis = [&](LogicalAxis aAxis) { const auto startSide = MakeLogicalSide(aAxis, LogicalEdge::Start); const auto endSide = MakeLogicalSide(aAxis, LogicalEdge::End); @@ -1000,20 +1000,18 @@ void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout( ->IsAuto(); if (aAxis == LogicalAxis::Inline) { - ReflowInput::ComputeAbsPosInlineAutoMargin( - availMarginSpace, outerWM, startSideMarginIsAuto, endSideMarginIsAuto, - aAnchorCenter, aMargin); + ReflowInput::ComputeAbsPosInlineAutoMargin(availMarginSpace, outerWM, + startSideMarginIsAuto, + endSideMarginIsAuto, aMargin); } else { - ReflowInput::ComputeAbsPosBlockAutoMargin( - availMarginSpace, outerWM, startSideMarginIsAuto, endSideMarginIsAuto, - aAnchorCenter, aMargin); + ReflowInput::ComputeAbsPosBlockAutoMargin(availMarginSpace, outerWM, + startSideMarginIsAuto, + endSideMarginIsAuto, aMargin); } }; - ResolveMarginsInAxis(LogicalAxis::Inline, - aKidReflowInput.mFlags.mIAnchorCenter); - ResolveMarginsInAxis(LogicalAxis::Block, - aKidReflowInput.mFlags.mBAnchorCenter); + ResolveMarginsInAxis(LogicalAxis::Inline); + ResolveMarginsInAxis(LogicalAxis::Block); aKidReflowInput.SetComputedLogicalMargin(outerWM, aMargin); nsMargin* propValue = @@ -1464,10 +1462,9 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame( const auto* placeholderContainer = GetPlaceholderContainer(kidReflowInput.mFrame); - if (!iInsetAuto || kidReflowInput.mFlags.mIAnchorCenter) { + if (!iInsetAuto) { MOZ_ASSERT( - !kidReflowInput.mFlags.mIOffsetsNeedCSSAlign || - kidReflowInput.mFlags.mIAnchorCenter, + !kidReflowInput.mFlags.mIOffsetsNeedCSSAlign, "Non-auto inline inset but requires CSS alignment for static " "position?"); auto alignOffset = OffsetToAlignedStaticPos( @@ -1484,9 +1481,8 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame( cbSize.ISize(outerWM) - (offsets.IStart(outerWM) + kidMarginBox.ISize(outerWM)); } - if (!bInsetAuto || kidReflowInput.mFlags.mBAnchorCenter) { - MOZ_ASSERT(!kidReflowInput.mFlags.mBOffsetsNeedCSSAlign || - kidReflowInput.mFlags.mBAnchorCenter, + if (!bInsetAuto) { + MOZ_ASSERT(!kidReflowInput.mFlags.mBOffsetsNeedCSSAlign, "Non-auto block inset but requires CSS alignment for static " "position?"); auto alignOffset = OffsetToAlignedStaticPos( diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp @@ -305,7 +305,6 @@ ReflowInput::ReflowInput(nsPresContext* aPresContext, mFlags.mDummyParentReflowInput = false; mFlags.mStaticPosIsCBOrigin = aFlags.contains(InitFlag::StaticPosIsCBOrigin); mFlags.mIOffsetsNeedCSSAlign = mFlags.mBOffsetsNeedCSSAlign = false; - mFlags.mIAnchorCenter = mFlags.mBAnchorCenter = false; // We don't want the mOrthogonalCellFinalReflow flag to be inherited; it's up // to the table row frame to set it for its direct children as needed. @@ -1145,18 +1144,7 @@ void ReflowInput::ComputeAbsPosInlineAutoMargin(nscoord aAvailMarginSpace, WritingMode aContainingBlockWM, bool aIsMarginIStartAuto, bool aIsMarginIEndAuto, - bool aIsIAnchorCenter, LogicalMargin& aMargin) { - if (aIsIAnchorCenter) { - // `anchor-center` sets any use of `auto` margin to 0. - if (aIsMarginIStartAuto) { - aMargin.IStart(aContainingBlockWM) = 0; - } - if (aIsMarginIEndAuto) { - aMargin.IEnd(aContainingBlockWM) = 0; - } - return; - } if (aIsMarginIStartAuto) { if (aIsMarginIEndAuto) { if (aAvailMarginSpace < 0) { @@ -1190,18 +1178,7 @@ void ReflowInput::ComputeAbsPosBlockAutoMargin(nscoord aAvailMarginSpace, WritingMode aContainingBlockWM, bool aIsMarginBStartAuto, bool aIsMarginBEndAuto, - bool aIsBAnchorCenter, LogicalMargin& aMargin) { - if (aIsBAnchorCenter) { - // `anchor-center` sets any use of `auto` margin to 0. - if (aIsMarginBStartAuto) { - aMargin.BStart(aContainingBlockWM) = 0; - } - if (aIsMarginBEndAuto) { - aMargin.BEnd(aContainingBlockWM) = 0; - } - return; - } if (aIsMarginBStartAuto) { if (aIsMarginBEndAuto) { // Both 'margin-top' and 'margin-bottom' are 'auto', so they get @@ -1719,19 +1696,6 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput, bool bStartIsAuto = bStartOffset->IsAuto(); bool bEndIsAuto = bEndOffset->IsAuto(); - // TODO(dshin): Needed anymore? - mFlags.mIAnchorCenter = anchorResolutionParams.mBaseParams - .mAutoResolutionOverrideParams.mIAnchorCenter; - mFlags.mBAnchorCenter = anchorResolutionParams.mBaseParams - .mAutoResolutionOverrideParams.mBAnchorCenter; - - // For anchor-center with both insets auto, insets need to be kept as 0 - // so hypothetical position should be skipped. - const bool inlineBothInsetsAuto = - mFlags.mIAnchorCenter && iStartIsAuto && iEndIsAuto; - const bool blockBothInsetsAuto = - mFlags.mBAnchorCenter && bStartIsAuto && bEndIsAuto; - // If both 'inline-start' and 'inline-end' are 'auto' or both 'block-start' // and 'block-end' are 'auto', then compute the hypothetical box position // where the element would have if it were in the flow. @@ -1817,7 +1781,7 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput, nsLayoutUtils::ComputeCBDependentValue(aCBSize.ISize(cbwm), iEndOffset); } - if (iStartIsAuto && iEndIsAuto && !inlineBothInsetsAuto) { + if (iStartIsAuto && iEndIsAuto) { if (cbwm.IsInlineReversed() != hypotheticalPos.mWritingMode.IsInlineReversed()) { offsets.IEnd(cbwm) = hypotheticalPos.mIStart; @@ -1841,7 +1805,7 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput, nsLayoutUtils::ComputeCBDependentValue(aCBSize.BSize(cbwm), bEndOffset); } - if (bStartIsAuto && bEndIsAuto && !blockBothInsetsAuto) { + if (bStartIsAuto && bEndIsAuto) { // Treat 'top' like 'static-position' offsets.BStart(cbwm) = hypotheticalPos.mBStart; bStartIsAuto = false; diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h @@ -512,11 +512,6 @@ struct ReflowInput : public SizeComputationInput { bool mIOffsetsNeedCSSAlign : 1; bool mBOffsetsNeedCSSAlign : 1; - // True when anchor-center is being used with a valid anchor and at least - // one inset is auto on this axis. Used to zero out margins. - bool mIAnchorCenter : 1; - bool mBAnchorCenter : 1; - // Is this frame or one of its ancestors being reflowed in a different // continuation than the one in which it was previously reflowed? In // other words, has it moved to a different column or page than it was in @@ -830,7 +825,6 @@ struct ReflowInput : public SizeComputationInput { WritingMode aContainingBlockWM, bool aIsMarginBStartAuto, bool aIsMarginBEndAuto, - bool aIsIAnchorCenter, LogicalMargin& aMargin); // Resolve any inline-axis 'auto' margins (if any) for an absolutely @@ -840,7 +834,6 @@ struct ReflowInput : public SizeComputationInput { WritingMode aContainingBlockWM, bool aIsMarginIStartAuto, bool aIsMarginIEndAuto, - bool aIsBAnchorCenter, LogicalMargin& aMargin); protected: