diff options
-rw-r--r-- | layout/generic/BlockReflowInput.cpp | 3 | ||||
-rw-r--r-- | layout/generic/ReflowInput.cpp | 14 | ||||
-rw-r--r-- | layout/generic/ReflowInput.h | 18 | ||||
-rw-r--r-- | layout/generic/nsBRFrame.cpp | 2 | ||||
-rw-r--r-- | layout/generic/nsRubyBaseContainerFrame.cpp | 2 |
5 files changed, 23 insertions, 16 deletions
diff --git a/layout/generic/BlockReflowInput.cpp b/layout/generic/BlockReflowInput.cpp index 86248ac141..e73ae6331c 100644 --- a/layout/generic/BlockReflowInput.cpp +++ b/layout/generic/BlockReflowInput.cpp @@ -43,6 +43,7 @@ BlockReflowInput::BlockReflowInput(const ReflowInput& aReflowInput, mOverflowTracker(nullptr), mBorderPadding(mReflowInput.ComputedLogicalBorderPadding()), mPrevBEndMargin(), + mMinLineHeight(aReflowInput.GetLineHeight()), mLineNumber(0), mFloatBreakType(StyleClear::None), mConsumedBSize(aConsumedBSize) @@ -141,8 +142,6 @@ BlockReflowInput::BlockReflowInput(const ReflowInput& aReflowInput, mPrevChild = nullptr; mCurrentLine = aFrame->LinesEnd(); - - mMinLineHeight = aReflowInput.CalcLineHeight(); } nscoord diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 0c3fef3825..f308ebcdf5 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -2798,15 +2798,19 @@ ComputeLineHeight(nsStyleContext* aStyleContext, return GetNormalLineHeight(fm); } -nscoord -ReflowInput::CalcLineHeight() const -{ +nscoord ReflowInput::GetLineHeight() const { + if (mLineHeight != NS_AUTOHEIGHT) { + return mLineHeight; + } + nscoord blockBSize = nsLayoutUtils::IsNonWrapperBlock(mFrame) ? ComputedBSize() : (mCBReflowInput ? mCBReflowInput->ComputedBSize() : NS_AUTOHEIGHT); - return CalcLineHeight(mFrame->GetContent(), mFrame->StyleContext(), blockBSize, - nsLayoutUtils::FontSizeInflationFor(mFrame)); + mLineHeight = CalcLineHeight(mFrame->GetContent(), + mFrame->StyleContext(), + blockBSize, + nsLayoutUtils::FontSizeInflationFor(mFrame)); } /* static */ nscoord diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index 1d2df6af68..d8e0518399 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -744,18 +744,19 @@ public: nscoord GetContainingBlockContentISize(mozilla::WritingMode aWritingMode) const; /** - * Calculate the used line-height property. The return value will be >= 0. + * Get the used line-height property. The return value will be >= 0. */ - nscoord CalcLineHeight() const; + nscoord GetLineHeight() const; /** - * Same as CalcLineHeight() above, but doesn't need a reflow state. + * Calculate the used line-height property without a reflow input instance. + * The return value will be >= 0. * * @param aBlockBSize The computed block size of the content rect of the block - * that the line should fill. - * Only used with line-height:-moz-block-height. - * NS_AUTOHEIGHT results in a normal line-height for - * line-height:-moz-block-height. + * that the line should fill. + * Only used with line-height:-moz-block-height. + * NS_AUTOHEIGHT results in a normal line-height for + * line-height:-moz-block-height. * @param aFontSizeInflation The result of the appropriate * nsLayoutUtils::FontSizeInflationFor call, * or 1.0 if during intrinsic size @@ -1000,6 +1001,9 @@ protected: nscoord* aOutsideBoxSizing) const; void CalculateBlockSideMargins(nsIAtom* aFrameType); + + // Cache the used line-height property. + mutable nscoord mLineHeight = NS_AUTOHEIGHT; }; } // namespace mozilla diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 08c0fe3dda..e02711353a 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -125,7 +125,7 @@ BRFrame::Reflow(nsPresContext* aPresContext, RefPtr<nsFontMetrics> fm = nsLayoutUtils::GetInflatedFontMetricsForFrame(this); if (fm) { - nscoord logicalHeight = aReflowInput.CalcLineHeight(); + nscoord logicalHeight = aReflowInput.GetLineHeight(); finalSize.BSize(wm) = logicalHeight; aMetrics.SetBlockStartAscent(nsLayoutUtils::GetCenteredFontBaseline( fm, logicalHeight, wm.IsLineInverted())); diff --git a/layout/generic/nsRubyBaseContainerFrame.cpp b/layout/generic/nsRubyBaseContainerFrame.cpp index 91bbf5de85..ed2a35b417 100644 --- a/layout/generic/nsRubyBaseContainerFrame.cpp +++ b/layout/generic/nsRubyBaseContainerFrame.cpp @@ -363,7 +363,7 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext, // Line number is useless for ruby text // XXX nullptr here may cause problem, see comments for // nsLineLayout::mBlockRI and nsLineLayout::AddFloat - lineLayout->Init(nullptr, reflowInput->CalcLineHeight(), -1); + lineLayout->Init(nullptr, reflowInput->GetLineHeight(), -1); reflowInput->mLineLayout = lineLayout; // Border and padding are suppressed on ruby text containers. |