Bug 1909761 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert

This patch changes the signature to `GetMinISize()`, `GetPrefISize()`,
`IntrinsicISize` by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing `IntrinsicSizeInput` struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
`IntrinsicSizeInput` for our children.

Differential Revision: https://phabricator.services.mozilla.com/D219521
This commit is contained in:
Ting-Yu Lin 2024-09-03 04:25:41 +00:00
Родитель 409ffc8b8e
Коммит 26a6db6fb1
71 изменённых файлов: 198 добавлений и 166 удалений

Просмотреть файл

@ -2622,10 +2622,11 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsDocumentViewer::GetContentSize(
const nscoord minISize = wm.IsVertical() ? constraints.mMinSize.height
: constraints.mMinSize.width;
const nscoord maxISize = wm.IsVertical() ? aMaxHeight : aMaxWidth;
const IntrinsicSizeInput input(rcx.get());
if (aPrefWidth) {
prefISize = std::max(root->GetMinISize(rcx.get()), aPrefWidth);
prefISize = std::max(root->GetMinISize(input), aPrefWidth);
} else {
prefISize = root->GetPrefISize(rcx.get());
prefISize = root->GetPrefISize(input);
}
prefISize = nsPresContext::RoundUpAppUnitsToCSSPixel(
std::max(minISize, std::min(prefISize, maxISize)));

Просмотреть файл

@ -4308,10 +4308,12 @@ static Maybe<nscoord> GetIntrinsicSize(nsIFrame::ExtremumLength aLength,
nscoord result;
if (aISizeFromAspectRatio) {
result = *aISizeFromAspectRatio;
} else if (aLength == nsIFrame::ExtremumLength::MaxContent) {
result = aFrame->GetPrefISize(aRenderingContext);
} else {
result = aFrame->GetMinISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
auto type = aLength == nsIFrame::ExtremumLength::MaxContent
? IntrinsicISizeType::PrefISize
: IntrinsicISizeType::MinISize;
result = aFrame->IntrinsicISize(input, type);
}
result += aContentBoxToBoxSizingDiff;
@ -4437,8 +4439,9 @@ static nscoord AddIntrinsicSizeOffset(
if (aISizeFromAspectRatio) {
minContent = maxContent = *aISizeFromAspectRatio;
} else {
minContent = aFrame->GetMinISize(aRenderingContext);
maxContent = aFrame->GetPrefISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
minContent = aFrame->GetMinISize(input);
maxContent = aFrame->GetPrefISize(input);
}
minContent += contentBoxToBoxSizingDiff;
maxContent += contentBoxToBoxSizingDiff;
@ -4731,7 +4734,8 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
result = aFrame->BSize();
}
} else {
result = aFrame->IntrinsicISize(aRenderingContext, aType);
const IntrinsicSizeInput input(aRenderingContext);
result = aFrame->IntrinsicISize(input, aType);
}
#ifdef DEBUG_INTRINSIC_WIDTH
--gNoiseIndent;
@ -4863,9 +4867,10 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
}
if (aFrame->IsTableFrame()) {
// Tables can't shrink smaller than their intrinsic minimum width,
// Tables can't shrink smaller than their intrinsic minimum inline size,
// no matter what.
min = aFrame->GetMinISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
min = aFrame->GetMinISize(input);
}
// If we have an aspect-ratio and a definite block size of |aFrame|, we should

Просмотреть файл

@ -43,7 +43,7 @@ void nsCheckboxRadioFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayBorderBackgroundOutline(aBuilder, aLists);
}
nscoord nsCheckboxRadioFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsCheckboxRadioFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return StyleDisplay()->HasAppearance() ? DefaultSize() : 0;
}

Просмотреть файл

