diff --git a/accessible/base/TextAttrs.cpp b/accessible/base/TextAttrs.cpp index eced0a21710c..6acc803029d2 100644 --- a/accessible/base/TextAttrs.cpp +++ b/accessible/base/TextAttrs.cpp @@ -460,8 +460,8 @@ bool TextAttrsMgr::FontFamilyTextAttr:: GetFontFamily(nsIFrame* aFrame, nsString& aFamily) { - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f); gfxFontGroup* fontGroup = fm->GetThebesFontGroup(); gfxFont* font = fontGroup->GetFirstValidFont(); @@ -618,8 +618,8 @@ TextAttrsMgr::FontWeightTextAttr:: { // nsFont::width isn't suitable here because it's necessary to expose real // value of font weight (used font might not have some font weight values). - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f); gfxFontGroup *fontGroup = fm->GetThebesFontGroup(); gfxFont *font = fontGroup->GetFirstValidFont(); diff --git a/accessible/windows/sdn/sdnTextAccessible.cpp b/accessible/windows/sdn/sdnTextAccessible.cpp index fa7b4c507e0b..b51caf44ed8c 100644 --- a/accessible/windows/sdn/sdnTextAccessible.cpp +++ b/accessible/windows/sdn/sdnTextAccessible.cpp @@ -179,8 +179,8 @@ sdnTextAccessible::get_fontFamily(BSTR __RPC_FAR* aFontFamily) if (!frame) return E_FAIL; - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(frame, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(frame, 1.0f); const nsString& name = fm->GetThebesFontGroup()->GetFirstValidFont()->GetName(); diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 25668c11f714..ea01005194c5 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -2468,13 +2468,12 @@ public: virtual float GetExLength() const override { - RefPtr fontMetrics; nsDeviceContext* dc = mPresContext->DeviceContext(); nsFontMetrics::Params params; params.language = mFontLanguage; params.explicitLanguage = mExplicitLanguage; params.textPerf = mPresContext->GetTextPerfMetrics(); - dc->GetMetricsFor(mFont, params, *getter_AddRefs(fontMetrics)); + RefPtr fontMetrics = dc->GetMetricsFor(mFont, params); return NSAppUnitsToFloatPixels(fontMetrics->XHeight(), nsPresContext::AppUnitsPerCSSPixel()); } @@ -3236,9 +3235,8 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont, params.explicitLanguage = fontStyle->mExplicitLanguage; params.userFontSet = c->GetUserFontSet(); params.textPerf = c->GetTextPerfMetrics(); - RefPtr metrics; - c->DeviceContext()->GetMetricsFor(resizedFont, params, - *getter_AddRefs(metrics)); + RefPtr metrics = + c->DeviceContext()->GetMetricsFor(resizedFont, params); gfxFontGroup* newFontGroup = metrics->GetThebesFontGroup(); CurrentState().fontGroup = newFontGroup; diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index 8101d5afcded..ea734423b263 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -1453,22 +1453,14 @@ ContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent) rect.x = posInFrame.x; rect.y = posInFrame.y; - nscoord fontHeight = 0; - RefPtr fontMetrics; - rv = nsLayoutUtils:: - GetInflatedFontMetricsForFrame(frame, getter_AddRefs(fontMetrics)); - if (NS_WARN_IF(!fontMetrics)) { - // If we cannot get font height, use frame size instead. - fontHeight = isVertical ? frame->GetSize().width : frame->GetSize().height; - } else { - fontHeight = fontMetrics->MaxAscent() + fontMetrics->MaxDescent(); - } + RefPtr fontMetrics = + nsLayoutUtils::GetInflatedFontMetricsForFrame(frame); if (isVertical) { - rect.width = fontHeight; + rect.width = fontMetrics->MaxHeight(); rect.height = caretRect.height; } else { rect.width = caretRect.width; - rect.height = fontHeight; + rect.height = fontMetrics->MaxHeight(); } rv = ConvertToRootRelativeOffset(frame, rect); diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 705c6bb63a55..a041de871088 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -2513,8 +2513,8 @@ EventStateManager::GetScrollAmount(nsPresContext* aPresContext, if (!rootFrame) { return nsSize(0, 0); } - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(rootFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(rootFrame); NS_ENSURE_TRUE(fm, nsSize(0, 0)); return nsSize(fm->AveCharWidth(), fm->MaxHeight()); } diff --git a/dom/svg/SVGContentUtils.cpp b/dom/svg/SVGContentUtils.cpp index 9bbd56b8a6fe..6b0f8f9760e8 100644 --- a/dom/svg/SVGContentUtils.cpp +++ b/dom/svg/SVGContentUtils.cpp @@ -340,9 +340,8 @@ SVGContentUtils::GetFontXHeight(nsStyleContext *aStyleContext) nsPresContext *presContext = aStyleContext->PresContext(); MOZ_ASSERT(presContext, "NULL pres context in GetFontXHeight"); - RefPtr fontMetrics; - nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, - getter_AddRefs(fontMetrics)); + RefPtr fontMetrics = + nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext); if (!fontMetrics) { // ReportToConsole diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 8e9bfd846d9a..ffc2c59dde39 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -64,9 +64,8 @@ public: void Init(nsDeviceContext* aContext); void Destroy(); - nsresult GetMetricsFor(const nsFont& aFont, - const nsFontMetrics::Params& aParams, - nsFontMetrics*& aMetrics); + already_AddRefed GetMetricsFor( + const nsFont& aFont, const nsFontMetrics::Params& aParams); void FontMetricsDeleted(const nsFontMetrics* aFontMetrics); void Compact(); @@ -122,10 +121,9 @@ nsFontCache::Observe(nsISupports*, const char* aTopic, const char16_t*) return NS_OK; } -nsresult +already_AddRefed nsFontCache::GetMetricsFor(const nsFont& aFont, - const nsFontMetrics::Params& aParams, - nsFontMetrics*& aMetrics) + const nsFontMetrics::Params& aParams) { nsIAtom* language = aParams.language ? aParams.language : mLocaleLanguage.get(); @@ -133,10 +131,9 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, // First check our cache // start from the end, which is where we put the most-recent-used element - nsFontMetrics* fm; int32_t n = mFontMetrics.Length() - 1; for (int32_t i = n; i >= 0; --i) { - fm = mFontMetrics[i]; + nsFontMetrics* fm = mFontMetrics[i]; if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aParams.userFontSet && fm->Language() == language && @@ -147,8 +144,7 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, mFontMetrics.AppendElement(fm); } fm->GetThebesFontGroup()->UpdateUserFonts(); - NS_ADDREF(aMetrics = fm); - return NS_OK; + return do_AddRef(Move(fm)); } } @@ -156,14 +152,11 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsFontMetrics::Params params = aParams; params.language = language; - fm = new nsFontMetrics(aFont, params, mContext); - NS_ADDREF(fm); + RefPtr fm = new nsFontMetrics(aFont, params, mContext); // the mFontMetrics list has the "head" at the end, because append // is cheaper than insert - mFontMetrics.AppendElement(fm); - aMetrics = fm; - NS_ADDREF(aMetrics); - return NS_OK; + mFontMetrics.AppendElement(do_AddRef(fm.get()).take()); + return fm.forget(); } void @@ -227,10 +220,9 @@ nsDeviceContext::~nsDeviceContext() } } -nsresult +already_AddRefed nsDeviceContext::GetMetricsFor(const nsFont& aFont, - const nsFontMetrics::Params& aParams, - nsFontMetrics*& aMetrics) + const nsFontMetrics::Params& aParams) { if (!mFontCache) { mFontCache = new nsFontCache(); @@ -238,7 +230,7 @@ nsDeviceContext::GetMetricsFor(const nsFont& aFont, mFontCache->Init(this); } - return mFontCache->GetMetricsFor(aFont, aParams, aMetrics); + return mFontCache->GetMetricsFor(aFont, aParams); } nsresult diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h index 40377324b4a1..92665c7cf592 100644 --- a/gfx/src/nsDeviceContext.h +++ b/gfx/src/nsDeviceContext.h @@ -113,12 +113,9 @@ public: * Get the nsFontMetrics that describe the properties of * an nsFont. * @param aFont font description to obtain metrics for - * @param aMetrics out parameter for font metrics - * @return error status */ - nsresult GetMetricsFor(const nsFont& aFont, - const nsFontMetrics::Params& aParams, - nsFontMetrics*& aMetrics); + already_AddRefed GetMetricsFor( + const nsFont& aFont, const nsFontMetrics::Params& aParams); /** * Notification when a font metrics instance created for this device is diff --git a/layout/base/PositionedEventTargeting.cpp b/layout/base/PositionedEventTargeting.cpp index 6f1675ffd207..3e6a2cdd0bfd 100644 --- a/layout/base/PositionedEventTargeting.cpp +++ b/layout/base/PositionedEventTargeting.cpp @@ -525,8 +525,8 @@ IsElementClickableAndReadable(nsIFrame* aFrame, WidgetGUIEvent* aEvent, const Ev } if (testFontSize) { - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame); if (fm && fm->EmHeight() > 0 && // See bug 1171731 (pc->AppUnitsToGfxUnits(fm->EmHeight()) * cumulativeResolution) < limitReadableSize) { return false; diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index e6fc8bca0832..fdad06680b69 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -321,8 +321,8 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame, "We should not be in the middle of reflow"); nscoord baseline = frame->GetCaretBaseline(); nscoord ascent = 0, descent = 0; - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame); NS_ASSERTION(fm, "We should be able to get the font metrics"); if (fm) { ascent = fm->MaxAscent(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5c8dea78f6ea..124e921c640a 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4024,19 +4024,14 @@ nsLayoutUtils::ComputeObjectDestRect(const nsRect& aConstraintRect, return nsRect(imageTopLeftPt, concreteObjectSize); } -nsresult -nsLayoutUtils::GetFontMetricsForFrame(const nsIFrame* aFrame, - nsFontMetrics** aFontMetrics, - float aInflation) +already_AddRefed +nsLayoutUtils::GetFontMetricsForFrame(const nsIFrame* aFrame, float aInflation) { - return nsLayoutUtils::GetFontMetricsForStyleContext(aFrame->StyleContext(), - aFontMetrics, - aInflation); + return GetFontMetricsForStyleContext(aFrame->StyleContext(), aInflation); } -nsresult +already_AddRefed nsLayoutUtils::GetFontMetricsForStyleContext(nsStyleContext* aStyleContext, - nsFontMetrics** aFontMetrics, float aInflation) { nsPresContext* pc = aStyleContext->PresContext(); @@ -4059,13 +4054,12 @@ nsLayoutUtils::GetFontMetricsForStyleContext(nsStyleContext* aStyleContext, // which would be lossy. Fortunately, in such cases, aInflation is // guaranteed to be 1.0f. if (aInflation == 1.0f) { - return pc->DeviceContext()->GetMetricsFor(styleFont->mFont, params, - *aFontMetrics); + return pc->DeviceContext()->GetMetricsFor(styleFont->mFont, params); } nsFont font = styleFont->mFont; font.size = NSToCoordRound(font.size * aInflation); - return pc->DeviceContext()->GetMetricsFor(font, params, *aFontMetrics); + return pc->DeviceContext()->GetMetricsFor(font, params); } nsIFrame* @@ -8492,8 +8486,8 @@ nsLayoutUtils::SetBSizeFromFontMetrics(const nsIFrame* aFrame, WritingMode aLineWM, WritingMode aFrameWM) { - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame); if (fm) { // Compute final height of the frame. diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 2884b4cd1c0f..217853ef95fb 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1222,47 +1222,36 @@ public: /** * Get the font metrics corresponding to the frame's style data. * @param aFrame the frame - * @param aFontMetrics the font metrics result * @param aSizeInflation number to multiply font size by - * @return success or failure code */ - static nsresult GetFontMetricsForFrame(const nsIFrame* aFrame, - nsFontMetrics** aFontMetrics, - float aSizeInflation); + static already_AddRefed GetFontMetricsForFrame( + const nsIFrame* aFrame, float aSizeInflation); - static nsresult GetInflatedFontMetricsForFrame(const nsIFrame* aFrame, - nsFontMetrics** aFontMetrics) + static already_AddRefed + GetInflatedFontMetricsForFrame(const nsIFrame* aFrame) { - return GetFontMetricsForFrame(aFrame, aFontMetrics, - FontSizeInflationFor(aFrame)); + return GetFontMetricsForFrame(aFrame, FontSizeInflationFor(aFrame)); } /** * Get the font metrics corresponding to the given style data. * @param aStyleContext the style data - * @param aFontMetrics the font metrics result * @param aSizeInflation number to multiply font size by - * @return success or failure code */ - static nsresult GetFontMetricsForStyleContext(nsStyleContext* aStyleContext, - nsFontMetrics** aFontMetrics, - float aSizeInflation = 1.0f); + static already_AddRefed GetFontMetricsForStyleContext( + nsStyleContext* aStyleContext, float aSizeInflation = 1.0f); /** * Get the font metrics of emphasis marks corresponding to the given * style data. The result is same as GetFontMetricsForStyleContext * except that the font size is scaled down to 50%. * @param aStyleContext the style data - * @param aFontMetrics the font metrics result * @param aInflation number to multiple font size by - * @return success or failure code */ - static nsresult GetFontMetricsOfEmphasisMarks(nsStyleContext* aStyleContext, - nsFontMetrics** aFontMetrics, - float aInflation) + static already_AddRefed GetFontMetricsOfEmphasisMarks( + nsStyleContext* aStyleContext, float aInflation) { - return GetFontMetricsForStyleContext(aStyleContext, aFontMetrics, - aInflation * 0.5f); + return GetFontMetricsForStyleContext(aStyleContext, aInflation * 0.5f); } /** diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 6c183438d872..4ecf2cc6fe3d 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -10344,9 +10344,8 @@ void ReflowCountMgr::PaintCount(const char* aName, nsFontMetrics::Params params; params.language = nsGkAtoms::x_western; params.textPerf = aPresContext->GetTextPerfMetrics(); - RefPtr fm; - aPresContext->DeviceContext()-> - GetMetricsFor(font, params, *getter_AddRefs(fm)); + RefPtr fm = + aPresContext->DeviceContext()->GetMetricsFor(font, params); char buf[16]; int len = snprintf_literal(buf, "%d", counter->mCount); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 570bf9e032f4..c595ce462387 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1551,16 +1551,9 @@ nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent) nscoord nsListControlFrame::CalcFallbackRowBSize(float aFontSizeInflation) { - nscoord rowBSize = 0; - - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), - aFontSizeInflation); - if (fontMet) { - rowBSize = fontMet->MaxHeight(); - } - - return rowBSize; + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation); + return fontMet->MaxHeight(); } nscoord diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index f97c279fd1cf..16ecf18e3b71 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -230,10 +230,8 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, const LogicalSize& aPadding, bool aShrinkWrap) { - RefPtr fontMet; - NS_ENSURE_SUCCESS(nsLayoutUtils::GetFontMetricsForFrame(this, - getter_AddRefs(fontMet), 1.0f), - LogicalSize(aWM)); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); const WritingMode wm = GetWritingMode(); LogicalSize autoSize(wm); @@ -251,9 +249,8 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, nscoord nsMeterFrame::GetMinISize(nsRenderingContext *aRenderingContext) { - RefPtr fontMet; - NS_ENSURE_SUCCESS( - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), 1.0f), 0); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); nscoord minISize = fontMet->Font().size; // 1em diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index b88f24f9a969..0ecb1d250ab9 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -257,9 +257,8 @@ nsProgressFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, nscoord nsProgressFrame::GetMinISize(nsRenderingContext *aRenderingContext) { - RefPtr fontMet; - NS_ENSURE_SUCCESS( - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), 1.0f), 0); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); nscoord minISize = fontMet->Font().size; // 1em diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index ac522bfb37ad..49d4ff7e20c5 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -155,11 +155,8 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext, nscoord charWidth = 0; nscoord charMaxAdvance = 0; - RefPtr fontMet; - nsresult rv = - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), - aFontSizeInflation); - NS_ENSURE_SUCCESS(rv, rv); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation); lineHeight = nsHTMLReflowState::CalcLineHeight(GetContent(), StyleContext(), @@ -523,9 +520,8 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext, lineHeight = nsHTMLReflowState::CalcLineHeight(GetContent(), StyleContext(), NS_AUTOHEIGHT, inflation); } - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), - inflation); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, inflation); // now adjust for our borders and padding aDesiredSize.SetBlockStartAscent( nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight, diff --git a/layout/generic/MathMLTextRunFactory.cpp b/layout/generic/MathMLTextRunFactory.cpp index ea7a28a97d12..1034d39572da 100644 --- a/layout/generic/MathMLTextRunFactory.cpp +++ b/layout/generic/MathMLTextRunFactory.cpp @@ -746,11 +746,9 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun, params.explicitLanguage = styles[0]->mExplicitLanguage; params.userFontSet = pc->GetUserFontSet(); params.textPerf = pc->GetTextPerfMetrics(); - RefPtr metrics; - pc->DeviceContext()->GetMetricsFor(font, params, *getter_AddRefs(metrics)); - if (metrics) { - newFontGroup = metrics->GetThebesFontGroup(); - } + RefPtr metrics = + pc->DeviceContext()->GetMetricsFor(font, params); + newFontGroup = metrics->GetThebesFontGroup(); } if (!newFontGroup) { diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 9b20e6658ed8..a40929f54aaf 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -49,8 +49,8 @@ private: static gfxTextRun* GetEllipsisTextRun(nsIFrame* aFrame) { - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame); LazyReferenceRenderingDrawTargetGetterFromFrame lazyRefDrawTargetGetter(aFrame); return fm->GetThebesFontGroup()->GetEllipsisTextRun( aFrame->PresContext()->AppUnitsPerDevPixel(), @@ -255,8 +255,8 @@ nsDisplayTextOverflowMarker::PaintTextToContext(nsRenderingContext* aCtx, gfxTextRun::DrawParams(aCtx->ThebesContext())); } } else { - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(mFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(mFrame); nsLayoutUtils::DrawString(mFrame, *fm, aCtx, mStyle->mString.get(), mStyle->mString.Length(), pt); } @@ -808,8 +808,8 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame) } else { nsRenderingContext rc( aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext()); - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame); mISize = nsLayoutUtils::AppUnitWidthOfStringBidi(mStyle->mString, aFrame, *fm, rc); } diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index da0d9e911417..2d7ec6487e1d 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -121,8 +121,8 @@ BRFrame::Reflow(nsPresContext* aPresContext, // We also do this in strict mode because BR should act like a // normal inline frame. That line-height is used is important // here for cases where the line-height is less than 1. - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); if (fm) { nscoord logicalHeight = aReflowState.CalcLineHeight(); finalSize.BSize(wm) = logicalHeight; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 79021bb1fcf1..942cd8ddccfe 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -505,9 +505,9 @@ nsBlockFrame::GetCaretBaseline() const return bp.top + firstLine->mFirstChild->GetCaretBaseline(); } } - RefPtr fm; float inflation = nsLayoutUtils::FontSizeInflationFor(this); - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, inflation); nscoord lineHeight = nsHTMLReflowState::CalcLineHeight(GetContent(), StyleContext(), contentRect.height, inflation); @@ -2625,8 +2625,8 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) } } - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); nscoord minAscent = nsLayoutUtils::GetCenteredFontBaseline(fm, aState.mMinLineHeight, diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index cb402b20f519..a2fafbb1c540 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -304,7 +304,6 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt, } } - RefPtr fm; ColorPattern color(ToDeviceColor( nsLayoutUtils::GetColor(this, eCSSProperty_color))); @@ -412,8 +411,8 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt, aRenderingContext.ThebesContext()->SetColor( Color::FromABGR(nsLayoutUtils::GetColor(this, eCSSProperty_color))); - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - GetFontSizeInflation()); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, GetFontSizeInflation()); nsAutoString text; GetListItemText(text); WritingMode wm = GetWritingMode(); @@ -535,9 +534,8 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX, const nsStyleList* myList = StyleList(); nscoord ascent; - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation); RemoveStateBits(BULLET_FRAME_IMAGE_LOADING); @@ -892,9 +890,8 @@ nsBulletFrame::GetLogicalBaseline(WritingMode aWritingMode) const if (GetStateBits() & BULLET_FRAME_IMAGE_LOADING) { ascent = BSize(aWritingMode); } else { - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - GetFontSizeInflation()); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, GetFontSizeInflation()); CounterStyle* listStyleType = StyleList()->GetCounterStyle(); switch (listStyleType->GetStyle()) { case NS_STYLE_LIST_STYLE_NONE: diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 4dd66c4f74c7..cee4fd9419b2 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -3904,8 +3904,8 @@ ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination, nsSize ScrollFrameHelper::GetLineScrollAmount() const { - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(mOuter, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(mOuter); NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit"); static nscoord sMinLineScrollAmountInPixels = -1; if (sMinLineScrollAmountInPixels < 0) { diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 77219ba220e7..49a5c3f7046a 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -2693,10 +2693,8 @@ ComputeLineHeight(nsStyleContext* aStyleContext, } } - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, - getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = nsLayoutUtils:: + GetFontMetricsForStyleContext(aStyleContext, aFontSizeInflation); return GetNormalLineHeight(fm); } diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 8c88e0af8e96..d05a7ff9ce2d 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1130,8 +1130,8 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext, // Set font and color aRenderingContext.ThebesContext()-> SetColor(Color::FromABGR(StyleColor()->mColor)); - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); // Format the text to display within the formatting rect diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index a60a38159a16..d09824d4d93e 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -1680,9 +1680,8 @@ nsLineLayout::PlaceTopBottomFrames(PerSpanData* psd, static nscoord GetBSizeOfEmphasisMarks(nsIFrame* aSpanFrame, float aInflation) { - RefPtr fm; - nsLayoutUtils::GetFontMetricsOfEmphasisMarks( - aSpanFrame->StyleContext(), getter_AddRefs(fm), aInflation); + RefPtr fm = nsLayoutUtils:: + GetFontMetricsOfEmphasisMarks(aSpanFrame->StyleContext(), aInflation); return fm->MaxHeight(); } @@ -1774,11 +1773,10 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - RefPtr fm; float inflation = GetInflationForBlockDirAlignment(spanFrame, mInflationMinFontSize); - nsLayoutUtils::GetFontMetricsForFrame(spanFrame, getter_AddRefs(fm), - inflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(spanFrame, inflation); bool preMode = mStyleText->WhiteSpaceIsSignificant(); diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 16bf48986a2b..60b3fc64c7ed 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -633,9 +633,8 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext, nsFontMetrics::Params params; params.userFontSet = pc->GetUserFontSet(); params.textPerf = pc->GetTextPerfMetrics(); - RefPtr fontMet; - pc->DeviceContext()->GetMetricsFor(mPD->mHeadFootFont, params, - *getter_AddRefs(fontMet)); + RefPtr fontMet = + pc->DeviceContext()->GetMetricsFor(mPD->mHeadFootFont, params); nscoord ascent = 0; nscoord visibleHeight = 0; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index ccdbd1631aa5..6a5c36a2ae7a 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -1814,12 +1814,8 @@ GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation, if (aOutFontMetrics) *aOutFontMetrics = nullptr; - RefPtr metrics; - nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(metrics), - aFontSizeInflation); - - if (!metrics) - return nullptr; + RefPtr metrics = + nsLayoutUtils::GetFontMetricsForFrame(aFrame, aFontSizeInflation); if (aOutFontMetrics) { *aOutFontMetrics = metrics; @@ -5168,9 +5164,8 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider) return nsRect(); } - RefPtr fm; - nsLayoutUtils::GetFontMetricsOfEmphasisMarks( - StyleContext(), getter_AddRefs(fm), GetFontSizeInflation()); + RefPtr fm = nsLayoutUtils:: + GetFontMetricsOfEmphasisMarks(StyleContext(), GetFontSizeInflation()); EmphasisMarkInfo* info = new EmphasisMarkInfo; info->textRun = GenerateTextRunForEmphasisMarks(this, fm, aWM, styleText); @@ -6946,9 +6941,8 @@ nsTextFrame::CombineSelectionUnderlineRect(nsPresContext* aPresContext, nsRect givenRect = aRect; - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - GetFontSizeInflation()); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, GetFontSizeInflation()); gfxFontGroup* fontGroup = fm->GetThebesFontGroup(); gfxFont* firstFont = fontGroup->GetFirstValidFont(); WritingMode wm = GetWritingMode(); diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index 341edd1886ac..a902ba50d863 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -996,9 +996,8 @@ nsMathMLChar::SetFontFamily(nsPresContext* aPresContext, params.explicitLanguage = styleFont->mExplicitLanguage; params.userFontSet = aPresContext->GetUserFontSet(); params.textPerf = aPresContext->GetTextPerfMetrics(); - RefPtr fm; - aPresContext->DeviceContext()-> - GetMetricsFor(font, params, *getter_AddRefs(fm)); + RefPtr fm = + aPresContext->DeviceContext()->GetMetricsFor(font, params); // Set the font if it is an unicode table // or if the same family name has been found gfxFont *firstFont = fm->GetThebesFontGroup()->GetFirstValidFont(); @@ -1537,9 +1536,8 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext, params.explicitLanguage = styleFont->mExplicitLanguage; params.userFontSet = aPresContext->GetUserFontSet(); params.textPerf = aPresContext->GetTextPerfMetrics(); - RefPtr fm; - aPresContext->DeviceContext()-> - GetMetricsFor(font, params, *getter_AddRefs(fm)); + RefPtr fm = + aPresContext->DeviceContext()->GetMetricsFor(font, params); uint32_t len = uint32_t(mData.Length()); nsAutoPtr textRun; textRun = fm->GetThebesFontGroup()-> diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp index faf2c9f5c339..f0dae173dd8f 100644 --- a/layout/mathml/nsMathMLContainerFrame.cpp +++ b/layout/mathml/nsMathMLContainerFrame.cpp @@ -49,8 +49,8 @@ nsMathMLContainerFrame::ReflowError(DrawTarget* aDrawTarget, /////////////// // Set font - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); // bounding metrics nsAutoString errorMsg; errorMsg.AssignLiteral("invalid-markup"); @@ -92,8 +92,8 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) { // Set color and font ... - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(mFrame, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(mFrame, 1.0f); nsPoint pt = ToReferenceFrame(); int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index a8363979b91a..42c7c89b427b 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -232,10 +232,8 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext, } else if (eCSSUnit_XHeight == unit) { aPresContext->SetUsesExChUnits(true); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, - getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = nsLayoutUtils:: + GetFontMetricsForStyleContext(aStyleContext, aFontSizeInflation); nscoord xHeight = fm->XHeight(); return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight); } diff --git a/layout/mathml/nsMathMLFrame.h b/layout/mathml/nsMathMLFrame.h index 287de00ce04c..0e6464d1a6df 100644 --- a/layout/mathml/nsMathMLFrame.h +++ b/layout/mathml/nsMathMLFrame.h @@ -198,9 +198,8 @@ public: nscoord& aSubDrop, float aFontSizeInflation) { - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aChild, getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(aChild, aFontSizeInflation); GetSubDrop(fm, aSubDrop); } @@ -209,9 +208,8 @@ public: nscoord& aSupDrop, float aFontSizeInflation) { - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aChild, getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(aChild, aFontSizeInflation); GetSupDrop(fm, aSupDrop); } diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp index 21a78b2e775e..604aeaa62e7b 100644 --- a/layout/mathml/nsMathMLTokenFrame.cpp +++ b/layout/mathml/nsMathMLTokenFrame.cpp @@ -173,8 +173,8 @@ nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget, mBoundingMetrics += childSize.mBoundingMetrics; } - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); nscoord ascent = fm->MaxAscent(); nscoord descent = fm->MaxDescent(); diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index 9dc02df765f2..93176793a657 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -344,9 +344,8 @@ nsMathMLmencloseFrame::PlaceInternal(DrawTarget* aDrawTarget, nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); GetRuleThickness(aDrawTarget, fm, mRuleThickness); if (mRuleThickness < onePixel) { mRuleThickness = onePixel; diff --git a/layout/mathml/nsMathMLmfencedFrame.cpp b/layout/mathml/nsMathMLmfencedFrame.cpp index 915e3a05a315..db58d51709f7 100644 --- a/layout/mathml/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/nsMathMLmfencedFrame.cpp @@ -223,9 +223,8 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext, int32_t i; const nsStyleFont* font = StyleFont(); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord axisHeight, em; GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight); GetEmHeight(fm, em); @@ -612,9 +611,8 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon nsPresContext* presContext = PresContext(); const nsStyleFont* font = StyleFont(); float fontSizeInflation = nsLayoutUtils:: FontSizeInflationFor(this); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord em; GetEmHeight(fm, em); diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp index b5b88d074559..4cc04283d2dc 100644 --- a/layout/mathml/nsMathMLmfracFrame.cpp +++ b/layout/mathml/nsMathMLmfracFrame.cpp @@ -218,9 +218,8 @@ nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget, nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord defaultRuleThickness, axisHeight; nscoord oneDevPixel = fm->AppUnitsPerDevPixel(); diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index 01a3599fe388..99807b905b1c 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -185,9 +185,8 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // get x-height (an ex) const nsStyleFont* font = aFrame->StyleFont(); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm), - aFontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(baseFrame, aFontSizeInflation); nscoord xHeight = fm->XHeight(); diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp index 145d9c800c29..12e876100e12 100644 --- a/layout/mathml/nsMathMLmoFrame.cpp +++ b/layout/mathml/nsMathMLmoFrame.cpp @@ -362,9 +362,8 @@ nsMathMLmoFrame::ProcessOperatorData() // Cache the default values of lspace and rspace. // since these values are relative to the 'em' unit, convert to twips now nscoord em; - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); GetEmHeight(fm, em); mEmbellishData.leadingSpace = NSToCoordRound(lspace * em); @@ -619,9 +618,8 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, // get the axis height; float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord axisHeight, height; GetAxisHeight(aDrawTarget, fm, axisHeight); diff --git a/layout/mathml/nsMathMLmrootFrame.cpp b/layout/mathml/nsMathMLmrootFrame.cpp index c667d11d20fd..2045180fe01f 100644 --- a/layout/mathml/nsMathMLmrootFrame.cpp +++ b/layout/mathml/nsMathMLmrootFrame.cpp @@ -225,10 +225,9 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext, //////////// // Prepare the radical symbol and the overline bar - RefPtr fm; float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord ruleThickness, leading, psi; GetRadicalParameters(fm, StyleFont()->mMathDisplay == @@ -382,9 +381,8 @@ nsMathMLmrootFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingConte fontSizeInflation); nscoord dxSqr; - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); GetRadicalXOffsets(indexWidth, sqrWidth, fm, nullptr, &dxSqr); nscoord width = dxSqr + sqrWidth + baseWidth; diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index 2583fb414a58..951757ee0b0e 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -506,9 +506,8 @@ ParseSpacingAttribute(nsMathMLmtableFrame* aFrame, nsIAtom* aAttribute) nscoord value2; // Set defaults float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(aFrame); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(aFrame, fontSizeInflation); if (nsGkAtoms::rowspacing_ == aAttribute) { value = kDefaultRowspacingEx * fm->XHeight(); value2 = 0; @@ -882,8 +881,8 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext, case eAlign_axis: default: { // XXX should instead use style data from the row of reference here ? - RefPtr fm; - nsLayoutUtils::GetInflatedFontMetricsForFrame(this, getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetInflatedFontMetricsForFrame(this); nscoord axisHeight; GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight); if (rowFrame) { diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp index 0532849257e0..9e8aff7bc312 100644 --- a/layout/mathml/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -398,9 +398,8 @@ nsMathMLmunderoverFrame::Place(DrawTarget* aDrawTarget, //////////////////// // Place Children - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), - fontSizeInflation); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord xHeight = fm->XHeight(); nscoord oneDevPixel = fm->AppUnitsPerDevPixel(); diff --git a/layout/style/nsFontFaceUtils.cpp b/layout/style/nsFontFaceUtils.cpp index 376b02f23c0f..d715dfe06cf3 100644 --- a/layout/style/nsFontFaceUtils.cpp +++ b/layout/style/nsFontFaceUtils.cpp @@ -34,10 +34,8 @@ StyleContextContainsFont(nsStyleContext* aStyleContext, // family name is in the fontlist, check to see if the font group // associated with the frame includes the specific userfont - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, - getter_AddRefs(fm), - 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext, 1.0f); if (fm->GetThebesFontGroup()->ContainsUserFont(aFont)) { return true; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 940a50d40ae7..19573d047244 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -335,10 +335,7 @@ GetMetricsFor(nsPresContext* aPresContext, params.userFontSet = aUseUserFontSet ? aPresContext->GetUserFontSet() : nullptr; params.textPerf = aPresContext->GetTextPerfMetrics(); - RefPtr fm; - aPresContext->DeviceContext()-> - GetMetricsFor(font, params, *getter_AddRefs(fm)); - return fm.forget(); + return aPresContext->DeviceContext()->GetMetricsFor(font, params); } diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp index 74400c618045..7fb7e453b0fb 100644 --- a/layout/xul/nsListBoxBodyFrame.cpp +++ b/layout/xul/nsListBoxBodyFrame.cpp @@ -197,8 +197,8 @@ nsListBoxBodyFrame::Init(nsIContent* aContent, scrollbarFrame->SetScrollbarMediatorContent(GetContent()); } } - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); mRowHeight = fm->MaxHeight(); } @@ -728,9 +728,8 @@ nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState) } } - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(styleContext, - getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForStyleContext(styleContext); nscoord textWidth = nsLayoutUtils::AppUnitWidthOfStringBidi(value, this, *fm, diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 54e88ae4fab5..5c55e3c11df8 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -458,8 +458,8 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext, } while (0 != decorMask && (f = nsLayoutUtils::GetParentOrPlaceholderFor(f))); - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), 1.0f); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); fontMet->SetVertical(wm.IsVertical()); fontMet->SetTextOrientation(StyleVisibility()->mTextOrientation); @@ -633,8 +633,8 @@ nsTextBoxFrame::CalculateTitleForWidth(nsRenderingContext& aRenderingContext, return 0; } - RefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), 1.0f); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); // see if the text will completely fit in the width given nscoord titleWidth = @@ -969,8 +969,8 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState) nsRect scrollBounds(nsPoint(0, 0), GetSize()); nsRect textRect = mTextDrawRect; - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), 1.0f); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); nsBoundingMetrics metrics = fontMet->GetInkBoundsForVisualOverflow(mCroppedTitle.get(), mCroppedTitle.Length(), @@ -1030,8 +1030,8 @@ nsTextBoxFrame::GetTextSize(nsRenderingContext& aRenderingContext, const nsString& aString, nsSize& aSize, nscoord& aAscent) { - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet), 1.0f); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForFrame(this, 1.0f); aSize.height = fontMet->MaxHeight(); aSize.width = nsLayoutUtils::AppUnitWidthOfStringBidi(aString, this, *fontMet, diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 8b511142a986..d86ea7983899 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -1249,9 +1249,8 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n // we add in borders and padding to the text dimension and give that back. nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(textContext, - getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForStyleContext(textContext); nscoord height = fm->MaxHeight(); nsMargin textMargin; @@ -1621,9 +1620,8 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect, AdjustForBorderPadding(textContext, textRect); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(textContext, - getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForStyleContext(textContext); AdjustForCellText(cellText, aRowIndex, aColumn, rc, *fm, textRect); if (aX >= textRect.x && aX < textRect.x + textRect.width) @@ -1749,9 +1747,8 @@ nsTreeBodyFrame::GetCellWidth(int32_t aRow, nsTreeColumn* aCol, // Get the borders and padding for the text. GetBorderPadding(textContext, bp); - RefPtr fm; - nsLayoutUtils::GetFontMetricsForStyleContext(textContext, - getter_AddRefs(fm)); + RefPtr fm = + nsLayoutUtils::GetFontMetricsForStyleContext(textContext); // Get the width of the text itself nscoord width = nsLayoutUtils::AppUnitWidthOfStringBidi(cellText, this, *fm, *aRenderingContext); @@ -3730,9 +3727,8 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex, textRect.Deflate(bp); // Compute our text size. - RefPtr fontMet; - nsLayoutUtils::GetFontMetricsForStyleContext(textContext, - getter_AddRefs(fontMet)); + RefPtr fontMet = + nsLayoutUtils::GetFontMetricsForStyleContext(textContext); nscoord height = fontMet->MaxHeight(); nscoord baseline = fontMet->MaxAscent();