diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /layout/forms/nsTextControlFrame.cpp | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/forms/nsTextControlFrame.cpp')
-rw-r--r-- | layout/forms/nsTextControlFrame.cpp | 104 |
1 files changed, 33 insertions, 71 deletions
diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index c51b94c56a..32e817be8a 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -173,15 +173,14 @@ void nsTextControlFrame::Destroy(DestroyContext& aContext) { nsContainerFrame::Destroy(aContext); } -LogicalSize nsTextControlFrame::CalcIntrinsicSize( - gfxContext* aRenderingContext, WritingMode aWM, - float aFontSizeInflation) const { +LogicalSize nsTextControlFrame::CalcIntrinsicSize(gfxContext* aRenderingContext, + WritingMode aWM) const { LogicalSize intrinsicSize(aWM); + const float inflation = nsLayoutUtils::FontSizeInflationFor(this); RefPtr<nsFontMetrics> fontMet = - nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation); - const nscoord lineHeight = - ReflowInput::CalcLineHeight(*Style(), PresContext(), GetContent(), - NS_UNCONSTRAINEDSIZE, aFontSizeInflation); + nsLayoutUtils::GetFontMetricsForFrame(this, inflation); + const nscoord lineHeight = ReflowInput::CalcLineHeight( + *Style(), PresContext(), GetContent(), NS_UNCONSTRAINEDSIZE, inflation); // Use the larger of the font's "average" char width or the width of the // zero glyph (if present) as the basis for resolving the size attribute. const nscoord charWidth = @@ -554,58 +553,14 @@ void nsTextControlFrame::AppendAnonymousContentTo( } nscoord nsTextControlFrame::GetPrefISize(gfxContext* aRenderingContext) { - nscoord result = 0; - DISPLAY_PREF_INLINE_SIZE(this, result); - float inflation = nsLayoutUtils::FontSizeInflationFor(this); WritingMode wm = GetWritingMode(); - result = CalcIntrinsicSize(aRenderingContext, wm, inflation).ISize(wm); - return result; + return CalcIntrinsicSize(aRenderingContext, wm).ISize(wm); } nscoord nsTextControlFrame::GetMinISize(gfxContext* aRenderingContext) { - // Our min inline size is just our preferred width if we have auto inline size - nscoord result; - DISPLAY_MIN_INLINE_SIZE(this, result); - result = GetPrefISize(aRenderingContext); - return result; -} - -LogicalSize nsTextControlFrame::ComputeAutoSize( - gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize, - nscoord aAvailableISize, const LogicalSize& aMargin, - const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides, - ComputeSizeFlags aFlags) { - float inflation = nsLayoutUtils::FontSizeInflationFor(this); - LogicalSize autoSize = CalcIntrinsicSize(aRenderingContext, aWM, inflation); - - // Note: nsContainerFrame::ComputeAutoSize only computes the inline-size (and - // only for 'auto'), the block-size it returns is always NS_UNCONSTRAINEDSIZE. - const auto& styleISize = aSizeOverrides.mStyleISize - ? *aSizeOverrides.mStyleISize - : StylePosition()->ISize(aWM); - if (styleISize.IsAuto()) { - if (aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) { - // CalcIntrinsicSize isn't aware of grid-item margin-box clamping, so we - // fall back to nsContainerFrame's ComputeAutoSize to handle that. - // XXX maybe a font-inflation issue here? (per the assertion below). - autoSize.ISize(aWM) = - nsContainerFrame::ComputeAutoSize( - aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin, - aBorderPadding, aSizeOverrides, aFlags) - .ISize(aWM); - } -#ifdef DEBUG - else { - LogicalSize ancestorAutoSize = nsContainerFrame::ComputeAutoSize( - aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin, - aBorderPadding, aSizeOverrides, aFlags); - MOZ_ASSERT(inflation != 1.0f || - ancestorAutoSize.ISize(aWM) == autoSize.ISize(aWM), - "Incorrect size computed by ComputeAutoSize?"); - } -#endif - } - return autoSize; + // Our min inline size is just our preferred inline-size if we have auto + // inline size. + return GetPrefISize(aRenderingContext); } Maybe<nscoord> nsTextControlFrame::ComputeBaseline( @@ -641,12 +596,16 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext, nsReflowStatus& aStatus) { MarkInReflow(); DO_GLOBAL_REFLOW_COUNT("nsTextControlFrame"); - DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus); MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); // set values of reflow's out parameters WritingMode wm = aReflowInput.GetWritingMode(); - aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm)); + const auto contentBoxSize = aReflowInput.ComputedSizeWithBSizeFallback([&] { + return CalcIntrinsicSize(aReflowInput.mRenderingContext, wm).BSize(wm); + }); + aDesiredSize.SetSize( + wm, + contentBoxSize + aReflowInput.ComputedLogicalBorderPadding(wm).Size(wm)); { // Calculate the baseline and store it in mFirstBaseline. @@ -674,7 +633,7 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext, nscoord buttonBoxISize = 0; if (buttonBox) { ReflowTextControlChild(buttonBox, aPresContext, aReflowInput, aStatus, - aDesiredSize, buttonBoxISize); + aDesiredSize, contentBoxSize, buttonBoxISize); } // perform reflow on all kids @@ -684,7 +643,7 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext, MOZ_ASSERT(!IsButtonBox(kid), "Should only have one button box, and should be last"); ReflowTextControlChild(kid, aPresContext, aReflowInput, aStatus, - aDesiredSize, buttonBoxISize); + aDesiredSize, contentBoxSize, buttonBoxISize); } kid = kid->GetNextSibling(); } @@ -698,22 +657,28 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext, void nsTextControlFrame::ReflowTextControlChild( nsIFrame* aKid, nsPresContext* aPresContext, const ReflowInput& aReflowInput, nsReflowStatus& aStatus, - ReflowOutput& aParentDesiredSize, nscoord& aButtonBoxISize) { + ReflowOutput& aParentDesiredSize, const LogicalSize& aParentContentBoxSize, + nscoord& aButtonBoxISize) { const WritingMode outerWM = aReflowInput.GetWritingMode(); // compute available size and frame offsets for child const WritingMode wm = aKid->GetWritingMode(); - LogicalSize availSize = aReflowInput.ComputedSizeWithPadding(wm); + const auto parentPadding = aReflowInput.ComputedLogicalPadding(wm); + const LogicalSize contentBoxSize = + aParentContentBoxSize.ConvertTo(wm, outerWM); + const LogicalSize paddingBoxSize = contentBoxSize + parentPadding.Size(wm); + const LogicalSize borderBoxSize = + paddingBoxSize + aReflowInput.ComputedLogicalBorder(wm).Size(wm); + LogicalSize availSize = paddingBoxSize; availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE; - bool isButtonBox = IsButtonBox(aKid); + const bool isButtonBox = IsButtonBox(aKid); ReflowInput kidReflowInput(aPresContext, aReflowInput, aKid, availSize, Nothing(), ReflowInput::InitFlag::CallerWillInit); // Override padding with our computed padding in case we got it from theming // or percentage, if we're not the button box. - auto overridePadding = - isButtonBox ? Nothing() : Some(aReflowInput.ComputedLogicalPadding(wm)); + auto overridePadding = isButtonBox ? Nothing() : Some(parentPadding); if (!isButtonBox && aButtonBoxISize) { // Button box respects inline-end-padding, so we don't need to. overridePadding->IEnd(outerWM) = 0; @@ -722,8 +687,7 @@ void nsTextControlFrame::ReflowTextControlChild( // We want to let our button box fill the frame in the block axis, up to the // edge of the control's border. So, we use the control's padding-box as the // containing block size for our button box. - auto overrideCBSize = - isButtonBox ? Some(aReflowInput.ComputedSizeWithPadding(wm)) : Nothing(); + auto overrideCBSize = isButtonBox ? Some(paddingBoxSize) : Nothing(); kidReflowInput.Init(aPresContext, overrideCBSize, Nothing(), overridePadding); LogicalPoint position(wm); @@ -746,14 +710,12 @@ void nsTextControlFrame::ReflowTextControlChild( // the only exception, which has an auto size). kidReflowInput.SetComputedISize( std::max(0, aReflowInput.ComputedISize() - aButtonBoxISize)); - kidReflowInput.SetComputedBSize(aReflowInput.ComputedBSize()); + kidReflowInput.SetComputedBSize(contentBoxSize.BSize(wm)); } // reflow the child ReflowOutput desiredSize(aReflowInput); - const nsSize containerSize = - aReflowInput.ComputedSizeWithBorderPadding(outerWM).GetPhysicalSize( - outerWM); + const nsSize containerSize = borderBoxSize.GetPhysicalSize(wm); ReflowChild(aKid, aPresContext, desiredSize, kidReflowInput, wm, position, containerSize, ReflowChildFlags::Default, aStatus); @@ -767,7 +729,7 @@ void nsTextControlFrame::ReflowTextControlChild( buttonRect.ISize(outerWM) = size.ISize(outerWM); buttonRect.BStart(outerWM) = bp.BStart(outerWM) + - (aReflowInput.ComputedBSize() - size.BSize(outerWM)) / 2; + (aParentContentBoxSize.BSize(outerWM) - size.BSize(outerWM)) / 2; // Align to the inline-end of the content box. buttonRect.IStart(outerWM) = bp.IStart(outerWM) + aReflowInput.ComputedISize() - size.ISize(outerWM); |