Backed out 8 changesets (bug 1686603) for causing crashtest failures. CLOSED TREE

Backed out changeset 94b5d0986d27 (bug 1686603)
Backed out changeset e7edf6fcc41d (bug 1686603)
Backed out changeset 4c9271f07178 (bug 1686603)
Backed out changeset 7013b95266ae (bug 1686603)
Backed out changeset cf7a55638aef (bug 1686603)
Backed out changeset 7717a0f2a37b (bug 1686603)
Backed out changeset c82593b13a61 (bug 1686603)
Backed out changeset fd1d95a1e706 (bug 1686603)
This commit is contained in:
Csoregi Natalia 2021-01-26 04:32:13 +02:00
parent a99af52366
commit 0492d8333a
51 changed files with 484 additions and 414 deletions

View File

@ -67,8 +67,7 @@ nscoord nsCheckboxRadioFrame::GetPrefISize(gfxContext* aRenderingContext) {
LogicalSize nsCheckboxRadioFrame::ComputeAutoSize(
gfxContext* aRC, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
LogicalSize size(aWM, 0, 0);
if (!StyleDisplay()->HasAppearance()) {
return size;
@ -76,8 +75,7 @@ LogicalSize nsCheckboxRadioFrame::ComputeAutoSize(
// Note: this call always set the BSize to NS_UNCONSTRAINEDSIZE.
size = nsAtomicContainerFrame::ComputeAutoSize(
aRC, aWM, aCBSize, aAvailableISize, aMargin, aBorderPadding,
aSizeOverrides, aFlags);
aRC, aWM, aCBSize, aAvailableISize, aMargin, aBorderPadding, aFlags);
size.BSize(aWM) = DefaultSize();
return size;
}

View File

@ -48,12 +48,11 @@ class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
/**
* Our auto size is just intrinsic width and intrinsic height.
*/
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
/**

View File

@ -187,8 +187,7 @@ nsresult nsMeterFrame::AttributeChanged(int32_t aNameSpaceID,
LogicalSize nsMeterFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
RefPtr<nsFontMetrics> fontMet =
nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f);

View File

@ -53,7 +53,6 @@ class nsMeterFrame final : public nsContainerFrame,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;

View File

@ -204,8 +204,7 @@ nsresult nsProgressFrame::AttributeChanged(int32_t aNameSpaceID,
LogicalSize nsProgressFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
const WritingMode wm = GetWritingMode();
LogicalSize autoSize(wm);
autoSize.BSize(wm) = autoSize.ISize(wm) =

View File

@ -58,7 +58,6 @@ class nsProgressFrame final : public nsContainerFrame,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;

View File

@ -610,8 +610,7 @@ static mozilla::Length OneEm(nsRangeFrame* aFrame) {
LogicalSize nsRangeFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
bool isInlineOriented = IsInlineOriented();
auto em = OneEm(this);

View File

@ -71,12 +71,11 @@ class nsRangeFrame final : public nsContainerFrame,
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) override;
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;

View File

@ -560,32 +560,29 @@ nscoord nsTextControlFrame::GetMinISize(gfxContext* aRenderingContext) {
LogicalSize nsTextControlFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
LogicalSize autoSize = CalcIntrinsicSize(aRenderingContext, aWM, inflation);
// Note: nsContainerFrame::ComputeAutoSize only computes the inline-size (and
// only for 'auto'), the block-size it returns is always NS_UNCONSTRAINEDSIZE.
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: StylePosition()->ISize(aWM);
if (styleISize.IsAuto()) {
const auto& iSizeCoord = StylePosition()->ISize(aWM);
if (iSizeCoord.IsAuto()) {
if (aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) {
// CalcIntrinsicSize isn't aware of grid-item margin-box clamping, so we
// fall back to nsContainerFrame's ComputeAutoSize to handle that.
// XXX maybe a font-inflation issue here? (per the assertion below).
autoSize.ISize(aWM) =
nsContainerFrame::ComputeAutoSize(
aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin,
aBorderPadding, aSizeOverrides, aFlags)
nsContainerFrame::ComputeAutoSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin,
aBorderPadding, aFlags)
.ISize(aWM);
}
#ifdef DEBUG
else {
LogicalSize ancestorAutoSize = nsContainerFrame::ComputeAutoSize(
aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin,
aBorderPadding, aSizeOverrides, aFlags);
aBorderPadding, aFlags);
// Disabled when there's inflation; see comment in GetXULPrefSize.
MOZ_ASSERT(inflation != 1.0f ||
ancestorAutoSize.ISize(aWM) == autoSize.ISize(aWM),

View File

@ -70,7 +70,6 @@ class nsTextControlFrame : public nsContainerFrame,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

View File

@ -621,7 +621,7 @@ static nscoord FloatMarginISize(const ReflowInput& aCBReflowInput,
aCBReflowInput.mRenderingContext, wm, aCBReflowInput.ComputedSize(wm),
aFloatAvailableISize,
aFloatOffsetState.ComputedLogicalMargin(wm).Size(wm),
aFloatOffsetState.ComputedLogicalBorderPadding(wm).Size(wm), {},
aFloatOffsetState.ComputedLogicalBorderPadding(wm).Size(wm),
ComputeSizeFlag::ShrinkWrap);
WritingMode cbwm = aCBReflowInput.GetWritingMode();

View File

@ -156,9 +156,7 @@ ReflowInput::ReflowInput(nsPresContext* aPresContext,
const ReflowInput& aParentReflowInput,
nsIFrame* aFrame, const LogicalSize& aAvailableSpace,
const Maybe<LogicalSize>& aContainingBlockSize,
InitFlags aFlags,
const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aComputeSizeFlags)
InitFlags aFlags, ComputeSizeFlags aComputeSizeFlags)
: SizeComputationInput(aFrame, aParentReflowInput.mRenderingContext),
mParentReflowInput(&aParentReflowInput),
mFloatManager(aParentReflowInput.mFloatManager),
@ -171,7 +169,6 @@ ReflowInput::ReflowInput(nsPresContext* aPresContext,
? aParentReflowInput.mPercentBSizeObserver
: nullptr),
mFlags(aParentReflowInput.mFlags),
mStyleSizeOverrides(aSizeOverrides),
mComputeSizeFlags(aComputeSizeFlags),
mReflowDepth(aParentReflowInput.mReflowDepth + 1),
mAvailableSize(aAvailableSpace) {
@ -752,6 +749,16 @@ void ReflowInput::InitDynamicReflowRoot() {
}
}
nscoord ReflowInput::GetContainingBlockContentISize(
WritingMode aWritingMode) const {
if (!mCBReflowInput) {
return 0;
}
return mCBReflowInput->GetWritingMode().IsOrthogonalTo(aWritingMode)
? mCBReflowInput->ComputedBSize()
: mCBReflowInput->ComputedISize();
}
/* static */
LogicalMargin ReflowInput::ComputeRelativeOffsets(WritingMode aWM,
nsIFrame* aFrame,
@ -1623,7 +1630,7 @@ void ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
cbSize.ConvertTo(wm, cbwm).ISize(wm), // XXX or AvailableISize()?
ComputedLogicalMargin(wm).Size(wm) +
ComputedLogicalOffsets(wm).Size(wm),
ComputedLogicalBorderPadding(wm).Size(wm), {}, mComputeSizeFlags);
ComputedLogicalBorderPadding(wm).Size(wm), mComputeSizeFlags);
ComputedISize() = sizeResult.mLogicalSize.ISize(wm);
ComputedBSize() = sizeResult.mLogicalSize.BSize(wm);
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
@ -2349,11 +2356,10 @@ void ReflowInput::InitConstraints(
cbSize.ISize(wm) = AvailableISize();
}
auto size =
mFrame->ComputeSize(mRenderingContext, wm, cbSize, AvailableISize(),
ComputedLogicalMargin(wm).Size(wm),
ComputedLogicalBorderPadding(wm).Size(wm),
mStyleSizeOverrides, mComputeSizeFlags);
auto size = mFrame->ComputeSize(
mRenderingContext, wm, cbSize, AvailableISize(),
ComputedLogicalMargin(wm).Size(wm),
ComputedLogicalBorderPadding(wm).Size(wm), mComputeSizeFlags);
ComputedISize() = size.mLogicalSize.ISize(wm);
ComputedBSize() = size.mLogicalSize.BSize(wm);

View File

@ -30,20 +30,7 @@ class nsReflowStatus;
namespace mozilla {
enum class LayoutFrameType : uint8_t;
/**
* A set of StyleSizes used as an input parameter to various functions that
* compute sizes like nsIFrame::ComputeSize(). If any of the member fields has a
* value, the function may use the value instead of retrieving it from the
* frame's style.
*
* The logical sizes are assumed to be in the associated frame's writing-mode.
*/
struct StyleSizeOverrides {
Maybe<StyleSize> mStyleISize;
Maybe<StyleSize> mStyleBSize;
};
} // namespace mozilla
}
/**
* @return aValue clamped to [aMinValue, aMaxValue].
@ -525,9 +512,6 @@ struct ReflowInput : public SizeComputationInput {
bool mIsBSizeSetByAspectRatio : 1;
};
Flags mFlags;
mozilla::StyleSizeOverrides mStyleSizeOverrides;
mozilla::ComputeSizeFlags mComputeSizeFlags;
// This value keeps track of how deeply nested a given reflow input
@ -628,8 +612,6 @@ struct ReflowInput : public SizeComputationInput {
* Init() instead.
* @param aFlags A set of flags used for additional boolean parameters (see
* InitFlags above).
* @param aStyleSizeOverrides The style data used to override mFrame's when we
* call nsIFrame::ComputeSize() internally.
* @param aComputeSizeFlags A set of flags used when we call
* nsIFrame::ComputeSize() internally.
*/
@ -639,7 +621,6 @@ struct ReflowInput : public SizeComputationInput {
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize =
mozilla::Nothing(),
InitFlags aFlags = {},
const mozilla::StyleSizeOverrides& aSizeOverrides = {},
mozilla::ComputeSizeFlags aComputeSizeFlags = {});
/**
@ -662,6 +643,13 @@ struct ReflowInput : public SizeComputationInput {
const mozilla::Maybe<mozilla::LogicalMargin>& aPadding =
mozilla::Nothing());
/**
* Find the content isize of our containing block for the given writing mode,
* which need not be the same as the reflow input's mode.
*/
nscoord GetContainingBlockContentISize(
mozilla::WritingMode aWritingMode) const;
/**
* Calculate the used line-height property. The return value will be >= 0.
*/

