Bug 1452080: Remove ComputedStyle::PresContext usage from layout and canvas code. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 06 Apr 2018 14:52:12 +0200
changeset 412341 9e1a485cfb22d94fbe487efe2e2f3e2fda29dc87
parent 412340 231e55e4683e7e6626795335bb6c09d41b9f4f2c
child 412342 433416ba2a3a058eb99036f12783dd8f3e2519f2
push id33800
push usernerli@mozilla.com
push dateMon, 09 Apr 2018 16:45:06 +0000
treeherdermozilla-central@e37784665179 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1452080
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1452080: Remove ComputedStyle::PresContext usage from layout and canvas code. r=xidorn Couldn't find an easy way of splitting these up :( MozReview-Commit-ID: 2kTZ5McREUT
dom/canvas/CanvasRenderingContext2D.cpp
dom/svg/SVGContentUtils.cpp
dom/svg/SVGContentUtils.h
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/forms/nsTextControlFrame.cpp
layout/generic/ReflowInput.cpp
layout/generic/ReflowInput.h
layout/generic/nsBlockFrame.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsLineLayout.cpp
layout/generic/nsTextFrame.cpp
layout/generic/nsTextRunTransformations.h
layout/mathml/nsMathMLFrame.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsFontFaceUtils.cpp
layout/svg/nsSVGOuterSVGFrame.cpp
layout/xul/nsListBoxBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4294,19 +4294,20 @@ CanvasRenderingContext2D::DrawOrMeasureT
   gfxFontGroup* currentFontStyle = GetCurrentFontStyle();
   if (!currentFontStyle) {
     return NS_ERROR_FAILURE;
   }
 
   MOZ_ASSERT(!presShell->IsDestroying(),
              "GetCurrentFontStyle() should have returned null if the presshell is being destroyed");
 
+  nsPresContext* presContext = presShell->GetPresContext();
+
   // ensure user font set is up to date
-  currentFontStyle->
-    SetUserFontSet(presShell->GetPresContext()->GetUserFontSet());
+  currentFontStyle->SetUserFontSet(presContext->GetUserFontSet());
 
   if (currentFontStyle->GetStyle()->size == 0.0F) {
     if (aWidth) {
       *aWidth = 0;
     }
     return NS_OK;
   }
 
@@ -4315,16 +4316,17 @@ CanvasRenderingContext2D::DrawOrMeasureT
   }
 
   CanvasBidiProcessor processor;
 
   // If we don't have a ComputedStyle, we can't set up vertical-text flags
   // (for now, at least; perhaps we need new Canvas API to control this).
   processor.mTextRunFlags = canvasStyle
     ? nsLayoutUtils::GetTextRunFlagsForStyle(canvasStyle,
+                                             presContext,
                                              canvasStyle->StyleFont(),
                                              canvasStyle->StyleText(),
                                              0)
     : gfx::ShapedTextFlags();
 
   GetAppUnitsValues(&processor.mAppUnitsPerDevPixel, nullptr);
   processor.mPt = gfx::Point(aX, aY);
   processor.mDrawTarget =
--- a/dom/svg/SVGContentUtils.cpp
+++ b/dom/svg/SVGContentUtils.cpp
@@ -265,96 +265,105 @@ SVGContentUtils::GetStrokeWidth(nsSVGEle
   if (aContextPaint && styleSVG->StrokeWidthFromObject()) {
     return aContextPaint->GetStrokeWidth();
   }
 
   return SVGContentUtils::CoordToFloat(aElement, styleSVG->mStrokeWidth);
 }
 
 float
-SVGContentUtils::GetFontSize(Element *aElement)
+SVGContentUtils::GetFontSize(Element* aElement)
 {
-  if (!aElement)
+  if (!aElement) {
     return 1.0f;
+  }
+
+  nsPresContext* pc = nsContentUtils::GetContextForContent(aElement);
+  if (!pc) {
+    return 1.0f;
+  }
 
   RefPtr<ComputedStyle> computedStyle =
     nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
   if (!computedStyle) {
     // ReportToConsole
     NS_WARNING("Couldn't get ComputedStyle for content in GetFontStyle");
     return 1.0f;
   }
 
-  return GetFontSize(computedStyle);
+  return GetFontSize(computedStyle, pc);
 }
 
 float
-SVGContentUtils::GetFontSize(nsIFrame *aFrame)
+SVGContentUtils::GetFontSize(nsIFrame* aFrame)
 {
   MOZ_ASSERT(aFrame, "NULL frame in GetFontSize");
-  return GetFontSize(aFrame->Style());
+  return GetFontSize(aFrame->Style(), aFrame->PresContext());
 }
 
 float
-SVGContentUtils::GetFontSize(ComputedStyle *aComputedStyle)
+SVGContentUtils::GetFontSize(ComputedStyle* aComputedStyle,
+                             nsPresContext* aPresContext)
 {
-  MOZ_ASSERT(aComputedStyle, "NULL ComputedStyle in GetFontSize");
-
-  nsPresContext *presContext = aComputedStyle->PresContext();
-  MOZ_ASSERT(presContext, "NULL pres context in GetFontSize");
+  MOZ_ASSERT(aComputedStyle);
+  MOZ_ASSERT(aPresContext);
 
   nscoord fontSize = aComputedStyle->StyleFont()->mSize;
   return nsPresContext::AppUnitsToFloatCSSPixels(fontSize) /
-         presContext->EffectiveTextZoom();
+         aPresContext->EffectiveTextZoom();
 }
 
 float
