diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 3b69bb66749d..e58959970edd 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -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))); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index da155b3a7cb2..956441d2cf58 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4308,10 +4308,12 @@ static Maybe 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 diff --git a/layout/forms/nsCheckboxRadioFrame.cpp b/layout/forms/nsCheckboxRadioFrame.cpp index 646233afcd9f..28da908580c3 100644 --- a/layout/forms/nsCheckboxRadioFrame.cpp +++ b/layout/forms/nsCheckboxRadioFrame.cpp @@ -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; } diff --git a/layout/forms/nsCheckboxRadioFrame.h b/layout/forms/nsCheckboxRadioFrame.h index 4b771b56c4c0..ecb11f1a63fb 100644 --- a/layout/forms/nsCheckboxRadioFrame.h +++ b/layout/forms/nsCheckboxRadioFrame.h @@ -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( diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index d88dbf9d1af8..20219a39db07 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -170,7 +170,7 @@ nscoord nsComboboxControlFrame::GetLongestOptionISize( return maxOptionSize; } -nscoord nsComboboxControlFrame::IntrinsicISize(gfxContext* aContext, +nscoord nsComboboxControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) { Maybe 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). diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 71ea614d761e..e0fed2602959 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -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 diff --git a/layout/forms/nsDateTimeControlFrame.cpp b/layout/forms/nsDateTimeControlFrame.cpp index 98b90d6c4959..a012eba44411 100644 --- a/layout/forms/nsDateTimeControlFrame.cpp +++ b/layout/forms/nsDateTimeControlFrame.cpp @@ -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 nsDateTimeControlFrame::GetNaturalBaselineBOffset( diff --git a/layout/forms/nsDateTimeControlFrame.h b/layout/forms/nsDateTimeControlFrame.h index 08cf9f3b2c29..8aa05f6caf34 100644 --- a/layout/forms/nsDateTimeControlFrame.h +++ b/layout/forms/nsDateTimeControlFrame.h @@ -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, diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 9c243ea73374..26a864f964d4 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -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); diff --git a/layout/forms/nsFieldSetFrame.h b/layout/forms/nsFieldSetFrame.h index c6e6ffee8306..037fe9d46879 100644 --- a/layout/forms/nsFieldSetFrame.h +++ b/layout/forms/nsFieldSetFrame.h @@ -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; /** diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 423baaf16848..524b76ece3de 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -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 containISize = ContainIntrinsicISize()) { return *containISize; } - return nsLayoutUtils::IntrinsicForContainer(aContext, mFrames.FirstChild(), - aType); + return nsLayoutUtils::IntrinsicForContainer(aInput.mContext, + mFrames.FirstChild(), aType); } void nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext, diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index a58f35263e7f..c91026d4445c 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -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, diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index df817ae73622..e20b63263187 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -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 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)); diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 6f5d2177bc95..5b31c342fd6c 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -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, diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index f1bfe2572e18..b4fff77dae3d 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -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()) { diff --git a/layout/forms/nsMeterFrame.h b/layout/forms/nsMeterFrame.h index 3b12b4109a10..2817fcb77d28 100644 --- a/layout/forms/nsMeterFrame.h +++ b/layout/forms/nsMeterFrame.h @@ -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; /** diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index afb40008d987..7e7126d4cb2c 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -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()) { diff --git a/layout/forms/nsProgressFrame.h b/layout/forms/nsProgressFrame.h index 9e71931e0004..b1fbe48c7758 100644 --- a/layout/forms/nsProgressFrame.h +++ b/layout/forms/nsProgressFrame.h @@ -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; /** diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 8e2706fc01f2..343aecc6929f 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -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(); diff --git a/layout/forms/nsRangeFrame.h b/layout/forms/nsRangeFrame.h index cf00058e4990..2008ec321f50 100644 --- a/layout/forms/nsRangeFrame.h +++ b/layout/forms/nsRangeFrame.h @@ -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; /** diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 5fcbeeb2e2df..5900b6fa6f04 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -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 nsTextControlFrame::ComputeBaseline( diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index e45cc5b5cf6f..e0b9af26a67e 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -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, diff --git a/layout/generic/ColumnSetWrapperFrame.cpp b/layout/generic/ColumnSetWrapperFrame.cpp index 6cfeef261d21..71735bcefde6 100644 --- a/layout/generic/ColumnSetWrapperFrame.cpp +++ b/layout/generic/ColumnSetWrapperFrame.cpp @@ -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 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 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)); } } diff --git a/layout/generic/ColumnSetWrapperFrame.h b/layout/generic/ColumnSetWrapperFrame.h index 1b00767adf6d..2481c9d66a22 100644 --- a/layout/generic/ColumnSetWrapperFrame.h +++ b/layout/generic/ColumnSetWrapperFrame.h @@ -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 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); diff --git a/layout/generic/MiddleCroppingBlockFrame.cpp b/layout/generic/MiddleCroppingBlockFrame.cpp index 13be4832b705..514fb9a93a1e 100644 --- a/layout/generic/MiddleCroppingBlockFrame.cpp +++ b/layout/generic/MiddleCroppingBlockFrame.cpp @@ -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); diff --git a/layout/generic/MiddleCroppingBlockFrame.h b/layout/generic/MiddleCroppingBlockFrame.h index e2e05c374929..9438b1753f4f 100644 --- a/layout/generic/MiddleCroppingBlockFrame.h +++ b/layout/generic/MiddleCroppingBlockFrame.h @@ -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; /** diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp index 0dcb12c471bb..bc5ad7dd06bc 100644 --- a/layout/generic/ScrollContainerFrame.cpp +++ b/layout/generic/ScrollContainerFrame.cpp @@ -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 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, diff --git a/layout/generic/ScrollContainerFrame.h b/layout/generic/ScrollContainerFrame.h index dda85464a0ca..5c563de8c992 100644 --- a/layout/generic/ScrollContainerFrame.h +++ b/layout/generic/ScrollContainerFrame.h @@ -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, diff --git a/layout/generic/ViewportFrame.cpp b/layout/generic/ViewportFrame.cpp index 891c1ce7107a..3308e63611a8 100644 --- a/layout/generic/ViewportFrame.cpp +++ b/layout/generic/ViewportFrame.cpp @@ -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( diff --git a/layout/generic/ViewportFrame.h b/layout/generic/ViewportFrame.h index 74e21700c117..9368a466ad95 100644 --- a/layout/generic/ViewportFrame.h +++ b/layout/generic/ViewportFrame.h @@ -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, diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 5038224c86f8..9e9c7dbedacb 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -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 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 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 diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index aed2b15bddd2..ad3e3b9773da 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -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; diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 20e3c6ec1e39..4ab97137a540 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -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, diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index 2a406fc1fd5d..41a1d2a36084 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -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, diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index cf36292902ad..4f8fd0a2142c 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -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; } diff --git a/layout/generic/nsColumnSetFrame.h b/layout/generic/nsColumnSetFrame.h index e8600a288480..149d0cf9f2f5 100644 --- a/layout/generic/nsColumnSetFrame.h +++ b/layout/generic/nsColumnSetFrame.h @@ -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___ diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 3ee1dd555f7c..d6add298577f 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -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); } diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index 02b33e03f4cc..5129af24b8d2 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -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 */ diff --git a/layout/generic/nsFirstLetterFrame.h b/layout/generic/nsFirstLetterFrame.h index 9232abfff844..c848b9a8c780 100644 --- a/layout/generic/nsFirstLetterFrame.h +++ b/layout/generic/nsFirstLetterFrame.h @@ -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, diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 60890131c665..749e72c1e30b 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -6415,8 +6415,8 @@ void nsFlexContainerFrame::ReflowPlaceholders( } } -nscoord nsFlexContainerFrame::ComputeIntrinsicISize(gfxContext* aContext, - IntrinsicISizeType aType) { +nscoord nsFlexContainerFrame::ComputeIntrinsicISize( + const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) { if (Maybe 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; } diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index 553f0a8c895c..0010e6e494d9 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -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); /** diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index e1258fdcbdcc..c69f2c6534b9 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -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 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(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; } diff --git a/layout/generic/nsGridContainerFrame.h b/layout/generic/nsGridContainerFrame.h index 492d9fc800fe..a576ea4f768f 100644 --- a/layout/generic/nsGridContainerFrame.h +++ b/layout/generic/nsGridContainerFrame.h @@ -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 { diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 309b0f321302..857ec7301cf1 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -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. diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index e63bfc543a85..5eada26d7293 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -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; diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 8ff09bb0cc59..babd49c2cdc0 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -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 diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index d8b0b1a946e5..2811edd6d2cf 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -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. @@ -2579,8 +2590,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); } /** @@ -2589,8 +2600,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); } /** @@ -2599,7 +2610,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; } @@ -2893,7 +2904,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); /** diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 5a7d3edc6a0f..bcadde499ded 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -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. diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 31b8fbcdd822..cee68a6bc64c 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -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; } diff --git a/layout/generic/nsLeafFrame.cpp b/layout/generic/nsLeafFrame.cpp index c95c121f394b..ccef723c2d50 100644 --- a/layout/generic/nsLeafFrame.cpp +++ b/layout/generic/nsLeafFrame.cpp @@ -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); } diff --git a/layout/generic/nsLeafFrame.h b/layout/generic/nsLeafFrame.h index bb2b314444f8..426d59e0ba5b 100644 --- a/layout/generic/nsLeafFrame.h +++ b/layout/generic/nsLeafFrame.h @@ -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; /** diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 4c948ce6bdb4..bf43ed499f35 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -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 diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index 07a91d67dc40..7fe5832905bc 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -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; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index ab9ac01cc733..a4f0c5a75b09 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -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); } //---------------------------------------------------------------------- diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index 3307ea94eaac..4f0ecd94dd21 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -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, diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 096b2136d53c..1807355c5f47 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -373,7 +373,7 @@ nsIFrame::SizeComputationResult nsVideoFrame::ComputeSize( AspectRatioUsage::None}; } -nscoord nsVideoFrame::IntrinsicISize(gfxContext* aContext, +nscoord nsVideoFrame::IntrinsicISize(const IntrinsicSizeInput& aInput, IntrinsicISizeType aType) { //