View File

@ -702,7 +702,7 @@ load 1474768.html
load 1478178.html
load 1483972.html
load 1486457.html
asserts(6) load 1488762-1.html # asserts from integer overflow & bogus sizes
asserts(8) load 1488762-1.html # asserts from integer overflow & bogus sizes
load 1489287.html
load 1489863.html
load 1489770.html
@ -778,7 +778,7 @@ load 1638906.html
load 1640028.html
load 1640051.html
load 1640275.html
pref(layout.accessiblecaret.enabled,true) asserts(16-18) load 1644819.html # bug 1688115
pref(layout.accessiblecaret.enabled,true) load 1644819.html
load 1645549-1.html
load 1648577.html
load 1652618.html

View File

@ -49,8 +49,7 @@ void nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
LogicalSize nsBackdropFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Note that this frame is a child of the viewport frame.
LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
if (aFlags.contains(ComputeSizeFlag::ShrinkWrap)) {

View File

@ -25,12 +25,11 @@ class nsBackdropFrame final : public nsIFrame {
nsIFrame** aProviderFrame) const override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -7411,7 +7411,7 @@ void nsBlockFrame::ReflowOutsideMarker(nsIFrame* aMarkerFrame,
availSize.BSize(markerWM) = NS_UNCONSTRAINEDSIZE;
ReflowInput reflowInput(aState.mPresContext, ri, aMarkerFrame, availSize,
Nothing(), {}, {}, {ComputeSizeFlag::ShrinkWrap});
Nothing(), {}, {ComputeSizeFlag::ShrinkWrap});
nsReflowStatus status;
aMarkerFrame->Reflow(aState.mPresContext, aMetrics, reflowInput, status);

View File

@ -977,8 +977,7 @@ void nsContainerFrame::DoInlineIntrinsicISize(gfxContext* aRenderingContext,
LogicalSize nsContainerFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const StyleSizeOverrides& aSizeOverrides, ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
nscoord availBased =
aAvailableISize - aMargin.ISize(aWM) - aBorderPadding.ISize(aWM);
@ -986,10 +985,16 @@ LogicalSize nsContainerFrame::ComputeAutoSize(
if (aFlags.contains(ComputeSizeFlag::ShrinkWrap) ||
IsFrameOfType(eReplaced)) {
// Only bother computing our 'auto' ISize if the result will be used.
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: StylePosition()->ISize(aWM);
if (styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize)) {
// It'll be used under two scenarios:
// - If our ISize property is itself 'auto'.
// - If we're using flex-basis in place of our ISize property (i.e. we're a
// flex item with our inline axis being the main axis), AND we have
// flex-basis:content.
const nsStylePosition* pos = StylePosition();
if (pos->ISize(aWM).IsAuto() ||
aFlags.contains(ComputeSizeFlag::UseAutoISize) ||
(pos->mFlexBasis.IsContent() && IsFlexItem() &&
nsFlexContainerFrame::IsItemInlineAxisMainAxis(this))) {
result.ISize(aWM) =
ShrinkWidthToFit(aRenderingContext, availBased, aFlags);
}
@ -2385,15 +2390,10 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
gfxContext* aRenderingContext, WritingMode aWM,
const IntrinsicSize& aIntrinsicSize, const AspectRatio& aAspectRatio,
const LogicalSize& aCBSize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
const nsStylePosition* stylePos = StylePosition();
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: stylePos->ISize(aWM);
const auto& styleBSize = aSizeOverrides.mStyleBSize
? *aSizeOverrides.mStyleBSize
: stylePos->BSize(aWM);
const auto* inlineStyleCoord = &stylePos->ISize(aWM);
const auto* blockStyleCoord = &stylePos->BSize(aWM);
auto* parentFrame = GetParent();
const bool isGridItem = IsGridItem();
const bool isFlexItem =
@ -2404,11 +2404,72 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
// flex container's main axis.
LogicalAxis flexMainAxis =
eLogicalAxisInline; // (init to make valgrind happy)
Maybe<StyleSize> imposedMainSizeStyleCoord;
// If this is a flex item, and we're measuring its cross size after flexing
// to resolve its main size, then we need to use the resolved main size
// that the container provides to us *instead of* the main-size coordinate
// from our style struct. (Otherwise, we'll be using an irrelevant value in
// the aspect-ratio calculations below.)
if (isFlexItem) {
flexMainAxis = nsFlexContainerFrame::IsItemInlineAxisMainAxis(this)
? eLogicalAxisInline
: eLogicalAxisBlock;
// If FlexItemMainSizeOverride frame-property is set, then that means the
// flex container is imposing a main-size on this flex item for it to use
// as its size in the container's main axis.
bool didImposeMainSize;
nscoord imposedMainSize =
GetProperty(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize);
if (didImposeMainSize) {
imposedMainSizeStyleCoord = Some(StyleSize::LengthPercentage(
LengthPercentage::FromAppUnits(imposedMainSize)));
if (flexMainAxis == eLogicalAxisInline) {
inlineStyleCoord = imposedMainSizeStyleCoord.ptr();
} else {
blockStyleCoord = imposedMainSizeStyleCoord.ptr();
}
} else {
// Flex items use their "flex-basis" property in place of their main-size
// property (e.g. "width") for sizing purposes, *unless* they have
// "flex-basis:auto", in which case they use their main-size property
// after all.
// NOTE: The logic here should match the similar chunk for updating
// mainAxisCoord in nsIFrame::ComputeSize() (aside from using a different
// dummy value in the IsUsedFlexBasisContent() case).
const auto* flexBasis = &stylePos->mFlexBasis;
auto& mainAxisCoord =
(flexMainAxis == eLogicalAxisInline ? inlineStyleCoord
: blockStyleCoord);
if (nsFlexContainerFrame::IsUsedFlexBasisContent(*flexBasis,
*mainAxisCoord)) {
// If we get here, we're resolving the flex base size for a flex item,
// and we fall into the flexbox spec section 9.2 step 3, substep C (if
// we have a definite cross size) or E (if not). And specifically:
//
// * If we have a definite cross size, we're supposed to resolve our
// main-size based on that and our intrinsic ratio.
// * Otherwise, we're supposed to produce our max-content size.
//
// Conveniently, we can handle both of those scenarios (regardless of
// which substep we fall into) by using the 'auto' keyword for our
// main-axis coordinate here. (This makes sense, because the spec is
// effectively trying to produce the 'auto' sizing behavior).
static const StyleSize autoSize(StyleSize::Auto());
mainAxisCoord = &autoSize;
} else if (flexBasis->IsSize() && !flexBasis->IsAuto()) {
// For all other non-'auto' flex-basis values, we just swap in the
// flex-basis itself for the main-size property.
mainAxisCoord = &flexBasis->AsSize();
} else {
MOZ_ASSERT(flexBasis->IsAuto());
// else: flex-basis is 'auto', which is deferring to some explicit
// value in mainAxisCoord. So we proceed w/o touching mainAxisCoord.
}
}
}
// Handle intrinsic sizes and their interaction with
@ -2419,10 +2480,10 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
// a * (b / c) because of its reduced accuracy relative to a * b / c
// or (a * b) / c (which are equivalent).
const bool isAutoISize =
styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize);
const bool isAutoISize = inlineStyleCoord->IsAuto() ||
aFlags.contains(ComputeSizeFlag::UseAutoISize);
const bool isAutoBSize =
nsLayoutUtils::IsAutoBSize(styleBSize, aCBSize.BSize(aWM)) ||
nsLayoutUtils::IsAutoBSize(*blockStyleCoord, aCBSize.BSize(aWM)) ||
aFlags.contains(ComputeSizeFlag::UseAutoBSize);
const auto boxSizingAdjust = stylePos->mBoxSizing == StyleBoxSizing::Border
@ -2463,9 +2524,10 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
nscoord intrinsicBSize = std::max(0, bsizeCoord.valueOr(0));
if (!isAutoISize) {
iSize = ComputeISizeValue(aRenderingContext, aWM, aCBSize, boxSizingAdjust,
boxSizingToMarginEdgeISize, styleISize, aFlags)
.mISize;
iSize =
ComputeISizeValue(aRenderingContext, aWM, aCBSize, boxSizingAdjust,
boxSizingToMarginEdgeISize, *inlineStyleCoord, aFlags)
.mISize;
} else if (MOZ_UNLIKELY(isGridItem) &&
!parentFrame->IsMasonry(isOrthogonal ? eLogicalAxisBlock
: eLogicalAxisInline)) {
@ -2526,9 +2588,9 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
}
if (!isAutoBSize) {
bSize = nsLayoutUtils::ComputeBSizeValue(aCBSize.BSize(aWM),
boxSizingAdjust.BSize(aWM),
styleBSize.AsLengthPercentage());
bSize = nsLayoutUtils::ComputeBSizeValue(
aCBSize.BSize(aWM), boxSizingAdjust.BSize(aWM),
blockStyleCoord->AsLengthPercentage());
} else if (MOZ_UNLIKELY(isGridItem) &&
!parentFrame->IsMasonry(isOrthogonal ? eLogicalAxisInline
: eLogicalAxisBlock)) {

View File

@ -225,7 +225,6 @@ class nsContainerFrame : public nsSplittableFrame {
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
/**
@ -873,7 +872,6 @@ class nsContainerFrame : public nsSplittableFrame {
const mozilla::AspectRatio& aAspectRatio,
const mozilla::LogicalSize& aCBSize, const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags);
// Compute tight bounds assuming this frame honours its border, background

View File

@ -129,8 +129,7 @@ nscoord nsFirstLetterFrame::GetPrefISize(gfxContext* aRenderingContext) {
nsIFrame::SizeComputationResult nsFirstLetterFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
if (GetPrevInFlow()) {
// We're wrapping the text *after* the first letter, so behave like an
// inline frame.
@ -139,7 +138,7 @@ nsIFrame::SizeComputationResult nsFirstLetterFrame::ComputeSize(
}
return nsContainerFrame::ComputeSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin, aBorderPadding,
aSizeOverrides, aFlags);
aFlags);
}
void nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,

View File

@ -47,13 +47,13 @@ class nsFirstLetterFrame final : public nsContainerFrame {
virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
InlinePrefISizeData* aData) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -182,10 +182,16 @@ static inline bool IsAutoOrEnumOnBSize(const StyleSize& aSize, bool aIsInline) {
// these macros can be used to ensure that only the needed expression is
// evaluated.
#define GET_MAIN_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_) \
(axisTracker_).IsInlineAxisMainAxis((wm_)) ? (isize_) : (bsize_)
wm_.IsOrthogonalTo((axisTracker_).GetWritingMode()) != \
(axisTracker_).IsRowOriented() \
? (isize_) \
: (bsize_)
#define GET_CROSS_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_) \
(axisTracker_).IsInlineAxisMainAxis((wm_)) ? (bsize_) : (isize_)
wm_.IsOrthogonalTo((axisTracker_).GetWritingMode()) != \
(axisTracker_).IsRowOriented() \
? (bsize_) \
: (isize_)
// Encapsulates our flex container's main & cross axes. This class is backed by
// a FlexboxAxisInfo helper member variable, and it adds some convenience APIs
@ -315,16 +321,6 @@ class MOZ_STACK_CLASS nsFlexContainerFrame::FlexboxAxisTracker {
return IsRowOriented() != mWM.IsVertical();
}
// Returns true if this flex item's inline axis in aItemWM is parallel (or
// antiparallel) to the container's main axis. Returns false, otherwise.
//
// Note: this is a helper for implementing macros and can also be used before
// constructing FlexItem. Inside of flex reflow code,
// FlexItem::IsInlineAxisMainAxis() is equivalent & more optimal.
bool IsInlineAxisMainAxis(WritingMode aItemWM) const {
return IsRowOriented() != GetWritingMode().IsOrthogonalTo(aItemWM);
}
// Delete copy-constructor & reassignment operator, to prevent accidental
// (unnecessary) copying.
FlexboxAxisTracker(const FlexboxAxisTracker&) = delete;
@ -422,27 +418,6 @@ class nsFlexContainerFrame::FlexItem final {
return mCrossSize + MarginBorderPaddingSizeInCrossAxis();
}
// Convenience methods to synthesize a style main size or a style cross size
// with box-size considered, to provide the size overrides when constructing
// ReflowInput for flex items.
StyleSize StyleMainSize() const {
nscoord mainSize = MainSize();
if (Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) {
mainSize += BorderPaddingSizeInMainAxis();
}
return StyleSize::LengthPercentage(
LengthPercentage::FromAppUnits(mainSize));
}
StyleSize StyleCrossSize() const {
nscoord crossSize = CrossSize();
if (Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) {
crossSize += BorderPaddingSizeInCrossAxis();
}
return StyleSize::LengthPercentage(
LengthPercentage::FromAppUnits(crossSize));
}
// Returns the distance between this FlexItem's baseline and the cross-start
// edge of its margin-box. Used in baseline alignment.
//
@ -1308,61 +1283,12 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
FlexLine& aLine, nsIFrame* aChildFrame,
const ReflowInput& aParentReflowInput,
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis) {
const auto flexWM = aAxisTracker.GetWritingMode();
const auto childWM = aChildFrame->GetWritingMode();
const auto* stylePos = aChildFrame->StylePosition();
// Construct a StyleSizeOverrides for this flex item so that its ReflowInput
// below will use and resolve its flex base size rather than its corresponding
// preferred main size property (only for modern CSS flexbox).
StyleSizeOverrides sizeOverrides;
if (!IsLegacyBox(this)) {
Maybe<StyleSize> styleFlexBaseSize;
// When resolving flex base size, flex items use their 'flex-basis' property
// in place of their preferred main size (e.g. 'width') for sizing purposes,
// *unless* they have 'flex-basis:auto' in which case they use their
// preferred main size after all.
const auto& flexBasis = stylePos->mFlexBasis;
const auto& styleMainSize = stylePos->Size(aAxisTracker.MainAxis(), flexWM);
if (IsUsedFlexBasisContent(flexBasis, styleMainSize)) {
// If we get here, we're resolving the flex base size for a flex item, and
// we fall into the flexbox spec section 9.2 step 3, substep C (if we have
// a definite cross size) or E (if not).
if (aChildFrame->GetAspectRatio()) {
// FIXME: This is a workaround. Once bug 1670151 is fixed, aspect-ratio
// will be considered when resolving flex item's flex base size with the
// value 'max-content'.
styleFlexBaseSize.emplace(StyleSize::Auto());
} else {
styleFlexBaseSize.emplace(
StyleSize::ExtremumLength(StyleExtremumLength::MaxContent));
}
} else if (flexBasis.IsSize() && !flexBasis.IsAuto()) {
// For all other non-'auto' flex-basis values, we just swap in the
// flex-basis itself for the preferred main-size property.
styleFlexBaseSize.emplace(flexBasis.AsSize());
} else {
// else: flex-basis is 'auto', which is deferring to some explicit value
// in the preferred main size, so we proceed without emplacing
// styleFlexBaseSize.
MOZ_ASSERT(flexBasis.IsAuto());
}
// Provide the size override for the preferred main size property.
if (aAxisTracker.IsInlineAxisMainAxis(childWM)) {
sizeOverrides.mStyleISize = std::move(styleFlexBaseSize);
} else {
sizeOverrides.mStyleBSize = std::move(styleFlexBaseSize);
}
}
// Create temporary reflow input just for sizing -- to get hypothetical
// main-size and the computed values of min / max main-size property.
// (This reflow input will _not_ be used for reflow.)
ReflowInput childRI(PresContext(), aParentReflowInput, aChildFrame,
aParentReflowInput.ComputedSize(childWM), Nothing(), {},
sizeOverrides);
ReflowInput childRI(
PresContext(), aParentReflowInput, aChildFrame,
aParentReflowInput.ComputedSize(aChildFrame->GetWritingMode()));
childRI.mFlags.mInsideLineClamp = GetLineClampValue() != 0;
// FLEX GROW & SHRINK WEIGHTS
@ -1376,10 +1302,14 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
flexGrow = flexShrink = aChildFrame->StyleXUL()->mBoxFlex;
}
} else {
const nsStylePosition* stylePos = aChildFrame->StylePosition();
flexGrow = stylePos->mFlexGrow;
flexShrink = stylePos->mFlexShrink;
}
const auto childWM = childRI.GetWritingMode();
const auto flexWM = aAxisTracker.GetWritingMode();
// MAIN SIZES (flex base size, min/max size)
// -----------------------------------------
nscoord flexBaseSize = GET_MAIN_COMPONENT_LOGICAL(
@ -1667,7 +1597,7 @@ void nsFlexContainerFrame::ResolveAutoFlexBasisAndMinSize(
aItemReflowInput.mContainingBlockSize, availISize,
aItemReflowInput.ComputedLogicalMargin(itemWM).Size(itemWM),
aItemReflowInput.ComputedLogicalBorderPadding(itemWM).Size(itemWM),
{}, {ComputeSizeFlag::UseAutoISize, ComputeSizeFlag::ShrinkWrap});
{ComputeSizeFlag::UseAutoISize, ComputeSizeFlag::ShrinkWrap});
contentSizeSuggestion = aAxisTracker.MainComponent(
sizeInItemWM.mLogicalSize.ConvertTo(cbWM, itemWM));
@ -2054,7 +1984,8 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput, float aFlexGrow,
mCrossMinSize(aCrossMinSize),
mCrossMaxSize(aCrossMaxSize),
mCrossSize(aTentativeCrossSize),
mIsInlineAxisMainAxis(aAxisTracker.IsInlineAxisMainAxis(mWM))
mIsInlineAxisMainAxis(aAxisTracker.IsRowOriented() !=
aAxisTracker.GetWritingMode().IsOrthogonalTo(mWM))
// mNeedsMinSizeAutoResolution is initialized in CheckForMinSizeAuto()
// mAlignSelf, mHasAnyAutoMargin see below
{
@ -4656,6 +4587,45 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
}
}
// Class to let us temporarily provide an override value for the the main-size
// CSS property ('width' or 'height') on a flex item, for use in
// nsContainerFrame::ComputeSizeWithIntrinsicDimensions (and
// nsIFrame::ComputeSize, for items with 'aspect-ratio's).
// (We could use this overridden size more broadly, too, but it's probably
// better to avoid property-table accesses. So, where possible, we communicate
// the resolved main-size to the child via modifying its reflow input directly,
// instead of using this class.)
class MOZ_RAII AutoFlexItemMainSizeOverride final {
public:
explicit AutoFlexItemMainSizeOverride(FlexItem& aItem)
: mItemFrame(aItem.Frame()) {
MOZ_ASSERT(!mItemFrame->HasProperty(nsIFrame::FlexItemMainSizeOverride()),
"FlexItemMainSizeOverride prop shouldn't be set already; "
"it should only be set temporarily (& not recursively)");
NS_ASSERTION(aItem.HasAspectRatio(),
"This should only be needed for items with an aspect ratio");
nscoord mainSizeOverrideVal = aItem.MainSize();
// Note: aItem.MainSize() is the item's *content-box* main-size. If we
// have 'box-sizing: border-box', then we have to add our main-axis border
// and padding in order to produce an appopriate "override" value that
// gets us the content-box size that we expect.
if (aItem.Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) {
mainSizeOverrideVal += aItem.BorderPaddingSizeInMainAxis();
}
mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(),
mainSizeOverrideVal);
}
~AutoFlexItemMainSizeOverride() {
mItemFrame->RemoveProperty(nsIFrame::FlexItemMainSizeOverride());
}
private:
nsIFrame* mItemFrame;
};
void nsFlexContainerFrame::CalculatePackingSpace(
uint32_t aNumThingsToPack, const StyleContentDistribution& aAlignVal,
nscoord* aFirstSubjectOffset, uint32_t* aNumPackingSpacesRemaining,
@ -5005,21 +4975,35 @@ void nsFlexContainerFrame::DoFlexLayout(
// The item may already have the correct cross-size; only recalculate
// if the item's main size resolution (flexing) could have influenced it:
if (item.CanMainSizeInfluenceCrossSize()) {
StyleSizeOverrides sizeOverrides;
if (item.IsInlineAxisMainAxis()) {
sizeOverrides.mStyleISize.emplace(item.StyleMainSize());
} else {
sizeOverrides.mStyleBSize.emplace(item.StyleMainSize());
Maybe<AutoFlexItemMainSizeOverride> sizeOverride;
if (item.HasAspectRatio()) {
// For flex items with an aspect ratio, we have to impose an override
// for the main-size property *before* we even instantiate the reflow
// input, in order for aspect ratio calculations to produce the right
// cross size in the reflow input. (For other flex items, it's OK
// (and cheaper) to impose our main size *after* the reflow input has
// been constructed, since the main size shouldn't influence anything
// about cross-size measurement until we actually reflow the child.)
sizeOverride.emplace(item);
}
const WritingMode wm = item.GetWritingMode();
WritingMode wm = item.Frame()->GetWritingMode();
LogicalSize availSize = aReflowInput.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput childReflowInput(PresContext(), aReflowInput, item.Frame(),
availSize, Nothing(), {}, sizeOverrides);
availSize);
childReflowInput.mFlags.mInsideLineClamp = GetLineClampValue() != 0;
if (item.IsBlockAxisMainAxis() && item.TreatBSizeAsIndefinite()) {
childReflowInput.mFlags.mTreatBSizeAsIndefinite = true;
if (!sizeOverride) {
// Directly override the computed main-size, by tweaking reflow input:
if (item.IsInlineAxisMainAxis()) {
childReflowInput.SetComputedISize(item.MainSize());
} else {
childReflowInput.SetComputedBSize(item.MainSize());
childReflowInput.mFlags.mIsBSizeSetByAspectRatio = false;
if (item.TreatBSizeAsIndefinite()) {
childReflowInput.mFlags.mTreatBSizeAsIndefinite = true;
}
}
}
SizeItemInCrossAxis(childReflowInput, item);
@ -5433,32 +5417,8 @@ nsReflowStatus nsFlexContainerFrame::ReflowFlexItem(
const LogicalSize& aAvailableSize, const nsSize& aContainerSize,
bool aHasLineClampEllipsis) {
WritingMode outerWM = aReflowInput.GetWritingMode();
StyleSizeOverrides sizeOverrides;
// Override flex item's main size.
if (aItem.IsInlineAxisMainAxis()) {
sizeOverrides.mStyleISize.emplace(aItem.StyleMainSize());
} else {
sizeOverrides.mStyleBSize.emplace(aItem.StyleMainSize());
}
// Override flex item's cross size if it was stretched in the cross axis (in
// which case we're imposing a cross size).
if (aItem.IsStretched()) {
if (aItem.IsInlineAxisCrossAxis()) {
sizeOverrides.mStyleISize.emplace(aItem.StyleCrossSize());
} else {
sizeOverrides.mStyleBSize.emplace(aItem.StyleCrossSize());
}
}
if (sizeOverrides.mStyleBSize && aItem.HadMeasuringReflow()) {
// Because we are overriding the block-size, *and* we had an earlier
// "measuring" reflow, then this upcoming reflow needs to be treated as a
// resize. This sets relevant flags in ReflowInput::InitResizeFlags().
aItem.Frame()->SetHasBSizeChange(true);
}
ReflowInput childReflowInput(PresContext(), aReflowInput, aItem.Frame(),
aAvailableSize, Nothing(), {}, sizeOverrides);
aAvailableSize);
childReflowInput.mFlags.mInsideLineClamp = GetLineClampValue() != 0;
// This is the final reflow of this flex item; if we previously had a
// -webkit-line-clamp, and we missed our chance to clear the ellipsis
@ -5467,10 +5427,47 @@ nsReflowStatus nsFlexContainerFrame::ReflowFlexItem(
childReflowInput.mFlags.mApplyLineClamp =
!childReflowInput.mFlags.mInsideLineClamp && aHasLineClampEllipsis;
if (aItem.TreatBSizeAsIndefinite() && aItem.IsBlockAxisMainAxis()) {
childReflowInput.mFlags.mTreatBSizeAsIndefinite = true;
// Keep track of whether we've overriden the child's computed ISize
// and/or BSize, so we can set its resize flags accordingly.
bool didOverrideComputedISize = false;
bool didOverrideComputedBSize = false;
// Override computed main-size
if (aItem.IsInlineAxisMainAxis()) {
childReflowInput.SetComputedISize(aItem.MainSize());
didOverrideComputedISize = true;
} else {
childReflowInput.SetComputedBSize(aItem.MainSize());
childReflowInput.mFlags.mIsBSizeSetByAspectRatio = false;
didOverrideComputedBSize = true;
if (aItem.TreatBSizeAsIndefinite()) {
childReflowInput.mFlags.mTreatBSizeAsIndefinite = true;
}
}
// Override reflow input's computed cross-size if either:
// - the item was stretched (in which case we're imposing a cross size)
// ...or...
// - the item it has an aspect ratio (in which case the cross-size that's
// currently in the reflow input is based on arithmetic involving a stale
// main-size value that we just stomped on above). (Note that we could handle
// this case using an AutoFlexItemMainSizeOverride, as we do elsewhere; but
// given that we *already know* the correct cross size to use here, it's
// cheaper to just directly set it instead of setting a frame property.)
if (aItem.IsStretched() || aItem.HasAspectRatio()) {
if (aItem.IsInlineAxisCrossAxis()) {
childReflowInput.SetComputedISize(aItem.CrossSize());
didOverrideComputedISize = true;
} else {
// Note that in the above cases we don't need to worry about the BSize
// needing to be treated as indefinite, because this is for cases where
// the block size would always be considered definite (or where its
// definiteness would be irrelevant).
childReflowInput.SetComputedBSize(aItem.CrossSize());
childReflowInput.mFlags.mIsBSizeSetByAspectRatio = false;
didOverrideComputedBSize = true;
}
}
if (aItem.IsStretched() && aItem.IsBlockAxisCrossAxis()) {
// This item is stretched (in the cross axis), and that axis is its block
// axis. That stretching effectively gives it a relative BSize.
@ -5484,6 +5481,22 @@ nsReflowStatus nsFlexContainerFrame::ReflowFlexItem(
aItem.Frame()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
}
// If we're overriding the computed width or height, *and* we had an
// earlier "measuring" reflow, then this upcoming reflow needs to be
// treated as a resize.
if (aItem.HadMeasuringReflow()) {
if (didOverrideComputedISize) {
// (This is somewhat redundant, since ReflowInput::InitResizeFlags()
// already calls SetIResize() whenever our computed ISize has changed
// since the previous reflow. Still, it's nice for symmetry, and it might
// be necessary for some edge cases.)
childReflowInput.SetIResize(true);
}
if (didOverrideComputedBSize) {
childReflowInput.SetBResize(true);
childReflowInput.mFlags.mIsBResizeForPercentages = true;
}
}
// NOTE: Be very careful about doing anything else with childReflowInput
// after this point, because some of its methods (e.g. SetComputedWidth)
// internally call InitResizeFlags and stomp on mVResize & mHResize.

View File

@ -4984,7 +4984,7 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
} else {
aChild->RemoveProperty(nsIFrame::BClampMarginBoxMinSizeProperty());
}
ReflowInput childRI(pc, *rs, aChild, aAvailableSize, Some(aCBSize), {}, {},
ReflowInput childRI(pc, *rs, aChild, aAvailableSize, Some(aCBSize), {},
csFlags);
// Because we pass ComputeSizeFlag::UseAutoBSize, and the
@ -5036,7 +5036,7 @@ static void PostReflowStretchChild(
aChild->RemoveProperty(nsIFrame::BClampMarginBoxMinSizeProperty());
}
ReflowInput ri(pc, aReflowInput, aChild, aAvailableSize, Some(aCBSize), {},
{}, csFlags);
csFlags);
if (aChildAxis == eLogicalAxisBlock) {
ri.SetComputedBSize(ri.ApplyMinMaxBSize(aNewContentBoxSize));
} else {
@ -7245,7 +7245,7 @@ void nsGridContainerFrame::ReflowInFlowChild(
}
LogicalSize percentBasis(cb.Size(wm).ConvertTo(childWM, wm));
ReflowInput childRI(pc, *aState.mReflowInput, aChild, childCBSize,
Some(percentBasis), {}, {}, csFlags);
Some(percentBasis), {}, csFlags);
childRI.mFlags.mIsTopOfPage =
aFragmentainer ? aFragmentainer->mIsTopOfPage : false;

View File

@ -404,11 +404,10 @@ AspectRatio nsHTMLCanvasFrame::GetIntrinsicRatio() const {
nsIFrame::SizeComputationResult nsHTMLCanvasFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWM, GetIntrinsicSize(), GetAspectRatio(),
aCBSize, aMargin, aBorderPadding, aSizeOverrides, aFlags),
aCBSize, aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}

View File

@ -69,13 +69,13 @@ class nsHTMLCanvasFrame final : public nsContainerFrame {
virtual mozilla::IntrinsicSize GetIntrinsicSize() override;
mozilla::AspectRatio GetIntrinsicRatio() const override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -6076,14 +6076,13 @@ static MinMaxSize ComputeTransferredMinMaxInlineSize(
nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
MOZ_ASSERT(!GetIntrinsicRatio(),
"Please override this method and call "
"nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead.");
LogicalSize result =
ComputeAutoSize(aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin,
aBorderPadding, aSizeOverrides, aFlags);
aBorderPadding, aFlags);
const nsStylePosition* stylePos = StylePosition();
const nsStyleDisplay* disp = StyleDisplay();
auto aspectRatioUsage = AspectRatioUsage::None;
@ -6095,12 +6094,8 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
aBorderPadding.ISize(aWM) -
boxSizingAdjust.ISize(aWM);
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: stylePos->ISize(aWM);
const auto& styleBSize = aSizeOverrides.mStyleBSize
? *aSizeOverrides.mStyleBSize
: stylePos->BSize(aWM);
const auto* inlineStyleCoord = &stylePos->ISize(aWM);
const auto* blockStyleCoord = &stylePos->BSize(aWM);
auto parentFrame = GetParent();
auto alignCB = parentFrame;
@ -6127,28 +6122,85 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
// flex container's main axis.
LogicalAxis flexMainAxis =
eLogicalAxisInline; // (init to make valgrind happy)
// The holder of the imposed main size pointer. This is used for adjusting the
// main size of the flex item after we resolve its flexible length.
Maybe<StyleSize> imposedMainSizeStyleCoord;
if (isFlexItem) {
// Flex items use their "flex-basis" property in place of their main-size
// property for sizing purposes, *unless* they have "flex-basis:auto", in
// which case they use their main-size property after all.
flexMainAxis = nsFlexContainerFrame::IsItemInlineAxisMainAxis(this)
? eLogicalAxisInline
: eLogicalAxisBlock;
// NOTE: The logic here should match the similar chunk for updating
// mainAxisCoord in nsContainerFrame::ComputeSizeWithIntrinsicDimensions()
// (aside from using a different dummy value in the IsUsedFlexBasisContent()
// case).
const auto* flexBasis = &stylePos->mFlexBasis;
auto& mainAxisCoord =
(flexMainAxis == eLogicalAxisInline ? inlineStyleCoord
: blockStyleCoord);
// If FlexItemMainSizeOverride frame-property is set, then that means the
// flex container is imposing a main-size on this flex item for it to use
// as its size in the container's main axis.
bool didImposeMainSize;
nscoord imposedMainSize =
GetProperty(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize);
if (didImposeMainSize) {
imposedMainSizeStyleCoord = Some(StyleSize::LengthPercentage(
LengthPercentage::FromAppUnits(imposedMainSize)));
if (flexMainAxis == eLogicalAxisInline) {
inlineStyleCoord = imposedMainSizeStyleCoord.ptr();
} else {
blockStyleCoord = imposedMainSizeStyleCoord.ptr();
}
} else {
// NOTE: If we're a table-wrapper frame, we skip this clause and just
// stick with 'main-size:auto' behavior (which -- unlike 'content' i.e.
// 'max-content' -- will give us the ability to honor percent sizes on our
// table-box child when resolving the flex base size). The flexbox spec
// doesn't call for this special case, but webcompat &
// regression-avoidance seems to require it, for the time being... Tables
// sure are special.
if (nsFlexContainerFrame::IsUsedFlexBasisContent(*flexBasis,
*mainAxisCoord) &&
MOZ_LIKELY(!IsTableWrapperFrame())) {
static const StyleSize maxContStyleCoord(
StyleSize::ExtremumLength(StyleExtremumLength::MaxContent));
mainAxisCoord = &maxContStyleCoord;
// (Note: if our main axis is the block axis, then this 'max-content'
// value will be treated like 'auto', via the IsAutoBSize() call below.)
} else if (flexBasis->IsSize() && !flexBasis->IsAuto()) {
// For all other non-'auto' flex-basis values, we just swap in the
// flex-basis itself for the main-size property.
mainAxisCoord = &flexBasis->AsSize();
} else {
// else: flex-basis is 'auto', or 'content' in a table wrapper frame
// which we ignore. So we proceed w/o touching mainAxisCoord.
}
}
}
const auto aspectRatio = GetAspectRatio();
const bool isOrthogonal = aWM.IsOrthogonalTo(alignCB->GetWritingMode());
const bool isAutoISize =
styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize);
const bool isAutoISize = inlineStyleCoord->IsAuto() ||
aFlags.contains(ComputeSizeFlag::UseAutoISize);
// Compute inline-axis size
if (!isAutoISize) {
auto iSizeResult =
ComputeISizeValue(aRenderingContext, aWM, aCBSize, boxSizingAdjust,
boxSizingToMarginEdgeISize, styleISize, aFlags);
auto iSizeResult = ComputeISizeValue(
aRenderingContext, aWM, aCBSize, boxSizingAdjust,
boxSizingToMarginEdgeISize, *inlineStyleCoord, aFlags);
result.ISize(aWM) = iSizeResult.mISize;
aspectRatioUsage = iSizeResult.mAspectRatioUsage;
} else if (aspectRatio &&
!nsLayoutUtils::IsAutoBSize(styleBSize, aCBSize.BSize(aWM))) {
} else if (aspectRatio && !nsLayoutUtils::IsAutoBSize(*blockStyleCoord,
aCBSize.BSize(aWM))) {
auto bSize = nsLayoutUtils::ComputeBSizeValue(
aCBSize.BSize(aWM), boxSizingAdjust.BSize(aWM),
styleBSize.AsLengthPercentage());
blockStyleCoord->AsLengthPercentage());
result.ISize(aWM) = aspectRatio.ComputeRatioDependentSize(
LogicalAxis::eLogicalAxisInline, aWM, bSize, boxSizingAdjust);
aspectRatioUsage = AspectRatioUsage::ToComputeISize;
@ -6186,7 +6238,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
// aspect ratio is called the ratio-dependent axis, and the resulting size
// is definite if its input sizes are also definite.
const bool isDefiniteISize =
styleISize.IsLengthPercentage() ||
inlineStyleCoord->IsLengthPercentage() ||
aspectRatioUsage == AspectRatioUsage::ToComputeISize;
const bool isFlexItemInlineAxisMainAxis =
isFlexItem && flexMainAxis == eLogicalAxisInline;
@ -6238,7 +6290,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
// This implements "Implied Minimum Size of Grid Items".
// https://drafts.csswg.org/css-grid/#min-size-auto
minISize = std::min(maxISize, GetMinISize(aRenderingContext));
if (styleISize.IsLengthPercentage()) {
if (inlineStyleCoord->IsLengthPercentage()) {
minISize = std::min(minISize, result.ISize(aWM));
} else if (aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) {
// "if the grid item spans only grid tracks that have a fixed max track
@ -6276,17 +6328,17 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
// flag -- then, we'll just stick with the bsize that we already calculated
// in the initial ComputeAutoSize() call.)
if (!aFlags.contains(ComputeSizeFlag::UseAutoBSize)) {
if (!nsLayoutUtils::IsAutoBSize(styleBSize, aCBSize.BSize(aWM))) {
if (!nsLayoutUtils::IsAutoBSize(*blockStyleCoord, aCBSize.BSize(aWM))) {
result.BSize(aWM) = nsLayoutUtils::ComputeBSizeValue(
aCBSize.BSize(aWM), boxSizingAdjust.BSize(aWM),
styleBSize.AsLengthPercentage());
blockStyleCoord->AsLengthPercentage());
} else if (aspectRatio && result.ISize(aWM) != NS_UNCONSTRAINEDSIZE) {
result.BSize(aWM) = aspectRatio.ComputeRatioDependentSize(
LogicalAxis::eLogicalAxisBlock, aWM, result.ISize(aWM),
boxSizingAdjust);
MOZ_ASSERT(aspectRatioUsage == AspectRatioUsage::None);
aspectRatioUsage = AspectRatioUsage::ToComputeBSize;
} else if (MOZ_UNLIKELY(isGridItem) && styleBSize.IsAuto() &&
} else if (MOZ_UNLIKELY(isGridItem) && blockStyleCoord->IsAuto() &&
!IsTrueOverflowContainer() &&
!alignCB->IsMasonry(isOrthogonal ? eLogicalAxisInline
: eLogicalAxisBlock)) {
@ -6379,16 +6431,13 @@ LogicalSize nsIFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const StyleSizeOverrides& aSizeOverrides, ComputeSizeFlags aFlags) {
const mozilla::LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Use basic shrink-wrapping as a default implementation.
LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
// don't bother setting it if the result won't be used
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: StylePosition()->ISize(aWM);
if (styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize)) {
if (StylePosition()->ISize(aWM).IsAuto() ||
aFlags.contains(ComputeSizeFlag::UseAutoISize)) {
nscoord availBased =
aAvailableISize - aMargin.ISize(aWM) - aBorderPadding.ISize(aWM);
result.ISize(aWM) = ShrinkWidthToFit(aRenderingContext, availBased, aFlags);
@ -10633,7 +10682,7 @@ void nsIFrame::BoxReflow(nsBoxLayoutState& aState, nsPresContext* aPresContext,
ComputeSize(
aRenderingContext, wm, logicalSize, logicalSize.ISize(wm),
reflowInput.ComputedLogicalMargin(wm).Size(wm),
reflowInput.ComputedLogicalBorderPadding(wm).Size(wm), {}, {})
reflowInput.ComputedLogicalBorderPadding(wm).Size(wm), {})
.mLogicalSize.Height(wm));
}
}

View File

@ -1380,6 +1380,10 @@ class nsIFrame : public nsQueryFrame {
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(LineBaselineOffset, nscoord)
// Temporary override for a flex item's main-size property (either width
// or height), imposed by its flex container.
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(FlexItemMainSizeOverride, nscoord)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(InvalidationRect, nsRect)
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(RefusedAsyncAnimationProperty, bool)
@ -2737,9 +2741,6 @@ class nsIFrame : public nsQueryFrame {
* @param aBorderPadding The sum of the frame's inline / block border-widths
* and padding (including actual values resulting from
* percentage padding values).
* @param aSizeOverride Optional override values for size properties, which
* this function will use internally instead of the
* actual property values.
* @param aFlags Flags to further customize behavior (definitions in
* LayoutConstants.h).
*
@ -2766,7 +2767,6 @@ class nsIFrame : public nsQueryFrame {
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags);
protected:
@ -2780,21 +2780,15 @@ class nsIFrame : public nsQueryFrame {
* should override only ComputeAutoSize, and frames that cannot do so need to
* override ComputeSize to enforce their inline-size/block-size invariants.
*
* Implementations may optimize by returning a garbage inline-size if
* StylePosition()->ISize() is not 'auto' (or inline-size override in
* aSizeOverrides is not 'auto' if provided), and likewise for BSize(), since
* in such cases the result is guaranteed to be unused.
*
* Most of the frame are not expected to check the aSizeOverrides parameter
* apart from checking the inline size override for 'auto' if they want to
* optimize and return garbage inline-size.
* Implementations may optimize by returning a garbage width if
* StylePosition()->ISize() is not 'auto', and likewise for BSize(), since in
* such cases the result is guaranteed to be unused.
*/
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags);
/**

View File

@ -962,12 +962,11 @@ void nsImageFrame::EnsureIntrinsicSizeAndRatio() {
nsIFrame::SizeComputationResult nsImageFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
EnsureIntrinsicSizeAndRatio();
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWM, mIntrinsicSize, GetAspectRatio(), aCBSize,
aMargin, aBorderPadding, aSizeOverrides, aFlags),
aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}

View File

@ -215,13 +215,13 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
return !HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
}
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) final;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) final;
bool IsServerImageMap();

View File

@ -243,8 +243,7 @@ void nsInlineFrame::AddInlinePrefISize(gfxContext* aRenderingContext,
nsIFrame::SizeComputationResult nsInlineFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Inlines and text don't compute size before reflow.
return {LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
AspectRatioUsage::None};

View File

@ -76,13 +76,13 @@ class nsInlineFrame : public nsContainerFrame {
InlineMinISizeData* aData) override;
virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
InlinePrefISizeData* aData) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -42,8 +42,7 @@ nscoord nsLeafFrame::GetPrefISize(gfxContext* aRenderingContext) {
LogicalSize nsLeafFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
const WritingMode wm = GetWritingMode();
LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
return result.ConvertTo(aWM, wm);

View File

@ -37,12 +37,11 @@ class nsLeafFrame : public nsIFrame {
/**
* Our auto size is just intrinsic width and intrinsic height.
*/
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
/**

View File

@ -251,8 +251,7 @@ bool nsRubyBaseContainerFrame::CanContinueTextRun() const { return true; }
nsIFrame::SizeComputationResult nsRubyBaseContainerFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Ruby base container frame is inline,
// hence don't compute size before reflow.
return {LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),

View File

@ -35,13 +35,13 @@ class nsRubyBaseContainerFrame final : public nsContainerFrame {
InlineMinISizeData* aData) override;
virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
InlinePrefISizeData* aData) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;

View File

@ -671,12 +671,11 @@ AspectRatio nsSubDocumentFrame::GetIntrinsicRatio() const {
LogicalSize nsSubDocumentFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
if (!IsInline()) {
return nsIFrame::ComputeAutoSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin, aBorderPadding,
aSizeOverrides, aFlags);
aFlags);
}
const WritingMode wm = GetWritingMode();
@ -688,11 +687,10 @@ LogicalSize nsSubDocumentFrame::ComputeAutoSize(
nsIFrame::SizeComputationResult nsSubDocumentFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWM, GetIntrinsicSize(), GetAspectRatio(),
aCBSize, aMargin, aBorderPadding, aSizeOverrides, aFlags),
aCBSize, aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}

View File

@ -69,16 +69,15 @@ class nsSubDocumentFrame final : public nsAtomicContainerFrame,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -8676,8 +8676,7 @@ void nsTextFrame::AddInlinePrefISize(gfxContext* aRenderingContext,
nsIFrame::SizeComputationResult nsTextFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Inlines and text don't compute size before reflow.
return {LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
AspectRatioUsage::None};

View File

@ -398,13 +398,13 @@ class nsTextFrame : public nsIFrame {
InlineMinISizeData* aData) override;
void AddInlinePrefISize(gfxContext* aRenderingContext,
InlinePrefISizeData* aData) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) final;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) final;
nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const final;
nsresult GetPrefWidthTightBounds(gfxContext* aContext, nscoord* aX,
nscoord* aXMost) final;

View File

@ -556,17 +556,16 @@ nsresult nsVideoFrame::GetFrameName(nsAString& aResult) const {
nsIFrame::SizeComputationResult nsVideoFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
if (!HasVideoElement()) {
return nsContainerFrame::ComputeSize(
aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin,
aBorderPadding, aSizeOverrides, aFlags);
return nsContainerFrame::ComputeSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin,
aBorderPadding, aFlags);
}
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWM, GetIntrinsicSize(), GetAspectRatio(),
aCBSize, aMargin, aBorderPadding, aSizeOverrides, aFlags),
aCBSize, aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}

View File

@ -57,13 +57,13 @@ class nsVideoFrame final : public nsContainerFrame,
nsSize GetVideoIntrinsicSize() const;
mozilla::IntrinsicSize GetIntrinsicSize() override;
mozilla::AspectRatio GetIntrinsicRatio() const override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
nscoord GetMinISize(gfxContext* aRenderingContext) override;
nscoord GetPrefISize(gfxContext* aRenderingContext) override;
void DestroyFrom(nsIFrame* aDestructRoot,

View File

@ -80,8 +80,7 @@ void nsMathMLSelectedFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame::SizeComputationResult nsMathMLSelectedFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
nsIFrame* childFrame = GetSelectedFrame();
if (childFrame) {
// Delegate size computation to the child frame.
@ -95,8 +94,7 @@ nsIFrame::SizeComputationResult nsMathMLSelectedFrame::ComputeSize(
const auto bpSize = offsetState.ComputedLogicalBorderPadding(aWM).Size(aWM);
auto size = childFrame->ComputeSize(
aRenderingContext, aWM, cbSize, availableISize,
offsetState.ComputedLogicalMargin(aWM).Size(aWM), bpSize,
aSizeOverrides, aFlags);
offsetState.ComputedLogicalMargin(aWM).Size(aWM), bpSize, aFlags);
return {size.mLogicalSize + bpSize, size.mAspectRatioUsage};
}
return {LogicalSize(aWM), AspectRatioUsage::None};

View File

@ -27,13 +27,13 @@ class nsMathMLSelectedFrame : public nsMathMLContainerFrame {
virtual nsresult Place(DrawTarget* aDrawTarget, bool aPlaceOrigin,
ReflowOutput& aDesiredSize) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -291,7 +291,7 @@ nsIFrame::SizeComputationResult SVGOuterSVGFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWritingMode,
const LogicalSize& aCBSize, nscoord aAvailableISize,
const LogicalSize& aMargin, const LogicalSize& aBorderPadding,
const StyleSizeOverrides& aSizeOverrides, ComputeSizeFlags aFlags) {
ComputeSizeFlags aFlags) {
if (IsRootOfImage() || mIsInObjectOrEmbed) {
// The embedding element has sized itself using the CSS replaced element
// sizing rules, using our intrinsic dimensions as necessary. The SVG spec
@ -353,7 +353,7 @@ nsIFrame::SizeComputationResult SVGOuterSVGFrame::ComputeSize(
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWritingMode, intrinsicSize, GetAspectRatio(),
cbSize, aMargin, aBorderPadding, aSizeOverrides, aFlags),
cbSize, aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}

View File

@ -62,12 +62,13 @@ class SVGOuterSVGFrame final : public SVGDisplayContainerFrame,
virtual IntrinsicSize GetIntrinsicSize() override;
AspectRatio GetIntrinsicRatio() const override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, WritingMode aWritingMode,
const LogicalSize& aCBSize, nscoord aAvailableISize,
const LogicalSize& aMargin, const LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
WritingMode aWritingMode,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
const LogicalSize& aMargin,
const LogicalSize& aBorderPadding,
ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -1523,11 +1523,10 @@ nsTableFrame::IntrinsicISizeOffsets(nscoord aPercentageBasis) {
nsIFrame::SizeComputationResult nsTableFrame::ComputeSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
auto result = nsContainerFrame::ComputeSize(
aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin, aBorderPadding,
aSizeOverrides, aFlags);
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
auto result = nsContainerFrame::ComputeSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin,
aBorderPadding, aFlags);
// XXX The code below doesn't make sense if the caller's writing mode
// is orthogonal to this frame's. Not sure yet what should happen then;
@ -1581,8 +1580,7 @@ nscoord nsTableFrame::TableShrinkISizeToFit(gfxContext* aRenderingContext,
LogicalSize nsTableFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Tables always shrink-wrap.
nscoord cbBased =
aAvailableISize - aMargin.ISize(aWM) - aBorderPadding.ISize(aWM);

View File

@ -295,20 +295,19 @@ class nsTableFrame : public nsContainerFrame {
IntrinsicSizeOffsetData IntrinsicISizeOffsets(
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) override;
SizeComputationResult ComputeSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize,
nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
mozilla::ComputeSizeFlags aFlags) override;
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
/**

View File

@ -360,7 +360,7 @@ nscoord nsTableWrapperFrame::GetPrefISize(gfxContext* aRenderingContext) {
nscoord nsTableWrapperFrame::ChildShrinkWrapISize(
gfxContext* aRenderingContext, nsIFrame* aChildFrame, WritingMode aWM,
LogicalSize aCBSize, nscoord aAvailableISize,
const StyleSizeOverrides& aSizeOverrides, nscoord* aMarginResult) const {
nscoord* aMarginResult) const {
AutoMaybeDisableFontInflation an(aChildFrame);
SizeComputationInput offsets(aChildFrame, aRenderingContext, aWM,
@ -384,7 +384,7 @@ nscoord nsTableWrapperFrame::ChildShrinkWrapISize(
auto size =
aChildFrame->ComputeSize(aRenderingContext, aWM, aCBSize, aAvailableISize,
marginSize, bpSize, aSizeOverrides, flags);
marginSize, bpSize, flags);
if (aMarginResult) {
*aMarginResult = offsets.ComputedLogicalMargin(aWM).IStartEnd(aWM);
}
@ -396,8 +396,7 @@ nscoord nsTableWrapperFrame::ChildShrinkWrapISize(
LogicalSize nsTableWrapperFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
nscoord kidAvailableISize = aAvailableISize - aMargin.ISize(aWM);
NS_ASSERTION(aBorderPadding.IsAllZero(),
"Table wrapper frames cannot have borders or paddings");
@ -411,27 +410,24 @@ LogicalSize nsTableWrapperFrame::ComputeAutoSize(
uint8_t captionSide = GetCaptionSide();
nscoord inlineSize;
if (captionSide == NO_SIDE) {
inlineSize =
ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM, aCBSize,
kidAvailableISize, aSizeOverrides);
inlineSize = ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM,
aCBSize, kidAvailableISize);
} else if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
nscoord capISize =
ChildShrinkWrapISize(aRenderingContext, mCaptionFrames.FirstChild(),
aWM, aCBSize, kidAvailableISize, aSizeOverrides);
inlineSize =
capISize +
ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM, aCBSize,
kidAvailableISize - capISize, aSizeOverrides);
aWM, aCBSize, kidAvailableISize);
inlineSize = capISize +
ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM,
aCBSize, kidAvailableISize - capISize);
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
nscoord margin;
inlineSize =
ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM, aCBSize,
kidAvailableISize, aSizeOverrides, &margin);
inlineSize = ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM,
aCBSize, kidAvailableISize, &margin);
nscoord capISize =
ChildShrinkWrapISize(aRenderingContext, mCaptionFrames.FirstChild(),
aWM, aCBSize, inlineSize - margin, aSizeOverrides);
aWM, aCBSize, inlineSize - margin);
if (capISize > inlineSize) {
inlineSize = capISize;
}
@ -439,12 +435,11 @@ LogicalSize nsTableWrapperFrame::ComputeAutoSize(
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE,
"unexpected caption-side");
inlineSize =
ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM, aCBSize,
kidAvailableISize, aSizeOverrides);
inlineSize = ChildShrinkWrapISize(aRenderingContext, InnerTableFrame(), aWM,
aCBSize, kidAvailableISize);
nscoord capISize =
ChildShrinkWrapISize(aRenderingContext, mCaptionFrames.FirstChild(),
aWM, aCBSize, kidAvailableISize, aSizeOverrides);
aWM, aCBSize, kidAvailableISize);
if (capISize > inlineSize) {
inlineSize = capISize;
}

View File

@ -92,12 +92,11 @@ class nsTableWrapperFrame : public nsContainerFrame {
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
/** process a reflow command for the table.
@ -267,12 +266,11 @@ class nsTableWrapperFrame : public nsContainerFrame {
* If aMarginResult is non-null, fill it with the part of the
* margin-isize that was contributed by the margin.
*/
nscoord ChildShrinkWrapISize(
gfxContext* aRenderingContext, nsIFrame* aChildFrame,
mozilla::WritingMode aWM, mozilla::LogicalSize aCBSize,
nscoord aAvailableISize,
const mozilla::StyleSizeOverrides& aSizeOverrides,
nscoord* aMarginResult = nullptr) const;
nscoord ChildShrinkWrapISize(gfxContext* aRenderingContext,
nsIFrame* aChildFrame, mozilla::WritingMode aWM,
mozilla::LogicalSize aCBSize,
nscoord aAvailableISize,
nscoord* aMarginResult = nullptr) const;
private:
nsFrameList mCaptionFrames;

View File

@ -116,12 +116,11 @@ nscoord nsLeafBoxFrame::GetIntrinsicISize() {
LogicalSize nsLeafBoxFrame::ComputeAutoSize(
gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
nscoord aAvailableISize, const LogicalSize& aMargin,
const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
ComputeSizeFlags aFlags) {
const LogicalSize& aBorderPadding, ComputeSizeFlags aFlags) {
// Important: NOT calling our direct superclass here!
return nsIFrame::ComputeAutoSize(aRenderingContext, aWM, aCBSize,
aAvailableISize, aMargin, aBorderPadding,
aSizeOverrides, aFlags);
aFlags);
}
void nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,

View File

@ -44,12 +44,11 @@ class nsLeafBoxFrame : public nsLeafFrame {
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
// Our auto size is that provided by nsFrame, not nsLeafFrame
mozilla::LogicalSize ComputeAutoSize(
virtual mozilla::LogicalSize ComputeAutoSize(
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
const mozilla::LogicalSize& aMargin,
const mozilla::LogicalSize& aBorderPadding,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) override;
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,