-SVGContentUtils::GetFontXHeight(Element *aElement)
+SVGContentUtils::GetFontXHeight(Element* aElement)
 {
-  if (!aElement)
+  if (!aElement) {
     return 1.0f;
+  }
 
-  RefPtr<ComputedStyle> computedStyle =
+  nsPresContext* pc = nsContentUtils::GetContextForContent(aElement);
+  if (!pc) {
+    return 1.0f;
+  }
+
+  RefPtr<ComputedStyle> style =
     nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
-  if (!computedStyle) {
+  if (!style) {
     // ReportToConsole
     NS_WARNING("Couldn't get ComputedStyle for content in GetFontStyle");
     return 1.0f;
   }
 
-  return GetFontXHeight(computedStyle);
+  return GetFontXHeight(style, pc);
 }
 
 float
 SVGContentUtils::GetFontXHeight(nsIFrame *aFrame)
 {
   MOZ_ASSERT(aFrame, "NULL frame in GetFontXHeight");
-  return GetFontXHeight(aFrame->Style());
+  return GetFontXHeight(aFrame->Style(), aFrame->PresContext());
 }
 
 float
-SVGContentUtils::GetFontXHeight(ComputedStyle *aComputedStyle)
+SVGContentUtils::GetFontXHeight(ComputedStyle* aComputedStyle,
+                                nsPresContext* aPresContext)
 {
-  MOZ_ASSERT(aComputedStyle, "NULL ComputedStyle in GetFontXHeight");
-
-  nsPresContext *presContext = aComputedStyle->PresContext();
-  MOZ_ASSERT(presContext, "NULL pres context in GetFontXHeight");
+  MOZ_ASSERT(aComputedStyle && aPresContext);
 
   RefPtr<nsFontMetrics> fontMetrics =
-    nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle);
+    nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle, aPresContext);
 
   if (!fontMetrics) {
     // ReportToConsole
     NS_WARNING("no FontMetrics in GetFontXHeight()");
     return 1.0f;
   }
 
   nscoord xHeight = fontMetrics->XHeight();
   return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