@ -25,7 +25,7 @@ class nsCheckboxRadioFrame final : public nsAtomicContainerFrame {
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
mozilla::LogicalSize ComputeAutoSize(

Просмотреть файл

@ -170,7 +170,7 @@ nscoord nsComboboxControlFrame::GetLongestOptionISize(
return maxOptionSize;
}
nscoord nsComboboxControlFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsComboboxControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
Maybe<nscoord> containISize = ContainIntrinsicISize(NS_UNCONSTRAINEDSIZE);
if (containISize && *containISize != NS_UNCONSTRAINEDSIZE) {
@ -179,7 +179,7 @@ nscoord nsComboboxControlFrame::IntrinsicISize(gfxContext* aContext,
nscoord displayISize = 0;
if (!containISize && !StyleContent()->mContent.IsNone()) {
displayISize += GetLongestOptionISize(aContext);
displayISize += GetLongestOptionISize(aInput.mContext);
}
// Add room for the dropmarker button (if there is one).

Просмотреть файл

@ -46,7 +46,7 @@ class nsComboboxControlFrame final : public nsHTMLButtonControlFrame,
mozilla::a11y::AccType AccessibleType() final;
#endif
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
// We're a leaf, so we need to report ourselves as the content insertion

Просмотреть файл

@ -34,11 +34,11 @@ nsDateTimeControlFrame::nsDateTimeControlFrame(ComputedStyle* aStyle,
nsPresContext* aPresContext)
: nsContainerFrame(aStyle, aPresContext, kClassID) {}
nscoord nsDateTimeControlFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsDateTimeControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return mFrames.IsEmpty() ? 0
: nsLayoutUtils::IntrinsicForContainer(
aContext, mFrames.FirstChild(), aType);
aInput.mContext, mFrames.FirstChild(), aType);
}
Maybe<nscoord> nsDateTimeControlFrame::GetNaturalBaselineBOffset(

Просмотреть файл

@ -47,7 +47,7 @@ class nsDateTimeControlFrame final : public nsContainerFrame {
}
#endif
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -321,7 +321,7 @@ ImgDrawResult nsFieldSetFrame::PaintBorder(nsDisplayListBuilder* aBuilder,
return result;
}
nscoord nsFieldSetFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsFieldSetFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// Both inner and legend are children, and if the fieldset is
// size-contained they should not contribute to the intrinsic size.
@ -331,7 +331,8 @@ nscoord nsFieldSetFrame::IntrinsicISize(gfxContext* aContext,
nscoord legendWidth = 0;
if (nsIFrame* legend = GetLegend()) {
legendWidth = nsLayoutUtils::IntrinsicForContainer(aContext, legend, aType);
legendWidth =
nsLayoutUtils::IntrinsicForContainer(aInput.mContext, legend, aType);
}
nscoord contentWidth = 0;
@ -340,7 +341,8 @@ nscoord nsFieldSetFrame::IntrinsicISize(gfxContext* aContext,
// outer instead, and the padding computed for the inner is wrong
// for percentage padding.
contentWidth = nsLayoutUtils::IntrinsicForContainer(
aContext, inner, aType, Nothing(), nsLayoutUtils::IGNORE_PADDING);
aInput.mContext, inner, aType, Nothing(),
nsLayoutUtils::IGNORE_PADDING);
}
return std::max(legendWidth, contentWidth);

Просмотреть файл

@ -24,7 +24,7 @@ class nsFieldSetFrame final : public nsContainerFrame {
explicit nsFieldSetFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -234,13 +234,13 @@ void nsHTMLButtonControlFrame::BuildDisplayList(
DisplaySelectionOverlay(aBuilder, aLists.Content());
}
nscoord nsHTMLButtonControlFrame::IntrinsicISize(gfxContext* aContext,
IntrinsicISizeType aType) {
nscoord nsHTMLButtonControlFrame::IntrinsicISize(
const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) {
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
return *containISize;
}
return nsLayoutUtils::IntrinsicForContainer(aContext, mFrames.FirstChild(),
aType);
return nsLayoutUtils::IntrinsicForContainer(aInput.mContext,
mFrames.FirstChild(), aType);
}
void nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,

Просмотреть файл

@ -27,7 +27,7 @@ class nsHTMLButtonControlFrame : public nsContainerFrame {
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -227,7 +227,7 @@ nscoord nsListControlFrame::CalcBSizeOfARow() {
return rowBSize;
}
nscoord nsListControlFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsListControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// Always add scrollbar inline sizes to the intrinsic isize of the
// scrolled content. Combobox frames depend on this happening in the
@ -238,7 +238,7 @@ nscoord nsListControlFrame::IntrinsicISize(gfxContext* aContext,
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
result = *containISize;
} else {
result = GetScrolledFrame()->IntrinsicISize(aContext, aType);
result = GetScrolledFrame()->IntrinsicISize(aInput, aType);
}
LogicalMargin scrollbarSize(wm, GetDesiredScrollbarSizes());
result = NSCoordSaturatingAdd(result, scrollbarSize.IStartEnd(wm));

Просмотреть файл

@ -53,7 +53,7 @@ class nsListControlFrame final : public mozilla::ScrollContainerFrame,
void SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) final;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -178,7 +178,7 @@ nsresult nsMeterFrame::AttributeChanged(int32_t aNameSpaceID,
return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
}
nscoord nsMeterFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsMeterFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord iSize = OneEmInAppUnits();
if (ResolvedOrientationIsVertical() == GetWritingMode().IsVertical()) {

Просмотреть файл

@ -42,7 +42,7 @@ class nsMeterFrame final : public nsContainerFrame,
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -207,7 +207,7 @@ nsresult nsProgressFrame::AttributeChanged(int32_t aNameSpaceID,
return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
}
nscoord nsProgressFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsProgressFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord iSize = OneEmInAppUnits();
if (ResolvedOrientationIsVertical() == GetWritingMode().IsVertical()) {

Просмотреть файл

@ -49,7 +49,7 @@ class nsProgressFrame final : public nsContainerFrame,
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -624,7 +624,7 @@ nscoord nsRangeFrame::AutoCrossSize() {
NSToCoordRound(OneEmInAppUnits() * CROSS_AXIS_EM_SIZE));
}
nscoord nsRangeFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsRangeFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
if (aType == IntrinsicISizeType::MinISize) {
const auto* pos = StylePosition();

Просмотреть файл

@ -72,7 +72,7 @@ class nsRangeFrame final : public nsContainerFrame,
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -249,8 +249,8 @@ LogicalSize nsTextControlFrame::CalcIntrinsicSize(gfxContext* aRenderingContext,
// Add the inline size of the button if our char size is explicit, so as to
// make sure to make enough space for it.
if (maybeCols.isSome() && mButton && mButton->GetPrimaryFrame()) {
intrinsicSize.ISize(aWM) +=
mButton->GetPrimaryFrame()->GetMinISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
intrinsicSize.ISize(aWM) += mButton->GetPrimaryFrame()->GetMinISize(input);
}
return intrinsicSize;
@ -559,12 +559,12 @@ void nsTextControlFrame::AppendAnonymousContentTo(
aElements.AppendElement(mRootNode);
}
nscoord nsTextControlFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsTextControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// Our min inline size is just our preferred inline-size if we have auto
// inline size.
WritingMode wm = GetWritingMode();
return CalcIntrinsicSize(aContext, wm).ISize(wm);
return CalcIntrinsicSize(aInput.mContext, wm).ISize(wm);
}
Maybe<nscoord> nsTextControlFrame::ComputeBaseline(

Просмотреть файл

@ -60,7 +60,7 @@ class nsTextControlFrame : public nsContainerFrame,
mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -149,22 +149,22 @@ void ColumnSetWrapperFrame::MarkIntrinsicISizesDirty() {
}
}
nscoord ColumnSetWrapperFrame::IntrinsicISize(gfxContext* aContext,
nscoord ColumnSetWrapperFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
if (aType == IntrinsicISizeType::MinISize) {
if (mCachedMinISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
mCachedMinISize = MinISize(aContext);
mCachedMinISize = MinISize(aInput);
}
return mCachedMinISize;
}
if (mCachedPrefISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
mCachedPrefISize = PrefISize(aContext);
mCachedPrefISize = PrefISize(aInput);
}
return mCachedPrefISize;
}
nscoord ColumnSetWrapperFrame::MinISize(gfxContext* aContext) {
nscoord ColumnSetWrapperFrame::MinISize(const IntrinsicSizeInput& aInput) {
nscoord iSize = 0;
if (Maybe<nscoord> containISize =
@ -199,14 +199,15 @@ nscoord ColumnSetWrapperFrame::MinISize(gfxContext* aContext) {
}
} else {
for (nsIFrame* f : PrincipalChildList()) {
iSize = std::max(iSize, f->GetMinISize(aContext));
const IntrinsicSizeInput input(aInput.mContext);
iSize = std::max(iSize, f->GetMinISize(input));
}
}
return iSize;
}
nscoord ColumnSetWrapperFrame::PrefISize(gfxContext* aContext) {
nscoord ColumnSetWrapperFrame::PrefISize(const IntrinsicSizeInput& aInput) {
nscoord iSize = 0;
if (Maybe<nscoord> containISize =
@ -235,7 +236,8 @@ nscoord ColumnSetWrapperFrame::PrefISize(gfxContext* aContext) {
iSize = ColumnUtils::IntrinsicISize(numColumns, colGap, colISize);
} else {
for (nsIFrame* f : PrincipalChildList()) {
iSize = std::max(iSize, f->GetPrefISize(aContext));
const IntrinsicSizeInput input(aInput.mContext);
iSize = std::max(iSize, f->GetPrefISize(input));
}
}

Просмотреть файл

@ -55,7 +55,7 @@ class ColumnSetWrapperFrame final : public nsBlockFrame {
void MarkIntrinsicISizesDirty() override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) override;
Maybe<nscoord> GetNaturalBaselineBOffset(
@ -68,8 +68,8 @@ class ColumnSetWrapperFrame final : public nsBlockFrame {
~ColumnSetWrapperFrame() override = default;
// MinISize() and PrefISize() are helpers to implement IntrinsicISize().
nscoord MinISize(gfxContext* aContext);
nscoord PrefISize(gfxContext* aContext);
nscoord MinISize(const IntrinsicSizeInput& aInput);
nscoord PrefISize(const IntrinsicSizeInput& aInput);
#ifdef DEBUG
static void AssertColumnSpanWrapperSubtreeIsSane(const nsIFrame* aFrame);

Просмотреть файл

@ -56,8 +56,8 @@ void MiddleCroppingBlockFrame::UpdateDisplayedValueToUncroppedValue(
UpdateDisplayedValue(value, /* aIsCropped = */ false, aNotify);
}
nscoord MiddleCroppingBlockFrame::IntrinsicISize(gfxContext* aContext,
IntrinsicISizeType aType) {
nscoord MiddleCroppingBlockFrame::IntrinsicISize(
const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) {
nsAutoString prevValue;
bool restoreOldValue = false;
@ -71,7 +71,7 @@ nscoord MiddleCroppingBlockFrame::IntrinsicISize(gfxContext* aContext,
// Our min inline size is the same as our pref inline size, so we always
// delegate to nsBlockFrame's pref inline size.
nscoord result =
nsBlockFrame::IntrinsicISize(aContext, IntrinsicISizeType::PrefISize);
nsBlockFrame::IntrinsicISize(aInput, IntrinsicISizeType::PrefISize);
if (restoreOldValue) {
UpdateDisplayedValue(prevValue, /* aIsCropped = */ true, false);

Просмотреть файл

@ -34,7 +34,7 @@ class MiddleCroppingBlockFrame : public nsBlockFrame,
void Reflow(nsPresContext*, ReflowOutput&, const ReflowInput&,
nsReflowStatus&) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -1272,7 +1272,7 @@ static bool IsMarqueeScrollbox(const nsIFrame& aScrollFrame) {
return HTMLMarqueeElement::FromNodeOrNull(aScrollFrame.GetContent());
}
nscoord ScrollContainerFrame::IntrinsicISize(gfxContext* aContext,
nscoord ScrollContainerFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord result = [&] {
if (const Maybe<nscoord> containISize = ContainIntrinsicISize()) {
@ -1282,7 +1282,7 @@ nscoord ScrollContainerFrame::IntrinsicISize(gfxContext* aContext,
MOZ_UNLIKELY(IsMarqueeScrollbox(*this))) {
return 0;
}
return mScrolledFrame->IntrinsicISize(aContext, aType);
return mScrolledFrame->IntrinsicISize(aInput, aType);
}();
return NSCoordSaturatingAdd(result,

Просмотреть файл

@ -114,7 +114,7 @@ class ScrollContainerFrame : public nsContainerFrame,
nsIFrame::Sides aSkipSides,
nscoord aRadii[8]) const final;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -269,11 +269,11 @@ void ViewportFrame::RemoveFrame(DestroyContext& aContext, ChildListID aListID,
}
#endif
nscoord ViewportFrame::IntrinsicISize(gfxContext* aContext,
nscoord ViewportFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return mFrames.IsEmpty()
? 0
: mFrames.FirstChild()->IntrinsicISize(aContext, aType);
: mFrames.FirstChild()->IntrinsicISize(aInput, aType);
}
nsPoint ViewportFrame::AdjustReflowInputForScrollbars(

Просмотреть файл

@ -55,7 +55,7 @@ class ViewportFrame : public nsContainerFrame {
nsDisplayWrapList* BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
bool* aIsOpaque = nullptr);
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -807,30 +807,30 @@ bool nsBlockFrame::TextIndentAppliesTo(const LineIterator& aLine) const {
return isFirstLineOrAfterHardBreak != textIndent.hanging;
}
nscoord nsBlockFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsBlockFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nsIFrame* firstCont = FirstContinuation();
if (firstCont != this) {
return firstCont->IntrinsicISize(aContext, aType);
return firstCont->IntrinsicISize(aInput, aType);
}
CheckIntrinsicCacheAgainstShrinkWrapState();
if (aType == IntrinsicISizeType::MinISize) {
if (mCachedMinISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
mCachedMinISize = MinISize(aContext);
mCachedMinISize = MinISize(aInput);
}
return mCachedMinISize;
}
if (mCachedPrefISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
mCachedPrefISize = PrefISize(aContext);
mCachedPrefISize = PrefISize(aInput);
}
return mCachedPrefISize;
}
/* virtual */
nscoord nsBlockFrame::MinISize(gfxContext* aContext) {
nscoord nsBlockFrame::MinISize(const IntrinsicSizeInput& aInput) {
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
return *containISize;
}
@ -872,7 +872,7 @@ nscoord nsBlockFrame::MinISize(gfxContext* aContext) {
if (line->IsBlock()) {
data.ForceBreak();
data.mCurrentLine = nsLayoutUtils::IntrinsicForContainer(
aContext, line->mFirstChild, IntrinsicISizeType::MinISize);
aInput.mContext, line->mFirstChild, IntrinsicISizeType::MinISize);
data.ForceBreak();
} else {
if (!curFrame->GetPrevContinuation() && TextIndentAppliesTo(line)) {
@ -883,7 +883,7 @@ nscoord nsBlockFrame::MinISize(gfxContext* aContext) {
nsIFrame* kid = line->mFirstChild;
for (int32_t i = 0, i_end = line->GetChildCount(); i != i_end;
++i, kid = kid->GetNextSibling()) {
kid->AddInlineMinISize(aContext, &data);
kid->AddInlineMinISize(aInput.mContext, &data);
if (whiteSpaceCanWrap && data.mTrailingWhitespace) {
data.OptionallyBreak();
}
@ -903,7 +903,7 @@ nscoord nsBlockFrame::MinISize(gfxContext* aContext) {
}
/* virtual */
nscoord nsBlockFrame::PrefISize(gfxContext* aContext) {
nscoord nsBlockFrame::PrefISize(const IntrinsicSizeInput& aInput) {
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
return *containISize;
}
@ -949,7 +949,7 @@ nscoord nsBlockFrame::PrefISize(gfxContext* aContext) {
}
data.ForceBreak(clearType);
data.mCurrentLine = nsLayoutUtils::IntrinsicForContainer(
aContext, line->mFirstChild, IntrinsicISizeType::PrefISize);
aInput.mContext, line->mFirstChild, IntrinsicISizeType::PrefISize);
data.ForceBreak();
} else {
if (!curFrame->GetPrevContinuation() && TextIndentAppliesTo(line)) {
@ -965,7 +965,7 @@ nscoord nsBlockFrame::PrefISize(gfxContext* aContext) {
nsIFrame* kid = line->mFirstChild;
for (int32_t i = 0, i_end = line->GetChildCount(); i != i_end;
++i, kid = kid->GetNextSibling()) {
kid->AddInlinePrefISize(aContext, &data);
kid->AddInlinePrefISize(aInput.mContext, &data);
}
}
#ifdef DEBUG

Просмотреть файл

@ -274,11 +274,11 @@ class nsBlockFrame : public nsContainerFrame {
BaselineExportContext aExportContext) const;
// MinISize() and PrefISize() are helpers to implement IntrinsicISize().
nscoord MinISize(gfxContext* aContext);
nscoord PrefISize(gfxContext* aContext);
nscoord MinISize(const mozilla::IntrinsicSizeInput& aInput);
nscoord PrefISize(const mozilla::IntrinsicSizeInput& aInput);
public:
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;

Просмотреть файл

@ -601,11 +601,11 @@ void nsCanvasFrame::PaintFocus(DrawTarget* aDrawTarget, nsPoint aPt) {
text->mColor.ToColor());
}
nscoord nsCanvasFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsCanvasFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return mFrames.IsEmpty()
? 0
: mFrames.FirstChild()->IntrinsicISize(aContext, aType);
: mFrames.FirstChild()->IntrinsicISize(aInput, aType);
}
void nsCanvasFrame::Reflow(nsPresContext* aPresContext,

Просмотреть файл

@ -58,7 +58,7 @@ class nsCanvasFrame final : public nsContainerFrame,
void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override;
#endif
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,

Просмотреть файл

@ -411,17 +411,17 @@ static void MoveChildTo(nsIFrame* aChild, LogicalPoint aOrigin, WritingMode aWM,
nsContainerFrame::PlaceFrameView(aChild);
}
nscoord nsColumnSetFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsColumnSetFrame::IntrinsicISize(const IntrinsicSizeInput& input,
IntrinsicISizeType aType) {
return aType == IntrinsicISizeType::MinISize ? MinISize(aContext)
: PrefISize(aContext);
return aType == IntrinsicISizeType::MinISize ? MinISize(input)
: PrefISize(input);
}
nscoord nsColumnSetFrame::MinISize(gfxContext* aContext) {
nscoord nsColumnSetFrame::MinISize(const IntrinsicSizeInput& aInput) {
nscoord iSize = 0;
if (mFrames.FirstChild()) {
iSize = mFrames.FirstChild()->GetMinISize(aContext);
iSize = mFrames.FirstChild()->GetMinISize(aInput);
}
const nsStyleColumn* colStyle = StyleColumn();
if (colStyle->mColumnWidth.IsLength()) {
@ -446,7 +446,7 @@ nscoord nsColumnSetFrame::MinISize(gfxContext* aContext) {
return iSize;
}
nscoord nsColumnSetFrame::PrefISize(gfxContext* aContext) {
nscoord nsColumnSetFrame::PrefISize(const IntrinsicSizeInput& aInput) {
// Our preferred width is our desired column width, if specified, otherwise
// the child's preferred width, times the number of columns, plus the width
// of any required column gaps
@ -458,7 +458,7 @@ nscoord nsColumnSetFrame::PrefISize(gfxContext* aContext) {
colISize =
ColumnUtils::ClampUsedColumnWidth(colStyle->mColumnWidth.AsLength());
} else if (mFrames.FirstChild()) {
colISize = mFrames.FirstChild()->GetPrefISize(aContext);
colISize = mFrames.FirstChild()->GetPrefISize(aInput);
} else {
colISize = 0;
}

Просмотреть файл

@ -39,7 +39,7 @@ class nsColumnSetFrame final : public nsContainerFrame {
void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override;
#endif
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
nsContainerFrame* GetContentInsertionFrame() override {
@ -198,8 +198,8 @@ class nsColumnSetFrame final : public nsContainerFrame {
const nsPoint& aPt) const;
// MinISize() and PrefISize() are helpers to implement IntrinsicISize().
nscoord MinISize(gfxContext* aContext);
nscoord PrefISize(gfxContext* aContext);
nscoord MinISize(const mozilla::IntrinsicSizeInput& aInput);
nscoord PrefISize(const mozilla::IntrinsicSizeInput& aInput);
};
#endif // nsColumnSetFrame_h___

Просмотреть файл

@ -833,17 +833,18 @@ LogicalSize nsContainerFrame::ComputeAutoSize(
AutoMaybeDisableFontInflation an(this);
WritingMode tableWM = GetParent()->GetWritingMode();
const IntrinsicSizeInput input(aRenderingContext);
if (aWM.IsOrthogonalTo(tableWM)) {
// For an orthogonal caption on a block-dir side of the table, shrink-wrap
// to min-isize.
result.ISize(aWM) = GetMinISize(aRenderingContext);
result.ISize(aWM) = GetMinISize(input);
} else {
// The outer frame constrains our available isize to the isize of
// the table. Grow if our min-isize is bigger than that, but not
// larger than the containing block isize. (It would really be nice
// to transmit that information another way, so we could grow up to
// the table's available isize, but that's harder.)
nscoord min = GetMinISize(aRenderingContext);
nscoord min = GetMinISize(input);
if (min > aCBSize.ISize(aWM)) {
min = aCBSize.ISize(aWM);
}

Просмотреть файл

@ -123,9 +123,9 @@ void nsFirstLetterFrame::AddInlinePrefISize(gfxContext* aRenderingContext,
}
// Needed for floating first-letter frames.
nscoord nsFirstLetterFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsFirstLetterFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return IntrinsicISizeFromInline(aContext, aType);
return IntrinsicISizeFromInline(aInput.mContext, aType);
}
/* virtual */

Просмотреть файл

@ -35,7 +35,7 @@ class nsFirstLetterFrame : public nsContainerFrame {
bool IsFloating() const { return HasAnyStateBits(NS_FRAME_OUT_OF_FLOW); }
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
void AddInlineMinISize(gfxContext* aRenderingContext,

Просмотреть файл

@ -6415,8 +6415,8 @@ void nsFlexContainerFrame::ReflowPlaceholders(
}
}
nscoord nsFlexContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
IntrinsicISizeType aType) {
nscoord nsFlexContainerFrame::ComputeIntrinsicISize(
const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) {
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
return *containISize;
}
@ -6454,8 +6454,8 @@ nscoord nsFlexContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
continue;
}
nscoord childISize =
nsLayoutUtils::IntrinsicForContainer(aContext, childFrame, aType);
nscoord childISize = nsLayoutUtils::IntrinsicForContainer(
aInput.mContext, childFrame, aType);
// * For a row-oriented single-line flex container, the intrinsic
// {min/pref}-isize is the sum of its items' {min/pref}-isizes and
@ -6480,13 +6480,13 @@ nscoord nsFlexContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
return containerISize;
}
nscoord nsFlexContainerFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsFlexContainerFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord& cachedISize = aType == IntrinsicISizeType::MinISize
? mCachedMinISize
: mCachedPrefISize;
if (cachedISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
cachedISize = ComputeIntrinsicISize(aContext, aType);
cachedISize = ComputeIntrinsicISize(aInput, aType);
}
return cachedISize;
}

Просмотреть файл

@ -147,7 +147,7 @@ class nsFlexContainerFrame final : public nsContainerFrame,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
#ifdef DEBUG_FRAME_DUMP
@ -650,7 +650,7 @@ class nsFlexContainerFrame final : public nsContainerFrame,
/**
* Helper to implement IntrinsicISize().
*/
nscoord ComputeIntrinsicISize(gfxContext* aContext,
nscoord ComputeIntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType);
/**

Просмотреть файл

@ -9469,8 +9469,8 @@ void nsGridContainerFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
UpdateSubgridFrameState();
}
nscoord nsGridContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
IntrinsicISizeType aType) {
nscoord nsGridContainerFrame::ComputeIntrinsicISize(
const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) {
if (Maybe<nscoord> containISize = ContainIntrinsicISize()) {
return *containISize;
}
@ -9478,7 +9478,7 @@ nscoord nsGridContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
// Calculate the sum of column sizes under intrinsic sizing.
// https://drafts.csswg.org/css-grid-2/#intrinsic-sizes
NormalizeChildLists();
GridReflowInput state(this, *aContext);
GridReflowInput state(this, *aInput.mContext);
InitImplicitNamedAreas(state.mGridStyle); // XXX optimize
// The min/sz/max sizes are the input to the "repeat-to-fill" algorithm:
@ -9539,18 +9539,18 @@ nscoord nsGridContainerFrame::ComputeIntrinsicISize(gfxContext* aContext,
return last.mPosition + last.mBase;
}
nscoord nsGridContainerFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsGridContainerFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
auto* firstCont = static_cast<nsGridContainerFrame*>(FirstContinuation());
if (firstCont != this) {
return firstCont->IntrinsicISize(aContext, aType);
return firstCont->IntrinsicISize(aInput, aType);
}
nscoord& cachedISize = aType == IntrinsicISizeType::MinISize
? mCachedMinISize
: mCachedPrefISize;
if (cachedISize == NS_INTRINSIC_ISIZE_UNKNOWN) {
cachedISize = ComputeIntrinsicISize(aContext, aType);
cachedISize = ComputeIntrinsicISize(aInput, aType);
}
return cachedISize;
}

Просмотреть файл

@ -119,7 +119,7 @@ class nsGridContainerFrame final : public nsContainerFrame,
nsIFrame* aPrevInFlow) override;
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void MarkIntrinsicISizesDirty() override;
@ -373,7 +373,7 @@ class nsGridContainerFrame final : public nsContainerFrame,
/**
* Helper to implement IntrinsicISize().
*/
nscoord ComputeIntrinsicISize(gfxContext* aContext,
nscoord ComputeIntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType);
nscoord GetBBaseline(BaselineSharingGroup aBaselineGroup) const {

Просмотреть файл

@ -365,7 +365,7 @@ CSSIntSize nsHTMLCanvasFrame::GetCanvasSize() const {
return size;
}
nscoord nsHTMLCanvasFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsHTMLCanvasFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// XXX The caller doesn't account for constraints of the height,
// min-height, and max-height properties.

Просмотреть файл

@ -51,7 +51,7 @@ class nsHTMLCanvasFrame final : public nsContainerFrame {
// Get the size of the canvas's image in CSS pixels.
mozilla::CSSIntSize GetCanvasSize() const;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
virtual mozilla::IntrinsicSize GetIntrinsicSize() override;

Просмотреть файл

@ -6515,6 +6515,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
result.ISize(aWM) = std::min(maxISize, result.ISize(aWM));
}
const IntrinsicSizeInput input(aRenderingContext);
const auto& minISizeCoord = stylePos->MinISize(aWM);
nscoord minISize;
if (!minISizeCoord.IsAuto() && !shouldIgnoreMinMaxISize) {
@ -6526,7 +6527,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
aFlags.contains(ComputeSizeFlag::IApplyAutoMinSize))) {
// This implements "Implied Minimum Size of Grid Items".
// https://drafts.csswg.org/css-grid/#min-size-auto
minISize = std::min(maxISize, GetMinISize(aRenderingContext));
minISize = std::min(maxISize, GetMinISize(input));
if (styleISize.IsLengthPercentage()) {
minISize = std::min(minISize, result.ISize(aWM));
} else if (aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) {
@ -6549,7 +6550,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
"aspect-ratio minimums should not apply to replaced elements");
// The inline size computed by aspect-ratio shouldn't less than the
// min-content size, which should be capped by its maximum inline size.
minISize = std::min(GetMinISize(aRenderingContext), maxISize);
minISize = std::min(GetMinISize(input), maxISize);
} else {
// Treat "min-width: auto" as 0.
// NOTE: Technically, "auto" is supposed to behave like "min-content" on
@ -6710,12 +6711,13 @@ LogicalSize nsIFrame::ComputeAutoSize(
if (styleISize.IsAuto()) {
nscoord availBased =
aAvailableISize - aMargin.ISize(aWM) - aBorderPadding.ISize(aWM);
result.ISize(aWM) = ShrinkISizeToFit(aRenderingContext, availBased, aFlags);
const IntrinsicSizeInput input(aRenderingContext);
result.ISize(aWM) = ShrinkISizeToFit(input, availBased, aFlags);
}
return result;
}
nscoord nsIFrame::ShrinkISizeToFit(gfxContext* aRenderingContext,
nscoord nsIFrame::ShrinkISizeToFit(const IntrinsicSizeInput& aInput,
nscoord aISizeInCB,
ComputeSizeFlags aFlags) {
// If we're a container for font size inflation, then shrink
@ -6723,12 +6725,12 @@ nscoord nsIFrame::ShrinkISizeToFit(gfxContext* aRenderingContext,
AutoMaybeDisableFontInflation an(this);
nscoord result;
nscoord minISize = GetMinISize(aRenderingContext);
nscoord minISize = GetMinISize(aInput);
if (minISize > aISizeInCB) {
const bool clamp = aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize);
result = MOZ_UNLIKELY(clamp) ? aISizeInCB : minISize;
} else {
nscoord prefISize = GetPrefISize(aRenderingContext);
nscoord prefISize = GetPrefISize(aInput);
if (prefISize > aISizeInCB) {
result = aISizeInCB;
} else {
@ -6800,17 +6802,18 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
aAspectRatio));
}();
const IntrinsicSizeInput input(aRenderingContext);
nscoord result;
switch (aSize) {
case ExtremumLength::MaxContent:
result = iSizeFromAspectRatio ? *iSizeFromAspectRatio
: GetPrefISize(aRenderingContext);
result =
iSizeFromAspectRatio ? *iSizeFromAspectRatio : GetPrefISize(input);
NS_ASSERTION(result >= 0, "inline-size less than zero");
return {result, iSizeFromAspectRatio ? AspectRatioUsage::ToComputeISize
: AspectRatioUsage::None};
case ExtremumLength::MinContent:
result = iSizeFromAspectRatio ? *iSizeFromAspectRatio
: GetMinISize(aRenderingContext);
result =
iSizeFromAspectRatio ? *iSizeFromAspectRatio : GetMinISize(input);
NS_ASSERTION(result >= 0, "inline-size less than zero");
if (MOZ_UNLIKELY(
aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize))) {
@ -6827,8 +6830,8 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
// size computed from the block size and the aspect ratio.
pref = min = *iSizeFromAspectRatio;
} else {
pref = GetPrefISize(aRenderingContext);
min = GetMinISize(aRenderingContext);
pref = GetPrefISize(input);
min = GetMinISize(input);
}
const nscoord fill = aAvailableISizeOverride ? *aAvailableISizeOverride

Просмотреть файл

@ -416,6 +416,17 @@ struct FrameBidiData {
mozilla::intl::BidiEmbeddingLevel precedingControl;
};
// A struct aggregates necessary data to compute the intrinsic sizes for a
// frame, used as an input for GetMinISize(), GetPrefISize(), IntrinsicISize(),
// and others.
struct MOZ_STACK_CLASS IntrinsicSizeInput final {
gfxContext* const mContext;
explicit IntrinsicSizeInput(gfxContext* aContext) : mContext(aContext) {
MOZ_ASSERT(mContext);
}
};
} // namespace mozilla
/// Generic destructor for frame properties. Calls delete.
@ -2581,8 +2592,8 @@ class nsIFrame : public nsQueryFrame {
*
* This method must not return a negative value.
*/
nscoord GetMinISize(gfxContext* aContext) {
return IntrinsicISize(aContext, mozilla::IntrinsicISizeType::MinISize);
nscoord GetMinISize(const mozilla::IntrinsicSizeInput& aInput) {
return IntrinsicISize(aInput, mozilla::IntrinsicISizeType::MinISize);
}
/**
@ -2591,8 +2602,8 @@ class nsIFrame : public nsQueryFrame {
*
* Otherwise, all the comments for |GetMinISize| above apply.
*/
nscoord GetPrefISize(gfxContext* aContext) {
return IntrinsicISize(aContext, mozilla::IntrinsicISizeType::PrefISize);
nscoord GetPrefISize(const mozilla::IntrinsicSizeInput& aInput) {
return IntrinsicISize(aInput, mozilla::IntrinsicISizeType::PrefISize);
}
/**
@ -2601,7 +2612,7 @@ class nsIFrame : public nsQueryFrame {
*
* All the comments for GetMinISize() and GetPrefISize() apply.
*/
virtual nscoord IntrinsicISize(gfxContext* aContext,
virtual nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) {
return 0;
}
@ -2895,7 +2906,8 @@ class nsIFrame : public nsQueryFrame {
* Utility function for ComputeAutoSize implementations. Return
* max(GetMinISize(), min(aISizeInCB, GetPrefISize()))
*/
nscoord ShrinkISizeToFit(gfxContext* aRenderingContext, nscoord aISizeInCB,
nscoord ShrinkISizeToFit(const mozilla::IntrinsicSizeInput& aInput,
nscoord aISizeInCB,
mozilla::ComputeSizeFlags aFlags);
/**

Просмотреть файл

@ -1467,7 +1467,7 @@ nscoord nsImageFrame::GetContinuationOffset() const {
return offset;
}
nscoord nsImageFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsImageFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// XXX The caller doesn't account for constraints of the block-size,
// min-block-size, and max-block-size properties.

Просмотреть файл

@ -77,7 +77,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
nsIFrame* aPrevInFlow) override;
void BuildDisplayList(nsDisplayListBuilder*, const nsDisplayListSet&) final;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
mozilla::IntrinsicSize GetIntrinsicSize() final { return mIntrinsicSize; }

Просмотреть файл

@ -22,7 +22,7 @@ void nsLeafFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayBorderBackgroundOutline(aBuilder, aLists);
}
nscoord nsLeafFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsLeafFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return GetIntrinsicSize().ISize(GetWritingMode()).valueOr(0);
}

Просмотреть файл

@ -24,7 +24,7 @@ class nsLeafFrame : public nsIFrame {
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -555,7 +555,7 @@ nsresult nsSubDocumentFrame::GetFrameName(nsAString& aResult) const {
}
#endif
nscoord nsSubDocumentFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsSubDocumentFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// Note: when computing max-content inline size (i.e. when aType is
// IntrinsicISizeType::PrefISize), if the subdocument is an SVG document, then

Просмотреть файл

@ -49,7 +49,7 @@ class nsSubDocumentFrame final : public nsAtomicContainerFrame,
void Destroy(DestroyContext&) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
mozilla::IntrinsicSize GetIntrinsicSize() override;

Просмотреть файл

@ -4402,9 +4402,9 @@ nsIFrame* nsContinuingTextFrame::FirstInFlow() const {
// XXX We really need to make :first-letter happen during frame
// construction.
nscoord nsTextFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsTextFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return IntrinsicISizeFromInline(aContext, aType);
return IntrinsicISizeFromInline(aInput.mContext, aType);
}
//----------------------------------------------------------------------

Просмотреть файл

@ -394,7 +394,7 @@ class nsTextFrame : public nsIFrame {
void MarkIntrinsicISizesDirty() final;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
void AddInlineMinISize(gfxContext* aRenderingContext,

Просмотреть файл

@ -373,7 +373,7 @@ nsIFrame::SizeComputationResult nsVideoFrame::ComputeSize(
AspectRatioUsage::None};
}
nscoord nsVideoFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsVideoFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
// <audio> / <video> has the same min / pref ISize.
return GetIntrinsicSize().ISize(GetWritingMode()).valueOr(0);

Просмотреть файл

@ -59,7 +59,7 @@ class nsVideoFrame : public nsContainerFrame,
const mozilla::StyleSizeOverrides& aSizeOverrides,
mozilla::ComputeSizeFlags aFlags) final;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) final;
void Destroy(DestroyContext&) final;

Просмотреть файл

@ -896,9 +896,9 @@ void nsMathMLContainerFrame::UpdateIntrinsicISize(
}
}
nscoord nsMathMLContainerFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsMathMLContainerFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
UpdateIntrinsicISize(aContext);
UpdateIntrinsicISize(aInput.mContext);
return mIntrinsicISize;
}

Просмотреть файл

@ -72,7 +72,7 @@ class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame {
void RemoveFrame(DestroyContext&, ChildListID aListID,
nsIFrame* aOldFrame) override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
/**

Просмотреть файл

@ -122,7 +122,7 @@ NS_QUERYFRAME_TAIL_INHERITING(SVGDisplayContainerFrame)
//----------------------------------------------------------------------
// nsIFrame methods
nscoord SVGOuterSVGFrame::IntrinsicISize(gfxContext* aContext,
nscoord SVGOuterSVGFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
if (aType == IntrinsicISizeType::MinISize) {
return GetIntrinsicSize().ISize(GetWritingMode()).valueOr(0);

Просмотреть файл

@ -45,7 +45,7 @@ class SVGOuterSVGFrame final : public SVGDisplayContainerFrame,
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS(SVGOuterSVGFrame)
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) override;
IntrinsicSize GetIntrinsicSize() override;

Просмотреть файл

@ -5105,7 +5105,8 @@ void SVGTextFrame::DoReflow() {
kid->MarkIntrinsicISizesDirty();
}
nscoord inlineSize = kid->GetPrefISize(renderingContext.get());
const IntrinsicSizeInput input(renderingContext.get());
nscoord inlineSize = kid->GetPrefISize(input);
WritingMode wm = kid->GetWritingMode();
ReflowInput reflowInput(presContext, kid, renderingContext.get(),
LogicalSize(wm, inlineSize, NS_UNCONSTRAINEDSIZE));

Просмотреть файл

@ -84,8 +84,9 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
// wrapping inside of it should not apply font size inflation.
AutoMaybeDisableFontInflation an(aFrame);
minCoord = aFrame->GetMinISize(aRenderingContext);
prefCoord = aFrame->GetPrefISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
minCoord = aFrame->GetMinISize(input);
prefCoord = aFrame->GetPrefISize(input);
// Until almost the end of this function, minCoord and prefCoord
// represent the box-sizing based isize values (which mean they
// should include inline padding and border width when

Просмотреть файл

@ -596,10 +596,11 @@ ScrollContainerFrame* nsTableCellFrame::GetScrollTargetFrame() const {
return do_QueryFrame(Inner());
}
nscoord nsTableCellFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsTableCellFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
return nsLayoutUtils::IntrinsicForContainer(
aContext, Inner(), aType, Nothing(), nsLayoutUtils::IGNORE_PADDING);
return nsLayoutUtils::IntrinsicForContainer(aInput.mContext, Inner(), aType,
Nothing(),
nsLayoutUtils::IGNORE_PADDING);
}
/* virtual */ nsIFrame::IntrinsicSizeOffsetData

Просмотреть файл

@ -105,7 +105,7 @@ class nsTableCellFrame : public nsContainerFrame,
nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists);
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
IntrinsicSizeOffsetData IntrinsicISizeOffsets(

Просмотреть файл

@ -1345,17 +1345,17 @@ void nsTableFrame::MarkIntrinsicISizesDirty() {
nsContainerFrame::MarkIntrinsicISizesDirty();
}
nscoord nsTableFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsTableFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
if (NeedToCalcBCBorders()) {
CalcBCBorders();
}
ReflowColGroups(aContext);
ReflowColGroups(aInput.mContext);
return aType == IntrinsicISizeType::MinISize
? LayoutStrategy()->GetMinISize(aContext)
: LayoutStrategy()->GetPrefISize(aContext, false);
? LayoutStrategy()->GetMinISize(aInput.mContext)
: LayoutStrategy()->GetPrefISize(aInput.mContext, false);
}
/* virtual */ nsIFrame::IntrinsicSizeOffsetData
@ -1403,7 +1403,8 @@ nsIFrame::SizeComputationResult nsTableFrame::ComputeSize(
AutoMaybeDisableFontInflation an(this);
// Tables never shrink below their min inline-size.
nscoord minISize = GetMinISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
nscoord minISize = GetMinISize(input);
if (minISize > result.mLogicalSize.ISize(aWM)) {
result.mLogicalSize.ISize(aWM) = minISize;
}
@ -1418,7 +1419,8 @@ nscoord nsTableFrame::TableShrinkISizeToFit(gfxContext* aRenderingContext,
AutoMaybeDisableFontInflation an(this);
nscoord result;
nscoord minISize = GetMinISize(aRenderingContext);
const IntrinsicSizeInput input(aRenderingContext);
nscoord minISize = GetMinISize(input);
if (minISize > aISizeInCB) {
result = minISize;
} else {

Просмотреть файл

@ -271,7 +271,7 @@ class nsTableFrame : public nsContainerFrame {
void MarkIntrinsicISizesDirty() override;
// For border-collapse tables, the caller must not add padding and
// border to the results of these functions.
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
IntrinsicSizeOffsetData IntrinsicISizeOffsets(
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) override;

Просмотреть файл

@ -238,15 +238,16 @@ ComputedStyle* nsTableWrapperFrame::GetParentComputedStyle(
return (*aProviderFrame = InnerTableFrame())->Style();
}
nscoord nsTableWrapperFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsTableWrapperFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord iSize =
nsLayoutUtils::IntrinsicForContainer(aContext, InnerTableFrame(), aType);
nscoord iSize = nsLayoutUtils::IntrinsicForContainer(
aInput.mContext, InnerTableFrame(), aType);
if (mCaptionFrames.NotEmpty()) {
// The table wrapper's intrinsic inline size should be as least as large as
// caption's min inline size.
const nscoord capMinISize = nsLayoutUtils::IntrinsicForContainer(
aContext, mCaptionFrames.FirstChild(), IntrinsicISizeType::MinISize);
aInput.mContext, mCaptionFrames.FirstChild(),
IntrinsicISizeType::MinISize);
iSize = std::max(iSize, capMinISize);
}
return iSize;

Просмотреть файл

@ -71,7 +71,7 @@ class nsTableWrapperFrame : public nsContainerFrame {
mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup,
BaselineExportContext aExportContext) const override;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
SizeComputationResult ComputeSize(

Просмотреть файл

@ -458,9 +458,9 @@ void nsMenuPopupFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
PropagateStyleToWidget(flags);
}
nscoord nsMenuPopupFrame::IntrinsicISize(gfxContext* aContext,
nscoord nsMenuPopupFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
IntrinsicISizeType aType) {
nscoord iSize = nsBlockFrame::IntrinsicISize(aContext, aType);
nscoord iSize = nsBlockFrame::IntrinsicISize(aInput, aType);
if (!ShouldExpandToInflowParentOrAnchor()) {
return iSize;
}

Просмотреть файл

@ -165,7 +165,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
mozilla::dom::XULPopupElement& PopupElement() const;
nscoord IntrinsicISize(gfxContext* aContext,
nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput,
mozilla::IntrinsicISizeType aType) override;
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,