commit f50fd6ca170f6f8a8c35616df8d306feffd60c5c
parent a90f35c48d2fc15e519cef3854a035a9158d3d7f
Author: Ting-Yu Lin <tlin@mozilla.com>
Date: Tue, 28 Oct 2025 20:17:07 +0000
Bug 1996677 Part 2 - Change the containing block size parameter to use absCB's writing-mode. r=layout-reviewers,emilio
This patch makes the parameter on `ResolveSizeDependentOffsets()` and
`ResolveAutoMarginsAfterLayout()` consistent on using absolute containing
block's writing-mode. Also, drop `logical` in the parameter naming for brevity.
Differential Revision: https://phabricator.services.mozilla.com/D270249
Diffstat:
2 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -710,10 +710,9 @@ static nscoord OffsetToAlignedStaticPos(
}
void AbsoluteContainingBlock::ResolveSizeDependentOffsets(
- ReflowInput& aKidReflowInput, const LogicalSize& aLogicalCBSize,
+ ReflowInput& aKidReflowInput, const LogicalSize& aCBSize,
const LogicalSize& aKidSize, const LogicalMargin& aMargin,
const StylePositionArea& aResolvedPositionArea, LogicalMargin& aOffsets) {
- WritingMode wm = aKidReflowInput.GetWritingMode();
WritingMode outerWM = aKidReflowInput.mParentReflowInput->GetWritingMode();
// Now that we know the child's size, we resolve any sentinel values in its
@@ -729,9 +728,6 @@ void AbsoluteContainingBlock::ResolveSizeDependentOffsets(
(NS_AUTOOFFSET == aOffsets.BStart(outerWM)) ||
aKidReflowInput.mFlags.mIOffsetsNeedCSSAlign ||
aKidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
- const LogicalSize logicalCBSizeOuterWM =
- aLogicalCBSize.ConvertTo(outerWM, wm);
-
// placeholderContainer is used in each of the m{I,B}OffsetsNeedCSSAlign
// clauses. We declare it at this scope so we can avoid having to look
// it up twice (and only look it up if it's needed).
@@ -741,39 +737,39 @@ void AbsoluteContainingBlock::ResolveSizeDependentOffsets(
NS_ASSERTION(NS_AUTOOFFSET != aOffsets.IEnd(outerWM),
"Can't solve for both start and end");
aOffsets.IStart(outerWM) =
- logicalCBSizeOuterWM.ISize(outerWM) - aOffsets.IEnd(outerWM) -
+ aCBSize.ISize(outerWM) - aOffsets.IEnd(outerWM) -
aMargin.IStartEnd(outerWM) - aKidSize.ISize(outerWM);
} else if (aKidReflowInput.mFlags.mIOffsetsNeedCSSAlign) {
placeholderContainer = GetPlaceholderContainer(aKidReflowInput.mFrame);
nscoord offset = OffsetToAlignedStaticPos(
- aKidReflowInput, aKidSize, logicalCBSizeOuterWM, placeholderContainer,
- outerWM, LogicalAxis::Inline, Nothing{}, aResolvedPositionArea);
+ aKidReflowInput, aKidSize, aCBSize, placeholderContainer, outerWM,
+ LogicalAxis::Inline, Nothing{}, aResolvedPositionArea);
// Shift IStart from its current position (at start corner of the
// alignment container) by the returned offset. And set IEnd to the
// distance between the kid's end edge to containing block's end edge.
aOffsets.IStart(outerWM) += offset;
aOffsets.IEnd(outerWM) =
- logicalCBSizeOuterWM.ISize(outerWM) -
+ aCBSize.ISize(outerWM) -
(aOffsets.IStart(outerWM) + aKidSize.ISize(outerWM));
}
if (NS_AUTOOFFSET == aOffsets.BStart(outerWM)) {
aOffsets.BStart(outerWM) =
- logicalCBSizeOuterWM.BSize(outerWM) - aOffsets.BEnd(outerWM) -
+ aCBSize.BSize(outerWM) - aOffsets.BEnd(outerWM) -
aMargin.BStartEnd(outerWM) - aKidSize.BSize(outerWM);
} else if (aKidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
if (!placeholderContainer) {
placeholderContainer = GetPlaceholderContainer(aKidReflowInput.mFrame);
}
nscoord offset = OffsetToAlignedStaticPos(
- aKidReflowInput, aKidSize, logicalCBSizeOuterWM, placeholderContainer,
- outerWM, LogicalAxis::Block, Nothing{}, aResolvedPositionArea);
+ aKidReflowInput, aKidSize, aCBSize, placeholderContainer, outerWM,
+ LogicalAxis::Block, Nothing{}, aResolvedPositionArea);
// Shift BStart from its current position (at start corner of the
// alignment container) by the returned offset. And set BEnd to the
// distance between the kid's end edge to containing block's end edge.
aOffsets.BStart(outerWM) += offset;
aOffsets.BEnd(outerWM) =
- logicalCBSizeOuterWM.BSize(outerWM) -
+ aCBSize.BSize(outerWM) -
(aOffsets.BStart(outerWM) + aKidSize.BSize(outerWM));
}
aKidReflowInput.SetComputedLogicalOffsets(outerWM, aOffsets);
@@ -781,7 +777,7 @@ void AbsoluteContainingBlock::ResolveSizeDependentOffsets(
}
void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout(
- ReflowInput& aKidReflowInput, const LogicalSize& aLogicalCBSize,
+ ReflowInput& aKidReflowInput, const LogicalSize& aCBSize,
const LogicalSize& aKidSize, LogicalMargin& aMargin,
LogicalMargin& aOffsets) {
MOZ_ASSERT(aKidReflowInput.mFlags.mDeferAutoMarginComputation);
@@ -789,6 +785,7 @@ void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout(
WritingMode wm = aKidReflowInput.GetWritingMode();
WritingMode outerWM = aKidReflowInput.mParentReflowInput->GetWritingMode();
+ const LogicalSize cbSizeInWM = aCBSize.ConvertTo(wm, outerWM);
const LogicalSize kidSizeInWM = aKidSize.ConvertTo(wm, outerWM);
LogicalMargin marginInWM = aMargin.ConvertTo(wm, outerWM);
LogicalMargin offsetsInWM = aOffsets.ConvertTo(wm, outerWM);
@@ -800,7 +797,7 @@ void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout(
offsetsInWM.BStart(wm) == NS_AUTOOFFSET;
nscoord availMarginSpace =
autoOffset ? 0
- : aLogicalCBSize.BSize(wm) - kidSizeInWM.BSize(wm) -
+ : cbSizeInWM.BSize(wm) - kidSizeInWM.BSize(wm) -
offsetsInWM.BStartEnd(wm) - marginInWM.BStartEnd(wm);
const auto& styleMargin = aKidReflowInput.mStyleMargin;
@@ -994,6 +991,9 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
return aOriginalContainingBlockRect;
}();
+ const WritingMode outerWM = aReflowInput.GetWritingMode();
+ const LogicalSize cbSize(outerWM, usedCb.Size());
+
WritingMode wm = aKidFrame->GetWritingMode();
LogicalSize logicalCBSize(wm, usedCb.Size());
nscoord availISize = logicalCBSize.ISize(wm);
@@ -1048,7 +1048,6 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
aReflowInput.AvailableBSize());
// Get the border values
- const WritingMode outerWM = aReflowInput.GetWritingMode();
const LogicalMargin border =
aDelegatingFrame->GetLogicalUsedBorder(outerWM);
@@ -1099,12 +1098,12 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
// If we're solving for start in either inline or block direction,
// then compute it now that we know the dimensions.
- ResolveSizeDependentOffsets(kidReflowInput, logicalCBSize, kidSize,
- margin, resolvedPositionArea, offsets);
+ ResolveSizeDependentOffsets(kidReflowInput, cbSize, kidSize, margin,
+ resolvedPositionArea, offsets);
if (kidReflowInput.mFlags.mDeferAutoMarginComputation) {
- ResolveAutoMarginsAfterLayout(kidReflowInput, logicalCBSize, kidSize,
- margin, offsets);
+ ResolveAutoMarginsAfterLayout(kidReflowInput, cbSize, kidSize, margin,
+ offsets);
}
// If the inset is constrained as non-auto, we may have a child that does
diff --git a/layout/generic/AbsoluteContainingBlock.h b/layout/generic/AbsoluteContainingBlock.h
@@ -117,14 +117,13 @@ class AbsoluteContainingBlock {
* resolve size-dependent values in the ComputedLogicalOffsets on its
* reflow input.
*
- * aLogicalCBSize is expected in the abspos child's writing-mode. aKidSize,
- * aMargin, aOffsets, are all expected in the absolute containing block's
- * writing-mode.
+ * aCBSize, aKidSize, aMargin, aOffsets, are all expected in the absolute
+ * containing block's writing-mode.
*
* aOffset is an outparam.
*/
void ResolveSizeDependentOffsets(
- ReflowInput& aKidReflowInput, const LogicalSize& aLogicalCBSize,
+ ReflowInput& aKidReflowInput, const LogicalSize& aCBSize,
const LogicalSize& aKidSize, const LogicalMargin& aMargin,
const StylePositionArea& aResolvedPositionArea, LogicalMargin& aOffsets);
@@ -134,15 +133,14 @@ class AbsoluteContainingBlock {
* InitAbsoluteConstraints because the block-size isn't computed yet. This
* method computes the margins for them after layout.
*
- * aLogicalCBSize is expected in the abspos child's writing-mode. aKidSize,
- * aMargin, aOffsets, are all expected in the absolute containing block's
- * writing-mode.
+ * aCBSize, aKidSize, aMargin, aOffsets, are all expected in the absolute
+ * containing block's writing-mode.
*
* aMargin and aOffsets are both outparams (though we only touch aOffsets if
* the position is overconstrained)
*/
void ResolveAutoMarginsAfterLayout(ReflowInput& aKidReflowInput,
- const LogicalSize& aLogicalCBSize,
+ const LogicalSize& aCBSize,
const LogicalSize& aKidSize,
LogicalMargin& aMargin,
LogicalMargin& aOffsets);