-         presContext->EffectiveTextZoom();
+         aPresContext->EffectiveTextZoom();
 }
 nsresult
 SVGContentUtils::ReportToConsole(nsIDocument* doc,
                                  const char* aWarning,
                                  const char16_t **aParams,
                                  uint32_t aParamsLength)
 {
   return nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
--- a/dom/svg/SVGContentUtils.h
+++ b/dom/svg/SVGContentUtils.h
@@ -15,16 +15,17 @@
 #include "mozilla/RangedPtr.h"
 #include "nsError.h"
 #include "nsStringFwd.h"
 #include "gfx2DGlue.h"
 
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
+class nsPresContext;
 class nsStyleCoord;
 class nsSVGElement;
 
 namespace mozilla {
 class ComputedStyle;
 class nsSVGAnimatedTransformList;
 class SVGAnimatedPreserveAspectRatio;
 class SVGContextPaint;
@@ -175,29 +176,29 @@ public:
 
   /*
    * Get the number of CSS px (user units) per em (i.e. the em-height in user
    * units) for an nsIContent
    *
    * XXX document the conditions under which these may fail, and what they
    * return in those cases.
    */
-  static float GetFontSize(mozilla::dom::Element *aElement);
-  static float GetFontSize(nsIFrame *aFrame);
-  static float GetFontSize(ComputedStyle *aComputedStyle);
+  static float GetFontSize(mozilla::dom::Element* aElement);
+  static float GetFontSize(nsIFrame* aFrame);
+  static float GetFontSize(ComputedStyle*, nsPresContext*);
   /*
    * Get the number of CSS px (user units) per ex (i.e. the x-height in user
    * units) for an nsIContent
    *
    * XXX document the conditions under which these may fail, and what they
    * return in those cases.
    */
-  static float GetFontXHeight(mozilla::dom::Element *aElement);
-  static float GetFontXHeight(nsIFrame *aFrame);
-  static float GetFontXHeight(ComputedStyle *aComputedStyle);
+  static float GetFontXHeight(mozilla::dom::Element* aElement);
+  static float GetFontXHeight(nsIFrame* aFrame);
+  static float GetFontXHeight(ComputedStyle*, nsPresContext*);
 
   /*
    * Report a localized error message to the error console.
    */
   static nsresult ReportToConsole(nsIDocument* doc,
                                   const char* aWarning,
                                   const char16_t **aParams,
                                   uint32_t aParamsLength);
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -4418,18 +4418,17 @@ nsCSSFrameConstructor::FindXULDescriptio
 }
 
 #ifdef XP_MACOSX
 /* static */
 const nsCSSFrameConstructor::FrameConstructionData*
 nsCSSFrameConstructor::FindXULMenubarData(Element* aElement,
                                           ComputedStyle* aComputedStyle)
 {
-  nsCOMPtr<nsIDocShell> treeItem =
-    aComputedStyle->PresContext()->GetDocShell();
+  nsCOMPtr<nsIDocShell> treeItem = aElement->OwnerDoc()->GetDocShell();
   if (treeItem && nsIDocShellTreeItem::typeChrome == treeItem->ItemType()) {
     nsCOMPtr<nsIDocShellTreeItem> parent;
     treeItem->GetParent(getter_AddRefs(parent));
     if (!parent) {
       // This is the root.  Suppress the menubar, since on Mac
       // window menus are not attached to the window.
       static const FrameConstructionData sSuppressData = SUPPRESS_FCDATA();
       return &sSuppressData;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4690,52 +4690,52 @@ nsLayoutUtils::GetFontMetricsForFrame(co
     if (clusters == 2) {
       variantWidth = NS_FONT_VARIANT_WIDTH_HALF;
     } else if (clusters == 3) {
       variantWidth = NS_FONT_VARIANT_WIDTH_THIRD;
     } else if (clusters == 4) {
       variantWidth = NS_FONT_VARIANT_WIDTH_QUARTER;
     }
   }
-  return GetFontMetricsForComputedStyle(computedStyle, aInflation, variantWidth);
+  return GetFontMetricsForComputedStyle(computedStyle, aFrame->PresContext(),
+                                        aInflation, variantWidth);
 }
 
 already_AddRefed<nsFontMetrics>
 nsLayoutUtils::GetFontMetricsForComputedStyle(ComputedStyle* aComputedStyle,
-                                             float aInflation,
-                                             uint8_t aVariantWidth)
-{
-  nsPresContext* pc = aComputedStyle->PresContext();
-
+                                              nsPresContext* aPresContext,
+                                              float aInflation,
+                                              uint8_t aVariantWidth)
+{
   WritingMode wm(aComputedStyle);
   const nsStyleFont* styleFont = aComputedStyle->StyleFont();
   nsFontMetrics::Params params;
   params.language = styleFont->mLanguage;
   params.explicitLanguage = styleFont->mExplicitLanguage;
   params.orientation =
     wm.IsVertical() && !wm.IsSideways() ? gfxFont::eVertical
                                         : gfxFont::eHorizontal;
   // pass the user font set object into the device context to
   // pass along to CreateFontGroup
-  params.userFontSet = pc->GetUserFontSet();
-  params.textPerf = pc->GetTextPerfMetrics();
+  params.userFontSet = aPresContext->GetUserFontSet();
+  params.textPerf = aPresContext->GetTextPerfMetrics();
 
   // When aInflation is 1.0 and we don't require width variant, avoid
   // making a local copy of the nsFont.
   // This also avoids running font.size through floats when it is large,
   // which would be lossy.  Fortunately, in such cases, aInflation is
   // guaranteed to be 1.0f.
   if (aInflation == 1.0f && aVariantWidth == NS_FONT_VARIANT_WIDTH_NORMAL) {
-    return pc->DeviceContext()->GetMetricsFor(styleFont->mFont, params);
+    return aPresContext->DeviceContext()->GetMetricsFor(styleFont->mFont, params);
   }
 
   nsFont font = styleFont->mFont;
   font.size = NSToCoordRound(font.size * aInflation);
   font.variantWidth = aVariantWidth;
-  return pc->DeviceContext()->GetMetricsFor(font, params);
+  return aPresContext->DeviceContext()->GetMetricsFor(font, params);
 }
 
 nsIFrame*
 nsLayoutUtils::FindChildContainingDescendant(nsIFrame* aParent, nsIFrame* aDescendantFrame)
 {
   nsIFrame* result = aDescendantFrame;
 
   while (result) {
@@ -7516,16 +7516,17 @@ nsLayoutUtils::GetReferenceFrame(nsIFram
       return f;
     }
     f = parent;
   }
 }
 
 /* static */ gfx::ShapedTextFlags
 nsLayoutUtils::GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle,
+                                       nsPresContext* aPresContext,
                                        const nsStyleFont* aStyleFont,
                                        const nsStyleText* aStyleText,
                                        nscoord aLetterSpacing)
 {
   gfx::ShapedTextFlags result = gfx::ShapedTextFlags();
   if (aLetterSpacing != 0 ||
       aStyleText->mTextJustify == StyleTextJustify::InterCharacter) {
     result |= gfx::ShapedTextFlags::TEXT_DISABLE_OPTIONAL_LIGATURES;
@@ -7533,18 +7534,17 @@ nsLayoutUtils::GetTextRunFlagsForStyle(C
   if (aStyleText->mControlCharacterVisibility == NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN) {
     result |= gfx::ShapedTextFlags::TEXT_HIDE_CONTROL_CHARACTERS;
   }
   switch (aComputedStyle->StyleText()->mTextRendering) {
   case NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED:
     result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
     break;
   case NS_STYLE_TEXT_RENDERING_AUTO:
-    if (aStyleFont->mFont.size <
-        aComputedStyle->PresContext()->GetAutoQualityMinFontSize()) {
+    if (aStyleFont->mFont.size < aPresContext->GetAutoQualityMinFontSize()) {
       result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
     }
     break;
   default:
     break;
   }
   return result | GetTextRunOrientFlagsForStyle(aComputedStyle);
 }
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1298,31 +1298,35 @@ public:
 
   /**
    * Get the font metrics corresponding to the given style data.
    * @param aComputedStyle the style data
    * @param aSizeInflation number to multiply font size by
    */
   static already_AddRefed<nsFontMetrics> GetFontMetricsForComputedStyle(
       ComputedStyle* aComputedStyle,
+      nsPresContext* aPresContext,
       float aSizeInflation = 1.0f,
       uint8_t aVariantWidth = NS_FONT_VARIANT_WIDTH_NORMAL);
 
   /**
    * Get the font metrics of emphasis marks corresponding to the given
    * style data. The result is same as GetFontMetricsForComputedStyle
    * except that the font size is scaled down to 50%.
    * @param aComputedStyle the style data
    * @param aInflation number to multiple font size by
    */
   static already_AddRefed<nsFontMetrics> GetFontMetricsOfEmphasisMarks(
       ComputedStyle* aComputedStyle,
+      nsPresContext* aPresContext,
       float aInflation)
   {
-    return GetFontMetricsForComputedStyle(aComputedStyle, aInflation * 0.5f);
+    return GetFontMetricsForComputedStyle(aComputedStyle,
+                                          aPresContext,
+                                          aInflation * 0.5f);
   }
 
   /**
    * Find the immediate child of aParent whose frame subtree contains
    * aDescendantFrame. Returns null if aDescendantFrame is not a descendant
    * of aParent.
    */
   static nsIFrame* FindChildContainingDescendant(nsIFrame* aParent, nsIFrame* aDescendantFrame);
@@ -2061,16 +2065,17 @@ public:
    * Get textrun construction flags determined by a given style; in particular
    * some combination of:
    * -- TEXT_DISABLE_OPTIONAL_LIGATURES if letter-spacing is in use
    * -- TEXT_OPTIMIZE_SPEED if the text-rendering CSS property and font size
    * and prefs indicate we should be optimizing for speed over quality
    */
   static mozilla::gfx::ShapedTextFlags
   GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle,
+                          nsPresContext* aPresContext,
                           const nsStyleFont* aStyleFont,
                           const nsStyleText* aStyleText,
                           nscoord aLetterSpacing);
 
   /**
    * Get orientation flags for textrun construction.
    */
   static mozilla::gfx::ShapedTextFlags
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -170,18 +170,21 @@ nsTextControlFrame::CalcIntrinsicSize(gf
   nscoord lineHeight  = 0;
   nscoord charWidth   = 0;
   nscoord charMaxAdvance  = 0;
 
   RefPtr<nsFontMetrics> fontMet =
     nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation);
 
   lineHeight =
-    ReflowInput::CalcLineHeight(GetContent(), Style(),
-                                      NS_AUTOHEIGHT, aFontSizeInflation);
+    ReflowInput::CalcLineHeight(GetContent(),
+                                Style(),
+                                PresContext(),
+                                NS_AUTOHEIGHT,
+                                aFontSizeInflation);
   charWidth = fontMet->AveCharWidth();
   charMaxAdvance = fontMet->MaxAdvance();
 
   // Set the width equal to the width in characters
   int32_t cols = GetCols();
   intrinsicSize.ISize(aWM) = cols * charWidth;
 
   // To better match IE, take the maximum character width(in twips) and remove
@@ -628,18 +631,21 @@ nsTextControlFrame::Reflow(nsPresContext
               aReflowInput.ComputedBSize() +
               aReflowInput.ComputedLogicalBorderPadding().BStartEnd(wm));
   aDesiredSize.SetSize(wm, finalSize);
 
   // Calculate the baseline and store it in mFirstBaseline.
   nscoord lineHeight = aReflowInput.ComputedBSize();
   float inflation = nsLayoutUtils::FontSizeInflationFor(this);
   if (!IsSingleLineTextControl()) {
-    lineHeight = ReflowInput::CalcLineHeight(GetContent(), Style(),
-                                             NS_AUTOHEIGHT, inflation);
+    lineHeight = ReflowInput::CalcLineHeight(GetContent(),
+                                             Style(),
+                                             PresContext(),
+                                             NS_AUTOHEIGHT,
+                                             inflation);
   }
   RefPtr<nsFontMetrics> fontMet =
     nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
   mFirstBaseline =
     nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight,
                                            wm.IsLineInverted()) +
     aReflowInput.ComputedLogicalBorderPadding().BStart(wm);
   aDesiredSize.SetBlockStartAscent(mFirstBaseline);
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -2845,16 +2845,17 @@ GetNormalLineHeight(nsFontMetrics* aFont
     //case eNoExternalLeading:
     normalLineHeight = emHeight + internalLeading;
   }
   return normalLineHeight;
 }
 
 static inline nscoord
 ComputeLineHeight(ComputedStyle* aComputedStyle,
+                  nsPresContext* aPresContext,
                   nscoord aBlockBSize,
                   float aFontSizeInflation)
 {
   const nsStyleCoord& lhCoord = aComputedStyle->StyleText()->mLineHeight;
 
   if (lhCoord.GetUnit() == eStyleUnit_Coord) {
     nscoord result = lhCoord.GetCoordValue();
     if (aFontSizeInflation != 1.0f) {
@@ -2878,41 +2879,48 @@ ComputeLineHeight(ComputedStyle* aComput
     NS_ASSERTION(lhCoord.GetIntValue() == NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
                  "bad line-height value");
     if (aBlockBSize != NS_AUTOHEIGHT) {
       return aBlockBSize;
     }
   }
 
   RefPtr<nsFontMetrics> fm = nsLayoutUtils::
-    GetFontMetricsForComputedStyle(aComputedStyle, aFontSizeInflation);
+    GetFontMetricsForComputedStyle(aComputedStyle, aPresContext, aFontSizeInflation);
   return GetNormalLineHeight(fm);
 }
 
 nscoord
 ReflowInput::CalcLineHeight() const
 {
   nscoord blockBSize =
     nsLayoutUtils::IsNonWrapperBlock(mFrame) ? ComputedBSize() :
     (mCBReflowInput ? mCBReflowInput->ComputedBSize() : NS_AUTOHEIGHT);
 
-  return CalcLineHeight(mFrame->GetContent(), mFrame->Style(), blockBSize,
+  return CalcLineHeight(mFrame->GetContent(),
+                        mFrame->Style(),
+                        mFrame->PresContext(),
+                        blockBSize,
                         nsLayoutUtils::FontSizeInflationFor(mFrame));
 }
 
 /* static */ nscoord
 ReflowInput::CalcLineHeight(nsIContent* aContent,
-                                  ComputedStyle* aComputedStyle,
-                                  nscoord aBlockBSize,
-                                  float aFontSizeInflation)
+                            ComputedStyle* aComputedStyle,
+                            nsPresContext* aPresContext,
+                            nscoord aBlockBSize,
+                            float aFontSizeInflation)
 {
   NS_PRECONDITION(aComputedStyle, "Must have a ComputedStyle");
 
   nscoord lineHeight =
-    ComputeLineHeight(aComputedStyle, aBlockBSize, aFontSizeInflation);
+    ComputeLineHeight(aComputedStyle,
+                      aPresContext,
+                      aBlockBSize,
+                      aFontSizeInflation);
 
   NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
 
   HTMLInputElement* input = HTMLInputElement::FromNodeOrNull(aContent);
   if (input && input->IsSingleLineTextControl()) {
     // For Web-compatibility, single-line text input elements cannot
     // have a line-height smaller than one.
     nscoord lineHeightOne =
--- a/layout/generic/ReflowInput.h
+++ b/layout/generic/ReflowInput.h
@@ -766,16 +766,17 @@ public:
    *                     line-height:-moz-block-height.
    * @param aFontSizeInflation The result of the appropriate
    *                           nsLayoutUtils::FontSizeInflationFor call,
    *                           or 1.0 if during intrinsic size
    *                           calculation.
    */
   static nscoord CalcLineHeight(nsIContent* aContent,
                                 ComputedStyle* aComputedStyle,
+                                nsPresContext* aPresContext,
                                 nscoord aBlockBSize,
                                 float aFontSizeInflation);
 
 
   mozilla::LogicalSize ComputeContainingBlockRectangle(
          nsPresContext*           aPresContext,
          const ReflowInput* aContainingBlockRI) const;
 
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -525,18 +525,21 @@ nsBlockFrame::GetCaretBaseline() const
     if (firstLine->GetChildCount()) {
       return bp.top + firstLine->mFirstChild->GetCaretBaseline();
     }
   }
   float inflation = nsLayoutUtils::FontSizeInflationFor(this);
   RefPtr<nsFontMetrics> fm =
     nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
   nscoord lineHeight =
-    ReflowInput::CalcLineHeight(GetContent(), Style(),
-                                      contentRect.height, inflation);
+    ReflowInput::CalcLineHeight(GetContent(),
+                                Style(),
+                                PresContext(),
+                                contentRect.height,
+                                inflation);
   const WritingMode wm = GetWritingMode();
   return nsLayoutUtils::GetCenteredFontBaseline(fm, lineHeight,
                                                 wm.IsLineInverted()) + bp.top;
 }
 
 /////////////////////////////////////////////////////////////////////////////
 // Child frame enumeration
 
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -482,17 +482,17 @@ nsImageFrame::ShouldCreateImageFrameFor(
            !aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::alt) &&
            !aElement->IsHTMLElement(nsGkAtoms::object) &&
            !aElement->IsHTMLElement(nsGkAtoms::input)) {
     // Use a sized box if we have no alt text.  This means no alt attribute
     // and the node is not an object or an input (since those always have alt
     // text).
     useSizedBox = true;
   }
-  else if (aComputedStyle->PresContext()->CompatibilityMode() !=
+  else if (aElement->OwnerDoc()->GetCompatibilityMode() !=
            eCompatibility_NavQuirks) {
     useSizedBox = false;
   }
   else {
     // check whether we have specified size
     useSizedBox = HaveSpecifiedSize(aComputedStyle->StylePosition());
   }
 
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -1657,18 +1657,20 @@ nsLineLayout::PlaceTopBottomFrames(PerSp
       PlaceTopBottomFrames(span, fromStart, aLineBSize);
     }
   }
 }
 
 static nscoord
 GetBSizeOfEmphasisMarks(nsIFrame* aSpanFrame, float aInflation)
 {
-  RefPtr<nsFontMetrics> fm = nsLayoutUtils::
-    GetFontMetricsOfEmphasisMarks(aSpanFrame->Style(), aInflation);
+  RefPtr<nsFontMetrics> fm =
+    nsLayoutUtils::GetFontMetricsOfEmphasisMarks(aSpanFrame->Style(),
+                                                 aSpanFrame->PresContext(),
+                                                 aInflation);
   return fm->MaxHeight();
 }
 
 void
 nsLineLayout::AdjustLeadings(nsIFrame* spanFrame, PerSpanData* psd,
                              const nsStyleText* aStyleText, float aInflation,
                              bool* aZeroEffectiveSpanBox)
 {
@@ -1879,20 +1881,22 @@ nsLineLayout::VerticalAlignFrames(PerSpa
 #endif
   }
   else {
     // Compute the logical block size for this span. The logical block size
     // is based on the "line-height" value, not the font-size. Also
     // compute the top leading.
     float inflation =
       GetInflationForBlockDirAlignment(spanFrame, mInflationMinFontSize);
-    nscoord logicalBSize = ReflowInput::
-      CalcLineHeight(spanFrame->GetContent(), spanFrame->Style(),
-                     mBlockReflowInput->ComputedHeight(),
-                     inflation);
+    nscoord logicalBSize =
+      ReflowInput::CalcLineHeight(spanFrame->GetContent(),
+                                  spanFrame->Style(),
+                                  spanFrame->PresContext(),
+                                  mBlockReflowInput->ComputedHeight(),
+                                  inflation);
     nscoord contentBSize = spanFramePFD->mBounds.BSize(lineWM) -
       spanFramePFD->mBorderPadding.BStartEnd(lineWM);
 
     // Special-case for a ::first-letter frame, set the line height to
     // the frame block size if the user has left line-height == normal
     const nsStyleText* styleText = spanFrame->StyleText();
     if (spanFramePFD->mIsLetterFrame &&
         !spanFrame->GetPrevInFlow() &&
@@ -2168,18 +2172,21 @@ nsLineLayout::VerticalAlignFrames(PerSpa
     } else {
       // We have either a coord, a percent, or a calc().
       nscoord pctBasis = 0;
       if (verticalAlign.HasPercent()) {
         // Percentages are like lengths, except treated as a percentage
         // of the elements line block size value.
         float inflation =
           GetInflationForBlockDirAlignment(frame, mInflationMinFontSize);
-        pctBasis = ReflowInput::CalcLineHeight(frame->GetContent(),
-          frame->Style(), mBlockReflowInput->ComputedBSize(),
+        pctBasis = ReflowInput::CalcLineHeight(
+          frame->GetContent(),
+          frame->Style(),
+          frame->PresContext(),
+          mBlockReflowInput->ComputedBSize(),
           inflation);
       }
       nscoord offset = verticalAlign.ComputeCoordPercentCalc(pctBasis);
       // According to the CSS2 spec (10.8.1), a positive value
       // "raises" the box by the given distance while a negative value
       // "lowers" the box by the given distance (with zero being the
       // baseline). Since Y coordinates increase towards the bottom of
       // the screen we reverse the sign, unless the line orientation is
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -1892,25 +1892,28 @@ BuildTextRunsScanner::ContinueTextRunAcr
     return false;
   }
 
   ComputedStyle* sc2 = aFrame2->Style();
   const nsStyleText* textStyle2 = sc2->StyleText();
   if (sc1 == sc2)
     return true;
 
+  nsPresContext* pc = aFrame1->PresContext();
+  MOZ_ASSERT(pc == aFrame2->PresContext());
+
   const nsStyleFont* fontStyle1 = sc1->StyleFont();
   const nsStyleFont* fontStyle2 = sc2->StyleFont();
   nscoord letterSpacing1 = LetterSpacing(aFrame1);
   nscoord letterSpacing2 = LetterSpacing(aFrame2);
   return fontStyle1->mFont == fontStyle2->mFont &&
     fontStyle1->mLanguage == fontStyle2->mLanguage &&
     textStyle1->mTextTransform == textStyle2->mTextTransform &&
-    nsLayoutUtils::GetTextRunFlagsForStyle(sc1, fontStyle1, textStyle1, letterSpacing1) ==
-      nsLayoutUtils::GetTextRunFlagsForStyle(sc2, fontStyle2, textStyle2, letterSpacing2);
+    nsLayoutUtils::GetTextRunFlagsForStyle(sc1, pc, fontStyle1, textStyle1, letterSpacing1) ==
+      nsLayoutUtils::GetTextRunFlagsForStyle(sc2, pc, fontStyle2, textStyle2, letterSpacing2);
 }
 
 void BuildTextRunsScanner::ScanFrame(nsIFrame* aFrame)
 {
   LayoutFrameType frameType = aFrame->Type();
   if (frameType == LayoutFrameType::RubyTextContainer) {
     // Don't include any ruby text container into the text run.
     return;
@@ -2295,17 +2298,18 @@ BuildTextRunsScanner::BuildTextRunForFra
   }
   if (mNextRunContextInfo & nsTextFrameUtils::INCOMING_ARABICCHAR) {
     flags |= gfx::ShapedTextFlags::TEXT_TRAILING_ARABICCHAR;
   }
   // ContinueTextRunAcrossFrames guarantees that it doesn't matter which
   // frame's style is used, so we use a mixture of the first frame and
   // last frame's style
   flags |= nsLayoutUtils::GetTextRunFlagsForStyle(lastComputedStyle,
-      fontStyle, textStyle, LetterSpacing(firstFrame, textStyle));
+      firstFrame->PresContext(), fontStyle, textStyle,
+      LetterSpacing(firstFrame, textStyle));
   // XXX this is a bit of a hack. For performance reasons, if we're favouring
   // performance over quality, don't try to get accurate glyph extents.
   if (!(flags & gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED)) {
     flags |= gfx::ShapedTextFlags::TEXT_NEED_BOUNDING_BOX;
   }
 
   // Convert linebreak coordinates to transformed string offsets
   NS_ASSERTION(nextBreakIndex == mLineBreakBeforeFrames.Length(),
@@ -2344,17 +2348,17 @@ BuildTextRunsScanner::BuildTextRunForFra
            f = f->GetNextContinuation()) {
         uint32_t offset = iter.GetSkippedOffset();
         iter.AdvanceOriginal(f->GetContentLength());
         uint32_t end = iter.GetSkippedOffset();
         // Text-combined frames have content-dependent transform, so we
         // want to create new nsTransformedCharStyle for them anyway.
         if (sc != f->Style() || sc->IsTextCombined()) {
           sc = f->Style();
-          charStyle = new nsTransformedCharStyle(sc);
+          charStyle = new nsTransformedCharStyle(sc, f->PresContext());
           if (sc->IsTextCombined() && f->CountGraphemeClusters() > 1) {
             charStyle->mForceNonFullWidth = true;
           }
         }
         uint32_t j;
         for (j = offset; j < end; ++j) {
           styles.AppendElement(charStyle);
         }
@@ -5550,18 +5554,20 @@ nsTextFrame::UpdateTextEmphasis(WritingM
     return nsRect();
   }
 
   ComputedStyle* computedStyle = Style();
   bool isTextCombined = computedStyle->IsTextCombined();
   if (isTextCombined) {
     computedStyle = GetParent()->Style();
   }
-  RefPtr<nsFontMetrics> fm = nsLayoutUtils::
-    GetFontMetricsOfEmphasisMarks(computedStyle, GetFontSizeInflation());
+  RefPtr<nsFontMetrics> fm =
+    nsLayoutUtils::GetFontMetricsOfEmphasisMarks(computedStyle,
+                                                 PresContext(),
+                                                 GetFontSizeInflation());
   EmphasisMarkInfo* info = new EmphasisMarkInfo;
   info->textRun =
     GenerateTextRunForEmphasisMarks(this, fm, computedStyle, styleText);
   info->advance = info->textRun->GetAdvanceWidth();
 
   // Calculate the baseline offset
   LogicalSide side = styleText->TextEmphasisSide(aWM);
   LogicalSize frameSize = GetLogicalSize(aWM);
@@ -5782,18 +5788,20 @@ nsTextFrame::UnionAdditionalOverflow(nsP
 gfxFloat
 nsTextFrame::ComputeDescentLimitForSelectionUnderline(
                nsPresContext* aPresContext,
                const gfxFont::Metrics& aFontMetrics)
 {
   gfxFloat app = aPresContext->AppUnitsPerDevPixel();
   nscoord lineHeightApp =
     ReflowInput::CalcLineHeight(GetContent(),
-                                      Style(), NS_AUTOHEIGHT,
-                                      GetFontSizeInflation());
+                                Style(),
+                                PresContext(),
+                                NS_AUTOHEIGHT,
+                                GetFontSizeInflation());
   gfxFloat lineHeight = gfxFloat(lineHeightApp) / app;
   if (lineHeight <= aFontMetrics.maxHeight) {
     return aFontMetrics.maxDescent;
   }
   return aFontMetrics.maxDescent + (lineHeight - aFontMetrics.maxHeight) / 2;
 }
 
 // Make sure this stays in sync with DrawSelectionDecorations below
--- a/layout/generic/nsTextRunTransformations.h
+++ b/layout/generic/nsTextRunTransformations.h
@@ -7,34 +7,36 @@
 #ifndef NSTEXTRUNTRANSFORMATIONS_H_
 #define NSTEXTRUNTRANSFORMATIONS_H_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/UniquePtr.h"
 #include "gfxTextRun.h"
 #include "mozilla/ComputedStyle.h"
+#include "nsPresContext.h"
 
 class nsTransformedTextRun;
 
 struct nsTransformedCharStyle final {
   NS_INLINE_DECL_REFCOUNTING(nsTransformedCharStyle)
 
-  explicit nsTransformedCharStyle(mozilla::ComputedStyle* aStyle)
+  explicit nsTransformedCharStyle(mozilla::ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext)
     : mFont(aStyle->StyleFont()->mFont)
     , mLanguage(aStyle->StyleFont()->mLanguage)
-    , mPresContext(aStyle->PresContext())
+    , mPresContext(aPresContext)
     , mScriptSizeMultiplier(aStyle->StyleFont()->mScriptSizeMultiplier)
     , mTextTransform(aStyle->StyleText()->mTextTransform)
     , mMathVariant(aStyle->StyleFont()->mMathVariant)
     , mExplicitLanguage(aStyle->StyleFont()->mExplicitLanguage) {}
 
   nsFont                  mFont;
-  RefPtr<nsAtom>       mLanguage;
-  RefPtr<nsPresContext> mPresContext;
+  RefPtr<nsAtom>          mLanguage;
+  RefPtr<nsPresContext>   mPresContext;
   float                   mScriptSizeMultiplier;
   uint8_t                 mTextTransform;
   uint8_t                 mMathVariant;
   bool                    mExplicitLanguage;
   bool                    mForceNonFullWidth = false;
 
 private:
   ~nsTransformedCharStyle() {}
--- a/layout/mathml/nsMathMLFrame.cpp
+++ b/layout/mathml/nsMathMLFrame.cpp
@@ -226,17 +226,19 @@ nsMathMLFrame::CalcLength(nsPresContext*
 
   if (eCSSUnit_EM == unit) {
     const nsStyleFont* font = aComputedStyle->StyleFont();
     return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
   }
   else if (eCSSUnit_XHeight == unit) {
     aPresContext->SetUsesExChUnits(true);
     RefPtr<nsFontMetrics> fm = nsLayoutUtils::
-      GetFontMetricsForComputedStyle(aComputedStyle, aFontSizeInflation);
+      GetFontMetricsForComputedStyle(aComputedStyle,
+                                     aPresContext,
+                                     aFontSizeInflation);
     nscoord xHeight = fm->XHeight();
     return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
   }
 
   // MathML doesn't specify other CSS units such as rem or ch
   NS_ERROR("Unsupported unit");
   return 0;
 }
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -5631,28 +5631,32 @@ nsComputedDOMStyle::GetLineHeightCoord(n
 
     if (nsLayoutUtils::IsNonWrapperBlock(mInnerFrame)) {
       blockHeight = mInnerFrame->GetContentRect().height;
     } else {
       GetCBContentHeight(blockHeight);
     }
   }
 
+  nsPresContext* presContext = mPresShell->GetPresContext();
+
   // lie about font size inflation since we lie about font size (since
   // the inflation only applies to text)
-  aCoord = ReflowInput::CalcLineHeight(mContent, mComputedStyle,
+  aCoord = ReflowInput::CalcLineHeight(mContent,
+                                       mComputedStyle,
+                                       presContext,
                                        blockHeight, 1.0f);
 
   // CalcLineHeight uses font->mFont.size, but we want to use
   // font->mSize as the font size.  Adjust for that.  Also adjust for
   // the text zoom, if any.
   const nsStyleFont* font = StyleFont();
   float fCoord = float(aCoord);
   if (font->mAllowZoom) {
-    fCoord /= mPresShell->GetPresContext()->EffectiveTextZoom();
+    fCoord /= presContext->EffectiveTextZoom();
   }
   if (font->mFont.size != font->mSize) {
     fCoord = fCoord * (float(font->mSize) / float(font->mFont.size));
   }
   aCoord = NSToCoordRound(fCoord);
 
   return true;
 }
--- a/layout/style/nsFontFaceUtils.cpp
+++ b/layout/style/nsFontFaceUtils.cpp
@@ -13,16 +13,17 @@
 #include "nsPlaceholderFrame.h"
 #include "nsTArray.h"
 #include "SVGTextFrame.h"
 
 using namespace mozilla;
 
 static bool
 ComputedStyleContainsFont(ComputedStyle* aComputedStyle,
+                          nsPresContext* aPresContext,
                           const gfxUserFontSet* aUserFontSet,
                           const gfxUserFontEntry* aFont)
 {
   // if the font is null, simply check to see whether fontlist includes
   // downloadable fonts
   if (!aFont) {
     const mozilla::FontFamilyList& fontlist =
       aComputedStyle->StyleFont()->mFont.fontlist;
@@ -33,40 +34,43 @@ ComputedStyleContainsFont(ComputedStyle*
   const nsString& familyName = aFont->FamilyName();
   if (!aComputedStyle->StyleFont()->mFont.fontlist.Contains(familyName)) {
     return false;
   }
 
   // family name is in the fontlist, check to see if the font group
   // associated with the frame includes the specific userfont
   RefPtr<nsFontMetrics> fm =
-    nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle, 1.0f);
+    nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle,
+                                                  aPresContext,
+                                                  1.0f);
 
   if (fm->GetThebesFontGroup()->ContainsUserFont(aFont)) {
     return true;
   }
 
   return false;
 }
 
 static bool
 FrameUsesFont(nsIFrame* aFrame, const gfxUserFontEntry* aFont)
 {
   // check the style of the frame
-  gfxUserFontSet* ufs = aFrame->PresContext()->GetUserFontSet();
-  if (ComputedStyleContainsFont(aFrame->Style(), ufs, aFont)) {
+  nsPresContext* pc = aFrame->PresContext();
+  gfxUserFontSet* ufs = pc->GetUserFontSet();
+  if (ComputedStyleContainsFont(aFrame->Style(), pc, ufs, aFont)) {
     return true;
   }
 
   // check additional styles
   int32_t contextIndex = 0;
   for (ComputedStyle* extraContext;
        (extraContext = aFrame->GetAdditionalComputedStyle(contextIndex));
        ++contextIndex) {
-    if (ComputedStyleContainsFont(extraContext, ufs, aFont)) {
+    if (ComputedStyleContainsFont(extraContext, pc, ufs, aFont)) {
       return true;
     }
   }
 
   return false;
 }
 
 static void
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -62,17 +62,17 @@ NS_NewSVGOuterSVGFrame(nsIPresShell* aPr
   return new (aPresShell) nsSVGOuterSVGFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGFrame)
 
 nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(ComputedStyle* aStyle)
   : nsSVGDisplayContainerFrame(aStyle, kClassID)
   , mCallingReflowSVG(false)
-  , mFullZoom(aStyle->PresContext()->GetFullZoom())
+  , mFullZoom(PresContext()->GetFullZoom())
   , mViewportInitialized(false)
   , mIsRootContent(false)
 {
   // Outer-<svg> has CSS layout, so remove this bit:
   RemoveStateBits(NS_FRAME_SVG_LAYOUT);
 }
 
 // helper
--- a/layout/xul/nsListBoxBodyFrame.cpp
+++ b/layout/xul/nsListBoxBodyFrame.cpp
@@ -736,17 +736,18 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
           for (nsIContent* content = child->GetFirstChild();
                content; content = content->GetNextSibling()) {
             if (Text* text = content->GetAsText()) {
               text->AppendTextTo(value);
             }
           }
 
           RefPtr<nsFontMetrics> fm =
-            nsLayoutUtils::GetFontMetricsForComputedStyle(computedStyle);
+            nsLayoutUtils::GetFontMetricsForComputedStyle(computedStyle,
+                                                          presContext);
 
           nscoord textWidth =
             nsLayoutUtils::AppUnitWidthOfStringBidi(value, this, *fm,
                                                     *rendContext);
           textWidth += width;
 
           if (textWidth > largestWidth)
             largestWidth = textWidth;
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -1247,17 +1247,17 @@ nsTreeBodyFrame::GetCoordsForCellItem(in
 
     // Measure the width of the text. If the width of the text is greater than
     // the remaining width available, then we just assume that the text has
     // been cropped and use the remaining rect as the text Rect. Otherwise,
     // we add in borders and padding to the text dimension and give that back.
     ComputedStyle* textContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeCellText);
 
     RefPtr<nsFontMetrics> fm =
-      nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
+      nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, presContext);
     nscoord height = fm->MaxHeight();
 
     nsMargin textMargin;
     textContext->StyleMargin()->GetMargin(textMargin);
     textRect.Deflate(textMargin);
 
     // Center the text. XXX Obey vertical-align style prop?
     if (height < textRect.height) {
@@ -1621,17 +1621,17 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
 
   nsMargin textMargin;
   textContext->StyleMargin()->GetMargin(textMargin);
   textRect.Deflate(textMargin);
 
   AdjustForBorderPadding(textContext, textRect);
 
   RefPtr<nsFontMetrics> fm =
-    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
+    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, presContext);
   AdjustForCellText(cellText, aRowIndex, aColumn, *rc, *fm, textRect);
 
   if (aX >= textRect.x && aX < textRect.x + textRect.width)
     return nsCSSAnonBoxes::mozTreeCellText;
   else
     return nsCSSAnonBoxes::mozTreeCell;
 }
 
@@ -1749,17 +1749,17 @@ nsTreeBodyFrame::GetCellWidth(int32_t aR
   CheckTextForBidi(cellText);
 
   ComputedStyle* textContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeCellText);
 
   // Get the borders and padding for the text.
   GetBorderPadding(textContext, bp);
 
   RefPtr<nsFontMetrics> fm =
-    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
+    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, PresContext());
   // Get the width of the text itself
   nscoord width = nsLayoutUtils::AppUnitWidthOfStringBidi(cellText, this, *fm,
                                                           *aRenderingContext);
   nscoord totalTextWidth = width + bp.left + bp.right;
   aDesiredSize += totalTextWidth;
   return NS_OK;
 }
 
@@ -3747,17 +3747,17 @@ nsTreeBodyFrame::PaintText(int32_t      
 
   // Adjust the rect for its border and padding.
   nsMargin bp(0,0,0,0);
   GetBorderPadding(textContext, bp);
   textRect.Deflate(bp);
 
   // Compute our text size.
   RefPtr<nsFontMetrics> fontMet =
-    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
+    nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, PresContext());
 
   nscoord height = fontMet->MaxHeight();
   nscoord baseline = fontMet->MaxAscent();
 
   // Center the text. XXX Obey vertical-align style prop?
   if (height < textRect.height) {
     textRect.y += (textRect.height - height)/2;
     textRect.height = height;