Bug 1900522 Part 6 - Remove a SizeComputationInput::ComputeISizeValue() variant. r=layout-reviewers,emilio

This removed one is just forwarding the call to nsIFrame, and used internally
within ReflowInput.

While I'm here, rename local variables `inside*` and `outside*` to make them
clearer.

Differential Revision: https://phabricator.services.mozilla.com/D212509
This commit is contained in:
Ting-Yu Lin 2024-06-04 17:54:50 +00:00
parent 767f568b4f
commit 6e4d33524e
2 changed files with 29 additions and 39 deletions

View file

@ -254,32 +254,24 @@ ReflowInput::ReflowInput(nsPresContext* aPresContext,
} }
} }
template <typename SizeOrMaxSize>
inline nscoord SizeComputationInput::ComputeISizeValue(
const WritingMode aWM, const LogicalSize& aContainingBlockSize,
const LogicalSize& aContentEdgeToBoxSizing, nscoord aBoxSizingToMarginEdge,
const SizeOrMaxSize& aSize) const {
return mFrame
->ComputeISizeValue(mRenderingContext, aWM, aContainingBlockSize,
aContentEdgeToBoxSizing, aBoxSizingToMarginEdge,
aSize)
.mISize;
}
template <typename SizeOrMaxSize> template <typename SizeOrMaxSize>
nscoord SizeComputationInput::ComputeISizeValue( nscoord SizeComputationInput::ComputeISizeValue(
const LogicalSize& aContainingBlockSize, StyleBoxSizing aBoxSizing, const LogicalSize& aContainingBlockSize, StyleBoxSizing aBoxSizing,
const SizeOrMaxSize& aSize) const { const SizeOrMaxSize& aSize) const {
WritingMode wm = GetWritingMode(); WritingMode wm = GetWritingMode();
const auto borderPadding = ComputedLogicalBorderPadding(wm); const auto borderPadding = ComputedLogicalBorderPadding(wm);
LogicalSize inside = aBoxSizing == StyleBoxSizing::Border const LogicalSize contentEdgeToBoxSizing =
? borderPadding.Size(wm) aBoxSizing == StyleBoxSizing::Border ? borderPadding.Size(wm)
: LogicalSize(wm); : LogicalSize(wm);
nscoord outside = const nscoord boxSizingToMarginEdgeISize =
borderPadding.IStartEnd(wm) + ComputedLogicalMargin(wm).IStartEnd(wm); borderPadding.IStartEnd(wm) + ComputedLogicalMargin(wm).IStartEnd(wm) -
outside -= inside.ISize(wm); contentEdgeToBoxSizing.ISize(wm);
return ComputeISizeValue(wm, aContainingBlockSize, inside, outside, aSize); return mFrame
->ComputeISizeValue(mRenderingContext, wm, aContainingBlockSize,
contentEdgeToBoxSizing, boxSizingToMarginEdgeISize,
aSize)
.mISize;
} }
nscoord SizeComputationInput::ComputeBSizeValue( nscoord SizeComputationInput::ComputeBSizeValue(
@ -1273,17 +1265,18 @@ void ReflowInput::CalculateHypotheticalPosition(
// border/padding/margin that the element would have had if it had // border/padding/margin that the element would have had if it had
// been in the flow. Note that we ignore any 'auto' and 'inherit' // been in the flow. Note that we ignore any 'auto' and 'inherit'
// values // values
nscoord insideBoxISizing, outsideBoxISizing; nscoord contentEdgeToBoxSizingISize, boxSizingToMarginEdgeISize;
CalculateBorderPaddingMargin(LogicalAxis::Inline, CalculateBorderPaddingMargin(
blockContentSize.ISize(wm), &insideBoxISizing, LogicalAxis::Inline, blockContentSize.ISize(wm),
&outsideBoxISizing); &contentEdgeToBoxSizingISize, &boxSizingToMarginEdgeISize);
if (mFlags.mIsReplaced && isAutoISize) { if (mFlags.mIsReplaced && isAutoISize) {
// It's a replaced element with an 'auto' inline size so the box inline // It's a replaced element with an 'auto' inline size so the box inline
// size is its intrinsic size plus any border/padding/margin // size is its intrinsic size plus any border/padding/margin
if (intrinsicSize) { if (intrinsicSize) {
boxISize.emplace(LogicalSize(wm, *intrinsicSize).ISize(wm) + boxISize.emplace(LogicalSize(wm, *intrinsicSize).ISize(wm) +
outsideBoxISizing + insideBoxISizing); contentEdgeToBoxSizingISize +
boxSizingToMarginEdgeISize);
} }
} else if (isAutoISize) { } else if (isAutoISize) {
// The box inline size is the containing block inline size // The box inline size is the containing block inline size
@ -1292,15 +1285,20 @@ void ReflowInput::CalculateHypotheticalPosition(
// We need to compute it. It's important we do this, because if it's // We need to compute it. It's important we do this, because if it's
// percentage based this computed value may be different from the computed // percentage based this computed value may be different from the computed
// value calculated using the absolute containing block width // value calculated using the absolute containing block width
nscoord insideBoxBSizing, dummy; nscoord contentEdgeToBoxSizingBSize, dummy;
CalculateBorderPaddingMargin(LogicalAxis::Block, CalculateBorderPaddingMargin(LogicalAxis::Block,
blockContentSize.ISize(wm), blockContentSize.ISize(wm),
&insideBoxBSizing, &dummy); &contentEdgeToBoxSizingBSize, &dummy);
boxISize.emplace(
ComputeISizeValue(wm, blockContentSize, const auto contentISize =
LogicalSize(wm, insideBoxISizing, insideBoxBSizing), mFrame
outsideBoxISizing, styleISize) + ->ComputeISizeValue(mRenderingContext, wm, blockContentSize,
insideBoxISizing + outsideBoxISizing); LogicalSize(wm, contentEdgeToBoxSizingISize,
contentEdgeToBoxSizingBSize),
boxSizingToMarginEdgeISize, styleISize)
.mISize;
boxISize.emplace(contentISize + contentEdgeToBoxSizingISize +
boxSizingToMarginEdgeISize);
} }
} }

View file

@ -220,14 +220,6 @@ struct SizeComputationInput {
* sizes. * sizes.
*/ */
template <typename SizeOrMaxSize> template <typename SizeOrMaxSize>
inline nscoord ComputeISizeValue(const WritingMode aWM,
const LogicalSize& aContainingBlockSize,
const LogicalSize& aContentEdgeToBoxSizing,
nscoord aBoxSizingToMarginEdge,
const SizeOrMaxSize&) const;
// same as previous, but using mComputedBorderPadding, mComputedPadding,
// and mComputedMargin
template <typename SizeOrMaxSize>
inline nscoord ComputeISizeValue(const LogicalSize& aContainingBlockSize, inline nscoord ComputeISizeValue(const LogicalSize& aContainingBlockSize,
mozilla::StyleBoxSizing aBoxSizing, mozilla::StyleBoxSizing aBoxSizing,
const SizeOrMaxSize&) const; const SizeOrMaxSize&) const;