Bug 1525371 - Kill ComputedStyle::mPresContext, move the pointer to the frame instead. r=jwatt
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 05 Feb 2019 17:45:54 +0100
changeset 515475 525e804dc7e63855e026be9557af15340d71455a
parent 515474 c944db09eff52b26d73e00f561beefa200a8bef0
child 515476 56eeff69792c1809cd2dd51a77ea276cde635cdc
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1525371
milestone67.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 1525371 - Kill ComputedStyle::mPresContext, move the pointer to the frame instead. r=jwatt Differential Revision: https://phabricator.services.mozilla.com/D18734
layout/base/nsCSSFrameConstructor.cpp
layout/forms/nsCheckboxRadioFrame.cpp
layout/forms/nsCheckboxRadioFrame.h
layout/forms/nsColorControlFrame.cpp
layout/forms/nsColorControlFrame.h
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsComboboxControlFrame.h
layout/forms/nsDateTimeControlFrame.cpp
layout/forms/nsDateTimeControlFrame.h
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsFieldSetFrame.h
layout/forms/nsFileControlFrame.cpp
layout/forms/nsFileControlFrame.h
layout/forms/nsGfxButtonControlFrame.cpp
layout/forms/nsGfxButtonControlFrame.h
layout/forms/nsHTMLButtonControlFrame.cpp
layout/forms/nsHTMLButtonControlFrame.h
layout/forms/nsImageControlFrame.cpp
layout/forms/nsLegendFrame.cpp
layout/forms/nsLegendFrame.h
layout/forms/nsListControlFrame.cpp
layout/forms/nsListControlFrame.h
layout/forms/nsMeterFrame.cpp
layout/forms/nsMeterFrame.h
layout/forms/nsNumberControlFrame.cpp
layout/forms/nsNumberControlFrame.h
layout/forms/nsProgressFrame.cpp
layout/forms/nsProgressFrame.h
layout/forms/nsRangeFrame.cpp
layout/forms/nsRangeFrame.h
layout/forms/nsSelectsAreaFrame.cpp
layout/forms/nsSelectsAreaFrame.h
layout/forms/nsTextControlFrame.cpp
layout/forms/nsTextControlFrame.h
layout/generic/BRFrame.cpp
layout/generic/ColumnSetWrapperFrame.cpp
layout/generic/ColumnSetWrapperFrame.h
layout/generic/DetailsFrame.cpp
layout/generic/DetailsFrame.h
layout/generic/ViewportFrame.cpp
layout/generic/ViewportFrame.h
layout/generic/nsAtomicContainerFrame.h
layout/generic/nsBackdropFrame.h
layout/generic/nsBlockFrame.cpp
layout/generic/nsBlockFrame.h
layout/generic/nsBulletFrame.h
layout/generic/nsCanvasFrame.cpp
layout/generic/nsCanvasFrame.h
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsColumnSetFrame.h
layout/generic/nsContainerFrame.h
layout/generic/nsFirstLetterFrame.cpp
layout/generic/nsFirstLetterFrame.h
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFlexContainerFrame.h
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsFrameSetFrame.h
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsGridContainerFrame.h
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsHTMLCanvasFrame.h
layout/generic/nsIFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
layout/generic/nsInlineFrame.cpp
layout/generic/nsInlineFrame.h
layout/generic/nsLeafFrame.h
layout/generic/nsPageContentFrame.cpp
layout/generic/nsPageContentFrame.h
layout/generic/nsPageFrame.cpp
layout/generic/nsPageFrame.h
layout/generic/nsPlaceholderFrame.cpp
layout/generic/nsPlaceholderFrame.h
layout/generic/nsPluginFrame.cpp
layout/generic/nsPluginFrame.h
layout/generic/nsRubyBaseContainerFrame.cpp
layout/generic/nsRubyBaseContainerFrame.h
layout/generic/nsRubyBaseFrame.cpp
layout/generic/nsRubyBaseFrame.h
layout/generic/nsRubyContentFrame.h
layout/generic/nsRubyFrame.cpp
layout/generic/nsRubyFrame.h
layout/generic/nsRubyTextContainerFrame.cpp
layout/generic/nsRubyTextContainerFrame.h
layout/generic/nsRubyTextFrame.cpp
layout/generic/nsRubyTextFrame.h
layout/generic/nsSimplePageSequenceFrame.cpp
layout/generic/nsSimplePageSequenceFrame.h
layout/generic/nsSplittableFrame.h
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsSubDocumentFrame.h
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
layout/generic/nsVideoFrame.cpp
layout/generic/nsVideoFrame.h
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLContainerFrame.h
layout/mathml/nsMathMLSelectedFrame.h
layout/mathml/nsMathMLTokenFrame.cpp
layout/mathml/nsMathMLTokenFrame.h
layout/mathml/nsMathMLmactionFrame.cpp
layout/mathml/nsMathMLmactionFrame.h
layout/mathml/nsMathMLmencloseFrame.cpp
layout/mathml/nsMathMLmencloseFrame.h
layout/mathml/nsMathMLmfencedFrame.cpp
layout/mathml/nsMathMLmfencedFrame.h
layout/mathml/nsMathMLmfracFrame.cpp
layout/mathml/nsMathMLmfracFrame.h
layout/mathml/nsMathMLmmultiscriptsFrame.cpp
layout/mathml/nsMathMLmmultiscriptsFrame.h
layout/mathml/nsMathMLmoFrame.cpp
layout/mathml/nsMathMLmoFrame.h
layout/mathml/nsMathMLmpaddedFrame.cpp
layout/mathml/nsMathMLmpaddedFrame.h
layout/mathml/nsMathMLmrootFrame.cpp
layout/mathml/nsMathMLmrootFrame.h
layout/mathml/nsMathMLmrowFrame.cpp
layout/mathml/nsMathMLmrowFrame.h
layout/mathml/nsMathMLmspaceFrame.cpp
layout/mathml/nsMathMLmspaceFrame.h
layout/mathml/nsMathMLmsqrtFrame.cpp
layout/mathml/nsMathMLmsqrtFrame.h
layout/mathml/nsMathMLmtableFrame.cpp
layout/mathml/nsMathMLmtableFrame.h
layout/mathml/nsMathMLmunderoverFrame.cpp
layout/mathml/nsMathMLmunderoverFrame.h
layout/mathml/nsMathMLsemanticsFrame.cpp
layout/mathml/nsMathMLsemanticsFrame.h
layout/style/ComputedStyle.cpp
layout/style/ComputedStyle.h
layout/style/ServoStyleSet.cpp
layout/style/nsComputedDOMStyle.h
layout/svg/SVGFEContainerFrame.cpp
layout/svg/SVGFEImageFrame.cpp
layout/svg/SVGFELeafFrame.cpp
layout/svg/SVGFEUnstyledLeafFrame.cpp
layout/svg/SVGGeometryFrame.cpp
layout/svg/SVGGeometryFrame.h
layout/svg/SVGTextFrame.cpp
layout/svg/SVGTextFrame.h
layout/svg/SVGViewFrame.cpp
layout/svg/nsSVGAFrame.cpp
layout/svg/nsSVGClipPathFrame.cpp
layout/svg/nsSVGClipPathFrame.h
layout/svg/nsSVGContainerFrame.cpp
layout/svg/nsSVGContainerFrame.h
layout/svg/nsSVGFilterFrame.cpp
layout/svg/nsSVGFilterFrame.h
layout/svg/nsSVGForeignObjectFrame.cpp
layout/svg/nsSVGForeignObjectFrame.h
layout/svg/nsSVGGFrame.cpp
layout/svg/nsSVGGFrame.h
layout/svg/nsSVGGenericContainerFrame.cpp
layout/svg/nsSVGGenericContainerFrame.h
layout/svg/nsSVGGradientFrame.cpp
layout/svg/nsSVGGradientFrame.h
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGImageFrame.h
layout/svg/nsSVGInnerSVGFrame.cpp
layout/svg/nsSVGInnerSVGFrame.h
layout/svg/nsSVGMarkerFrame.cpp
layout/svg/nsSVGMarkerFrame.h
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGMaskFrame.h
layout/svg/nsSVGOuterSVGFrame.cpp
layout/svg/nsSVGOuterSVGFrame.h
layout/svg/nsSVGPaintServerFrame.h
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGPatternFrame.h
layout/svg/nsSVGStopFrame.cpp
layout/svg/nsSVGSwitchFrame.cpp
layout/svg/nsSVGSymbolFrame.cpp
layout/svg/nsSVGSymbolFrame.h
layout/svg/nsSVGUseFrame.cpp
layout/svg/nsSVGUseFrame.h
layout/svg/nsSVGViewportFrame.h
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableColFrame.cpp
layout/tables/nsTableColFrame.h
layout/tables/nsTableColGroupFrame.cpp
layout/tables/nsTableColGroupFrame.h
layout/tables/nsTableFrame.cpp
layout/tables/nsTableFrame.h
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowFrame.h
layout/tables/nsTableRowGroupFrame.cpp
layout/tables/nsTableRowGroupFrame.h
layout/tables/nsTableWrapperFrame.cpp
layout/tables/nsTableWrapperFrame.h
layout/xul/grid/nsGridRowGroupFrame.cpp
layout/xul/grid/nsGridRowGroupFrame.h
layout/xul/grid/nsGridRowLeafFrame.cpp
layout/xul/grid/nsGridRowLeafFrame.h
layout/xul/nsBox.cpp
layout/xul/nsBox.h
layout/xul/nsBoxFrame.cpp
layout/xul/nsBoxFrame.h
layout/xul/nsButtonBoxFrame.cpp
layout/xul/nsButtonBoxFrame.h
layout/xul/nsDeckFrame.cpp
layout/xul/nsDeckFrame.h
layout/xul/nsDocElementBoxFrame.cpp
layout/xul/nsGroupBoxFrame.cpp
layout/xul/nsImageBoxFrame.cpp
layout/xul/nsImageBoxFrame.h
layout/xul/nsLeafBoxFrame.cpp
layout/xul/nsLeafBoxFrame.h
layout/xul/nsMenuBarFrame.cpp
layout/xul/nsMenuBarFrame.h
layout/xul/nsMenuFrame.cpp
layout/xul/nsMenuFrame.h
layout/xul/nsMenuPopupFrame.cpp
layout/xul/nsMenuPopupFrame.h
layout/xul/nsPopupSetFrame.cpp
layout/xul/nsPopupSetFrame.h
layout/xul/nsResizerFrame.cpp
layout/xul/nsResizerFrame.h
layout/xul/nsRootBoxFrame.cpp
layout/xul/nsScrollbarButtonFrame.cpp
layout/xul/nsScrollbarButtonFrame.h
layout/xul/nsScrollbarFrame.cpp
layout/xul/nsScrollbarFrame.h
layout/xul/nsSliderFrame.cpp
layout/xul/nsSliderFrame.h
layout/xul/nsSplitterFrame.cpp
layout/xul/nsSplitterFrame.h
layout/xul/nsStackFrame.cpp
layout/xul/nsStackFrame.h
layout/xul/nsTextBoxFrame.cpp
layout/xul/nsTextBoxFrame.h
layout/xul/nsTitleBarFrame.cpp
layout/xul/nsTitleBarFrame.h
layout/xul/nsXULLabelFrame.cpp
layout/xul/nsXULLabelFrame.h
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
layout/xul/tree/nsTreeColFrame.cpp
layout/xul/tree/nsTreeColFrame.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1182,17 +1182,18 @@ void nsFrameConstructorState::ConstructB
       mPresShell->StyleSet()->ResolvePseudoElementStyle(
           aContent->AsElement(), CSSPseudoElementType::backdrop,
           /* aParentComputedStyle */ nullptr,
           /* aPseudoElement */ nullptr);
   MOZ_ASSERT(style->StyleDisplay()->mTopLayer == NS_STYLE_TOP_LAYER_TOP);
   nsContainerFrame* parentFrame =
       GetGeometricParent(*style->StyleDisplay(), nullptr);
 
-  nsBackdropFrame* backdropFrame = new (mPresShell) nsBackdropFrame(style);
+  nsBackdropFrame* backdropFrame =
+      new (mPresShell) nsBackdropFrame(style, mPresShell->GetPresContext());
   backdropFrame->Init(aContent, parentFrame, nullptr);
 
   nsFrameState placeholderType;
   nsAbsoluteItems* frameItems = GetOutOfFlowFrameItems(
       backdropFrame, true, true, false, &placeholderType);
   MOZ_ASSERT(placeholderType & PLACEHOLDER_FOR_TOPLAYER);
 
   nsIFrame* placeholder = nsCSSFrameConstructor::CreatePlaceholderFrameFor(
--- a/layout/forms/nsCheckboxRadioFrame.cpp
+++ b/layout/forms/nsCheckboxRadioFrame.cpp
@@ -17,21 +17,23 @@
 
 using namespace mozilla;
 using mozilla::dom::HTMLInputElement;
 
 //#define FCF_NOISY
 
 nsCheckboxRadioFrame* NS_NewCheckboxRadioFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsCheckboxRadioFrame(aStyle);
+  return new (aPresShell)
+      nsCheckboxRadioFrame(aStyle, aPresShell->GetPresContext());
 }
 
-nsCheckboxRadioFrame::nsCheckboxRadioFrame(ComputedStyle* aStyle)
-    : nsAtomicContainerFrame(aStyle, kClassID) {}
+nsCheckboxRadioFrame::nsCheckboxRadioFrame(ComputedStyle* aStyle,
+                                           nsPresContext* aPresContext)
+    : nsAtomicContainerFrame(aStyle, aPresContext, kClassID) {}
 
 nsCheckboxRadioFrame::~nsCheckboxRadioFrame() {}
 
 void nsCheckboxRadioFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                        PostDestroyData& aPostDestroyData) {
   // Unregister the access key registered in reflow
   nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
   nsAtomicContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
--- a/layout/forms/nsCheckboxRadioFrame.h
+++ b/layout/forms/nsCheckboxRadioFrame.h
@@ -18,17 +18,18 @@
  * GetScreenHeight) that are used by other form controls.
  */
 class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
                                    public nsIFormControlFrame {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsCheckboxRadioFrame)
 
-  explicit nsCheckboxRadioFrame(ComputedStyle* aStyle);
+  explicit nsCheckboxRadioFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext);
 
   // nsIFrame replacements
   virtual bool IsFrameOfType(uint32_t aFlags) const override {
     return nsAtomicContainerFrame::IsFrameOfType(
         aFlags & ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   }
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
--- a/layout/forms/nsColorControlFrame.cpp
+++ b/layout/forms/nsColorControlFrame.cpp
@@ -16,22 +16,24 @@
 #include "mozilla/dom/Document.h"
 
 using namespace mozilla;
 using mozilla::dom::CallerType;
 using mozilla::dom::Document;
 using mozilla::dom::Element;
 using mozilla::dom::HTMLInputElement;
 
-nsColorControlFrame::nsColorControlFrame(ComputedStyle* aStyle)
-    : nsHTMLButtonControlFrame(aStyle, kClassID) {}
+nsColorControlFrame::nsColorControlFrame(ComputedStyle* aStyle,
+                                         nsPresContext* aPresContext)
+    : nsHTMLButtonControlFrame(aStyle, aPresContext, kClassID) {}
 
 nsIFrame* NS_NewColorControlFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
-  return new (aPresShell) nsColorControlFrame(aStyle);
+  return new (aPresShell)
+      nsColorControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsColorControlFrame)
 
 NS_QUERYFRAME_HEAD(nsColorControlFrame)
   NS_QUERYFRAME_ENTRY(nsColorControlFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
 NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButtonControlFrame)
--- a/layout/forms/nsColorControlFrame.h
+++ b/layout/forms/nsColorControlFrame.h
@@ -46,14 +46,15 @@ class nsColorControlFrame final : public
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
   virtual nsContainerFrame* GetContentInsertionFrame() override;
 
   // Refresh the color swatch, using associated input's value
   nsresult UpdateColor();
 
  private:
-  explicit nsColorControlFrame(ComputedStyle* aStyle);
+  explicit nsColorControlFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext);
 
   nsCOMPtr<Element> mColorContent;
 };
 
 #endif  // nsColorControlFrame_h___
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -54,16 +54,17 @@
 #ifdef XP_WIN
 #  define COMBOBOX_ROLLUP_CONSUME_EVENT 0
 #else
 #  define COMBOBOX_ROLLUP_CONSUME_EVENT 1
 #endif
 
 using namespace mozilla;
 using namespace mozilla::gfx;
+using mozilla::dom::Document;
 
 NS_IMETHODIMP
 nsComboboxControlFrame::RedisplayTextEvent::Run() {
   if (mControlFrame) mControlFrame->HandleRedisplayTextEvent();
   return NS_OK;
 }
 
 #define FIX_FOR_BUG_53259
@@ -107,17 +108,18 @@ class nsComboButtonListener final : publ
 NS_IMPL_ISUPPORTS(nsComboButtonListener, nsIDOMEventListener)
 
 // static class data member for Bug 32920
 nsComboboxControlFrame* nsComboboxControlFrame::sFocused = nullptr;
 
 nsComboboxControlFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell,
                                                    ComputedStyle* aStyle,
                                                    nsFrameState aStateFlags) {
-  nsComboboxControlFrame* it = new (aPresShell) nsComboboxControlFrame(aStyle);
+  nsComboboxControlFrame* it = new (aPresShell)
+      nsComboboxControlFrame(aStyle, aPresShell->GetPresContext());
 
   if (it) {
     // set the state flags (if any are provided)
     it->AddStateBits(aStateFlags);
   }
 
   return it;
 }
@@ -212,18 +214,19 @@ static int32_t gReflowInx = -1;
 #else
 #  define PX(__v) __v
 #endif
 
 //------------------------------------------------------
 //-- Done with macros
 //------------------------------------------------------
 
-nsComboboxControlFrame::nsComboboxControlFrame(ComputedStyle* aStyle)
-    : nsBlockFrame(aStyle, kClassID),
+nsComboboxControlFrame::nsComboboxControlFrame(ComputedStyle* aStyle,
+                                               nsPresContext* aPresContext)
+    : nsBlockFrame(aStyle, aPresContext, kClassID),
       mDisplayFrame(nullptr),
       mButtonFrame(nullptr),
       mDropdownFrame(nullptr),
       mListControlFrame(nullptr),
       mDisplayISize(0),
       mRecentSelectedIndex(NS_SKIP_NOTIFY_INDEX),
       mDisplayedIndex(-1),
       mLastDropDownBeforeScreenBCoord(nscoord_MIN),
@@ -1201,17 +1204,18 @@ nsIContent* nsComboboxControlFrame::GetD
 // XXXbz this is a for-now hack.  Now that display:inline-block works,
 // need to revisit this.
 class nsComboboxDisplayFrame final : public nsBlockFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsComboboxDisplayFrame)
 
   nsComboboxDisplayFrame(ComputedStyle* aStyle,
                          nsComboboxControlFrame* aComboBox)
-      : nsBlockFrame(aStyle, kClassID), mComboBox(aComboBox) {}
+      : nsBlockFrame(aStyle, aComboBox->PresContext(), kClassID),
+        mComboBox(aComboBox) {}
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("ComboboxDisplay"), aResult);
   }
 #endif
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override {
@@ -1459,18 +1463,17 @@ void nsComboboxControlFrame::BuildDispla
     DisplayBorderBackgroundOutline(aBuilder, aLists);
   } else {
     // REVIEW: Our in-flow child frames are inline-level so they will paint in
     // our content list, so we don't need to mess with layers.
     nsBlockFrame::BuildDisplayList(aBuilder, aLists);
   }
 
   // draw a focus indicator only when focus rings should be drawn
-  Document* doc = mContent->GetComposedDoc();
-  if (doc) {
+  if (Document* doc = mContent->GetComposedDoc()) {
     nsPIDOMWindowOuter* window = doc->GetWindow();
     if (window && window->ShouldShowFocusRing()) {
       nsPresContext* presContext = PresContext();
       const nsStyleDisplay* disp = StyleDisplay();
       if ((!IsThemed(disp) ||
            !presContext->GetTheme()->ThemeDrawsFocusForWidget(
                disp->mAppearance)) &&
           mDisplayFrame && IsVisibleForPainting()) {
--- a/layout/forms/nsComboboxControlFrame.h
+++ b/layout/forms/nsComboboxControlFrame.h
@@ -51,17 +51,18 @@ class nsComboboxControlFrame final : pub
                                      public nsIStatefulFrame {
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
  public:
   friend nsComboboxControlFrame* NS_NewComboboxControlFrame(
       nsIPresShell* aPresShell, ComputedStyle* aStyle, nsFrameState aFlags);
   friend class nsComboboxDisplayFrame;
 
-  explicit nsComboboxControlFrame(ComputedStyle* aStyle);
+  explicit nsComboboxControlFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext);
   ~nsComboboxControlFrame();
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsComboboxControlFrame)
 
   // nsIAnonymousContentCreator
   virtual nsresult CreateAnonymousContent(
       nsTArray<ContentInfo>& aElements) override;
--- a/layout/forms/nsDateTimeControlFrame.cpp
+++ b/layout/forms/nsDateTimeControlFrame.cpp
@@ -24,27 +24,29 @@
 #include "nsJSUtils.h"
 #include "nsThreadUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewDateTimeControlFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsDateTimeControlFrame(aStyle);
+  return new (aPresShell)
+      nsDateTimeControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)
 
 NS_QUERYFRAME_HEAD(nsDateTimeControlFrame)
   NS_QUERYFRAME_ENTRY(nsDateTimeControlFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
-nsDateTimeControlFrame::nsDateTimeControlFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {}
+nsDateTimeControlFrame::nsDateTimeControlFrame(ComputedStyle* aStyle,
+                                               nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {}
 
 nscoord nsDateTimeControlFrame::GetMinISize(gfxContext* aRenderingContext) {
   nscoord result;
   DISPLAY_MIN_INLINE_SIZE(this, result);
 
   nsIFrame* kid = mFrames.FirstChild();
   if (kid) {  // display:none?
     result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, kid,
--- a/layout/forms/nsDateTimeControlFrame.h
+++ b/layout/forms/nsDateTimeControlFrame.h
@@ -25,17 +25,18 @@ namespace mozilla {
 namespace dom {
 struct DateTimeValue;
 }  // namespace dom
 }  // namespace mozilla
 
 class nsDateTimeControlFrame final : public nsContainerFrame {
   typedef mozilla::dom::DateTimeValue DateTimeValue;
 
-  explicit nsDateTimeControlFrame(ComputedStyle* aStyle);
+  explicit nsDateTimeControlFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext);
 
  public:
   friend nsIFrame* NS_NewDateTimeControlFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle);
 
   void ContentStatesChanged(mozilla::EventStates aStates) override;
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -21,23 +21,25 @@
 #include "nsStyleConsts.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layout;
 
 nsContainerFrame* NS_NewFieldSetFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle) {
-  return new (aPresShell) nsFieldSetFrame(aStyle);
+  return new (aPresShell) nsFieldSetFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFieldSetFrame)
 
-nsFieldSetFrame::nsFieldSetFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mLegendRect(GetWritingMode()) {
+nsFieldSetFrame::nsFieldSetFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
+      mLegendRect(GetWritingMode()) {
   mLegendSpace = 0;
 }
 
 nsRect nsFieldSetFrame::VisualBorderRectRelativeToSelf() const {
   WritingMode wm = GetWritingMode();
   LogicalRect r(wm, LogicalPoint(wm, 0, 0), GetLogicalSize(wm));
   nsSize containerSize = r.Size(wm).GetPhysicalSize(wm);
   if (nsIFrame* legend = GetLegend()) {
--- a/layout/forms/nsFieldSetFrame.h
+++ b/layout/forms/nsFieldSetFrame.h
@@ -12,17 +12,17 @@
 #include "nsContainerFrame.h"
 
 class nsFieldSetFrame final : public nsContainerFrame {
   typedef mozilla::image::ImgDrawResult ImgDrawResult;
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsFieldSetFrame)
 
-  explicit nsFieldSetFrame(ComputedStyle* aStyle);
+  explicit nsFieldSetFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   nscoord GetIntrinsicISize(gfxContext* aRenderingContext,
                             nsLayoutUtils::IntrinsicISizeType);
   virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
   virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
 
   /**
    * The area to paint box-shadows around.  It's the border rect except
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -29,23 +29,25 @@
 #include "nsTextNode.h"
 #include "nsTextFrame.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewFileControlFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsFileControlFrame(aStyle);
+  return new (aPresShell)
+      nsFileControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFileControlFrame)
 
-nsFileControlFrame::nsFileControlFrame(ComputedStyle* aStyle)
-    : nsBlockFrame(aStyle, kClassID) {
+nsFileControlFrame::nsFileControlFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsBlockFrame(aStyle, aPresContext, kClassID) {
   AddStateBits(NS_BLOCK_FLOAT_MGR);
 }
 
 void nsFileControlFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                               nsIFrame* aPrevInFlow) {
   nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
 
   mMouseListener = new DnDListener(this);
--- a/layout/forms/nsFileControlFrame.h
+++ b/layout/forms/nsFileControlFrame.h
@@ -24,17 +24,18 @@ class DataTransfer;
 
 class nsFileControlFrame final : public nsBlockFrame,
                                  public nsIFormControlFrame,
                                  public nsIAnonymousContentCreator {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsFileControlFrame)
 
-  explicit nsFileControlFrame(ComputedStyle* aStyle);
+  explicit nsFileControlFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
               const ReflowInput& aReflowInput,
               nsReflowStatus& aStatus) override;
 
--- a/layout/forms/nsGfxButtonControlFrame.cpp
+++ b/layout/forms/nsGfxButtonControlFrame.cpp
@@ -8,22 +8,24 @@
 #include "nsIFormControl.h"
 #include "nsGkAtoms.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "nsContentUtils.h"
 #include "nsTextNode.h"
 
 using namespace mozilla;
 
-nsGfxButtonControlFrame::nsGfxButtonControlFrame(ComputedStyle* aStyle)
-    : nsHTMLButtonControlFrame(aStyle, kClassID) {}
+nsGfxButtonControlFrame::nsGfxButtonControlFrame(ComputedStyle* aStyle,
+                                                 nsPresContext* aPresContext)
+    : nsHTMLButtonControlFrame(aStyle, aPresContext, kClassID) {}
 
 nsContainerFrame* NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle) {
-  return new (aPresShell) nsGfxButtonControlFrame(aStyle);
+  return new (aPresShell)
+      nsGfxButtonControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsGfxButtonControlFrame)
 
 void nsGfxButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                           PostDestroyData& aPostDestroyData) {
   aPostDestroyData.AddAnonymousContent(mTextContent.forget());
   nsHTMLButtonControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
--- a/layout/forms/nsGfxButtonControlFrame.h
+++ b/layout/forms/nsGfxButtonControlFrame.h
@@ -19,17 +19,18 @@ class nsTextNode;
 // The label for button is specified through generated content
 // in the ua.css file.
 
 class nsGfxButtonControlFrame final : public nsHTMLButtonControlFrame,
                                       public nsIAnonymousContentCreator {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsGfxButtonControlFrame)
 
-  explicit nsGfxButtonControlFrame(ComputedStyle* aStyle);
+  explicit nsGfxButtonControlFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext);
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   virtual nsresult HandleEvent(nsPresContext* aPresContext,
                                mozilla::WidgetGUIEvent* aEvent,
                                nsEventStatus* aEventStatus) override;
 
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -17,24 +17,26 @@
 #include "nsNameSpaceManager.h"
 #include "nsDisplayList.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 nsContainerFrame* NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsHTMLButtonControlFrame(aStyle);
+  return new (aPresShell)
+      nsHTMLButtonControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
 
 nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(ComputedStyle* aStyle,
+                                                   nsPresContext* aPresContext,
                                                    nsIFrame::ClassID aID)
-    : nsContainerFrame(aStyle, aID) {}
+    : nsContainerFrame(aStyle, aPresContext, aID) {}
 
 nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame() {}
 
 void nsHTMLButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                            PostDestroyData& aPostDestroyData) {
   nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
   nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
 }
--- a/layout/forms/nsHTMLButtonControlFrame.h
+++ b/layout/forms/nsHTMLButtonControlFrame.h
@@ -13,18 +13,19 @@
 #include "nsButtonFrameRenderer.h"
 
 class gfxContext;
 class nsPresContext;
 
 class nsHTMLButtonControlFrame : public nsContainerFrame,
                                  public nsIFormControlFrame {
  public:
-  explicit nsHTMLButtonControlFrame(ComputedStyle* aStyle)
-      : nsHTMLButtonControlFrame(aStyle, kClassID) {}
+  explicit nsHTMLButtonControlFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsHTMLButtonControlFrame(aStyle, aPresContext, kClassID) {}
 
   ~nsHTMLButtonControlFrame();
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
@@ -92,17 +93,18 @@ class nsHTMLButtonControlFrame : public 
     return nsContainerFrame::IsFrameOfType(
         aFlags & ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   }
 
   // Return the ::-moz-button-content anonymous box.
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
  protected:
-  nsHTMLButtonControlFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID);
+  nsHTMLButtonControlFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                           nsIFrame::ClassID aID);
 
   virtual bool IsInput() { return false; }
 
   // Indicates whether we should clip our children's painting to our
   // border-box (either because of "overflow" or because of legacy reasons
   // about how <input>-flavored buttons work).
   bool ShouldClipPaintingToBorderBox();
 
--- a/layout/forms/nsImageControlFrame.cpp
+++ b/layout/forms/nsImageControlFrame.cpp
@@ -14,17 +14,18 @@
 #include "mozilla/MouseEvents.h"
 #include "nsIContent.h"
 
 using namespace mozilla;
 
 class nsImageControlFrame final : public nsImageFrame,
                                   public nsIFormControlFrame {
  public:
-  explicit nsImageControlFrame(ComputedStyle* aStyle);
+  explicit nsImageControlFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext);
   ~nsImageControlFrame();
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   NS_DECL_QUERYFRAME
@@ -51,32 +52,34 @@ class nsImageControlFrame final : public
   virtual nsresult GetCursor(const nsPoint& aPoint,
                              nsIFrame::Cursor& aCursor) override;
   // nsIFormContromFrame
   virtual void SetFocus(bool aOn, bool aRepaint) override;
   virtual nsresult SetFormProperty(nsAtom* aName,
                                    const nsAString& aValue) override;
 };
 
-nsImageControlFrame::nsImageControlFrame(ComputedStyle* aStyle)
-    : nsImageFrame(aStyle, kClassID) {}
+nsImageControlFrame::nsImageControlFrame(ComputedStyle* aStyle,
+                                         nsPresContext* aPresContext)
+    : nsImageFrame(aStyle, aPresContext, kClassID) {}
 
 nsImageControlFrame::~nsImageControlFrame() {}
 
 void nsImageControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                       PostDestroyData& aPostDestroyData) {
   if (!GetPrevInFlow()) {
     nsCheckboxRadioFrame::RegUnRegAccessKey(this, false);
   }
   nsImageFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
 }
 
 nsIFrame* NS_NewImageControlFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
-  return new (aPresShell) nsImageControlFrame(aStyle);
+  return new (aPresShell)
+      nsImageControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsImageControlFrame)
 
 void nsImageControlFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                                nsIFrame* aPrevInFlow) {
   nsImageFrame::Init(aContent, aParent, aPrevInFlow);
 
--- a/layout/forms/nsLegendFrame.cpp
+++ b/layout/forms/nsLegendFrame.cpp
@@ -20,17 +20,18 @@ using namespace mozilla;
 
 nsIFrame* NS_NewLegendFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
 #ifdef DEBUG
   const nsStyleDisplay* disp = aStyle->StyleDisplay();
   NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
                "Legends should not be positioned and should not float");
 #endif
 
-  nsIFrame* f = new (aPresShell) nsLegendFrame(aStyle);
+  nsIFrame* f =
+      new (aPresShell) nsLegendFrame(aStyle, aPresShell->GetPresContext());
   f->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
   return f;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
 
 void nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                 PostDestroyData& aPostDestroyData) {
--- a/layout/forms/nsLegendFrame.h
+++ b/layout/forms/nsLegendFrame.h
@@ -10,18 +10,18 @@
 #include "mozilla/Attributes.h"
 #include "nsBlockFrame.h"
 
 class nsLegendFrame final : public nsBlockFrame {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsLegendFrame)
 
-  explicit nsLegendFrame(ComputedStyle* aStyle)
-      : nsBlockFrame(aStyle, kClassID) {}
+  explicit nsLegendFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBlockFrame(aStyle, aPresContext, kClassID) {}
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -77,28 +77,30 @@ class nsListEventListener final : public
   ~nsListEventListener() {}
 
   nsListControlFrame* mFrame;
 };
 
 //---------------------------------------------------------
 nsContainerFrame* NS_NewListControlFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle) {
-  nsListControlFrame* it = new (aPresShell) nsListControlFrame(aStyle);
+  nsListControlFrame* it =
+      new (aPresShell) nsListControlFrame(aStyle, aPresShell->GetPresContext());
 
   it->AddStateBits(NS_FRAME_INDEPENDENT_SELECTION);
 
   return it;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsListControlFrame)
 
 //---------------------------------------------------------
-nsListControlFrame::nsListControlFrame(ComputedStyle* aStyle)
-    : nsHTMLScrollFrame(aStyle, kClassID, false),
+nsListControlFrame::nsListControlFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsHTMLScrollFrame(aStyle, aPresContext, kClassID, false),
       mView(nullptr),
       mMightNeedSecondPass(false),
       mHasPendingInterruptAtStartOfReflow(false),
       mDropdownCanGrow(false),
       mForceSelection(false),
       mLastDropdownComputedBSize(NS_UNCONSTRAINEDSIZE) {
   mComboboxFrame = nullptr;
   mChangesSinceDragStart = false;
--- a/layout/forms/nsListControlFrame.h
+++ b/layout/forms/nsListControlFrame.h
@@ -318,17 +318,18 @@ class nsListControlFrame final : public 
                                  int32_t aDoAdjustIncNext);
 
   /**
    * Resets the select back to it's original default values;
    * those values as determined by the original HTML
    */
   virtual void ResetList(bool aAllowScrolling);
 
-  explicit nsListControlFrame(ComputedStyle* aStyle);
+  explicit nsListControlFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
   virtual ~nsListControlFrame();
 
   /**
    * Sets the mSelectedIndex and mOldSelectedIndex from figuring out what
    * item was selected using content
    * @param aPoint the event point, in listcontrolframe coordinates
    * @return NS_OK if it successfully found the selection
    */
--- a/layout/forms/nsMeterFrame.cpp
+++ b/layout/forms/nsMeterFrame.cpp
@@ -22,23 +22,23 @@
 #include "nsStyleConsts.h"
 #include <algorithm>
 
 using namespace mozilla;
 using mozilla::dom::Element;
 using mozilla::dom::HTMLMeterElement;
 
 nsIFrame* NS_NewMeterFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsMeterFrame(aStyle);
+  return new (aPresShell) nsMeterFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMeterFrame)
 
-nsMeterFrame::nsMeterFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mBarDiv(nullptr) {}
+nsMeterFrame::nsMeterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID), mBarDiv(nullptr) {}
 
 nsMeterFrame::~nsMeterFrame() {}
 
 void nsMeterFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                PostDestroyData& aPostDestroyData) {
   NS_ASSERTION(!GetPrevContinuation(),
                "nsMeterFrame should not have continuations; if it does we "
                "need to call RegUnregAccessKey only for the first.");
--- a/layout/forms/nsMeterFrame.h
+++ b/layout/forms/nsMeterFrame.h
@@ -18,17 +18,17 @@ class nsMeterFrame final : public nsCont
 
 {
   typedef mozilla::dom::Element Element;
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsMeterFrame)
 
-  explicit nsMeterFrame(ComputedStyle* aStyle);
+  explicit nsMeterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsMeterFrame();
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   virtual void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -29,29 +29,32 @@
 #  include "mozilla/a11y/AccTypes.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewNumberControlFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle) {
-  return new (aPresShell) nsNumberControlFrame(aStyle);
+  return new (aPresShell)
+      nsNumberControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsNumberControlFrame)
 
 NS_QUERYFRAME_HEAD(nsNumberControlFrame)
   NS_QUERYFRAME_ENTRY(nsNumberControlFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
   NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
-nsNumberControlFrame::nsNumberControlFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mHandlingInputEvent(false) {}
+nsNumberControlFrame::nsNumberControlFrame(ComputedStyle* aStyle,
+                                           nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
+      mHandlingInputEvent(false) {}
 
 void nsNumberControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                        PostDestroyData& aPostDestroyData) {
   NS_ASSERTION(
       !GetPrevContinuation() && !GetNextContinuation(),
       "nsNumberControlFrame should not have continuations; if it does we "
       "need to call RegUnregAccessKey only for the first");
   nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
--- a/layout/forms/nsNumberControlFrame.h
+++ b/layout/forms/nsNumberControlFrame.h
@@ -35,17 +35,18 @@ class nsNumberControlFrame final : publi
                                             ComputedStyle* aStyle);
 
   typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
   typedef mozilla::dom::Element Element;
   typedef mozilla::dom::HTMLInputElement HTMLInputElement;
   typedef mozilla::WidgetEvent WidgetEvent;
   typedef mozilla::WidgetGUIEvent WidgetGUIEvent;
 
-  explicit nsNumberControlFrame(ComputedStyle* aStyle);
+  explicit nsNumberControlFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext);
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsNumberControlFrame)
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
   virtual void ContentStatesChanged(mozilla::EventStates aStates) override;
--- a/layout/forms/nsProgressFrame.cpp
+++ b/layout/forms/nsProgressFrame.cpp
@@ -21,23 +21,24 @@
 #include "nsCSSPseudoElements.h"
 #include "nsStyleConsts.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewProgressFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsProgressFrame(aStyle);
+  return new (aPresShell) nsProgressFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsProgressFrame)
 
-nsProgressFrame::nsProgressFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mBarDiv(nullptr) {}
+nsProgressFrame::nsProgressFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID), mBarDiv(nullptr) {}
 
 nsProgressFrame::~nsProgressFrame() {}
 
 void nsProgressFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                   PostDestroyData& aPostDestroyData) {
   NS_ASSERTION(!GetPrevContinuation(),
                "nsProgressFrame should not have continuations; if it does we "
                "need to call RegUnregAccessKey only for the first.");
--- a/layout/forms/nsProgressFrame.h
+++ b/layout/forms/nsProgressFrame.h
@@ -20,17 +20,17 @@ class nsProgressFrame final : public nsC
                               public nsIAnonymousContentCreator {
   typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
   typedef mozilla::dom::Element Element;
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsProgressFrame)
 
-  explicit nsProgressFrame(ComputedStyle* aStyle);
+  explicit nsProgressFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsProgressFrame();
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
--- a/layout/forms/nsRangeFrame.cpp
+++ b/layout/forms/nsRangeFrame.cpp
@@ -36,21 +36,21 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::image;
 
 NS_IMPL_ISUPPORTS(nsRangeFrame::DummyTouchListener, nsIDOMEventListener)
 
 nsIFrame* NS_NewRangeFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsRangeFrame(aStyle);
+  return new (aPresShell) nsRangeFrame(aStyle, aPresShell->GetPresContext());
 }
 
-nsRangeFrame::nsRangeFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {}
+nsRangeFrame::nsRangeFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {}
 
 nsRangeFrame::~nsRangeFrame() {}
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRangeFrame)
 
 NS_QUERYFRAME_HEAD(nsRangeFrame)
   NS_QUERYFRAME_ENTRY(nsRangeFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
--- a/layout/forms/nsRangeFrame.h
+++ b/layout/forms/nsRangeFrame.h
@@ -25,17 +25,17 @@ class Event;
 
 class nsRangeFrame final : public nsContainerFrame,
                            public nsIAnonymousContentCreator {
   friend nsIFrame* NS_NewRangeFrame(nsIPresShell* aPresShell,
                                     ComputedStyle* aStyle);
 
   friend class nsDisplayRangeFocusRing;
 
-  explicit nsRangeFrame(ComputedStyle* aStyle);
+  explicit nsRangeFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsRangeFrame();
 
   typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
   typedef mozilla::dom::Element Element;
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsRangeFrame)
--- a/layout/forms/nsSelectsAreaFrame.cpp
+++ b/layout/forms/nsSelectsAreaFrame.cpp
@@ -9,17 +9,18 @@
 #include "nsDisplayList.h"
 #include "WritingModes.h"
 
 using namespace mozilla;
 
 nsContainerFrame* NS_NewSelectsAreaFrame(nsIPresShell* aShell,
                                          ComputedStyle* aStyle,
                                          nsFrameState aFlags) {
-  nsSelectsAreaFrame* it = new (aShell) nsSelectsAreaFrame(aStyle);
+  nsSelectsAreaFrame* it =
+      new (aShell) nsSelectsAreaFrame(aStyle, aShell->GetPresContext());
 
   // We need NS_BLOCK_FLOAT_MGR to ensure that the options inside the select
   // aren't expanded by right floats outside the select.
   it->AddStateBits(aFlags | NS_BLOCK_FLOAT_MGR);
 
   return it;
 }
 
--- a/layout/forms/nsSelectsAreaFrame.h
+++ b/layout/forms/nsSelectsAreaFrame.h
@@ -25,18 +25,19 @@ class nsSelectsAreaFrame final : public 
 
   virtual void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
   nscoord BSizeOfARow() const { return mBSizeOfARow; }
 
  protected:
-  explicit nsSelectsAreaFrame(ComputedStyle* aStyle)
-      : nsBlockFrame(aStyle, kClassID),
+  explicit nsSelectsAreaFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : nsBlockFrame(aStyle, aPresContext, kClassID),
         // initialize to wacky value so first call of
         // nsSelectsAreaFrame::Reflow will always invalidate
         mBSizeOfARow(nscoord_MIN) {}
 
   // We cache the block size of a single row so that changes to the
   // "size" attribute, padding, etc. can all be handled with only one
   // reflow.  We'll have to reflow twice if someone changes our font
   // size or something like that, so that the block size of our options
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -48,17 +48,18 @@
 
 #define DEFAULT_COLUMN_WIDTH 20
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewTextControlFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsTextControlFrame(aStyle);
+  return new (aPresShell)
+      nsTextControlFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTextControlFrame)
 
 NS_QUERYFRAME_HEAD(nsTextControlFrame)
   NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
   NS_QUERYFRAME_ENTRY(nsITextControlFrame)
@@ -104,18 +105,19 @@ class nsTextControlFrame::nsAnonDivObser
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
  private:
   ~nsAnonDivObserver() {}
   nsTextControlFrame& mFrame;
 };
 
-nsTextControlFrame::nsTextControlFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID),
+nsTextControlFrame::nsTextControlFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
       mFirstBaseline(NS_INTRINSIC_WIDTH_UNKNOWN),
       mEditorHasBeenInitialized(false),
       mIsProcessing(false)
 #ifdef DEBUG
       ,
       mInEditorInitialization(false)
 #endif
 {
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -31,17 +31,18 @@ class nsTextControlFrame final : public 
                                  public nsIAnonymousContentCreator,
                                  public nsITextControlFrame,
                                  public nsIStatefulFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsTextControlFrame)
 
   NS_DECLARE_FRAME_PROPERTY_DELETABLE(ContentScrollPos, nsPoint)
 
-  explicit nsTextControlFrame(ComputedStyle* aStyle);
+  explicit nsTextControlFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
   virtual ~nsTextControlFrame();
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   virtual nsIScrollableFrame* GetScrollTargetFrame() override {
     return do_QueryFrame(PrincipalChildList().FirstChild());
   }
--- a/layout/generic/BRFrame.cpp
+++ b/layout/generic/BRFrame.cpp
@@ -64,28 +64,29 @@ class BRFrame final : public nsFrame {
         aFlags & ~(nsIFrame::eReplaced | nsIFrame::eLineParticipant));
   }
 
 #ifdef ACCESSIBILITY
   virtual mozilla::a11y::AccType AccessibleType() override;
 #endif
 
  protected:
-  explicit BRFrame(ComputedStyle* aStyle)
-      : nsFrame(aStyle, kClassID), mAscent(NS_INTRINSIC_WIDTH_UNKNOWN) {}
+  explicit BRFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID),
+        mAscent(NS_INTRINSIC_WIDTH_UNKNOWN) {}
 
   virtual ~BRFrame();
 
   nscoord mAscent;
 };
 
 }  // namespace mozilla
 
 nsIFrame* NS_NewBRFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) BRFrame(aStyle);
+  return new (aPresShell) BRFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(BRFrame)
 
 BRFrame::~BRFrame() {}
 
 void BRFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
                      const ReflowInput& aReflowInput, nsReflowStatus& aStatus) {
--- a/layout/generic/ColumnSetWrapperFrame.cpp
+++ b/layout/generic/ColumnSetWrapperFrame.cpp
@@ -10,33 +10,35 @@
 #include "nsIFrame.h"
 #include "nsIFrameInlines.h"
 
 using namespace mozilla;
 
 nsBlockFrame* NS_NewColumnSetWrapperFrame(nsIPresShell* aPresShell,
                                           ComputedStyle* aStyle,
                                           nsFrameState aStateFlags) {
-  ColumnSetWrapperFrame* frame = new (aPresShell) ColumnSetWrapperFrame(aStyle);
+  ColumnSetWrapperFrame* frame = new (aPresShell)
+      ColumnSetWrapperFrame(aStyle, aPresShell->GetPresContext());
 
   // CSS Multi-column level 1 section 2: A multi-column container
   // establishes a new block formatting context, as per CSS 2.1 section
   // 9.4.1.
   frame->AddStateBits(aStateFlags | NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
   return frame;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(ColumnSetWrapperFrame)
 
 NS_QUERYFRAME_HEAD(ColumnSetWrapperFrame)
   NS_QUERYFRAME_ENTRY(ColumnSetWrapperFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
 
-ColumnSetWrapperFrame::ColumnSetWrapperFrame(ComputedStyle* aStyle)
-    : nsBlockFrame(aStyle, kClassID) {}
+ColumnSetWrapperFrame::ColumnSetWrapperFrame(ComputedStyle* aStyle,
+                                             nsPresContext* aPresContext)
+    : nsBlockFrame(aStyle, aPresContext, kClassID) {}
 
 void ColumnSetWrapperFrame::Init(nsIContent* aContent,
                                  nsContainerFrame* aParent,
                                  nsIFrame* aPrevInFlow) {
   nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
 
   // ColumnSetWrapperFrame doesn't need to call ResolveBidi().
   RemoveStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
--- a/layout/generic/ColumnSetWrapperFrame.h
+++ b/layout/generic/ColumnSetWrapperFrame.h
@@ -48,17 +48,18 @@ class ColumnSetWrapperFrame final : publ
   void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
                     nsFrameList& aFrameList) override;
 
   void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
 
   void MarkIntrinsicISizesDirty() override;
 
  private:
-  explicit ColumnSetWrapperFrame(ComputedStyle* aStyle);
+  explicit ColumnSetWrapperFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext);
   ~ColumnSetWrapperFrame() override = default;
 
 #ifdef DEBUG
   static void AssertColumnSpanWrapperSubtreeIsSane(const nsIFrame* aFrame);
 
   // True if frame constructor has finished building this frame and all of
   // its descendants.
   bool mFinishedBuildingColumns = false;
--- a/layout/generic/DetailsFrame.cpp
+++ b/layout/generic/DetailsFrame.cpp
@@ -20,23 +20,23 @@ NS_IMPL_FRAMEARENA_HELPERS(DetailsFrame)
 
 NS_QUERYFRAME_HEAD(DetailsFrame)
   NS_QUERYFRAME_ENTRY(DetailsFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
 
 nsBlockFrame* NS_NewDetailsFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) DetailsFrame(aStyle);
+  return new (aPresShell) DetailsFrame(aStyle, aPresShell->GetPresContext());
 }
 
 namespace mozilla {
 
-DetailsFrame::DetailsFrame(ComputedStyle* aStyle)
-    : nsBlockFrame(aStyle, kClassID) {}
+DetailsFrame::DetailsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsBlockFrame(aStyle, aPresContext, kClassID) {}
 
 DetailsFrame::~DetailsFrame() {}
 
 void DetailsFrame::SetInitialChildList(ChildListID aListID,
                                        nsFrameList& aChildList) {
 #ifdef DEBUG
   if (aListID == kPrincipalList) {
     CheckValidMainSummary(aChildList);
--- a/layout/generic/DetailsFrame.h
+++ b/layout/generic/DetailsFrame.h
@@ -19,17 +19,17 @@ namespace mozilla {
 // DetailsFrame.
 //
 class DetailsFrame final : public nsBlockFrame,
                            public nsIAnonymousContentCreator {
  public:
   NS_DECL_FRAMEARENA_HELPERS(DetailsFrame)
   NS_DECL_QUERYFRAME
 
-  explicit DetailsFrame(ComputedStyle* aStyle);
+  explicit DetailsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   virtual ~DetailsFrame();
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("Details"), aResult);
   }
 #endif
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -22,17 +22,17 @@
 #include "nsIMozBrowserFrame.h"
 #include "nsPlaceholderFrame.h"
 
 using namespace mozilla;
 typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags;
 
 ViewportFrame* NS_NewViewportFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle) {
-  return new (aPresShell) ViewportFrame(aStyle);
+  return new (aPresShell) ViewportFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(ViewportFrame)
 NS_QUERYFRAME_HEAD(ViewportFrame)
   NS_QUERYFRAME_ENTRY(ViewportFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 void ViewportFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/generic/ViewportFrame.h
+++ b/layout/generic/ViewportFrame.h
@@ -26,18 +26,18 @@ class ServoRestyleState;
  * scroll frame containing the doc root frame. ViewportFrame stores this child
  * in its primary child list.
  */
 class ViewportFrame : public nsContainerFrame {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(ViewportFrame)
 
-  explicit ViewportFrame(ComputedStyle* aStyle)
-      : ViewportFrame(aStyle, kClassID) {}
+  explicit ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : ViewportFrame(aStyle, aPresContext, kClassID) {}
 
   virtual ~ViewportFrame() {}  // useful for debugging
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
 #ifdef DEBUG
   virtual void AppendFrames(ChildListID aListID,
@@ -80,18 +80,18 @@ class ViewportFrame : public nsContainer
    */
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
-  ViewportFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsContainerFrame(aStyle, aID), mView(nullptr) {}
+  ViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
+      : nsContainerFrame(aStyle, aPresContext, aID), mView(nullptr) {}
 
   /**
    * Calculate how much room is available for fixed frames. That means
    * determining if the viewport is scrollable and whether the vertical and/or
    * horizontal scrollbars are visible.  Adjust the computed width/height and
    * available width for aReflowInput accordingly.
    * @return the current scroll position, or 0,0 if not scrollable
    */
--- a/layout/generic/nsAtomicContainerFrame.h
+++ b/layout/generic/nsAtomicContainerFrame.h
@@ -31,13 +31,14 @@ class nsAtomicContainerFrame : public ns
   FrameSearchResult PeekOffsetCharacter(
       bool aForward, int32_t* aOffset,
       PeekOffsetCharacterOptions aOptions =
           PeekOffsetCharacterOptions()) override {
     return nsFrame::PeekOffsetCharacter(aForward, aOffset, aOptions);
   }
 
  protected:
-  nsAtomicContainerFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsContainerFrame(aStyle, aID) {}
+  nsAtomicContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                         ClassID aID)
+      : nsContainerFrame(aStyle, aPresContext, aID) {}
 };
 
 #endif  // nsAtomicContainerFrame_h___
--- a/layout/generic/nsBackdropFrame.h
+++ b/layout/generic/nsBackdropFrame.h
@@ -10,17 +10,18 @@
 #define nsBackdropFrame_h___
 
 #include "nsFrame.h"
 
 class nsBackdropFrame final : public nsFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsBackdropFrame)
 
-  explicit nsBackdropFrame(ComputedStyle* aStyle) : nsFrame(aStyle, kClassID) {}
+  explicit nsBackdropFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {}
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
   virtual ComputedStyle* GetParentComputedStyle(
       nsIFrame** aProviderFrame) const override;
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -284,17 +284,17 @@ NS_DECLARE_FRAME_PROPERTY_FRAMELIST(Push
 NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OutsideBulletProperty)
 NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(InsideBulletProperty, nsBulletFrame)
 NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(BlockEndEdgeOfChildrenProperty, nscoord)
 
 //----------------------------------------------------------------------
 
 nsBlockFrame* NS_NewBlockFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsBlockFrame(aStyle);
+  return new (aPresShell) nsBlockFrame(aStyle, aPresShell->GetPresContext());
 }
 
 nsBlockFrame* NS_NewBlockFormattingContext(nsIPresShell* aPresShell,
                                            ComputedStyle* aComputedStyle) {
   nsBlockFrame* blockFrame = NS_NewBlockFrame(aPresShell, aComputedStyle);
   blockFrame->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
   return blockFrame;
 }
@@ -6793,17 +6793,17 @@ void nsBlockFrame::CreateBulletFrameForL
   CSSPseudoElementType pseudoType = style->IsBullet()
                                         ? CSSPseudoElementType::mozListBullet
                                         : CSSPseudoElementType::mozListNumber;
 
   RefPtr<ComputedStyle> kidSC =
       ResolveBulletStyle(pseudoType, shell->StyleSet());
 
   // Create bullet frame
-  nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC);
+  nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC, pc);
   bullet->Init(mContent, this, nullptr);
 
   // If the list bullet frame should be positioned inside then add
   // it to the flow now.
   if (styleList->mListStylePosition == NS_STYLE_LIST_STYLE_POSITION_INSIDE) {
     nsFrameList bulletList(bullet, bullet);
     AddFrames(bulletList, nullptr);
     SetProperty(InsideBulletProperty(), bullet);
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -405,18 +405,19 @@ class nsBlockFrame : public nsContainerF
    */
   void UpdatePseudoElementStyles(mozilla::ServoRestyleState& aRestyleState);
 
   // Update our first-letter styles during stylo post-traversal.  This needs to
   // be done at a slightly different time than our other pseudo-elements.
   void UpdateFirstLetterStyle(mozilla::ServoRestyleState& aRestyleState);
 
  protected:
-  explicit nsBlockFrame(ComputedStyle* aStyle, ClassID aID = kClassID)
-      : nsContainerFrame(aStyle, aID),
+  explicit nsBlockFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                        ClassID aID = kClassID)
+      : nsContainerFrame(aStyle, aPresContext, aID),
         mMinWidth(NS_INTRINSIC_WIDTH_UNKNOWN),
         mPrefWidth(NS_INTRINSIC_WIDTH_UNKNOWN) {
 #ifdef DEBUG
     InitDebugFlags();
 #endif
   }
 
   virtual ~nsBlockFrame();
--- a/layout/generic/nsBulletFrame.h
+++ b/layout/generic/nsBulletFrame.h
@@ -44,18 +44,18 @@ class nsBulletFrame final : public nsFra
   typedef mozilla::image::ImgDrawResult ImgDrawResult;
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsBulletFrame)
 #ifdef DEBUG
   NS_DECL_QUERYFRAME
 #endif
 
-  explicit nsBulletFrame(ComputedStyle* aStyle)
-      : nsFrame(aStyle, kClassID),
+  explicit nsBulletFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID),
         mPadding(GetWritingMode()),
         mIntrinsicSize(GetWritingMode()),
         mOrdinal(0),
         mRequestRegistered(false) {}
 
   virtual ~nsBulletFrame();
 
   NS_IMETHOD Notify(imgIRequest* aRequest, int32_t aType,
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -40,17 +40,17 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layout;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 nsCanvasFrame* NS_NewCanvasFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsCanvasFrame(aStyle);
+  return new (aPresShell) nsCanvasFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsCanvasFrame)
 
 NS_QUERYFRAME_HEAD(nsCanvasFrame)
   NS_QUERYFRAME_ENTRY(nsCanvasFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
   NS_QUERYFRAME_ENTRY(nsIPopupContainer)
--- a/layout/generic/nsCanvasFrame.h
+++ b/layout/generic/nsCanvasFrame.h
@@ -31,18 +31,18 @@ class nsPopupSetFrame;
  * @note nsCanvasFrame keeps overflow container continuations of its child
  * frame in the main child list.
  */
 class nsCanvasFrame final : public nsContainerFrame,
                             public nsIScrollPositionListener,
                             public nsIAnonymousContentCreator,
                             public nsIPopupContainer {
  public:
-  explicit nsCanvasFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID),
+  explicit nsCanvasFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID),
         mDoPaintFocus(false),
         mAddedScrollPositionListener(false),
         mPopupSetFrame(nullptr) {}
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsCanvasFrame)
 
   nsPopupSetFrame* GetPopupSetFrame() override;
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -97,25 +97,28 @@ bool nsDisplayColumnRule::CreateWebRende
  * XXX cursor movement around the top and bottom of colums seems to make the
  * editor lose the caret.
  *
  * XXX should we support CSS columns applied to table elements?
  */
 nsContainerFrame* NS_NewColumnSetFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle,
                                        nsFrameState aStateFlags) {
-  nsColumnSetFrame* it = new (aPresShell) nsColumnSetFrame(aStyle);
+  nsColumnSetFrame* it =
+      new (aPresShell) nsColumnSetFrame(aStyle, aPresShell->GetPresContext());
   it->AddStateBits(aStateFlags);
   return it;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsColumnSetFrame)
 
-nsColumnSetFrame::nsColumnSetFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mLastBalanceBSize(NS_INTRINSICSIZE) {}
+nsColumnSetFrame::nsColumnSetFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
+      mLastBalanceBSize(NS_INTRINSICSIZE) {}
 
 void nsColumnSetFrame::ForEachColumnRule(
     const std::function<void(const nsRect& lineRect)>& aSetLineRect,
     const nsPoint& aPt) {
   nsIFrame* child = mFrames.FirstChild();
   if (!child) return;  // no columns
 
   nsIFrame* nextSibling = child->GetNextSibling();
--- a/layout/generic/nsColumnSetFrame.h
+++ b/layout/generic/nsColumnSetFrame.h
@@ -17,17 +17,17 @@
  * nsColumnSetFrame implements CSS multi-column layout.
  * @note nsColumnSetFrame keeps true overflow containers in the normal flow
  * child lists (i.e. the principal and overflow lists).
  */
 class nsColumnSetFrame final : public nsContainerFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsColumnSetFrame)
 
-  explicit nsColumnSetFrame(ComputedStyle* aStyle);
+  explicit nsColumnSetFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
 #ifdef DEBUG
   virtual void SetInitialChildList(ChildListID aListID,
                                    nsFrameList& aChildList) override;
--- a/layout/generic/nsContainerFrame.h
+++ b/layout/generic/nsContainerFrame.h
@@ -503,18 +503,19 @@ class nsContainerFrame : public nsSplitt
   // Use this to suppress the CRAZY_SIZE assertions.
   NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(DebugReflowingWithInfiniteISize, bool)
   bool IsCrazySizeAssertSuppressed() const {
     return GetProperty(DebugReflowingWithInfiniteISize());
   }
 #endif
 
  protected:
-  nsContainerFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsSplittableFrame(aStyle, aID) {}
+  nsContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                   ClassID aID)
+      : nsSplittableFrame(aStyle, aPresContext, aID) {}
 
   ~nsContainerFrame();
 
   /**
    * Helper for DestroyFrom. DestroyAbsoluteFrames is called before
    * destroying frames on lists that can contain placeholders.
    * Derived classes must do that too, if they destroy such frame lists.
    * See nsBlockFrame::DestroyFrom for an example.
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -18,17 +18,18 @@
 #include "nsPlaceholderFrame.h"
 #include "nsCSSFrameConstructor.h"
 
 using namespace mozilla;
 using namespace mozilla::layout;
 
 nsFirstLetterFrame* NS_NewFirstLetterFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle) {
-  return new (aPresShell) nsFirstLetterFrame(aStyle);
+  return new (aPresShell)
+      nsFirstLetterFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFirstLetterFrame)
 
 NS_QUERYFRAME_HEAD(nsFirstLetterFrame)
   NS_QUERYFRAME_ENTRY(nsFirstLetterFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
--- a/layout/generic/nsFirstLetterFrame.h
+++ b/layout/generic/nsFirstLetterFrame.h
@@ -12,18 +12,19 @@
 #include "mozilla/Attributes.h"
 #include "nsContainerFrame.h"
 
 class nsFirstLetterFrame final : public nsContainerFrame {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsFirstLetterFrame)
 
-  explicit nsFirstLetterFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID) {}
+  explicit nsFirstLetterFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID) {}
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
   virtual void SetInitialChildList(ChildListID aListID,
                                    nsFrameList& aChildList) override;
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -2320,17 +2320,18 @@ class MOZ_STACK_CLASS SingleLineCrossAxi
 NS_QUERYFRAME_HEAD(nsFlexContainerFrame)
   NS_QUERYFRAME_ENTRY(nsFlexContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFlexContainerFrame)
 
 nsContainerFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle) {
-  return new (aPresShell) nsFlexContainerFrame(aStyle);
+  return new (aPresShell)
+      nsFlexContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsFlexContainerFrame Method Implementations
 // ===========================================
 
 /* virtual */
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -227,18 +227,19 @@ class nsFlexContainerFrame final : publi
 
   /**
    * Callback for nsFrame::MarkIntrinsicISizesDirty() on a flex item.
    */
   static void MarkCachedFlexMeasurementsDirty(nsIFrame* aItemFrame);
 
  protected:
   // Protected constructor & destructor
-  explicit nsFlexContainerFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID),
+  explicit nsFlexContainerFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID),
         mCachedMinISize(NS_INTRINSIC_WIDTH_UNKNOWN),
         mCachedPrefISize(NS_INTRINSIC_WIDTH_UNKNOWN),
         mBaselineFromLastReflow(NS_INTRINSIC_WIDTH_UNKNOWN),
         mLastBaselineFromLastReflow(NS_INTRINSIC_WIDTH_UNKNOWN) {}
 
   virtual ~nsFlexContainerFrame();
 
   /*
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -462,24 +462,23 @@ void WeakFrame::Init(nsIFrame* aFrame) {
       shell->AddWeakFrame(this);
     } else {
       mFrame = nullptr;
     }
   }
 }
 
 nsIFrame* NS_NewEmptyFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsFrame(aStyle);
-}
-
-nsFrame::nsFrame(ComputedStyle* aStyle, ClassID aID) : nsBox(aID) {
+  return new (aPresShell) nsFrame(aStyle, aPresShell->GetPresContext());
+}
+
+nsFrame::nsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                 ClassID aID)
+    : nsBox(aStyle, aPresContext, aID) {
   MOZ_COUNT_CTOR(nsFrame);
-
-  mComputedStyle = aStyle;
-  mWritingMode = WritingMode(mComputedStyle);
 }
 
 nsFrame::~nsFrame() {
   MOZ_COUNT_DTOR(nsFrame);
 
   MOZ_ASSERT(GetVisibility() != Visibility::APPROXIMATELY_VISIBLE,
              "Visible nsFrame is being destroyed");
 }
@@ -1196,18 +1195,16 @@ void nsIFrame::MarkNeedsDisplayItemRebui
 
   RemoveStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS | NS_FRAME_SIMPLE_DISPLAYLIST);
 
   mMayHaveRoundedCorners = true;
 }
 
 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
 void nsIFrame::AssertNewStyleIsSane(ComputedStyle& aNewStyle) {
-  MOZ_DIAGNOSTIC_ASSERT(PresShell() ==
-                        aNewStyle.PresContextForFrame()->PresShell());
   MOZ_DIAGNOSTIC_ASSERT(
       aNewStyle.GetPseudo() == mComputedStyle->GetPseudo() ||
       // ::first-line continuations are weird, this should probably be fixed via
       // bug 1465474.
       (mComputedStyle->GetPseudo() == nsCSSPseudoElements::firstLine() &&
        aNewStyle.GetPseudo() == nsCSSAnonBoxes::mozLineFrame()) ||
       // ::first-letter continuations are broken, in particular floating ones,
       // see bug 1490281. The construction code tries to fix this up after the
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -536,19 +536,19 @@ class nsFrame : public nsBox {
    *                           Must not be null.
    * @param aChildPseudo the child's pseudo type, if any.
    */
   static nsIFrame* CorrectStyleParentFrame(nsIFrame* aProspectiveParent,
                                            nsAtom* aChildPseudo);
 
  protected:
   // Protected constructor and destructor
-  nsFrame(ComputedStyle* aStyle, ClassID aID);
-  explicit nsFrame(ComputedStyle* aStyle)
-      : nsFrame(aStyle, ClassID::nsFrame_id) {}
+  nsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID);
+  explicit nsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, ClassID::nsFrame_id) {}
   virtual ~nsFrame();
 
   /**
    * To be called by |BuildDisplayLists| of this class or derived classes to add
    * a translucent overlay if this frame's content is selected.
    * @param aContentType an nsISelectionDisplay DISPLAY_ constant identifying
    * which kind of content this is for
    */
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -99,17 +99,17 @@ class nsHTMLFramesetBorderFrame final : 
 
   bool GetVisibility() { return mVisibility; }
   void SetVisibility(bool aVisibility);
   void SetColor(nscolor aColor);
 
   void PaintBorder(DrawTarget* aDrawTarget, nsPoint aPt);
 
  protected:
-  nsHTMLFramesetBorderFrame(ComputedStyle* aStyle, int32_t aWidth,
+  nsHTMLFramesetBorderFrame(ComputedStyle*, nsPresContext*, int32_t aWidth,
                             bool aVertical, bool aVisible);
   virtual ~nsHTMLFramesetBorderFrame();
   virtual nscoord GetIntrinsicISize() override;
   virtual nscoord GetIntrinsicBSize() override;
 
   // the prev and next neighbors are indexes into the row (for a horizontal
   // border) or col (for a vertical border) of nsHTMLFramesetFrames or
   // nsHTMLFrames
@@ -139,35 +139,37 @@ class nsHTMLFramesetBlankFrame final : p
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
  protected:
-  explicit nsHTMLFramesetBlankFrame(ComputedStyle* aStyle)
-      : nsLeafFrame(aStyle, kClassID) {}
+  explicit nsHTMLFramesetBlankFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsLeafFrame(aStyle, aPresContext, kClassID) {}
 
   virtual ~nsHTMLFramesetBlankFrame();
   virtual nscoord GetIntrinsicISize() override;
   virtual nscoord GetIntrinsicBSize() override;
 
   friend class nsHTMLFramesetFrame;
   friend class nsHTMLFrameset;
 };
 
 /*******************************************************************************
  * nsHTMLFramesetFrame
  ******************************************************************************/
 bool nsHTMLFramesetFrame::gDragInProgress = false;
 #define DEFAULT_BORDER_WIDTH_PX 6
 
-nsHTMLFramesetFrame::nsHTMLFramesetFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {
+nsHTMLFramesetFrame::nsHTMLFramesetFrame(ComputedStyle* aStyle,
+                                         nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {
   mNumRows = 0;
   mNumCols = 0;
   mEdgeVisibility = 0;
   mParentFrameborder = eFrameborder_Yes;  // default
   mParentBorderWidth = -1;                // default not set
   mParentBorderColor = NO_COLOR;          // default not set
   mFirstDragPoint.x = mFirstDragPoint.y = 0;
   mMinDrag = nsPresContext::CSSPixelsToAppUnits(2);
@@ -314,18 +316,18 @@ void nsHTMLFramesetFrame::Init(nsIConten
   for (int blankX = mChildCount; blankX < numCells; blankX++) {
     RefPtr<ComputedStyle> pseudoComputedStyle;
     pseudoComputedStyle =
         shell->StyleSet()->ResolveNonInheritingAnonymousBoxStyle(
             nsCSSAnonBoxes::framesetBlank());
 
     // XXX the blank frame is using the content of its parent - at some point it
     // should just have null content, if we support that
-    nsHTMLFramesetBlankFrame* blankFrame =
-        new (shell) nsHTMLFramesetBlankFrame(pseudoComputedStyle);
+    nsHTMLFramesetBlankFrame* blankFrame = new (shell)
+        nsHTMLFramesetBlankFrame(pseudoComputedStyle, PresContext());
 
     blankFrame->Init(mContent, this, nullptr);
 
     mFrames.AppendFrame(nullptr, blankFrame);
 
     mChildBorderColors[mChildCount].Set(NO_COLOR);
     mChildCount++;
   }
@@ -871,17 +873,17 @@ void nsHTMLFramesetFrame::Reflow(nsPresC
       offset.y += lastSize.height;
       if (firstTime) {  // create horizontal border
 
         RefPtr<ComputedStyle> pseudoComputedStyle;
         pseudoComputedStyle = styleSet->ResolveNonInheritingAnonymousBoxStyle(
             nsCSSAnonBoxes::horizontalFramesetBorder());
 
         borderFrame = new (shell) nsHTMLFramesetBorderFrame(
-            pseudoComputedStyle, borderWidth, false, false);
+            pseudoComputedStyle, PresContext(), borderWidth, false, false);
         borderFrame->Init(mContent, this, nullptr);
         mChildCount++;
         mFrames.AppendFrame(nullptr, borderFrame);
         mHorBorders[cellIndex.y - 1] = borderFrame;
         // set the neighbors for determining drag boundaries
         borderFrame->mPrevNeighbor = lastRow;
         borderFrame->mNextNeighbor = cellIndex.y;
       } else {
@@ -900,17 +902,17 @@ void nsHTMLFramesetFrame::Reflow(nsPresC
           if (firstTime) {       // create vertical border
 
             RefPtr<ComputedStyle> pseudoComputedStyle;
             pseudoComputedStyle =
                 styleSet->ResolveNonInheritingAnonymousBoxStyle(
                     nsCSSAnonBoxes::verticalFramesetBorder());
 
             borderFrame = new (shell) nsHTMLFramesetBorderFrame(
-                pseudoComputedStyle, borderWidth, true, false);
+                pseudoComputedStyle, PresContext(), borderWidth, true, false);
             borderFrame->Init(mContent, this, nullptr);
             mChildCount++;
             mFrames.AppendFrame(nullptr, borderFrame);
             mVerBorders[cellIndex.x - 1] = borderFrame;
             // set the neighbors for determining drag boundaries
             borderFrame->mPrevNeighbor = lastCol;
             borderFrame->mNextNeighbor = cellIndex.x;
           } else {
@@ -1263,29 +1265,29 @@ void nsHTMLFramesetFrame::EndMouseDrag(n
 nsIFrame* NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
 #ifdef DEBUG
   const nsStyleDisplay* disp = aStyle->StyleDisplay();
   NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
                "Framesets should not be positioned and should not float");
 #endif
 
-  return new (aPresShell) nsHTMLFramesetFrame(aStyle);
+  return new (aPresShell)
+      nsHTMLFramesetFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
 
 /*******************************************************************************
  * nsHTMLFramesetBorderFrame
  ******************************************************************************/
-nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(ComputedStyle* aStyle,
-                                                     int32_t aWidth,
-                                                     bool aVertical,
-                                                     bool aVisibility)
-    : nsLeafFrame(aStyle, kClassID),
+nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(
+    ComputedStyle* aStyle, nsPresContext* aPresContext, int32_t aWidth,
+    bool aVertical, bool aVisibility)
+    : nsLeafFrame(aStyle, aPresContext, kClassID),
       mWidth(aWidth),
       mVertical(aVertical),
       mVisibility(aVisibility) {
   mCanResize = true;
   mColor = NO_COLOR;
   mPrevNeighbor = 0;
   mNextNeighbor = 0;
 }
--- a/layout/generic/nsFrameSetFrame.h
+++ b/layout/generic/nsFrameSetFrame.h
@@ -60,17 +60,18 @@ struct nsFramesetDrag {
 /*******************************************************************************
  * nsHTMLFramesetFrame
  ******************************************************************************/
 class nsHTMLFramesetFrame final : public nsContainerFrame {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
 
-  explicit nsHTMLFramesetFrame(ComputedStyle* aStyle);
+  explicit nsHTMLFramesetFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext);
 
   virtual ~nsHTMLFramesetFrame();
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   virtual void SetInitialChildList(ChildListID aListID,
                                    nsFrameList& aChildList) override;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -104,24 +104,26 @@ static uint32_t GetOverflowChange(const 
 }
 
 //----------------------------------------------------------------------
 
 //----------nsHTMLScrollFrame-------------------------------------------
 
 nsHTMLScrollFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle, bool aIsRoot) {
-  return new (aPresShell) nsHTMLScrollFrame(aStyle, aIsRoot);
+  return new (aPresShell)
+      nsHTMLScrollFrame(aStyle, aPresShell->GetPresContext(), aIsRoot);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsHTMLScrollFrame)
 
 nsHTMLScrollFrame::nsHTMLScrollFrame(ComputedStyle* aStyle,
+                                     nsPresContext* aPresContext,
                                      nsIFrame::ClassID aID, bool aIsRoot)
-    : nsContainerFrame(aStyle, aID),
+    : nsContainerFrame(aStyle, aPresContext, aID),
       mHelper(ALLOW_THIS_IN_INITIALIZER_LIST(this), aIsRoot) {}
 
 void nsHTMLScrollFrame::ScrollbarActivityStarted() const {
   if (mHelper.mScrollbarActivity) {
     mHelper.mScrollbarActivity->ActivityStarted();
   }
 }
 
@@ -1193,25 +1195,26 @@ NS_QUERYFRAME_HEAD(nsHTMLScrollFrame)
   NS_QUERYFRAME_ENTRY(nsIScrollbarMediator)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 //----------nsXULScrollFrame-------------------------------------------
 
 nsXULScrollFrame* NS_NewXULScrollFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle, bool aIsRoot,
                                        bool aClipAllDescendants) {
-  return new (aPresShell)
-      nsXULScrollFrame(aStyle, aIsRoot, aClipAllDescendants);
+  return new (aPresShell) nsXULScrollFrame(aStyle, aPresShell->GetPresContext(),
+                                           aIsRoot, aClipAllDescendants);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsXULScrollFrame)
 
-nsXULScrollFrame::nsXULScrollFrame(ComputedStyle* aStyle, bool aIsRoot,
+nsXULScrollFrame::nsXULScrollFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext, bool aIsRoot,
                                    bool aClipAllDescendants)
-    : nsBoxFrame(aStyle, kClassID, aIsRoot),
+    : nsBoxFrame(aStyle, aPresContext, kClassID, aIsRoot),
       mHelper(ALLOW_THIS_IN_INITIALIZER_LIST(this), aIsRoot) {
   SetXULLayoutManager(nullptr);
   mHelper.mClipAllDescendants = aClipAllDescendants;
 }
 
 void nsXULScrollFrame::ScrollbarActivityStarted() const {
   if (mHelper.mScrollbarActivity) {
     mHelper.mScrollbarActivity->ActivityStarted();
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -1182,20 +1182,22 @@ class nsHTMLScrollFrame : public nsConta
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
 #ifdef ACCESSIBILITY
   virtual mozilla::a11y::AccType AccessibleType() override;
 #endif
 
  protected:
-  nsHTMLScrollFrame(ComputedStyle* aStyle, bool aIsRoot)
-      : nsHTMLScrollFrame(aStyle, kClassID, aIsRoot) {}
+  nsHTMLScrollFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                    bool aIsRoot)
+      : nsHTMLScrollFrame(aStyle, aPresContext, kClassID, aIsRoot) {}
 
-  nsHTMLScrollFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID, bool aIsRoot);
+  nsHTMLScrollFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                    nsIFrame::ClassID aID, bool aIsRoot);
   void SetSuppressScrollbarUpdate(bool aSuppress) {
     mHelper.mSuppressScrollbarUpdate = aSuppress;
   }
   bool GuessHScrollbarNeeded(const ScrollReflowInput& aState);
   bool GuessVScrollbarNeeded(const ScrollReflowInput& aState);
 
   bool IsScrollbarUpdateSuppressed() const {
     return mHelper.mSuppressScrollbarUpdate;
@@ -1653,17 +1655,17 @@ class nsXULScrollFrame final : public ns
     aResult.AppendElement(OwnedAnonBox(mHelper.GetScrolledFrame()));
   }
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
-  nsXULScrollFrame(ComputedStyle* aStyle, bool aIsRoot,
+  nsXULScrollFrame(ComputedStyle*, nsPresContext*, bool aIsRoot,
                    bool aClipAllDescendants);
 
   void ClampAndSetBounds(nsBoxLayoutState& aState, nsRect& aRect,
                          nsPoint aScrollPosition,
                          bool aRemoveOverflowAreas = false) {
     /*
      * For RTL frames, restore the original scrolled position of the right
      * edge, then subtract the current width to find the physical position.
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -2486,17 +2486,18 @@ static uint16_t GetAlignJustifyFallbackI
 NS_QUERYFRAME_HEAD(nsGridContainerFrame)
   NS_QUERYFRAME_ENTRY(nsGridContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsGridContainerFrame)
 
 nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle) {
-  return new (aPresShell) nsGridContainerFrame(aStyle);
+  return new (aPresShell)
+      nsGridContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsGridContainerFrame Method Implementations
 // ===========================================
 
 /*static*/ const nsRect& nsGridContainerFrame::GridItemCB(nsIFrame* aChild) {
--- a/layout/generic/nsGridContainerFrame.h
+++ b/layout/generic/nsGridContainerFrame.h
@@ -271,18 +271,19 @@ class nsGridContainerFrame final : publi
   class LineNameMap;
   struct LineRange;
   struct SharedGridData;
   struct TrackSizingFunctions;
   struct Tracks;
   struct TranslatedLineRange;
   friend nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
                                                     ComputedStyle* aStyle);
-  explicit nsGridContainerFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID),
+  explicit nsGridContainerFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID),
         mCachedMinISize(NS_INTRINSIC_WIDTH_UNKNOWN),
         mCachedPrefISize(NS_INTRINSIC_WIDTH_UNKNOWN) {
     mBaseline[0][0] = NS_INTRINSIC_WIDTH_UNKNOWN;
     mBaseline[0][1] = NS_INTRINSIC_WIDTH_UNKNOWN;
     mBaseline[1][0] = NS_INTRINSIC_WIDTH_UNKNOWN;
     mBaseline[1][1] = NS_INTRINSIC_WIDTH_UNKNOWN;
   }
 
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -222,17 +222,18 @@ class nsDisplayCanvas final : public nsD
     nsHTMLCanvasFrame* f = static_cast<nsHTMLCanvasFrame*>(Frame());
     HTMLCanvasElement* canvas = HTMLCanvasElement::FromNode(f->GetContent());
     return canvas->MaybeModified();
   }
 };
 
 nsIFrame* NS_NewHTMLCanvasFrame(nsIPresShell* aPresShell,
                                 ComputedStyle* aStyle) {
-  return new (aPresShell) nsHTMLCanvasFrame(aStyle);
+  return new (aPresShell)
+      nsHTMLCanvasFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_QUERYFRAME_HEAD(nsHTMLCanvasFrame)
   NS_QUERYFRAME_ENTRY(nsHTMLCanvasFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame)
 
--- a/layout/generic/nsHTMLCanvasFrame.h
+++ b/layout/generic/nsHTMLCanvasFrame.h
@@ -34,18 +34,19 @@ class nsHTMLCanvasFrame final : public n
   typedef mozilla::layers::Layer Layer;
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::layers::WebRenderCanvasData WebRenderCanvasData;
   typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame)
 
-  explicit nsHTMLCanvasFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID), mBorderPadding(GetWritingMode()) {}
+  explicit nsHTMLCanvasFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID),
+        mBorderPadding(GetWritingMode()) {}
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
   already_AddRefed<Layer> BuildLayer(
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -568,24 +568,27 @@ class nsIFrame : public nsQueryFrame {
   typedef mozilla::Sides Sides;
   typedef mozilla::LogicalSides LogicalSides;
   typedef mozilla::SmallPointerArray<mozilla::DisplayItemData>
       DisplayItemDataArray;
   typedef nsQueryFrame::ClassID ClassID;
 
   NS_DECL_QUERYFRAME_TARGET(nsIFrame)
 
-  explicit nsIFrame(ClassID aID)
+  explicit nsIFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                    ClassID aID)
       : mRect(),
         mContent(nullptr),
-        mComputedStyle(nullptr),
+        mComputedStyle(aStyle),
+        mPresContext(aPresContext),
         mParent(nullptr),
         mNextSibling(nullptr),
         mPrevSibling(nullptr),
         mState(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY),
+        mWritingMode(aStyle),
         mClass(aID),
         mMayHaveRoundedCorners(false),
         mHasImageRequest(false),
         mHasFirstLetterChild(false),
         mParentIsWrapperAnonBox(false),
         mIsWrapperBoxNeedingRestyle(false),
         mReflowRequestedForCharDataChange(false),
         mForceDescendIntoIfVisible(false),
@@ -593,20 +596,22 @@ class nsIFrame : public nsQueryFrame {
         mFrameIsModified(false),
         mHasOverrideDirtyRegion(false),
         mMayHaveWillChangeBudget(false),
         mIsPrimaryFrame(false),
         mMayHaveTransformAnimation(false),
         mMayHaveOpacityAnimation(false),
         mAllDescendantsAreInvisible(false),
         mInScrollAnchorChain(false) {
+    MOZ_ASSERT(mComputedStyle);
+    MOZ_ASSERT(mPresContext);
     mozilla::PodZero(&mOverflow);
   }
 
-  nsPresContext* PresContext() const { return Style()->PresContextForFrame(); }
+  nsPresContext* PresContext() const { return mPresContext; }
 
   nsIPresShell* PresShell() const { return PresContext()->PresShell(); }
 
   /**
    * Called to initialize the frame. This is called immediately after creating
    * the frame.
    *
    * If the frame is a continuing frame, then aPrevInFlow indicates the previous
@@ -772,18 +777,16 @@ class nsIFrame : public nsQueryFrame {
   /**
    * SetComputedStyleWithoutNotification is for changes to the style
    * context that should suppress style change processing, in other
    * words, those that aren't really changes.  This generally means only
    * changes that happen during frame construction.
    */
   void SetComputedStyleWithoutNotification(ComputedStyle* aStyle) {
     if (aStyle != mComputedStyle) {
-      MOZ_DIAGNOSTIC_ASSERT(PresShell() ==
-                            aStyle->PresContextForFrame()->PresShell());
       mComputedStyle = aStyle;
     }
   }
 
   // Style post processing hook
   // Attention: the old style is the one we're forgetting,
   // and hence possibly completely bogus for GetStyle* purposes.
   // Use PeekStyleData instead.
@@ -4157,16 +4160,17 @@ class nsIFrame : public nsQueryFrame {
   virtual bool IsLeafDynamic() const { return false; }
 
   // Members
   nsRect mRect;
   nsCOMPtr<nsIContent> mContent;
   RefPtr<ComputedStyle> mComputedStyle;
 
  private:
+  nsPresContext* const mPresContext;
   nsContainerFrame* mParent;
   nsIFrame* mNextSibling;  // doubly-linked list of frames
   nsIFrame* mPrevSibling;  // Do not touch outside SetNextSibling!
 
   DisplayItemDataArray mDisplayItemData;
 
   void MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder);
 
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -87,16 +87,18 @@
 #include "mozilla/dom/HTMLAnchorElement.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 using namespace mozilla::layers;
 
+using mozilla::layout::TextDrawTarget;
+
 // sizes (pixels) for image icon, padding and border frame
 #define ICON_SIZE (16)
 #define ICON_PADDING (3)
 #define ALT_BORDER_WIDTH (1)
 
 // Default alignment value (so we can tell an unset value from a set value)
 #define ALIGN_UNSET uint8_t(-1)
 
@@ -125,30 +127,31 @@ static bool HaveFixedSize(const ReflowIn
   // Don't try to make this optimization when an image has percentages
   // in its 'width' or 'height'.  The percentages might be treated like
   // auto (especially for intrinsic width calculations and for heights).
   return aReflowInput.mStylePosition->mHeight.ConvertsToLength() &&
          aReflowInput.mStylePosition->mWidth.ConvertsToLength();
 }
 
 nsIFrame* NS_NewImageFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell)
-      nsImageFrame(aStyle, nsImageFrame::Kind::ImageElement);
+  return new (aPresShell) nsImageFrame(aStyle, aPresShell->GetPresContext(),
+                                       nsImageFrame::Kind::ImageElement);
 }
 
 nsIFrame* NS_NewImageFrameForContentProperty(nsIPresShell* aPresShell,
                                              ComputedStyle* aStyle) {
-  return new (aPresShell)
-      nsImageFrame(aStyle, nsImageFrame::Kind::ContentProperty);
+  return new (aPresShell) nsImageFrame(aStyle, aPresShell->GetPresContext(),
+                                       nsImageFrame::Kind::ContentProperty);
 }
 
 nsIFrame* NS_NewImageFrameForGeneratedContentIndex(nsIPresShell* aPresShell,
                                                    ComputedStyle* aStyle) {
   return new (aPresShell)
-      nsImageFrame(aStyle, nsImageFrame::Kind::ContentPropertyAtIndex);
+      nsImageFrame(aStyle, aPresShell->GetPresContext(),
+                   nsImageFrame::Kind::ContentPropertyAtIndex);
 }
 
 bool nsImageFrame::ShouldShowBrokenImageIcon() const {
   // NOTE(emilio, https://github.com/w3c/csswg-drafts/issues/2832): WebKit and
   // Blink behave differently here for content: url(..), for now adapt to
   // Blink's behavior.
   if (mKind != Kind::ImageElement) {
     return false;
@@ -164,23 +167,25 @@ bool nsImageFrame::ShouldShowBrokenImage
 
   nsCOMPtr<nsIImageLoadingContent> loader = do_QueryInterface(mContent);
   MOZ_ASSERT(loader);
   return loader->GetImageBlockingStatus() != nsIContentPolicy::ACCEPT;
 }
 
 nsImageFrame* nsImageFrame::CreateContinuingFrame(nsIPresShell* aPresShell,
                                                   ComputedStyle* aStyle) const {
-  return new (aPresShell) nsImageFrame(aStyle, mKind);
+  return new (aPresShell)
+      nsImageFrame(aStyle, aPresShell->GetPresContext(), mKind);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsImageFrame)
 
-nsImageFrame::nsImageFrame(ComputedStyle* aStyle, ClassID aID, Kind aKind)
-    : nsAtomicContainerFrame(aStyle, aID),
+nsImageFrame::nsImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                           ClassID aID, Kind aKind)
+    : nsAtomicContainerFrame(aStyle, aPresContext, aID),
       mComputedSize(0, 0),
       mIntrinsicRatio(0, 0),
       mKind(aKind),
       mContentURLRequestRegistered(false),
       mDisplayingIcon(false),
       mFirstFrameComplete(false),
       mReflowCallbackPosted(false),
       mForceSyncDecoding(false) {
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -197,24 +197,24 @@ class nsImageFrame : public nsAtomicCont
 
  private:
   friend nsIFrame* NS_NewImageFrame(nsIPresShell*, ComputedStyle*);
   friend nsIFrame* NS_NewImageFrameForContentProperty(nsIPresShell*,
                                                       ComputedStyle*);
   friend nsIFrame* NS_NewImageFrameForGeneratedContentIndex(nsIPresShell*,
                                                             ComputedStyle*);
 
-  nsImageFrame(ComputedStyle* aStyle, Kind aKind)
-      : nsImageFrame(aStyle, kClassID, aKind) {}
+  nsImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, Kind aKind)
+      : nsImageFrame(aStyle, aPresContext, kClassID, aKind) {}
 
-  nsImageFrame(ComputedStyle*, ClassID, Kind);
+  nsImageFrame(ComputedStyle*, nsPresContext* aPresContext, ClassID, Kind);
 
  protected:
-  nsImageFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsImageFrame(aStyle, aID, Kind::ImageElement) {}
+  nsImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
+      : nsImageFrame(aStyle, aPresContext, aID, Kind::ImageElement) {}
 
   virtual ~nsImageFrame();
 
   void EnsureIntrinsicSizeAndRatio();
 
   bool GotInitialReflow() const {
     return !HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
   }
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -31,17 +31,17 @@ using namespace mozilla;
 using namespace mozilla::layout;
 
 //////////////////////////////////////////////////////////////////////
 
 // Basic nsInlineFrame methods
 
 nsInlineFrame* NS_NewInlineFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsInlineFrame(aStyle);
+  return new (aPresShell) nsInlineFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsInlineFrame)
 
 NS_QUERYFRAME_HEAD(nsInlineFrame)
   NS_QUERYFRAME_ENTRY(nsInlineFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
@@ -926,17 +926,18 @@ void nsInlineFrame::UpdateStyleOfOwnedAn
 }
 
 //////////////////////////////////////////////////////////////////////
 
 // nsLineFrame implementation
 
 nsFirstLineFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) nsFirstLineFrame(aStyle);
+  return new (aPresShell)
+      nsFirstLineFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFirstLineFrame)
 
 void nsFirstLineFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                             nsIFrame* aPrevInFlow) {
   nsInlineFrame::Init(aContent, aParent, aPrevInFlow);
   if (!aPrevInFlow) {
--- a/layout/generic/nsInlineFrame.h
+++ b/layout/generic/nsInlineFrame.h
@@ -133,18 +133,19 @@ class nsInlineFrame : public nsContainer
       mPrevFrame = nullptr;
       mNextInFlow = nullptr;
       mLineContainer = nullptr;
       mLineLayout = nullptr;
       mSetParentPointer = false;
     }
   };
 
-  nsInlineFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsContainerFrame(aStyle, aID), mBaseline(NS_INTRINSIC_WIDTH_UNKNOWN) {}
+  nsInlineFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
+      : nsContainerFrame(aStyle, aPresContext, aID),
+        mBaseline(NS_INTRINSIC_WIDTH_UNKNOWN) {}
 
   virtual LogicalSides GetLogicalSkipSides(
       const ReflowInput* aReflowInput = nullptr) const override;
 
   void ReflowFrames(nsPresContext* aPresContext,
                     const ReflowInput& aReflowInput, InlineReflowInput& rs,
                     ReflowOutput& aMetrics, nsReflowStatus& aStatus);
 
@@ -157,18 +158,18 @@ class nsInlineFrame : public nsContainer
   static bool HasFramesToPull(nsInlineFrame* aNextInFlow);
 
   virtual nsIFrame* PullOneFrame(nsPresContext*, InlineReflowInput&);
 
   virtual void PushFrames(nsPresContext* aPresContext, nsIFrame* aFromChild,
                           nsIFrame* aPrevSibling, InlineReflowInput& aState);
 
  private:
-  explicit nsInlineFrame(ComputedStyle* aStyle)
-      : nsInlineFrame(aStyle, kClassID) {}
+  explicit nsInlineFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsInlineFrame(aStyle, aPresContext, kClassID) {}
 
   /**
    * Move any frames on our overflow list to the end of our principal list.
    * @param aInFirstLine whether we're in a first-line frame.
    * @return true if there were any overflow frames
    */
   bool DrainSelfOverflowListInternal(bool aInFirstLine);
 
@@ -197,15 +198,15 @@ class nsFirstLineFrame final : public ns
                       nsReflowStatus& aStatus) override;
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
   virtual void PullOverflowsFromPrevInFlow() override;
   virtual bool DrainSelfOverflowList() override;
 
  protected:
-  explicit nsFirstLineFrame(ComputedStyle* aStyle)
-      : nsInlineFrame(aStyle, kClassID) {}
+  explicit nsFirstLineFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsInlineFrame(aStyle, aPresContext, kClassID) {}
 
   nsIFrame* PullOneFrame(nsPresContext*, InlineReflowInput&) override;
 };
 
 #endif /* nsInlineFrame_h___ */
--- a/layout/generic/nsLeafFrame.h
+++ b/layout/generic/nsLeafFrame.h
@@ -55,17 +55,18 @@ class nsLeafFrame : public nsFrame {
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override {
     // We don't actually contain a block, but we do always want a
     // computed width, so tell a little white lie here.
     return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
   }
 
  protected:
-  nsLeafFrame(ComputedStyle* aStyle, ClassID aID) : nsFrame(aStyle, aID) {}
+  nsLeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
+      : nsFrame(aStyle, aPresContext, aID) {}
 
   virtual ~nsLeafFrame();
 
   /**
    * Return the intrinsic isize of the frame's content area. Note that this
    * should not include borders or padding and should not depend on the applied
    * styles.
    */
--- a/layout/generic/nsPageContentFrame.cpp
+++ b/layout/generic/nsPageContentFrame.cpp
@@ -9,17 +9,18 @@
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsSimplePageSequenceFrame.h"
 
 using namespace mozilla;
 
 nsPageContentFrame* NS_NewPageContentFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle) {
-  return new (aPresShell) nsPageContentFrame(aStyle);
+  return new (aPresShell)
+      nsPageContentFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPageContentFrame)
 
 void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
                                 ReflowOutput& aDesiredSize,
                                 const ReflowInput& aReflowInput,
                                 nsReflowStatus& aStatus) {
--- a/layout/generic/nsPageContentFrame.h
+++ b/layout/generic/nsPageContentFrame.h
@@ -41,15 +41,16 @@ class nsPageContentFrame final : public 
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
 #ifdef DEBUG_FRAME_DUMP
   // Debugging
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
-  explicit nsPageContentFrame(ComputedStyle* aStyle)
-      : ViewportFrame(aStyle, kClassID) {}
+  explicit nsPageContentFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : ViewportFrame(aStyle, aPresContext, kClassID) {}
 
   nsSharedPageData* mPD;
 };
 
 #endif /* nsPageContentFrame_h___ */
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -24,27 +24,27 @@
 #include "mozilla/Logging.h"
 extern mozilla::LazyLogModule gLayoutPrintingLog;
 #define PR_PL(_p1) MOZ_LOG(gLayoutPrintingLog, mozilla::LogLevel::Debug, _p1)
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 nsPageFrame* NS_NewPageFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsPageFrame(aStyle);
+  return new (aPresShell) nsPageFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPageFrame)
 
 NS_QUERYFRAME_HEAD(nsPageFrame)
   NS_QUERYFRAME_ENTRY(nsPageFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
-nsPageFrame::nsPageFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {}
+nsPageFrame::nsPageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {}
 
 nsPageFrame::~nsPageFrame() {}
 
 void nsPageFrame::Reflow(nsPresContext* aPresContext,
                          ReflowOutput& aDesiredSize,
                          const ReflowInput& aReflowInput,
                          nsReflowStatus& aStatus) {
   MarkInReflow();
@@ -632,23 +632,25 @@ void nsPageFrame::AppendDirectlyOwnedAno
 
 nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
   MOZ_ASSERT(aPresShell, "null PresShell");
   // check that we are only creating page break frames when printing
   NS_ASSERTION(aPresShell->GetPresContext()->IsPaginated(),
                "created a page break frame while not printing");
 
-  return new (aPresShell) nsPageBreakFrame(aStyle);
+  return new (aPresShell)
+      nsPageBreakFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPageBreakFrame)
 
-nsPageBreakFrame::nsPageBreakFrame(ComputedStyle* aStyle)
-    : nsLeafFrame(aStyle, kClassID), mHaveReflowed(false) {}
+nsPageBreakFrame::nsPageBreakFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext)
+    : nsLeafFrame(aStyle, aPresContext, kClassID), mHaveReflowed(false) {}
 
 nsPageBreakFrame::~nsPageBreakFrame() {}
 
 nscoord nsPageBreakFrame::GetIntrinsicISize() {
   return nsPresContext::CSSPixelsToAppUnits(1);
 }
 
 nscoord nsPageBreakFrame::GetIntrinsicBSize() { return 0; }
--- a/layout/generic/nsPageFrame.h
+++ b/layout/generic/nsPageFrame.h
@@ -50,17 +50,17 @@ class nsPageFrame final : public nsConta
                          bool aSubpixelAA);
 
   /**
    * Return our page content frame.
    */
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
  protected:
-  explicit nsPageFrame(ComputedStyle* aStyle);
+  explicit nsPageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsPageFrame();
 
   typedef enum { eHeader, eFooter } nsHeaderFooterEnum;
 
   nscoord GetXPosition(gfxContext& aRenderingContext,
                        nsFontMetrics& aFontMetrics, const nsRect& aRect,
                        int32_t aJust, const nsString& aStr);
 
@@ -84,17 +84,17 @@ class nsPageFrame final : public nsConta
 
   nsSharedPageData* mPD;
   nsMargin mPageContentMargin;
 };
 
 class nsPageBreakFrame final : public nsLeafFrame {
   NS_DECL_FRAMEARENA_HELPERS(nsPageBreakFrame)
 
-  explicit nsPageBreakFrame(ComputedStyle* aStyle);
+  explicit nsPageBreakFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   ~nsPageBreakFrame();
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
--- a/layout/generic/nsPlaceholderFrame.cpp
+++ b/layout/generic/nsPlaceholderFrame.cpp
@@ -24,17 +24,18 @@
 #include "nsIContentInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 nsPlaceholderFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle,
                                            nsFrameState aTypeBits) {
-  return new (aPresShell) nsPlaceholderFrame(aStyle, aTypeBits);
+  return new (aPresShell)
+      nsPlaceholderFrame(aStyle, aPresShell->GetPresContext(), aTypeBits);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPlaceholderFrame)
 
 #ifdef DEBUG
 NS_QUERYFRAME_HEAD(nsPlaceholderFrame)
   NS_QUERYFRAME_ENTRY(nsPlaceholderFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsFrame)
--- a/layout/generic/nsPlaceholderFrame.h
+++ b/layout/generic/nsPlaceholderFrame.h
@@ -62,18 +62,19 @@ class nsPlaceholderFrame final : public 
   /**
    * Create a new placeholder frame.  aTypeBit must be one of the
    * PLACEHOLDER_FOR_* constants above.
    */
   friend nsPlaceholderFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
                                                     ComputedStyle* aStyle,
                                                     nsFrameState aTypeBits);
 
-  nsPlaceholderFrame(ComputedStyle* aStyle, nsFrameState aTypeBits)
-      : nsFrame(aStyle, kClassID), mOutOfFlowFrame(nullptr) {
+  nsPlaceholderFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                     nsFrameState aTypeBits)
+      : nsFrame(aStyle, aPresContext, kClassID), mOutOfFlowFrame(nullptr) {
     MOZ_ASSERT(
         aTypeBits == PLACEHOLDER_FOR_FLOAT ||
             aTypeBits == PLACEHOLDER_FOR_ABSPOS ||
             aTypeBits == PLACEHOLDER_FOR_FIXEDPOS ||
             aTypeBits == PLACEHOLDER_FOR_POPUP ||
             aTypeBits == (PLACEHOLDER_FOR_TOPLAYER | PLACEHOLDER_FOR_ABSPOS) ||
             aTypeBits == (PLACEHOLDER_FOR_TOPLAYER | PLACEHOLDER_FOR_FIXEDPOS),
         "Unexpected type bit");
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -128,18 +128,18 @@ class PluginBackgroundSink : public Read
     }
     return false;
   }
 
   uint64_t mLastSequenceNumber;
   nsPluginFrame* mFrame;
 };
 
-nsPluginFrame::nsPluginFrame(ComputedStyle* aStyle)
-    : nsFrame(aStyle, kClassID),
+nsPluginFrame::nsPluginFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsFrame(aStyle, aPresContext, kClassID),
       mInstanceOwner(nullptr),
       mOuterView(nullptr),
       mInnerView(nullptr),
       mBackgroundSink(nullptr),
       mReflowCallbackPosted(false) {
   MOZ_LOG(sPluginFrameLog, LogLevel::Debug,
           ("Created new nsPluginFrame %p\n", this));
 }
@@ -1680,17 +1680,17 @@ nsIObjectFrame* nsPluginFrame::GetNextOb
   }
 
   if (objectFrame->mInstanceOwner) {
     objectFrame->RegisterPluginForGeometryUpdates();
   }
 }
 
 nsIFrame* NS_NewObjectFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsPluginFrame(aStyle);
+  return new (aPresShell) nsPluginFrame(aStyle, aPresShell->GetPresContext());
 }
 
 bool nsPluginFrame::IsPaintedByGecko() const {
 #ifdef XP_MACOSX
   return true;
 #else
   return !mWidget;
 #endif
--- a/layout/generic/nsPluginFrame.h
+++ b/layout/generic/nsPluginFrame.h
@@ -226,17 +226,17 @@ class nsPluginFrame final : public nsFra
   bool CreateWebRenderCommands(
       nsDisplayItem* aItem, mozilla::wr::DisplayListBuilder& aBuilder,
       mozilla::wr::IpcResourceUpdateQueue& aResources,
       const StackingContextHelper& aSc,
       mozilla::layers::RenderRootStateManager* aManager,
       nsDisplayListBuilder* aDisplayListBuilder);
 
  protected:
-  explicit nsPluginFrame(ComputedStyle* aStyle);
+  explicit nsPluginFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsPluginFrame();
 
   // NOTE:  This frame class does not inherit from |nsLeafFrame|, so
   // this is not a virtual method implementation.
   void GetDesiredSize(nsPresContext* aPresContext,
                       const ReflowInput& aReflowInput,
                       ReflowOutput& aDesiredSize);
 
--- a/layout/generic/nsRubyBaseContainerFrame.cpp
+++ b/layout/generic/nsRubyBaseContainerFrame.cpp
@@ -32,17 +32,18 @@ using namespace mozilla::gfx;
 NS_QUERYFRAME_HEAD(nsRubyBaseContainerFrame)
   NS_QUERYFRAME_ENTRY(nsRubyBaseContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRubyBaseContainerFrame)
 
 nsContainerFrame* NS_NewRubyBaseContainerFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsRubyBaseContainerFrame(aStyle);
+  return new (aPresShell)
+      nsRubyBaseContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsRubyBaseContainerFrame Method Implementations
 // ===============================================
 
 #ifdef DEBUG_FRAME_DUMP
--- a/layout/generic/nsRubyBaseContainerFrame.h
+++ b/layout/generic/nsRubyBaseContainerFrame.h
@@ -53,18 +53,19 @@ class nsRubyBaseContainerFrame final : p
   mozilla::RubyBlockLeadings GetDescendantLeadings() const {
     return mDescendantLeadings;
   }
 
  protected:
   friend nsContainerFrame* NS_NewRubyBaseContainerFrame(
       nsIPresShell* aPresShell, ComputedStyle* aStyle);
 
-  explicit nsRubyBaseContainerFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID) {}
+  explicit nsRubyBaseContainerFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID) {}
 
   struct RubyReflowInput;
   nscoord ReflowColumns(const RubyReflowInput& aReflowInput,
                         nsReflowStatus& aStatus);
   nscoord ReflowOneColumn(const RubyReflowInput& aReflowInput,
                           uint32_t aColumnIndex,
                           const mozilla::RubyColumn& aColumn,
                           nsReflowStatus& aStatus);
--- a/layout/generic/nsRubyBaseFrame.cpp
+++ b/layout/generic/nsRubyBaseFrame.cpp
@@ -23,17 +23,17 @@ using namespace mozilla;
 NS_QUERYFRAME_HEAD(nsRubyBaseFrame)
   NS_QUERYFRAME_ENTRY(nsRubyBaseFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRubyBaseFrame)
 
 nsContainerFrame* NS_NewRubyBaseFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle) {
-  return new (aPresShell) nsRubyBaseFrame(aStyle);
+  return new (aPresShell) nsRubyBaseFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsRubyBaseFrame Method Implementations
 // ======================================
 
 #ifdef DEBUG_FRAME_DUMP
--- a/layout/generic/nsRubyBaseFrame.h
+++ b/layout/generic/nsRubyBaseFrame.h
@@ -25,13 +25,13 @@ class nsRubyBaseFrame final : public nsR
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
   friend nsContainerFrame* NS_NewRubyBaseFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle);
-  explicit nsRubyBaseFrame(ComputedStyle* aStyle)
-      : nsRubyContentFrame(aStyle, kClassID) {}
+  explicit nsRubyBaseFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsRubyContentFrame(aStyle, aPresContext, kClassID) {}
 };
 
 #endif /* nsRubyBaseFrame_h___ */
--- a/layout/generic/nsRubyContentFrame.h
+++ b/layout/generic/nsRubyContentFrame.h
@@ -21,13 +21,14 @@ class nsRubyContentFrame : public nsInli
   // Indicates whether this is an "intra-level whitespace" frame, i.e.
   // an anonymous frame that was created to contain non-droppable
   // whitespaces directly inside a ruby level container. This impacts
   // ruby pairing behavior.
   // See http://dev.w3.org/csswg/css-ruby/#anon-gen-interpret-space
   bool IsIntraLevelWhitespace() const;
 
  protected:
-  nsRubyContentFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsInlineFrame(aStyle, aID) {}
+  nsRubyContentFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                     ClassID aID)
+      : nsInlineFrame(aStyle, aPresContext, aID) {}
 };
 
 #endif /* nsRubyContentFrame_h___ */
--- a/layout/generic/nsRubyFrame.cpp
+++ b/layout/generic/nsRubyFrame.cpp
@@ -27,17 +27,17 @@ using namespace mozilla;
 NS_QUERYFRAME_HEAD(nsRubyFrame)
   NS_QUERYFRAME_ENTRY(nsRubyFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsInlineFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRubyFrame)
 
 nsContainerFrame* NS_NewRubyFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
-  return new (aPresShell) nsRubyFrame(aStyle);
+  return new (aPresShell) nsRubyFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsRubyFrame Method Implementations
 // ==================================
 
 /* virtual */ bool nsRubyFrame::IsFrameOfType(uint32_t aFlags) const {
--- a/layout/generic/nsRubyFrame.h
+++ b/layout/generic/nsRubyFrame.h
@@ -38,18 +38,18 @@ class nsRubyFrame final : public nsInlin
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   mozilla::RubyBlockLeadings GetBlockLeadings() const { return mLeadings; }
 
  protected:
   friend nsContainerFrame* NS_NewRubyFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle);
-  explicit nsRubyFrame(ComputedStyle* aStyle)
-      : nsInlineFrame(aStyle, kClassID) {}
+  explicit nsRubyFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsInlineFrame(aStyle, aPresContext, kClassID) {}
 
   void ReflowSegment(nsPresContext* aPresContext,
                      const ReflowInput& aReflowInput,
                      nsRubyBaseContainerFrame* aBaseContainer,
                      nsReflowStatus& aStatus);
 
   nsRubyBaseContainerFrame* PullOneSegment(const nsLineLayout* aLineLayout,
                                            ContinuationTraversingState& aState);
--- a/layout/generic/nsRubyTextContainerFrame.cpp
+++ b/layout/generic/nsRubyTextContainerFrame.cpp
@@ -24,17 +24,18 @@ using namespace mozilla;
 NS_QUERYFRAME_HEAD(nsRubyTextContainerFrame)
   NS_QUERYFRAME_ENTRY(nsRubyTextContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextContainerFrame)
 
 nsContainerFrame* NS_NewRubyTextContainerFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsRubyTextContainerFrame(aStyle);
+  return new (aPresShell)
+      nsRubyTextContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsRubyTextContainerFrame Method Implementations
 // ===============================================
 
 #ifdef DEBUG_FRAME_DUMP
--- a/layout/generic/nsRubyTextContainerFrame.h
+++ b/layout/generic/nsRubyTextContainerFrame.h
@@ -45,18 +45,19 @@ class nsRubyTextContainerFrame final : p
   bool IsSpanContainer() const {
     return GetStateBits() & NS_RUBY_TEXT_CONTAINER_IS_SPAN;
   }
 
  protected:
   friend nsContainerFrame* NS_NewRubyTextContainerFrame(
       nsIPresShell* aPresShell, ComputedStyle* aStyle);
 
-  explicit nsRubyTextContainerFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID), mISize(0) {}
+  explicit nsRubyTextContainerFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID), mISize(0) {}
 
   void UpdateSpanFlag();
 
   friend class nsRubyBaseContainerFrame;
   void SetISize(nscoord aISize) { mISize = aISize; }
 
   // The intended inline size of the ruby text container. It is set by
   // the corresponding ruby base container when the segment is reflowed,
--- a/layout/generic/nsRubyTextFrame.cpp
+++ b/layout/generic/nsRubyTextFrame.cpp
@@ -23,17 +23,17 @@ using namespace mozilla;
 NS_QUERYFRAME_HEAD(nsRubyTextFrame)
   NS_QUERYFRAME_ENTRY(nsRubyTextFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsRubyContentFrame)
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRubyTextFrame)
 
 nsContainerFrame* NS_NewRubyTextFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle) {
-  return new (aPresShell) nsRubyTextFrame(aStyle);
+  return new (aPresShell) nsRubyTextFrame(aStyle, aPresShell->GetPresContext());
 }
 
 //----------------------------------------------------------------------
 
 // nsRubyTextFrame Method Implementations
 // ======================================
 
 /* virtual */ bool nsRubyTextFrame::CanContinueTextRun() const { return false; }
--- a/layout/generic/nsRubyTextFrame.h
+++ b/layout/generic/nsRubyTextFrame.h
@@ -39,13 +39,13 @@ class nsRubyTextFrame final : public nsR
 
   bool IsAutoHidden() const {
     return GetStateBits() & NS_RUBY_TEXT_FRAME_AUTOHIDE;
   }
 
  protected:
   friend nsContainerFrame* NS_NewRubyTextFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle);
-  explicit nsRubyTextFrame(ComputedStyle* aStyle)
-      : nsRubyContentFrame(aStyle, kClassID) {}
+  explicit nsRubyTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsRubyContentFrame(aStyle, aPresContext, kClassID) {}
 };
 
 #endif /* nsRubyTextFrame_h___ */
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -33,23 +33,25 @@ using namespace mozilla::dom;
 
 #include "mozilla/Logging.h"
 mozilla::LazyLogModule gLayoutPrintingLog("printing-layout");
 
 #define PR_PL(_p1) MOZ_LOG(gLayoutPrintingLog, mozilla::LogLevel::Debug, _p1)
 
 nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(
     nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSimplePageSequenceFrame(aStyle);
+  return new (aPresShell)
+      nsSimplePageSequenceFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame)
 
-nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID),
+nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(
+    ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
       mTotalPages(-1),
       mCalledBeginPage(false),
       mCurrentCanvasListSetup(false) {
   nscoord halfInch = PresContext()->CSSTwipsToAppUnits(NS_INCHES_TO_TWIPS(0.5));
   mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch);
 
   // XXX Unsafe to assume successful allocation
   mPageData = new nsSharedPageData();
--- a/layout/generic/nsSimplePageSequenceFrame.h
+++ b/layout/generic/nsSimplePageSequenceFrame.h
@@ -98,17 +98,17 @@ class nsSimplePageSequenceFrame final : 
    */
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
-  explicit nsSimplePageSequenceFrame(ComputedStyle* aStyle);
+  nsSimplePageSequenceFrame(ComputedStyle*, nsPresContext*);
   virtual ~nsSimplePageSequenceFrame();
 
   void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal,
                            bool aPageNumOnly);
 
   // SharedPageData Helper methods
   void SetDateTimeStr(const nsAString& aDateTimeStr);
   void SetPageNumberFormat(const nsAString& aFormatStr, bool aForPageNumOnly);
--- a/layout/generic/nsSplittableFrame.h
+++ b/layout/generic/nsSplittableFrame.h
@@ -69,18 +69,19 @@ class nsSplittableFrame : public nsFrame
   nsIFrame* LastInFlow() const final;
 
   // Remove the frame from the flow. Connects the frame's prev-in-flow
   // and its next-in-flow. This should only be called in frame Destroy()
   // methods.
   static void RemoveFromFlow(nsIFrame* aFrame);
 
  protected:
-  nsSplittableFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsFrame(aStyle, aID),
+  nsSplittableFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                    ClassID aID)
+      : nsFrame(aStyle, aPresContext, aID),
         mPrevContinuation(nullptr),
         mNextContinuation(nullptr) {}
 
   /**
    * Return the sum of the block-axis content size of our prev-in-flows.
    * @param aWM a writing-mode to determine the block-axis
    *
    * @note (bz) This makes laying out a splittable frame with N in-flows
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -54,18 +54,19 @@ static bool sShowPreviousPage = true;
 static Document* GetDocumentFromView(nsView* aView) {
   MOZ_ASSERT(aView, "null view");
 
   nsViewManager* vm = aView->GetViewManager();
   nsIPresShell* ps = vm ? vm->GetPresShell() : nullptr;
   return ps ? ps->GetDocument() : nullptr;
 }
 
-nsSubDocumentFrame::nsSubDocumentFrame(ComputedStyle* aStyle)
-    : nsAtomicContainerFrame(aStyle, kClassID),
+nsSubDocumentFrame::nsSubDocumentFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsAtomicContainerFrame(aStyle, aPresContext, kClassID),
       mOuterView(nullptr),
       mInnerView(nullptr),
       mIsInline(false),
       mPostedReflowCallback(false),
       mDidCreateDoc(false),
       mCallingShow(false) {}
 
 #ifdef ACCESSIBILITY
@@ -871,17 +872,18 @@ nsresult nsSubDocumentFrame::AttributeCh
     if (frameloader) frameloader->MarginsChanged(margins.width, margins.height);
   }
 
   return NS_OK;
 }
 
 nsIFrame* NS_NewSubDocumentFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsSubDocumentFrame(aStyle);
+  return new (aPresShell)
+      nsSubDocumentFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSubDocumentFrame)
 
 class nsHideViewer : public Runnable {
  public:
   nsHideViewer(nsIContent* aFrameElement, nsFrameLoader* aFrameLoader,
                nsIPresShell* aPresShell, bool aHideViewerIfFrameless)
--- a/layout/generic/nsSubDocumentFrame.h
+++ b/layout/generic/nsSubDocumentFrame.h
@@ -22,17 +22,18 @@ class RenderFrame;
 /******************************************************************************
  * nsSubDocumentFrame
  *****************************************************************************/
 class nsSubDocumentFrame final : public nsAtomicContainerFrame,
                                  public nsIReflowCallback {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSubDocumentFrame)
 
-  explicit nsSubDocumentFrame(ComputedStyle* aStyle);
+  explicit nsSubDocumentFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
 
 #ifdef DEBUG_FRAME_DUMP
   void List(FILE* out = stderr, const char* aPrefix = "",
             uint32_t aFlags = 0) const override;
   nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   NS_DECL_QUERYFRAME
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -4403,18 +4403,19 @@ class nsContinuingTextFrame final : publ
   nsIFrame* FirstContinuation() const final;
 
   void AddInlineMinISize(gfxContext* aRenderingContext,
                          InlineMinISizeData* aData) final;
   void AddInlinePrefISize(gfxContext* aRenderingContext,
                           InlinePrefISizeData* aData) final;
 
  protected:
-  explicit nsContinuingTextFrame(ComputedStyle* aStyle)
-      : nsTextFrame(aStyle, kClassID) {}
+  explicit nsContinuingTextFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+      : nsTextFrame(aStyle, aPresContext, kClassID) {}
 
   nsTextFrame* mPrevContinuation;
 };
 
 void nsContinuingTextFrame::Init(nsIContent* aContent,
                                  nsContainerFrame* aParent,
                                  nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aPrevInFlow, "Must be a continuation!");
@@ -4568,24 +4569,25 @@ static void VerifyNotDirty(nsFrameState 
   if (!isZero && isDirty) NS_WARNING("internal offsets may be out-of-sync");
 }
 #  define DEBUG_VERIFY_NOT_DIRTY(state) VerifyNotDirty(state)
 #else
 #  define DEBUG_VERIFY_NOT_DIRTY(state)
 #endif
 
 nsIFrame* NS_NewTextFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsTextFrame(aStyle);
+  return new (aPresShell) nsTextFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTextFrame)
 
 nsIFrame* NS_NewContinuingTextFrame(nsIPresShell* aPresShell,
                                     ComputedStyle* aStyle) {
-  return new (aPresShell) nsContinuingTextFrame(aStyle);
+  return new (aPresShell)
+      nsContinuingTextFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsContinuingTextFrame)
 
 nsTextFrame::~nsTextFrame() {}
 
 nsresult nsTextFrame::GetCursor(const nsPoint& aPoint,
                                 nsIFrame::Cursor& aCursor) {
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -47,18 +47,19 @@ class nsTextFrame : public nsFrame {
   typedef mozilla::TextRangeStyle TextRangeStyle;
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Point Point;
   typedef mozilla::gfx::Rect Rect;
   typedef mozilla::gfx::Size Size;
   typedef gfxTextRun::Range Range;
 
  public:
-  explicit nsTextFrame(ComputedStyle* aStyle, ClassID aID = kClassID)
-      : nsFrame(aStyle, aID),
+  explicit nsTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                       ClassID aID = kClassID)
+      : nsFrame(aStyle, aPresContext, aID),
         mNextContinuation(nullptr),
         mContentOffset(0),
         mContentLengthHint(0),
         mAscent(0) {}
 
   NS_DECL_FRAMEARENA_HELPERS(nsTextFrame)
 
   friend class nsContinuingTextFrame;
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -31,17 +31,17 @@
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 nsIFrame* NS_NewHTMLVideoFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsVideoFrame(aStyle);
+  return new (aPresShell) nsVideoFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsVideoFrame)
 
 // A matrix to obtain a correct-rotated video frame.
 static Matrix ComputeRotationMatrix(gfxFloat aRotatedWidth,
                                     gfxFloat aRotatedHeight,
                                     VideoInfo::Rotation aDegrees) {
@@ -66,18 +66,18 @@ static void SwapScaleWidthHeightForRotat
   if (aDegrees == VideoInfo::Rotation::kDegree_90 ||
       aDegrees == VideoInfo::Rotation::kDegree_270) {
     int32_t tmpWidth = aSize.width;
     aSize.width = aSize.height;
     aSize.height = tmpWidth;
   }
 }
 
-nsVideoFrame::nsVideoFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {
+nsVideoFrame::nsVideoFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {
   EnableVisibilityTracking();
 }
 
 nsVideoFrame::~nsVideoFrame() {}
 
 NS_QUERYFRAME_HEAD(nsVideoFrame)
   NS_QUERYFRAME_ENTRY(nsVideoFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
--- a/layout/generic/nsVideoFrame.h
+++ b/layout/generic/nsVideoFrame.h
@@ -33,17 +33,17 @@ class nsVideoFrame final : public nsCont
   using Maybe = mozilla::Maybe<T>;
   using Nothing = mozilla::Nothing;
   using Visibility = mozilla::Visibility;
 
   typedef mozilla::layers::Layer Layer;
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
 
-  explicit nsVideoFrame(ComputedStyle* aStyle);
+  explicit nsVideoFrame(ComputedStyle*, nsPresContext*);
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsVideoFrame)
 
   void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                         const nsDisplayListSet& aLists) override;
 
   nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -1446,29 +1446,31 @@ nsresult nsMathMLContainerFrame::ReportI
                             mContent->NodeInfo()->NameAtom()->GetUTF16String()};
   return ReportErrorToConsole("InvalidChild", argv, 2);
 }
 
 //==========================
 
 nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell,
                                              ComputedStyle* aStyle) {
-  auto newFrame = new (aPresShell) nsMathMLmathBlockFrame(aStyle);
+  auto newFrame = new (aPresShell)
+      nsMathMLmathBlockFrame(aStyle, aPresShell->GetPresContext());
   newFrame->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
   return newFrame;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmathBlockFrame)
 
 NS_QUERYFRAME_HEAD(nsMathMLmathBlockFrame)
   NS_QUERYFRAME_ENTRY(nsMathMLmathBlockFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
 
 nsContainerFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmathInlineFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmathInlineFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmathInlineFrame)
 
 NS_QUERYFRAME_HEAD(nsMathMLmathInlineFrame)
   NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsInlineFrame)
--- a/layout/mathml/nsMathMLContainerFrame.h
+++ b/layout/mathml/nsMathMLContainerFrame.h
@@ -28,18 +28,19 @@
 #define STRETCH_CONSIDER_ACTUAL_SIZE 0x00000001  // just use our current size
 #define STRETCH_CONSIDER_EMBELLISHMENTS \
   0x00000002  // size calculations include embellishments
 
 class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame {
   friend class nsMathMLmfencedFrame;
 
  public:
-  nsMathMLContainerFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsContainerFrame(aStyle, aID),
+  nsMathMLContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                         ClassID aID)
+      : nsContainerFrame(aStyle, aPresContext, aID),
         mIntrinsicWidth(NS_INTRINSIC_WIDTH_UNKNOWN),
         mBlockStartAscent(0) {}
 
   NS_DECL_QUERYFRAME_TARGET(nsMathMLContainerFrame)
   NS_DECL_QUERYFRAME
   NS_DECL_ABSTRACT_FRAME(nsMathMLContainerFrame)
 
   // --------------------------------------------------------------------------
@@ -417,18 +418,19 @@ class nsMathMLmathBlockFrame final : pub
   }
 
   // See nsIMathMLFrame.h
   bool IsMrowLike() {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmathBlockFrame(ComputedStyle* aStyle)
-      : nsBlockFrame(aStyle, kClassID) {
+  explicit nsMathMLmathBlockFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext)
+      : nsBlockFrame(aStyle, aPresContext, kClassID) {
     // We should always have a float manager.  Not that things can really try
     // to float out of us anyway, but we need one for line layout.
     // Bug 1301881: Do we still need to set NS_BLOCK_FLOAT_MGR?
     // AddStateBits(NS_BLOCK_FLOAT_MGR);
   }
   virtual ~nsMathMLmathBlockFrame() {}
 };
 
@@ -482,15 +484,16 @@ class nsMathMLmathInlineFrame final : pu
         aFlags & ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
   }
 
   bool IsMrowLike() override {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmathInlineFrame(ComputedStyle* aStyle)
-      : nsInlineFrame(aStyle, kClassID) {}
+  explicit nsMathMLmathInlineFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext)
+      : nsInlineFrame(aStyle, aPresContext, kClassID) {}
 
   virtual ~nsMathMLmathInlineFrame() {}
 };
 
 #endif /* nsMathMLContainerFrame_h___ */
--- a/layout/mathml/nsMathMLSelectedFrame.h
+++ b/layout/mathml/nsMathMLSelectedFrame.h
@@ -33,18 +33,19 @@ class nsMathMLSelectedFrame : public nsM
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
   virtual nsQueryFrame::FrameIID GetFrameId() override = 0;
 
  protected:
-  nsMathMLSelectedFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsMathMLContainerFrame(aStyle, aID),
+  nsMathMLSelectedFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                        ClassID aID)
+      : nsMathMLContainerFrame(aStyle, aPresContext, aID),
         mSelectedFrame(nullptr),
         mInvalidMarkup(false) {}
   virtual ~nsMathMLSelectedFrame();
 
   virtual nsIFrame* GetSelectedFrame() = 0;
   nsIFrame* mSelectedFrame;
 
   bool mInvalidMarkup;
--- a/layout/mathml/nsMathMLTokenFrame.cpp
+++ b/layout/mathml/nsMathMLTokenFrame.cpp
@@ -9,17 +9,18 @@
 #include "nsContentUtils.h"
 #include "nsTextFrame.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 nsIFrame* NS_NewMathMLTokenFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLTokenFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLTokenFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLTokenFrame)
 
 nsMathMLTokenFrame::~nsMathMLTokenFrame() {}
 
 NS_IMETHODIMP
 nsMathMLTokenFrame::InheritAutomaticData(nsIFrame* aParent) {
--- a/layout/mathml/nsMathMLTokenFrame.h
+++ b/layout/mathml/nsMathMLTokenFrame.h
@@ -48,16 +48,18 @@ class nsMathMLTokenFrame : public nsMath
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
   virtual nsresult Place(DrawTarget* aDrawTarget, bool aPlaceOrigin,
                          ReflowOutput& aDesiredSize) override;
 
  protected:
-  explicit nsMathMLTokenFrame(ComputedStyle* aStyle, ClassID aID = kClassID)
-      : nsMathMLContainerFrame(aStyle, aID) {}
+  explicit nsMathMLTokenFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext,
+                              ClassID aID = kClassID)
+      : nsMathMLContainerFrame(aStyle, aPresContext, aID) {}
   virtual ~nsMathMLTokenFrame();
 
   void MarkTextFramesAsTokenMathML();
 };
 
 #endif /* nsMathMLTokentFrame_h___ */
--- a/layout/mathml/nsMathMLmactionFrame.cpp
+++ b/layout/mathml/nsMathMLmactionFrame.cpp
@@ -58,17 +58,18 @@ static int32_t GetActionType(nsIContent*
     return NS_MATHML_ACTION_TYPE_STATUSLINE;
   if (value.EqualsLiteral("tooltip")) return NS_MATHML_ACTION_TYPE_TOOLTIP;
 
   return NS_MATHML_ACTION_TYPE_UNKNOWN;
 }
 
 nsIFrame* NS_NewMathMLmactionFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmactionFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmactionFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmactionFrame)
 
 nsMathMLmactionFrame::~nsMathMLmactionFrame() {
   // unregister us as a mouse event listener ...
   //  printf("maction:%p unregistering as mouse event listener ...\n", this);
   if (mListener) {
--- a/layout/mathml/nsMathMLmactionFrame.h
+++ b/layout/mathml/nsMathMLmactionFrame.h
@@ -48,18 +48,19 @@ class nsMathMLmactionFrame final : publi
     NS_DECL_NSIDOMEVENTLISTENER
 
     explicit MouseListener(nsMathMLmactionFrame* aOwner) : mOwner(aOwner) {}
 
     nsMathMLmactionFrame* mOwner;
   };
 
  protected:
-  explicit nsMathMLmactionFrame(ComputedStyle* aStyle)
-      : nsMathMLSelectedFrame(aStyle, kClassID) {}
+  explicit nsMathMLmactionFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsMathMLSelectedFrame(aStyle, aPresContext, kClassID) {}
   virtual ~nsMathMLmactionFrame();
 
  private:
   int32_t mActionType;
   int32_t mChildCount;
   int32_t mSelection;
   RefPtr<MouseListener> mListener;
 
--- a/layout/mathml/nsMathMLmencloseFrame.cpp
+++ b/layout/mathml/nsMathMLmencloseFrame.cpp
@@ -36,23 +36,26 @@ static const char16_t kRadicalChar = 0x2
 // updiagonalstrike
 static const uint8_t kArrowHeadSize = 10;
 
 // phasorangle
 static const uint8_t kPhasorangleWidth = 8;
 
 nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell,
                                     ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmencloseFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmencloseFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmencloseFrame)
 
-nsMathMLmencloseFrame::nsMathMLmencloseFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsMathMLContainerFrame(aStyle, aID),
+nsMathMLmencloseFrame::nsMathMLmencloseFrame(ComputedStyle* aStyle,
+                                             nsPresContext* aPresContext,
+                                             ClassID aID)
+    : nsMathMLContainerFrame(aStyle, aPresContext, aID),
       mRuleThickness(0),
       mRadicalRuleThickness(0),
       mLongDivCharIndex(-1),
       mRadicalCharIndex(-1),
       mContentWidth(0) {}
 
 nsMathMLmencloseFrame::~nsMathMLmencloseFrame() {}
 
--- a/layout/mathml/nsMathMLmencloseFrame.h
+++ b/layout/mathml/nsMathMLmencloseFrame.h
@@ -74,17 +74,19 @@ class nsMathMLmencloseFrame : public nsM
 
   virtual nscoord FixInterFrameSpacing(ReflowOutput& aDesiredSize) override;
 
   bool IsMrowLike() override {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmencloseFrame(ComputedStyle* aStyle, ClassID aID = kClassID);
+  explicit nsMathMLmencloseFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext,
+                                 ClassID aID = kClassID);
   virtual ~nsMathMLmencloseFrame();
 
   nsresult PlaceInternal(DrawTarget* aDrawTarget, bool aPlaceOrigin,
                          ReflowOutput& aDesiredSize, bool aWidthOnly);
 
   // functions to parse the "notation" attribute.
   nsresult AddNotation(const nsAString& aNotation);
   void InitNotations();
--- a/layout/mathml/nsMathMLmfencedFrame.cpp
+++ b/layout/mathml/nsMathMLmfencedFrame.cpp
@@ -14,17 +14,18 @@ using namespace mozilla;
 using mozilla::gfx::DrawTarget;
 
 //
 // <mfenced> -- surround content with a pair of fences
 //
 
 nsIFrame* NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmfencedFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmfencedFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfencedFrame)
 
 void nsMathMLmfencedFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                        PostDestroyData& aPostDestroyData) {
   RemoveFencesAndSeparators();
   nsMathMLContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
--- a/layout/mathml/nsMathMLmfencedFrame.h
+++ b/layout/mathml/nsMathMLmfencedFrame.h
@@ -72,18 +72,19 @@ class nsMathMLmfencedFrame final : publi
     // <mfenced> <mo>%</mo> </mfenced>
     // renders equivalently to
     // <mrow> <mo> ( </mo> <mo>%</mo> <mo> ) </mo> </mrow>
     // This also holds with multiple children.  (MathML3 3.3.8.1)
     return true;
   }
 
  protected:
-  explicit nsMathMLmfencedFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID),
+  explicit nsMathMLmfencedFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mOpenChar(nullptr),
         mCloseChar(nullptr),
         mSeparatorsChar(nullptr),
         mSeparatorsCount(0) {}
 
   nsMathMLChar* mOpenChar;
   nsMathMLChar* mCloseChar;
   nsMathMLChar* mSeparatorsChar;
--- a/layout/mathml/nsMathMLmfracFrame.cpp
+++ b/layout/mathml/nsMathMLmfracFrame.cpp
@@ -30,17 +30,18 @@ using namespace mozilla::gfx;
 #define THIN_FRACTION_LINE 0.5f
 #define THIN_FRACTION_LINE_MINIMUM_PIXELS 1  // minimum of 1 pixel
 
 #define THICK_FRACTION_LINE 2.0f
 #define THICK_FRACTION_LINE_MINIMUM_PIXELS 2  // minimum of 2 pixels
 
 nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmfracFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmfracFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfracFrame)
 
 nsMathMLmfracFrame::~nsMathMLmfracFrame() {}
 
 eMathMLFrameType nsMathMLmfracFrame::GetMathMLFrameType() {
   // frac is "inner" in TeXBook, Appendix G, rule 15e. See also page 170.
--- a/layout/mathml/nsMathMLmfracFrame.h
+++ b/layout/mathml/nsMathMLmfracFrame.h
@@ -83,18 +83,19 @@ class nsMathMLmfracFrame final : public 
                                    nsString& aThicknessAttribute,
                                    nscoord onePixel,
                                    nscoord aDefaultRuleThickness,
                                    float aFontSizeInflation);
 
   uint8_t ScriptIncrement(nsIFrame* aFrame) override;
 
  protected:
-  explicit nsMathMLmfracFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID),
+  explicit nsMathMLmfracFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mLineRect(),
         mSlashChar(nullptr),
         mLineThickness(0),
         mIsBevelled(false) {}
   virtual ~nsMathMLmfracFrame();
 
   nsresult PlaceInternal(DrawTarget* aDrawTarget, bool aPlaceOrigin,
                          ReflowOutput& aDesiredSize, bool aWidthOnly);
--- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
+++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
@@ -16,17 +16,18 @@ using namespace mozilla;
 // <mmultiscripts> -- attach prescripts and tensor indices to a base -
 // implementation <msub> -- attach a subscript to a base - implementation
 // <msubsup> -- attach a subscript-superscript pair to a base - implementation
 // <msup> -- attach a superscript to a base - implementation
 //
 
 nsIFrame* NS_NewMathMLmmultiscriptsFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmmultiscriptsFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmmultiscriptsFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmmultiscriptsFrame)
 
 nsMathMLmmultiscriptsFrame::~nsMathMLmmultiscriptsFrame() {}
 
 uint8_t nsMathMLmmultiscriptsFrame::ScriptIncrement(nsIFrame* aFrame) {
   if (!aFrame) return 0;
--- a/layout/mathml/nsMathMLmmultiscriptsFrame.h
+++ b/layout/mathml/nsMathMLmmultiscriptsFrame.h
@@ -36,14 +36,15 @@ class nsMathMLmmultiscriptsFrame final :
                                    nsMathMLContainerFrame* aForFrame,
                                    nscoord aUserSubScriptShift,
                                    nscoord aUserSupScriptShift,
                                    float aFontSizeInflation);
 
   uint8_t ScriptIncrement(nsIFrame* aFrame) override;
 
  protected:
-  explicit nsMathMLmmultiscriptsFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID) {}
+  explicit nsMathMLmmultiscriptsFrame(ComputedStyle* aStyle,
+                                      nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID) {}
   virtual ~nsMathMLmmultiscriptsFrame();
 };
 
 #endif /* nsMathMLmmultiscriptsFrame_h___ */
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -17,17 +17,17 @@ using namespace mozilla;
 //
 // <mo> -- operator, fence, or separator - implementation
 //
 
 // additional ComputedStyle to be used by our MathMLChar.
 #define NS_MATHML_CHAR_STYLE_CONTEXT_INDEX 0
 
 nsIFrame* NS_NewMathMLmoFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmoFrame(aStyle);
+  return new (aPresShell) nsMathMLmoFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmoFrame)
 
 nsMathMLmoFrame::~nsMathMLmoFrame() {}
 
 static const char16_t kApplyFunction = char16_t(0x2061);
 static const char16_t kInvisibleTimes = char16_t(0x2062);
--- a/layout/mathml/nsMathMLmoFrame.h
+++ b/layout/mathml/nsMathMLmoFrame.h
@@ -64,18 +64,18 @@ class nsMathMLmoFrame final : public nsM
           ReflowOutput& aDesiredStretchSize) override;
 
   virtual nsresult ChildListChanged(int32_t aModType) override {
     ProcessTextData();
     return nsMathMLContainerFrame::ChildListChanged(aModType);
   }
 
  protected:
-  explicit nsMathMLmoFrame(ComputedStyle* aStyle)
-      : nsMathMLTokenFrame(aStyle, kClassID),
+  explicit nsMathMLmoFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsMathMLTokenFrame(aStyle, aPresContext, kClassID),
         mFlags(0),
         mMinSize(0),
         mMaxSize(0) {}
   virtual ~nsMathMLmoFrame();
 
   nsMathMLChar
       mMathMLChar;  // Here is the MathMLChar that will deal with the operator.
   nsOperatorFlags mFlags;
--- a/layout/mathml/nsMathMLmpaddedFrame.cpp
+++ b/layout/mathml/nsMathMLmpaddedFrame.cpp
@@ -25,17 +25,18 @@ using namespace mozilla;
 #define NS_MATHML_PSEUDO_UNIT_ITSELF 1  // special
 #define NS_MATHML_PSEUDO_UNIT_WIDTH 2
 #define NS_MATHML_PSEUDO_UNIT_HEIGHT 3
 #define NS_MATHML_PSEUDO_UNIT_DEPTH 4
 #define NS_MATHML_PSEUDO_UNIT_NAMEDSPACE 5
 
 nsIFrame* NS_NewMathMLmpaddedFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmpaddedFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmpaddedFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmpaddedFrame)
 
 nsMathMLmpaddedFrame::~nsMathMLmpaddedFrame() {}
 
 NS_IMETHODIMP
 nsMathMLmpaddedFrame::InheritAutomaticData(nsIFrame* aParent) {
--- a/layout/mathml/nsMathMLmpaddedFrame.h
+++ b/layout/mathml/nsMathMLmpaddedFrame.h
@@ -36,18 +36,19 @@ class nsMathMLmpaddedFrame final : publi
   virtual nsresult Place(DrawTarget* aDrawTarget, bool aPlaceOrigin,
                          ReflowOutput& aDesiredSize) override;
 
   bool IsMrowLike() override {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmpaddedFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID),
+  explicit nsMathMLmpaddedFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mWidthSign(0),
         mHeightSign(0),
         mDepthSign(0),
         mLeadingSpaceSign(0),
         mVerticalOffsetSign(0),
         mWidthPseudoUnit(0),
         mHeightPseudoUnit(0),
         mDepthPseudoUnit(0),
--- a/layout/mathml/nsMathMLmrootFrame.cpp
+++ b/layout/mathml/nsMathMLmrootFrame.cpp
@@ -18,23 +18,27 @@ using namespace mozilla;
 
 // additional ComputedStyle to be used by our MathMLChar.
 #define NS_SQR_CHAR_STYLE_CONTEXT_INDEX 0
 
 static const char16_t kSqrChar = char16_t(0x221A);
 
 nsIFrame* NS_NewMathMLmrootFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmrootFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmrootFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmrootFrame)
 
-nsMathMLmrootFrame::nsMathMLmrootFrame(ComputedStyle* aStyle)
-    : nsMathMLContainerFrame(aStyle, kClassID), mSqrChar(), mBarRect() {}
+nsMathMLmrootFrame::nsMathMLmrootFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
+      mSqrChar(),
+      mBarRect() {}
 
 nsMathMLmrootFrame::~nsMathMLmrootFrame() {}
 
 void nsMathMLmrootFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                               nsIFrame* aPrevInFlow) {
   nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
 
   nsPresContext* presContext = PresContext();
--- a/layout/mathml/nsMathMLmrootFrame.h
+++ b/layout/mathml/nsMathMLmrootFrame.h
@@ -47,16 +47,17 @@ class nsMathMLmrootFrame final : public 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
   uint8_t ScriptIncrement(nsIFrame* aFrame) override {
     return (aFrame && aFrame == mFrames.LastChild()) ? 2 : 0;
   }
 
  protected:
-  explicit nsMathMLmrootFrame(ComputedStyle* aStyle);
+  explicit nsMathMLmrootFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
   virtual ~nsMathMLmrootFrame();
 
   nsMathMLChar mSqrChar;
   nsRect mBarRect;
 };
 
 #endif /* nsMathMLmrootFrame_h___ */
--- a/layout/mathml/nsMathMLmrowFrame.cpp
+++ b/layout/mathml/nsMathMLmrowFrame.cpp
@@ -10,17 +10,18 @@
 using namespace mozilla;
 
 //
 // <mrow> -- horizontally group any number of subexpressions - implementation
 //
 
 nsIFrame* NS_NewMathMLmrowFrame(nsIPresShell* aPresShell,
                                 ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmrowFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmrowFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmrowFrame)
 
 nsMathMLmrowFrame::~nsMathMLmrowFrame() {}
 
 NS_IMETHODIMP
 nsMathMLmrowFrame::InheritAutomaticData(nsIFrame* aParent) {
--- a/layout/mathml/nsMathMLmrowFrame.h
+++ b/layout/mathml/nsMathMLmrowFrame.h
@@ -39,14 +39,14 @@ class nsMathMLmrowFrame final : public n
   bool IsMrowLike() override {
     // <mrow> elements with a single child are treated identically to the case
     // where the child wasn't within an mrow, so we pretend the mrow isn't an
     // mrow in that situation.
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmrowFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID) {}
+  explicit nsMathMLmrowFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID) {}
   virtual ~nsMathMLmrowFrame();
 };
 
 #endif /* nsMathMLmrowFrame_h___ */
--- a/layout/mathml/nsMathMLmspaceFrame.cpp
+++ b/layout/mathml/nsMathMLmspaceFrame.cpp
@@ -12,17 +12,18 @@
 using namespace mozilla;
 
 //
 // <mspace> -- space - implementation
 //
 
 nsIFrame* NS_NewMathMLmspaceFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmspaceFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmspaceFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmspaceFrame)
 
 nsMathMLmspaceFrame::~nsMathMLmspaceFrame() {}
 
 void nsMathMLmspaceFrame::ProcessAttributes(nsPresContext* aPresContext) {
   nsAutoString value;
--- a/layout/mathml/nsMathMLmspaceFrame.h
+++ b/layout/mathml/nsMathMLmspaceFrame.h
@@ -29,18 +29,19 @@ class nsMathMLmspaceFrame final : public
     return NS_OK;
   }
 
   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                       const ReflowInput& aReflowInput,
                       nsReflowStatus& aStatus) override;
 
  protected:
-  explicit nsMathMLmspaceFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID),
+  explicit nsMathMLmspaceFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mWidth(0),
         mHeight(0),
         mDepth(0) {}
   virtual ~nsMathMLmspaceFrame();
 
   virtual nsresult MeasureForWidth(DrawTarget* aDrawTarget,
                                    ReflowOutput& aDesiredSize) override;
 
--- a/layout/mathml/nsMathMLmsqrtFrame.cpp
+++ b/layout/mathml/nsMathMLmsqrtFrame.cpp
@@ -10,23 +10,25 @@
 //
 // <msqrt> -- form a radical - implementation
 //
 
 using namespace mozilla;
 
 nsIFrame* NS_NewMathMLmsqrtFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmsqrtFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmsqrtFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmsqrtFrame)
 
-nsMathMLmsqrtFrame::nsMathMLmsqrtFrame(ComputedStyle* aStyle)
-    : nsMathMLmencloseFrame(aStyle, kClassID) {}
+nsMathMLmsqrtFrame::nsMathMLmsqrtFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsMathMLmencloseFrame(aStyle, aPresContext, kClassID) {}
 
 nsMathMLmsqrtFrame::~nsMathMLmsqrtFrame() {}
 
 void nsMathMLmsqrtFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                               nsIFrame* aPrevInFlow) {
   nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
   AllocateMathMLChar(NOTATION_RADICAL);
   mNotationsToDraw += NOTATION_RADICAL;
--- a/layout/mathml/nsMathMLmsqrtFrame.h
+++ b/layout/mathml/nsMathMLmsqrtFrame.h
@@ -49,13 +49,14 @@ class nsMathMLmsqrtFrame final : public 
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
 
   virtual bool IsMrowLike() override {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmsqrtFrame(ComputedStyle* aStyle);
+  explicit nsMathMLmsqrtFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
   virtual ~nsMathMLmsqrtFrame();
 };
 
 #endif /* nsMathMLmsqrtFrame_h___ */
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -649,17 +649,18 @@ static void ListMathMLTree(nsIFrame* atL
 // implementation of nsMathMLmtableWrapperFrame
 
 NS_QUERYFRAME_HEAD(nsMathMLmtableWrapperFrame)
   NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsTableWrapperFrame)
 
 nsContainerFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmtableWrapperFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmtableWrapperFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableWrapperFrame)
 
 nsMathMLmtableWrapperFrame::~nsMathMLmtableWrapperFrame() {}
 
 nsresult nsMathMLmtableWrapperFrame::AttributeChanged(int32_t aNameSpaceID,
                                                       nsAtom* aAttribute,
@@ -873,17 +874,18 @@ void nsMathMLmtableWrapperFrame::Reflow(
   mBoundingMetrics.rightBearing = aDesiredSize.Width();
 
   aDesiredSize.mBoundingMetrics = mBoundingMetrics;
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
 }
 
 nsContainerFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell,
                                           ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmtableFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmtableFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
 
 nsMathMLmtableFrame::~nsMathMLmtableFrame() {}
 
 void nsMathMLmtableFrame::SetInitialChildList(ChildListID aListID,
                                               nsFrameList& aChildList) {
@@ -1026,17 +1028,18 @@ NS_QUERYFRAME_HEAD(nsMathMLmtableFrame)
   NS_QUERYFRAME_ENTRY(nsMathMLmtableFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsTableFrame)
 
 // --------
 // implementation of nsMathMLmtrFrame
 
 nsContainerFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmtrFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmtrFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
 
 nsMathMLmtrFrame::~nsMathMLmtrFrame() {}
 
 nsresult nsMathMLmtrFrame::AttributeChanged(int32_t aNameSpaceID,
                                             nsAtom* aAttribute,
@@ -1164,23 +1167,25 @@ nsMargin nsMathMLmtdFrame::GetBorderOver
 // implementation of nsMathMLmtdInnerFrame
 
 NS_QUERYFRAME_HEAD(nsMathMLmtdInnerFrame)
   NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
 
 nsContainerFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell,
                                             ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmtdInnerFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmtdInnerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
 
-nsMathMLmtdInnerFrame::nsMathMLmtdInnerFrame(ComputedStyle* aStyle)
-    : nsBlockFrame(aStyle, kClassID)
+nsMathMLmtdInnerFrame::nsMathMLmtdInnerFrame(ComputedStyle* aStyle,
+                                             nsPresContext* aPresContext)
+    : nsBlockFrame(aStyle, aPresContext, kClassID)
       // Make a copy of the parent nsStyleText for later modification.
       ,
       mUniqueStyleText(MakeUnique<nsStyleText>(*StyleText())) {}
 
 void nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
                                    ReflowOutput& aDesiredSize,
                                    const ReflowInput& aReflowInput,
                                    nsReflowStatus& aStatus) {
--- a/layout/mathml/nsMathMLmtableFrame.h
+++ b/layout/mathml/nsMathMLmtableFrame.h
@@ -37,18 +37,19 @@ class nsMathMLmtableWrapperFrame final :
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override {
     return nsTableWrapperFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
   }
 
  protected:
-  explicit nsMathMLmtableWrapperFrame(ComputedStyle* aStyle)
-      : nsTableWrapperFrame(aStyle, kClassID) {}
+  explicit nsMathMLmtableWrapperFrame(ComputedStyle* aStyle,
+                                      nsPresContext* aPresContext)
+      : nsTableWrapperFrame(aStyle, aPresContext, kClassID) {}
 
   virtual ~nsMathMLmtableWrapperFrame();
 
   // helper to find the row frame at a given index, positive or negative, e.g.,
   // 1..n means the first row down to the last row, -1..-n means the last row
   // up to the first row. Used for alignments that are relative to a given row
   nsIFrame* GetRowFrameAt(int32_t aRowIndex);
 };  // class nsMathMLmtableWrapperFrame
@@ -127,18 +128,19 @@ class nsMathMLmtableFrame final : public
    * spacing based on padding and border-spacing, or one based upon the
    * rowspacing, columnspacing and framespacing attributes.  The second
    * approach is used if the user specifies at least one of those attributes.
    */
   void SetUseCSSSpacing();
   bool GetUseCSSSpacing() { return mUseCSSSpacing; }
 
  protected:
-  explicit nsMathMLmtableFrame(ComputedStyle* aStyle)
-      : nsTableFrame(aStyle, kClassID),
+  explicit nsMathMLmtableFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+      : nsTableFrame(aStyle, aPresContext, kClassID),
         mFrameSpacingX(0),
         mFrameSpacingY(0),
         mUseCSSSpacing(false) {}
 
   virtual ~nsMathMLmtableFrame();
 
  private:
   nsTArray<nscoord> mColSpacing;
@@ -188,18 +190,18 @@ class nsMathMLmtrFrame final : public ns
     nsTableFrame* tableFrame = GetTableFrame();
     if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
       // relayout the table
       ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
     }
   }
 
  protected:
-  explicit nsMathMLmtrFrame(ComputedStyle* aStyle)
-      : nsTableRowFrame(aStyle, kClassID) {}
+  explicit nsMathMLmtrFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsTableRowFrame(aStyle, aPresContext, kClassID) {}
 
   virtual ~nsMathMLmtrFrame();
 };  // class nsMathMLmtrFrame
 
 // --------------
 
 class nsMathMLmtdFrame final : public nsTableCellFrame {
  public:
@@ -270,16 +272,17 @@ class nsMathMLmtdInnerFrame final : publ
   virtual const nsStyleText* StyleTextForLineLayout() override;
   virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
 
   bool IsMrowLike() override {
     return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
   }
 
  protected:
-  explicit nsMathMLmtdInnerFrame(ComputedStyle* aStyle);
+  explicit nsMathMLmtdInnerFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext);
   virtual ~nsMathMLmtdInnerFrame() {}
 
   mozilla::UniquePtr<nsStyleText> mUniqueStyleText;
 
 };  // class nsMathMLmtdInnerFrame
 
 #endif /* nsMathMLmtableFrame_h___ */
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp
+++ b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -18,17 +18,18 @@ using namespace mozilla;
 // <munderover> -- attach an underscript-overscript pair to a base
 //                 implementation
 // <mover> -- attach an overscript to a base - implementation
 // <munder> -- attach an underscript to a base - implementation
 //
 
 nsIFrame* NS_NewMathMLmunderoverFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLmunderoverFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLmunderoverFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmunderoverFrame)
 
 nsMathMLmunderoverFrame::~nsMathMLmunderoverFrame() {}
 
 nsresult nsMathMLmunderoverFrame::AttributeChanged(int32_t aNameSpaceID,
                                                    nsAtom* aAttribute,
--- a/layout/mathml/nsMathMLmunderoverFrame.h
+++ b/layout/mathml/nsMathMLmunderoverFrame.h
@@ -40,18 +40,19 @@ class nsMathMLmunderoverFrame final : pu
 
   uint8_t ScriptIncrement(nsIFrame* aFrame) override;
 
   // nsIReflowCallback.
   bool ReflowFinished() override;
   void ReflowCallbackCanceled() override;
 
  protected:
-  explicit nsMathMLmunderoverFrame(ComputedStyle* aStyle)
-      : nsMathMLContainerFrame(aStyle, kClassID),
+  explicit nsMathMLmunderoverFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext)
+      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mIncrementUnder(false),
         mIncrementOver(false) {}
 
   virtual ~nsMathMLmunderoverFrame();
 
  private:
   // Helper to set the "increment script level" flag on the element belonging
   // to a child frame given by aChildIndex.
--- a/layout/mathml/nsMathMLsemanticsFrame.cpp
+++ b/layout/mathml/nsMathMLsemanticsFrame.cpp
@@ -11,17 +11,18 @@
 using namespace mozilla;
 
 //
 // <semantics> -- associate annotations with a MathML expression
 //
 
 nsIFrame* NS_NewMathMLsemanticsFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsMathMLsemanticsFrame(aStyle);
+  return new (aPresShell)
+      nsMathMLsemanticsFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMathMLsemanticsFrame)
 
 nsMathMLsemanticsFrame::~nsMathMLsemanticsFrame() {}
 
 nsIFrame* nsMathMLsemanticsFrame::GetSelectedFrame() {
   // By default, we will display the first child of the <semantics> element.
--- a/layout/mathml/nsMathMLsemanticsFrame.h
+++ b/layout/mathml/nsMathMLsemanticsFrame.h
@@ -17,16 +17,17 @@
 class nsMathMLsemanticsFrame final : public nsMathMLSelectedFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsMathMLsemanticsFrame)
 
   friend nsIFrame* NS_NewMathMLsemanticsFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle);
 
  protected:
-  explicit nsMathMLsemanticsFrame(ComputedStyle* aStyle)
-      : nsMathMLSelectedFrame(aStyle, kClassID) {}
+  explicit nsMathMLsemanticsFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext)
+      : nsMathMLSelectedFrame(aStyle, aPresContext, kClassID) {}
   virtual ~nsMathMLsemanticsFrame();
 
   nsIFrame* GetSelectedFrame() override;
 };
 
 #endif /* nsMathMLsemanticsFrame_h___ */
--- a/layout/style/ComputedStyle.cpp
+++ b/layout/style/ComputedStyle.cpp
@@ -22,17 +22,16 @@
 
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 
 #include "GeckoProfiler.h"
 #include "mozilla/dom/Document.h"
 #include "nsPrintfCString.h"
 #include "RubyUtils.h"
-#include "mozilla/ArenaObjectID.h"
 #include "mozilla/ComputedStyleInlines.h"
 #include "mozilla/Preferences.h"
 
 #include "mozilla/ReflowInput.h"
 #include "nsLayoutUtils.h"
 #include "nsCoord.h"
 
 // Ensure the binding function declarations in ComputedStyle.h matches
@@ -41,18 +40,17 @@
 
 namespace mozilla {
 
 //----------------------------------------------------------------------
 
 ComputedStyle::ComputedStyle(nsPresContext* aPresContext, nsAtom* aPseudoTag,
                              CSSPseudoElementType aPseudoType,
                              ServoComputedDataForgotten aComputedValues)
-    : mPresContext(aPresContext),
-      mSource(aComputedValues),
+    : mSource(aComputedValues),
       mPseudoTag(aPseudoTag),
       mBits(static_cast<Bit>(Servo_ComputedValues_GetStyleBits(this))),
       mPseudoType(aPseudoType) {}
 
 nsChangeHint ComputedStyle::CalcStyleDifference(const ComputedStyle& aNewStyle,
                                                 uint32_t* aEqualStructs) const {
   AUTO_PROFILER_LABEL("ComputedStyle::CalcStyleDifference", LAYOUT);
   static_assert(StyleStructConstants::kStyleStructCount <= 32,
@@ -267,18 +265,16 @@ void ComputedStyle::List(FILE* out, int3
     AppendUTF16toUTF8(buffer, str);
     str.Append(' ');
   }
 
   fprintf_stderr(out, "%s{ServoComputedData}\n", str.get());
 }
 #endif
 
-nsIPresShell* ComputedStyle::Arena() { return mPresContext->PresShell(); }
-
 template <typename Func>
 static nscolor GetVisitedDependentColorInternal(ComputedStyle* aSc,
                                                 Func aColorFunc) {
   nscolor colors[2];
   colors[0] = aColorFunc(aSc);
   if (ComputedStyle* visitedStyle = aSc->GetStyleIfVisited()) {
     colors[1] = aColorFunc(visitedStyle);
     return ComputedStyle::CombineVisitedColors(colors,
--- a/layout/style/ComputedStyle.h
+++ b/layout/style/ComputedStyle.h
@@ -6,17 +6,16 @@
 
 /* the interface (to internal code) for retrieving computed style data */
 
 #ifndef _ComputedStyle_h_
 #define _ComputedStyle_h_
 
 #include "nsIMemoryReporter.h"
 #include <algorithm>
-#include "mozilla/ArenaObjectID.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/CachedInheritingStyles.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/ServoComputedData.h"
 #include "mozilla/ServoTypes.h"
 #include "mozilla/ServoUtils.h"
 #include "mozilla/StyleComplexColor.h"
 #include "nsCSSAnonBoxes.h"
@@ -79,28 +78,16 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Co
 class ComputedStyle {
   using Bit = ComputedStyleBit;
 
  public:
   ComputedStyle(nsPresContext* aPresContext, nsAtom* aPseudoTag,
                 CSSPseudoElementType aPseudoType,
                 ServoComputedDataForgotten aComputedValues);
 
-  // FIXME(emilio, bug 548397): This will need to go away. Don't add new callers
-  // of this methed.
-  nsPresContext* PresContextForFrame() const { return mPresContext; }
-
-  // These two methods are for use by ArenaRefPtr.
-  //
-  // FIXME(emilio): Think this can go away.
-  static mozilla::ArenaObjectID ArenaObjectID() {
-    return mozilla::eArenaObjectID_GeckoComputedStyle;
-  }
-  nsIPresShell* Arena();
-
   void AddRef() { Servo_ComputedStyle_AddRef(this); }
   void Release() { Servo_ComputedStyle_Release(this); }
 
   // Return the ComputedStyle whose style data should be used for the R,
   // G, and B components of color, background-color, and border-*-color
   // if RelevantLinkIsVisited().
   //
   // GetPseudo() and GetPseudoType() on this ComputedStyle return the
@@ -293,18 +280,16 @@ class ComputedStyle {
  protected:
 
   // Needs to be friend so that it can call the destructor without making it
   // public.
   friend void ::Gecko_ComputedStyle_Destroy(ComputedStyle*);
 
   ~ComputedStyle() = default;
 
-  nsPresContext* const mPresContext;
-
   ServoComputedData mSource;
 
   // A cache of anonymous box and lazy pseudo styles inheriting from this style.
   CachedInheritingStyles mCachedInheritingStyles;
 
   // If this ComputedStyle is for a pseudo-element or anonymous box,
   // the relevant atom.
   const RefPtr<nsAtom> mPseudoTag;
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1242,20 +1242,16 @@ already_AddRefed<ComputedStyle> ServoSty
                                                         aPseudoType)) {
     computedValues =
         Servo_ResolveStyleLazily(elementForStyleResolution,
                                  pseudoTypeForStyleResolution, aRuleInclusion,
                                  &Snapshots(), mRawSet.get())
             .Consume();
   }
 
-  MOZ_DIAGNOSTIC_ASSERT(computedValues->PresContextForFrame() ==
-                            GetPresContext() ||
-                        aElement->OwnerDoc()->GetBFCacheEntry());
-
   return computedValues.forget();
 }
 
 bool ServoStyleSet::AppendFontFaceRules(
     nsTArray<nsFontFaceRuleContainer>& aArray) {
   // TODO(emilio): Can we make this so this asserts instead?
   UpdateStylistIfNeeded();
   Servo_StyleSet_GetFontFaceRules(mRawSet.get(), &aArray);
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -4,18 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* DOM object returned from element.getComputedStyle() */
 
 #ifndef nsComputedDOMStyle_h__
 #define nsComputedDOMStyle_h__
 
-#include "mozilla/ArenaRefPtr.h"
-#include "mozilla/ArenaRefPtrInlines.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/StyleComplexColor.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/dom/Element.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nscore.h"
 #include "nsDOMCSSDeclaration.h"
@@ -496,21 +494,18 @@ class nsComputedDOMStyle final : public 
    *
    * If we got the ComputedStyle from the frame, we clear out mComputedStyle
    * in ClearCurrentStyleSources.  If we resolved one ourselves, then
    * ClearCurrentStyleSources leaves it in mComputedStyle for use the next
    * time this nsComputedDOMStyle object is queried.  UpdateCurrentStyleSources
    * in this case will check that the ComputedStyle is still valid to be used,
    * by checking whether flush styles results in any restyles having been
    * processed.
-   *
-   * Since an ArenaRefPtr is used to hold the ComputedStyle, it will be cleared
-   * if the pres arena from which it was allocated goes away.
    */
-  mozilla::ArenaRefPtr<mozilla::ComputedStyle> mComputedStyle;
+  RefPtr<mozilla::ComputedStyle> mComputedStyle;
   RefPtr<nsAtom> mPseudo;
 
   /*
    * While computing style data, the primary frame for mContent --- named
    * "outer" because we should use it to compute positioning data.  Null
    * otherwise.
    */
   nsIFrame* mOuterFrame;
--- a/layout/svg/SVGFEContainerFrame.cpp
+++ b/layout/svg/SVGFEContainerFrame.cpp
@@ -18,18 +18,19 @@ using namespace mozilla;
  * This frame is used by filter primitive elements that
  * have special child elements that provide parameters.
  */
 class SVGFEContainerFrame final : public nsContainerFrame {
   friend nsIFrame* NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell,
                                              ComputedStyle* aStyle);
 
  protected:
-  explicit SVGFEContainerFrame(ComputedStyle* aStyle)
-      : nsContainerFrame(aStyle, kClassID) {
+  explicit SVGFEContainerFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+      : nsContainerFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override {
     if (aFlags & eSupportsContainLayoutAndPaint) {
@@ -57,17 +58,18 @@ class SVGFEContainerFrame final : public
   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     // We don't maintain a visual overflow rect
     return false;
   }
 };
 
 nsIFrame* NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell,
                                     ComputedStyle* aStyle) {
-  return new (aPresShell) SVGFEContainerFrame(aStyle);
+  return new (aPresShell)
+      SVGFEContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
 
 #ifdef DEBUG
 void SVGFEContainerFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                                nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER),
--- a/layout/svg/SVGFEImageFrame.cpp
+++ b/layout/svg/SVGFEImageFrame.cpp
@@ -17,17 +17,18 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class SVGFEImageFrame final : public nsFrame {
   friend nsIFrame* NS_NewSVGFEImageFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle);
 
  protected:
-  explicit SVGFEImageFrame(ComputedStyle* aStyle) : nsFrame(aStyle, kClassID) {
+  explicit SVGFEImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
 
     // This frame isn't actually displayed, but it contains an image and we want
     // to use the nsImageLoadingContent machinery for managing images, which
     // requires visibility tracking, so we enable visibility tracking and
     // forcibly mark it visible below.
     EnableVisibilityTracking();
   }
@@ -64,17 +65,17 @@ class SVGFEImageFrame final : public nsF
   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     // We don't maintain a visual overflow rect
     return false;
   }
 };
 
 nsIFrame* NS_NewSVGFEImageFrame(nsIPresShell* aPresShell,
                                 ComputedStyle* aStyle) {
-  return new (aPresShell) SVGFEImageFrame(aStyle);
+  return new (aPresShell) SVGFEImageFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGFEImageFrame)
 
 /* virtual */ void SVGFEImageFrame::DestroyFrom(
     nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) {
   DecApproximateVisibleCount();
 
--- a/layout/svg/SVGFELeafFrame.cpp
+++ b/layout/svg/SVGFELeafFrame.cpp
@@ -18,17 +18,18 @@ using namespace mozilla;
  * This frame is used by filter primitive elements that don't
  * have special child elements that provide parameters.
  */
 class SVGFELeafFrame final : public nsFrame {
   friend nsIFrame* NS_NewSVGFELeafFrame(nsIPresShell* aPresShell,
                                         ComputedStyle* aStyle);
 
  protected:
-  explicit SVGFELeafFrame(ComputedStyle* aStyle) : nsFrame(aStyle, kClassID) {
+  explicit SVGFELeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(SVGFELeafFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
@@ -55,17 +56,17 @@ class SVGFELeafFrame final : public nsFr
   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     // We don't maintain a visual overflow rect
     return false;
   }
 };
 
 nsIFrame* NS_NewSVGFELeafFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) SVGFELeafFrame(aStyle);
+  return new (aPresShell) SVGFELeafFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
 
 #ifdef DEBUG
 void SVGFELeafFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                           nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aContent->IsNodeOfType(nsINode::eFILTER),
--- a/layout/svg/SVGFEUnstyledLeafFrame.cpp
+++ b/layout/svg/SVGFEUnstyledLeafFrame.cpp
@@ -13,18 +13,19 @@
 
 using namespace mozilla;
 
 class SVGFEUnstyledLeafFrame final : public nsFrame {
   friend nsIFrame* NS_NewSVGFEUnstyledLeafFrame(nsIPresShell* aPresShell,
                                                 ComputedStyle* aStyle);
 
  protected:
-  explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle)
-      : nsFrame(aStyle, kClassID) {
+  explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override {}
@@ -49,17 +50,18 @@ class SVGFEUnstyledLeafFrame final : pub
   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     // We don't maintain a visual overflow rect
     return false;
   }
 };
 
 nsIFrame* NS_NewSVGFEUnstyledLeafFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) SVGFEUnstyledLeafFrame(aStyle);
+  return new (aPresShell)
+      SVGFEUnstyledLeafFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)
 
 nsresult SVGFEUnstyledLeafFrame::AttributeChanged(int32_t aNameSpaceID,
                                                   nsAtom* aAttribute,
                                                   int32_t aModType) {
   SVGFEUnstyledElement* element =
--- a/layout/svg/SVGGeometryFrame.cpp
+++ b/layout/svg/SVGGeometryFrame.cpp
@@ -34,17 +34,18 @@ using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGGeometryFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) SVGGeometryFrame(aStyle);
+  return new (aPresShell)
+      SVGGeometryFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGGeometryFrame)
 
 //----------------------------------------------------------------------
 // nsQueryFrame methods
 
 NS_QUERYFRAME_HEAD(SVGGeometryFrame)
--- a/layout/svg/SVGGeometryFrame.h
+++ b/layout/svg/SVGGeometryFrame.h
@@ -42,24 +42,22 @@ class SVGGeometryFrame : public nsFrame,
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
   friend nsIFrame* ::NS_NewSVGGeometryFrame(nsIPresShell* aPresShell,
                                             ComputedStyle* aStyle);
 
   friend class ::nsDisplaySVGGeometry;
 
  protected:
-  SVGGeometryFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID)
-      : nsFrame(aStyle, aID) {
+  SVGGeometryFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                   nsIFrame::ClassID aID = kClassID)
+      : nsFrame(aStyle, aPresContext, aID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED);
   }
 
-  explicit SVGGeometryFrame(ComputedStyle* aStyle)
-      : SVGGeometryFrame(aStyle, kClassID) {}
-
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(SVGGeometryFrame)
 
   // nsIFrame interface:
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -2906,17 +2906,17 @@ void nsDisplaySVGText::Paint(nsDisplayLi
 NS_QUERYFRAME_HEAD(SVGTextFrame)
   NS_QUERYFRAME_ENTRY(SVGTextFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsSVGDisplayContainerFrame)
 
 // ---------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGTextFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) SVGTextFrame(aStyle);
+  return new (aPresShell) SVGTextFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGTextFrame)
 
 // ---------------------------------------------------------------------
 // nsIFrame methods
 
 void SVGTextFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/svg/SVGTextFrame.h
+++ b/layout/svg/SVGTextFrame.h
@@ -171,18 +171,18 @@ class SVGTextFrame final : public nsSVGD
   friend class nsDisplaySVGText;
 
   typedef gfxTextRun::Range Range;
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::Point Point;
 
  protected:
-  explicit SVGTextFrame(ComputedStyle* aStyle)
-      : nsSVGDisplayContainerFrame(aStyle, kClassID),
+  explicit SVGTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID),
         mTrailingUndisplayedCharacters(0),
         mFontSizeScaleFactor(1.0f),
         mLastContextScale(1.0f),
         mLengthAdjustScaleFactor(1.0f) {
     AddStateBits(NS_STATE_SVG_TEXT_CORRESPONDENCE_DIRTY |
                  NS_STATE_SVG_POSITIONING_DIRTY);
   }
 
--- a/layout/svg/SVGViewFrame.cpp
+++ b/layout/svg/SVGViewFrame.cpp
@@ -20,17 +20,18 @@ using namespace mozilla::dom;
  * identifier. The SVGViewFrame class passes on any attribute changes
  * the view receives to the overridden <svg> element (if there is one).
  **/
 class SVGViewFrame final : public nsFrame {
   friend nsIFrame* NS_NewSVGViewFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle);
 
  protected:
-  explicit SVGViewFrame(ComputedStyle* aStyle) : nsFrame(aStyle, kClassID) {
+  explicit SVGViewFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(SVGViewFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
@@ -56,17 +57,17 @@ class SVGViewFrame final : public nsFram
 
   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     // We don't maintain a visual overflow rect
     return false;
   }
 };
 
 nsIFrame* NS_NewSVGViewFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) SVGViewFrame(aStyle);
+  return new (aPresShell) SVGViewFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(SVGViewFrame)
 
 #ifdef DEBUG
 void SVGViewFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                         nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::view),
--- a/layout/svg/nsSVGAFrame.cpp
+++ b/layout/svg/nsSVGAFrame.cpp
@@ -16,18 +16,18 @@
 
 using namespace mozilla;
 
 class nsSVGAFrame final : public nsSVGDisplayContainerFrame {
   friend nsIFrame* NS_NewSVGAFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGAFrame(ComputedStyle* aStyle)
-      : nsSVGDisplayContainerFrame(aStyle, kClassID) {}
+  explicit nsSVGAFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGAFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 #endif
@@ -42,17 +42,17 @@ class nsSVGAFrame final : public nsSVGDi
   }
 #endif
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGAFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGAFrame(aStyle);
+  return new (aPresShell) nsSVGAFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods
 #ifdef DEBUG
 void nsSVGAFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/svg/nsSVGClipPathFrame.cpp
+++ b/layout/svg/nsSVGClipPathFrame.cpp
@@ -23,17 +23,18 @@ using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGClipPathFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGClipPathFrame(aStyle);
+  return new (aPresShell)
+      nsSVGClipPathFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGClipPathFrame)
 
 void nsSVGClipPathFrame::ApplyClipPath(gfxContext& aContext,
                                        nsIFrame* aClippedFrame,
                                        const gfxMatrix& aMatrix) {
   MOZ_ASSERT(IsTrivial(), "Caller needs to use GetClipMask");
--- a/layout/svg/nsSVGClipPathFrame.h
+++ b/layout/svg/nsSVGClipPathFrame.h
@@ -19,18 +19,20 @@ class nsSVGClipPathFrame final : public 
   friend nsIFrame* NS_NewSVGClipPathFrame(nsIPresShell* aPresShell,
                                           ComputedStyle* aStyle);
 
   typedef mozilla::gfx::Matrix Matrix;
   typedef mozilla::gfx::SourceSurface SourceSurface;
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
 
  protected:
-  explicit nsSVGClipPathFrame(ComputedStyle* aStyle)
-      : nsSVGContainerFrame(aStyle, kClassID), mIsBeingProcessed(false) {
+  explicit nsSVGClipPathFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : nsSVGContainerFrame(aStyle, aPresContext, kClassID),
+        mIsBeingProcessed(false) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGClipPathFrame)
 
   // nsIFrame methods:
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
--- a/layout/svg/nsSVGContainerFrame.cpp
+++ b/layout/svg/nsSVGContainerFrame.cpp
@@ -26,18 +26,18 @@ NS_QUERYFRAME_TAIL_INHERITING(nsContaine
 
 NS_QUERYFRAME_HEAD(nsSVGDisplayContainerFrame)
   NS_QUERYFRAME_ENTRY(nsSVGDisplayContainerFrame)
   NS_QUERYFRAME_ENTRY(nsSVGDisplayableFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrame)
 
 nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
-  nsIFrame* frame = new (aPresShell)
-      nsSVGContainerFrame(aStyle, nsSVGContainerFrame::kClassID);
+  nsIFrame* frame = new (aPresShell) nsSVGContainerFrame(
+      aStyle, aPresShell->GetPresContext(), nsSVGContainerFrame::kClassID);
   // If we were called directly, then the frame is for a <defs> or
   // an unknown element type. In both cases we prevent the content
   // from displaying directly.
   frame->AddStateBits(NS_FRAME_IS_NONDISPLAY);
   return frame;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGContainerFrame)
--- a/layout/svg/nsSVGContainerFrame.h
+++ b/layout/svg/nsSVGContainerFrame.h
@@ -35,18 +35,19 @@ struct nsRect;
  * Do *not* blindly cast to SVG element types in this class's methods (see the
  * warning comment for nsSVGDisplayContainerFrame below).
  */
 class nsSVGContainerFrame : public nsContainerFrame {
   friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle);
 
  protected:
-  nsSVGContainerFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsContainerFrame(aStyle, aID) {
+  nsSVGContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                      ClassID aID)
+      : nsContainerFrame(aStyle, aPresContext, aID) {
     AddStateBits(NS_FRAME_SVG_LAYOUT);
   }
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsSVGContainerFrame)
 
   // Returns the transform to our gfxContext (to device pixels, not CSS px)
@@ -101,18 +102,19 @@ class nsSVGContainerFrame : public nsCon
  * This class's methods can *not* assume that mContent points to an instance of
  * an SVG element class since this class is inherited by
  * nsSVGGenericContainerFrame which is used for unrecognized elements in the
  * SVG namespace. Do *not* blindly cast to SVG element types.
  */
 class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,
                                    public nsSVGDisplayableFrame {
  protected:
-  nsSVGDisplayContainerFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID)
-      : nsSVGContainerFrame(aStyle, aID) {
+  nsSVGDisplayContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                             nsIFrame::ClassID aID)
+      : nsSVGContainerFrame(aStyle, aPresContext, aID) {
     AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
   }
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
   NS_DECL_ABSTRACT_FRAME(nsSVGDisplayContainerFrame)
 
--- a/layout/svg/nsSVGFilterFrame.cpp
+++ b/layout/svg/nsSVGFilterFrame.cpp
@@ -19,17 +19,18 @@
 #include "nsSVGUtils.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewSVGFilterFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGFilterFrame(aStyle);
+  return new (aPresShell)
+      nsSVGFilterFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGFilterFrame)
 
 uint16_t nsSVGFilterFrame::GetEnumValue(uint32_t aIndex, nsIContent* aDefault) {
   SVGEnum& thisEnum =
       static_cast<SVGFilterElement*>(GetContent())->mEnumAttributes[aIndex];
 
--- a/layout/svg/nsSVGFilterFrame.h
+++ b/layout/svg/nsSVGFilterFrame.h
@@ -27,18 +27,18 @@ class SVGFilterElement;
 }  // namespace dom
 }  // namespace mozilla
 
 class nsSVGFilterFrame final : public nsSVGContainerFrame {
   friend nsIFrame* NS_NewSVGFilterFrame(nsIPresShell* aPresShell,
                                         ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGFilterFrame(ComputedStyle* aStyle)
-      : nsSVGContainerFrame(aStyle, kClassID),
+  explicit nsSVGFilterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGContainerFrame(aStyle, aPresContext, kClassID),
         mLoopFlag(false),
         mNoHRefURI(false) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGFilterFrame)
 
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -27,23 +27,25 @@ using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsContainerFrame* NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGForeignObjectFrame(aStyle);
+  return new (aPresShell)
+      nsSVGForeignObjectFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGForeignObjectFrame)
 
-nsSVGForeignObjectFrame::nsSVGForeignObjectFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mInReflow(false) {
+nsSVGForeignObjectFrame::nsSVGForeignObjectFrame(ComputedStyle* aStyle,
+                                                 nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID), mInReflow(false) {
   AddStateBits(NS_FRAME_REFLOW_ROOT | NS_FRAME_MAY_BE_TRANSFORMED |
                NS_FRAME_SVG_LAYOUT);
 }
 
 //----------------------------------------------------------------------
 // nsIFrame methods
 
 NS_QUERYFRAME_HEAD(nsSVGForeignObjectFrame)
--- a/layout/svg/nsSVGForeignObjectFrame.h
+++ b/layout/svg/nsSVGForeignObjectFrame.h
@@ -18,17 +18,18 @@
 class gfxContext;
 
 class nsSVGForeignObjectFrame final : public nsContainerFrame,
                                       public nsSVGDisplayableFrame {
   friend nsContainerFrame* NS_NewSVGForeignObjectFrame(nsIPresShell* aPresShell,
                                                        ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGForeignObjectFrame(ComputedStyle* aStyle);
+  explicit nsSVGForeignObjectFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext);
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsSVGForeignObjectFrame)
 
   // nsIFrame:
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
--- a/layout/svg/nsSVGGFrame.cpp
+++ b/layout/svg/nsSVGGFrame.cpp
@@ -17,17 +17,17 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGGFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGGFrame(aStyle);
+  return new (aPresShell) nsSVGGFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame)
 
 #ifdef DEBUG
 void nsSVGGFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                        nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aContent->IsSVGElement() &&
--- a/layout/svg/nsSVGGFrame.h
+++ b/layout/svg/nsSVGGFrame.h
@@ -10,21 +10,23 @@
 #include "mozilla/Attributes.h"
 #include "gfxMatrix.h"
 #include "nsAutoPtr.h"
 #include "nsSVGContainerFrame.h"
 
 class nsSVGGFrame : public nsSVGDisplayContainerFrame {
   friend nsIFrame* NS_NewSVGGFrame(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle);
-  explicit nsSVGGFrame(ComputedStyle* aStyle) : nsSVGGFrame(aStyle, kClassID) {}
+  explicit nsSVGGFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGGFrame(aStyle, aPresContext, kClassID) {}
 
  protected:
-  nsSVGGFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID)
-      : nsSVGDisplayContainerFrame(aStyle, aID) {}
+  nsSVGGFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+              nsIFrame::ClassID aID)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, aID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGGFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 #endif
--- a/layout/svg/nsSVGGenericContainerFrame.cpp
+++ b/layout/svg/nsSVGGenericContainerFrame.cpp
@@ -10,17 +10,18 @@
 
 using namespace mozilla;
 
 //----------------------------------------------------------------------
 // nsSVGGenericContainerFrame Implementation
 
 nsIFrame* NS_NewSVGGenericContainerFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGGenericContainerFrame(aStyle);
+  return new (aPresShell)
+      nsSVGGenericContainerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGGenericContainerFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods
 
 nsresult nsSVGGenericContainerFrame::AttributeChanged(int32_t aNameSpaceID,
--- a/layout/svg/nsSVGGenericContainerFrame.h
+++ b/layout/svg/nsSVGGenericContainerFrame.h
@@ -18,18 +18,19 @@ class nsAtom;
 class nsIFrame;
 class nsIPresShell;
 
 class nsSVGGenericContainerFrame final : public nsSVGDisplayContainerFrame {
   friend nsIFrame* NS_NewSVGGenericContainerFrame(nsIPresShell* aPresShell,
                                                   ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGGenericContainerFrame(ComputedStyle* aStyle)
-      : nsSVGDisplayContainerFrame(aStyle, kClassID) {}
+  explicit nsSVGGenericContainerFrame(ComputedStyle* aStyle,
+                                      nsPresContext* aPresContext)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGGenericContainerFrame)
 
   // nsIFrame:
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
 
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -25,18 +25,19 @@ using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::SVGGradientElement_Binding;
 using namespace mozilla::dom::SVGUnitTypes_Binding;
 using namespace mozilla::gfx;
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGGradientFrame::nsSVGGradientFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsSVGPaintServerFrame(aStyle, aID),
+nsSVGGradientFrame::nsSVGGradientFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext, ClassID aID)
+    : nsSVGPaintServerFrame(aStyle, aPresContext, aID),
       mSource(nullptr),
       mLoopFlag(false),
       mNoHRefURI(false) {}
 
 //----------------------------------------------------------------------
 // nsIFrame methods:
 
 nsresult nsSVGGradientFrame::AttributeChanged(int32_t aNameSpaceID,
@@ -589,19 +590,21 @@ already_AddRefed<gfxPattern> nsSVGRadial
 }
 
 // -------------------------------------------------------------------------
 // Public functions
 // -------------------------------------------------------------------------
 
 nsIFrame* NS_NewSVGLinearGradientFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGLinearGradientFrame(aStyle);
+  return new (aPresShell)
+      nsSVGLinearGradientFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGLinearGradientFrame)
 
 nsIFrame* NS_NewSVGRadialGradientFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGRadialGradientFrame(aStyle);
+  return new (aPresShell)
+      nsSVGRadialGradientFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGRadialGradientFrame)
--- a/layout/svg/nsSVGGradientFrame.h
+++ b/layout/svg/nsSVGGradientFrame.h
@@ -28,17 +28,18 @@ class SVGLinearGradientElement;
 class SVGRadialGradientElement;
 }  // namespace dom
 }  // namespace mozilla
 
 class nsSVGGradientFrame : public nsSVGPaintServerFrame {
   typedef mozilla::gfx::ExtendMode ExtendMode;
 
  protected:
-  nsSVGGradientFrame(ComputedStyle* aStyle, ClassID aID);
+  nsSVGGradientFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                     ClassID aID);
 
  public:
   NS_DECL_ABSTRACT_FRAME(nsSVGGradientFrame)
 
   // nsSVGPaintServerFrame methods:
   virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
       nsIFrame* aSource, const DrawTarget* aDrawTarget,
       const gfxMatrix& aContextMatrix,
@@ -107,18 +108,19 @@ class nsSVGGradientFrame : public nsSVGP
 // Linear Gradients
 // -------------------------------------------------------------------------
 
 class nsSVGLinearGradientFrame final : public nsSVGGradientFrame {
   friend nsIFrame* NS_NewSVGLinearGradientFrame(nsIPresShell* aPresShell,
                                                 ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGLinearGradientFrame(ComputedStyle* aStyle)
-      : nsSVGGradientFrame(aStyle, kClassID) {}
+  explicit nsSVGLinearGradientFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsSVGGradientFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGLinearGradientFrame)
 
   // nsIFrame interface:
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
@@ -146,18 +148,19 @@ class nsSVGLinearGradientFrame final : p
 // Radial Gradients
 // -------------------------------------------------------------------------
 
 class nsSVGRadialGradientFrame final : public nsSVGGradientFrame {
   friend nsIFrame* NS_NewSVGRadialGradientFrame(nsIPresShell* aPresShell,
                                                 ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGRadialGradientFrame(ComputedStyle* aStyle)
-      : nsSVGGradientFrame(aStyle, kClassID) {}
+  explicit nsSVGRadialGradientFrame(ComputedStyle* aStyle,
+                                    nsPresContext* aPresContext)
+      : nsSVGGradientFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGRadialGradientFrame)
 
   // nsIFrame interface:
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -32,17 +32,17 @@ using namespace mozilla::image;
 
 // ---------------------------------------------------------------------
 // nsQueryFrame methods
 NS_QUERYFRAME_HEAD(nsSVGImageFrame)
   NS_QUERYFRAME_ENTRY(nsSVGImageFrame)
 NS_QUERYFRAME_TAIL_INHERITING(SVGGeometryFrame)
 
 nsIFrame* NS_NewSVGImageFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGImageFrame(aStyle);
+  return new (aPresShell) nsSVGImageFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGImageFrame)
 
 nsSVGImageFrame::~nsSVGImageFrame() {
   // set the frame to null so we don't send messages to a dead object.
   if (mListener) {
     nsCOMPtr<nsIImageLoadingContent> imageLoader =
--- a/layout/svg/nsSVGImageFrame.h
+++ b/layout/svg/nsSVGImageFrame.h
@@ -43,18 +43,18 @@ class nsSVGImageListener final : public 
 };
 
 class nsSVGImageFrame final : public mozilla::SVGGeometryFrame,
                               public nsIReflowCallback {
   friend nsIFrame* NS_NewSVGImageFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGImageFrame(ComputedStyle* aStyle)
-      : SVGGeometryFrame(aStyle, kClassID),
+  explicit nsSVGImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : SVGGeometryFrame(aStyle, aPresContext, kClassID),
         mReflowCallbackPosted(false),
         mForceSyncDecoding(false) {
     EnableVisibilityTracking();
   }
 
   virtual ~nsSVGImageFrame();
 
  public:
--- a/layout/svg/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/nsSVGInnerSVGFrame.cpp
@@ -6,17 +6,18 @@
 
 // Main header first:
 #include "nsSVGInnerSVGFrame.h"
 
 using namespace mozilla;
 
 nsIFrame* NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGInnerSVGFrame(aStyle);
+  return new (aPresShell)
+      nsSVGInnerSVGFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGInnerSVGFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods
 
 NS_QUERYFRAME_HEAD(nsSVGInnerSVGFrame)
--- a/layout/svg/nsSVGInnerSVGFrame.h
+++ b/layout/svg/nsSVGInnerSVGFrame.h
@@ -9,18 +9,19 @@
 
 #include "nsSVGViewportFrame.h"
 
 class nsSVGInnerSVGFrame final : public nsSVGViewportFrame {
   friend nsIFrame* NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell,
                                           ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGInnerSVGFrame(ComputedStyle* aStyle)
-      : nsSVGViewportFrame(aStyle, kClassID) {}
+  explicit nsSVGInnerSVGFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext)
+      : nsSVGViewportFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsSVGInnerSVGFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
--- a/layout/svg/nsSVGMarkerFrame.cpp
+++ b/layout/svg/nsSVGMarkerFrame.cpp
@@ -16,17 +16,18 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 nsContainerFrame* NS_NewSVGMarkerFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGMarkerFrame(aStyle);
+  return new (aPresShell)
+      nsSVGMarkerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGMarkerFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods:
 
 nsresult nsSVGMarkerFrame::AttributeChanged(int32_t aNameSpaceID,
@@ -209,17 +210,18 @@ nsSVGMarkerFrame::AutoMarkerReferencer::
   mFrame->mInUse = false;
 }
 
 //----------------------------------------------------------------------
 // Implementation of nsSVGMarkerAnonChildFrame
 
 nsContainerFrame* NS_NewSVGMarkerAnonChildFrame(nsIPresShell* aPresShell,
                                                 ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGMarkerAnonChildFrame(aStyle);
+  return new (aPresShell)
+      nsSVGMarkerAnonChildFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGMarkerAnonChildFrame)
 
 #ifdef DEBUG
 void nsSVGMarkerAnonChildFrame::Init(nsIContent* aContent,
                                      nsContainerFrame* aParent,
                                      nsIFrame* aPrevInFlow) {
--- a/layout/svg/nsSVGMarkerFrame.h
+++ b/layout/svg/nsSVGMarkerFrame.h
@@ -33,18 +33,18 @@ class nsSVGMarkerFrame final : public ns
   typedef mozilla::SVGMark SVGMark;
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
 
   friend class nsSVGMarkerAnonChildFrame;
   friend nsContainerFrame* NS_NewSVGMarkerFrame(nsIPresShell* aPresShell,
                                                 ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGMarkerFrame(ComputedStyle* aStyle)
-      : nsSVGContainerFrame(aStyle, kClassID),
+  explicit nsSVGMarkerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGContainerFrame(aStyle, aPresContext, kClassID),
         mMarkedFrame(nullptr),
         mInUse(false),
         mInUse2(false) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGMarkerFrame)
@@ -126,18 +126,19 @@ class nsSVGMarkerFrame final : public ns
 
 ////////////////////////////////////////////////////////////////////////
 // nsMarkerAnonChildFrame class
 
 class nsSVGMarkerAnonChildFrame final : public nsSVGDisplayContainerFrame {
   friend nsContainerFrame* NS_NewSVGMarkerAnonChildFrame(
       nsIPresShell* aPresShell, ComputedStyle* aStyle);
 
-  explicit nsSVGMarkerAnonChildFrame(ComputedStyle* aStyle)
-      : nsSVGDisplayContainerFrame(aStyle, kClassID) {}
+  explicit nsSVGMarkerAnonChildFrame(ComputedStyle* aStyle,
+                                     nsPresContext* aPresContext)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGMarkerAnonChildFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 #endif
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -32,17 +32,17 @@ static LuminanceType GetLuminanceType(ui
     default: {
       NS_WARNING("Unknown SVG mask type, defaulting to luminance");
       return LuminanceType::LUMINANCE;
     }
   }
 }
 
 nsIFrame* NS_NewSVGMaskFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGMaskFrame(aStyle);
+  return new (aPresShell) nsSVGMaskFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
 
 already_AddRefed<SourceSurface> nsSVGMaskFrame::GetMaskForMaskedFrame(
     MaskParams& aParams) {
   // Make sure we break reference loops and over long reference chains:
   static int16_t sRefChainLengthCounter = AutoReferenceChainGuard::noChain;
--- a/layout/svg/nsSVGMaskFrame.h
+++ b/layout/svg/nsSVGMaskFrame.h
@@ -21,18 +21,18 @@ class nsSVGMaskFrame final : public nsSV
   friend nsIFrame* NS_NewSVGMaskFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle);
 
   typedef mozilla::gfx::Matrix Matrix;
   typedef mozilla::gfx::SourceSurface SourceSurface;
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
 
  protected:
-  explicit nsSVGMaskFrame(ComputedStyle* aStyle)
-      : nsSVGContainerFrame(aStyle, kClassID), mInUse(false) {
+  explicit nsSVGMaskFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGContainerFrame(aStyle, aPresContext, kClassID), mInUse(false) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
 
   struct MaskParams {
     gfxContext* ctx;
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -54,23 +54,25 @@ void nsSVGOuterSVGFrame::UnregisterForei
   return mForeignObjectHash->RemoveEntry(aFrame);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsContainerFrame* NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGOuterSVGFrame(aStyle);
+  return new (aPresShell)
+      nsSVGOuterSVGFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGFrame)
 
-nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(ComputedStyle* aStyle)
-    : nsSVGDisplayContainerFrame(aStyle, kClassID),
+nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+    : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID),
       mCallingReflowSVG(false),
       mFullZoom(PresContext()->GetFullZoom()),
       mViewportInitialized(false),
       mIsRootContent(false) {
   // Outer-<svg> has CSS layout, so remove this bit:
   RemoveStateBits(NS_FRAME_SVG_LAYOUT);
 }
 
@@ -923,17 +925,18 @@ void nsSVGOuterSVGFrame::AppendDirectlyO
   aResult.AppendElement(OwnedAnonBox(anonKid));
 }
 
 //----------------------------------------------------------------------
 // Implementation of nsSVGOuterSVGAnonChildFrame
 
 nsContainerFrame* NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell,
                                                   ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGOuterSVGAnonChildFrame(aStyle);
+  return new (aPresShell)
+      nsSVGOuterSVGAnonChildFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGAnonChildFrame)
 
 #ifdef DEBUG
 void nsSVGOuterSVGAnonChildFrame::Init(nsIContent* aContent,
                                        nsContainerFrame* aParent,
                                        nsIFrame* aPrevInFlow) {
--- a/layout/svg/nsSVGOuterSVGFrame.h
+++ b/layout/svg/nsSVGOuterSVGFrame.h
@@ -22,17 +22,18 @@ class nsSVGForeignObjectFrame;
 class nsSVGOuterSVGFrame final : public nsSVGDisplayContainerFrame,
                                  public nsISVGSVGFrame {
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
 
   friend nsContainerFrame* NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell,
                                                   ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGOuterSVGFrame(ComputedStyle* aStyle);
+  explicit nsSVGOuterSVGFrame(ComputedStyle* aStyle,
+                              nsPresContext* aPresContext);
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsSVGOuterSVGFrame)
 
 #ifdef DEBUG
   ~nsSVGOuterSVGFrame() {
     NS_ASSERTION(!mForeignObjectHash || mForeignObjectHash->Count() == 0,
@@ -212,18 +213,19 @@ class nsSVGOuterSVGFrame final : public 
  * handling for these inner wrappers in multiple parts of the SVG code. For
  * example, the implementations of IsSVGTransformed and GetCanvasTM assume
  * nsSVGContainerFrame instances all the way up to the nsSVGOuterSVGFrame.
  */
 class nsSVGOuterSVGAnonChildFrame final : public nsSVGDisplayContainerFrame {
   friend nsContainerFrame* NS_NewSVGOuterSVGAnonChildFrame(
       nsIPresShell* aPresShell, ComputedStyle* aStyle);
 
-  explicit nsSVGOuterSVGAnonChildFrame(ComputedStyle* aStyle)
-      : nsSVGDisplayContainerFrame(aStyle, kClassID) {}
+  explicit nsSVGOuterSVGAnonChildFrame(ComputedStyle* aStyle,
+                                       nsPresContext* aPresContext)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGOuterSVGAnonChildFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 #endif
--- a/layout/svg/nsSVGPaintServerFrame.h
+++ b/layout/svg/nsSVGPaintServerFrame.h
@@ -46,18 +46,19 @@ class MOZ_RAII AutoSetRestorePaintServer
   nsIFrame* mFrame;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 class nsSVGPaintServerFrame : public nsSVGContainerFrame {
  protected:
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
-  nsSVGPaintServerFrame(ComputedStyle* aStyle, ClassID aID)
-      : nsSVGContainerFrame(aStyle, aID) {
+  nsSVGPaintServerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                        ClassID aID)
+      : nsSVGContainerFrame(aStyle, aPresContext, aID) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
 
   NS_DECL_ABSTRACT_FRAME(nsSVGPaintServerFrame)
 
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -30,18 +30,19 @@ using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::SVGUnitTypes_Binding;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGPatternFrame::nsSVGPatternFrame(ComputedStyle *aStyle)
-    : nsSVGPaintServerFrame(aStyle, kClassID),
+nsSVGPatternFrame::nsSVGPatternFrame(ComputedStyle *aStyle,
+                                     nsPresContext *aPresContext)
+    : nsSVGPaintServerFrame(aStyle, aPresContext, kClassID),
       mSource(nullptr),
       mLoopFlag(false),
       mNoHRefURI(false) {}
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGPatternFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods:
@@ -701,10 +702,11 @@ already_AddRefed<gfxPattern> nsSVGPatter
 }
 
 // -------------------------------------------------------------------------
 // Public functions
 // -------------------------------------------------------------------------
 
 nsIFrame *NS_NewSVGPatternFrame(nsIPresShell *aPresShell,
                                 ComputedStyle *aStyle) {
-  return new (aPresShell) nsSVGPatternFrame(aStyle);
+  return new (aPresShell)
+      nsSVGPatternFrame(aStyle, aPresShell->GetPresContext());
 }
--- a/layout/svg/nsSVGPatternFrame.h
+++ b/layout/svg/nsSVGPatternFrame.h
@@ -28,17 +28,18 @@ class nsSVGPatternFrame final : public n
   typedef mozilla::gfx::SourceSurface SourceSurface;
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGPatternFrame)
 
   friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
                                          ComputedStyle* aStyle);
 
-  explicit nsSVGPatternFrame(ComputedStyle* aStyle);
+  explicit nsSVGPatternFrame(ComputedStyle* aStyle,
+                             nsPresContext* aPresContext);
 
   // nsSVGPaintServerFrame methods:
   virtual already_AddRefed<gfxPattern> GetPaintServerPattern(
       nsIFrame* aSource, const DrawTarget* aDrawTarget,
       const gfxMatrix& aContextMatrix,
       nsStyleSVGPaint nsStyleSVG::*aFillOrStroke, float aOpacity,
       imgDrawingParams& aImgParams, const gfxRect* aOverrideBounds) override;
 
--- a/layout/svg/nsSVGStopFrame.cpp
+++ b/layout/svg/nsSVGStopFrame.cpp
@@ -17,17 +17,18 @@ using namespace mozilla;
 // events and propagate them to the parent.  Most of the heavy lifting is done
 // within the nsSVGGradientFrame, which is the parent for this frame
 
 class nsSVGStopFrame : public nsFrame {
   friend nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGStopFrame(ComputedStyle* aStyle) : nsFrame(aStyle, kClassID) {
+  explicit nsSVGStopFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsFrame(aStyle, aPresContext, kClassID) {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGStopFrame)
 
   // nsIFrame interface:
 #ifdef DEBUG
@@ -88,10 +89,10 @@ nsresult nsSVGStopFrame::AttributeChange
   return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
 }
 
 // -------------------------------------------------------------------------
 // Public functions
 // -------------------------------------------------------------------------
 
 nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGStopFrame(aStyle);
+  return new (aPresShell) nsSVGStopFrame(aStyle, aPresShell->GetPresContext());
 }
--- a/layout/svg/nsSVGSwitchFrame.cpp
+++ b/layout/svg/nsSVGSwitchFrame.cpp
@@ -15,18 +15,18 @@ using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 class nsSVGSwitchFrame final : public nsSVGGFrame {
   friend nsIFrame* NS_NewSVGSwitchFrame(nsIPresShell* aPresShell,
                                         ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGSwitchFrame(ComputedStyle* aStyle)
-      : nsSVGGFrame(aStyle, kClassID) {}
+  explicit nsSVGSwitchFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGGFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGSwitchFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 #endif
@@ -53,17 +53,18 @@ class nsSVGSwitchFrame final : public ns
   nsIFrame* GetActiveChildFrame();
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGSwitchFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGSwitchFrame(aStyle);
+  return new (aPresShell)
+      nsSVGSwitchFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGSwitchFrame)
 
 #ifdef DEBUG
 void nsSVGSwitchFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                             nsIFrame* aPrevInFlow) {
   NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::svgSwitch),
--- a/layout/svg/nsSVGSymbolFrame.cpp
+++ b/layout/svg/nsSVGSymbolFrame.cpp
@@ -6,17 +6,18 @@
 
 // Main header first:
 #include "nsSVGSymbolFrame.h"
 
 using namespace mozilla;
 
 nsIFrame* NS_NewSVGSymbolFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGSymbolFrame(aStyle);
+  return new (aPresShell)
+      nsSVGSymbolFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGSymbolFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods
 
 NS_QUERYFRAME_HEAD(nsSVGSymbolFrame)
--- a/layout/svg/nsSVGSymbolFrame.h
+++ b/layout/svg/nsSVGSymbolFrame.h
@@ -9,18 +9,18 @@
 
 #include "nsSVGViewportFrame.h"
 
 class nsSVGSymbolFrame final : public nsSVGViewportFrame {
   friend nsIFrame* NS_NewSVGSymbolFrame(nsIPresShell* aPresShell,
                                         ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGSymbolFrame(ComputedStyle* aStyle)
-      : nsSVGViewportFrame(aStyle, kClassID) {}
+  explicit nsSVGSymbolFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGViewportFrame(aStyle, aPresContext, kClassID) {}
 
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsSVGSymbolFrame)
 
 #ifdef DEBUG
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
--- a/layout/svg/nsSVGUseFrame.cpp
+++ b/layout/svg/nsSVGUseFrame.cpp
@@ -12,17 +12,17 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame* NS_NewSVGUseFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSVGUseFrame(aStyle);
+  return new (aPresShell) nsSVGUseFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGUseFrame)
 
 //----------------------------------------------------------------------
 // nsIFrame methods:
 
 void nsSVGUseFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/svg/nsSVGUseFrame.h
+++ b/layout/svg/nsSVGUseFrame.h
@@ -10,18 +10,19 @@
 // Keep in (case-insensitive) order:
 #include "nsSVGGFrame.h"
 
 class nsSVGUseFrame final : public nsSVGGFrame {
   friend nsIFrame* NS_NewSVGUseFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle);
 
  protected:
-  explicit nsSVGUseFrame(ComputedStyle* aStyle)
-      : nsSVGGFrame(aStyle, kClassID), mHasValidDimensions(true) {}
+  explicit nsSVGUseFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsSVGGFrame(aStyle, aPresContext, kClassID),
+        mHasValidDimensions(true) {}
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSVGUseFrame)
 
   // nsIFrame interface:
   void Init(nsIContent* aContent, nsContainerFrame* aParent,
             nsIFrame* aPrevInFlow) override;
 
--- a/layout/svg/nsSVGViewportFrame.h
+++ b/layout/svg/nsSVGViewportFrame.h
@@ -14,18 +14,19 @@
 
 class gfxContext;
 /**
  * Superclass for inner SVG frames and symbol frames.
  */
 class nsSVGViewportFrame : public nsSVGDisplayContainerFrame,
                            public nsISVGSVGFrame {
  protected:
-  nsSVGViewportFrame(ComputedStyle* aStyle, nsIFrame::ClassID aID)
-      : nsSVGDisplayContainerFrame(aStyle, aID) {}
+  nsSVGViewportFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                     nsIFrame::ClassID aID)
+      : nsSVGDisplayContainerFrame(aStyle, aPresContext, aID) {}
 
  public:
   NS_DECL_ABSTRACT_FRAME(nsSVGViewportFrame)
 
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
 
   // nsSVGDisplayableFrame interface:
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -69,17 +69,17 @@ class nsDisplayTableCellSelection final 
     }
 
     return true;
   }
 };
 
 nsTableCellFrame::nsTableCellFrame(ComputedStyle* aStyle,
                                    nsTableFrame* aTableFrame, ClassID aID)
-    : nsContainerFrame(aStyle, aID),
+    : nsContainerFrame(aStyle, aTableFrame->PresContext(), aID),
       mDesiredSize(aTableFrame->GetWritingMode()) {
   mColIndex = 0;
   mPriorAvailISize = 0;
 
   SetContentEmpty(false);
   SetHasPctOverBSize(false);
 }
 
--- a/layout/tables/nsTableColFrame.cpp
+++ b/layout/tables/nsTableColFrame.cpp
@@ -17,18 +17,19 @@ using namespace mozilla;
 
 #define COL_TYPE_BITS                                                         \
   (NS_FRAME_STATE_BIT(28) | NS_FRAME_STATE_BIT(29) | NS_FRAME_STATE_BIT(30) | \
    NS_FRAME_STATE_BIT(31))
 #define COL_TYPE_OFFSET 28
 
 using namespace mozilla;
 
-nsTableColFrame::nsTableColFrame(ComputedStyle* aStyle)
-    : nsSplittableFrame(aStyle, kClassID),
+nsTableColFrame::nsTableColFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsSplittableFrame(aStyle, aPresContext, kClassID),
       mMinCoord(0),
       mPrefCoord(0),
       mSpanMinCoord(0),
       mSpanPrefCoord(0),
       mPrefPercent(0.0f),
       mSpanPrefPercent(0.0f),
       mFinalISize(0),
       mColIndex(0),
@@ -150,17 +151,17 @@ void nsTableColFrame::Dump(int32_t aInde
   printf("\n%s**END COL DUMP** ", indent);
   delete[] indent;
 }
 #endif
 /* ----- global methods ----- */
 
 nsTableColFrame* NS_NewTableColFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableColFrame(aStyle);
+  return new (aPresShell) nsTableColFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
 
 nsTableColFrame* nsTableColFrame::GetNextCol() const {
   nsIFrame* childFrame = GetNextSibling();
   while (childFrame) {
     if (childFrame->IsTableColFrame()) {
--- a/layout/tables/nsTableColFrame.h
+++ b/layout/tables/nsTableColFrame.h
@@ -269,17 +269,17 @@ class nsTableColFrame final : public nsS
   virtual void InvalidateFrameWithRect(
       const nsRect& aRect, uint32_t aDisplayItemKey = 0,
       bool aRebuildDisplayItems = true) override;
   virtual void InvalidateFrameForRemoval() override {
     InvalidateFrameSubtree();
   }
 
  protected:
-  explicit nsTableColFrame(ComputedStyle* aStyle);
+  explicit nsTableColFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   ~nsTableColFrame();
 
   nscoord mMinCoord;
   nscoord mPrefCoord;
   nscoord mSpanMinCoord;   // XXX...
   nscoord mSpanPrefCoord;  // XXX...
   float mPrefPercent;
   float mSpanPrefPercent;  // XXX...
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -396,17 +396,18 @@ void nsTableColGroupFrame::GetContinuous
   aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(d2a, mBStartContBorderWidth);
   aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a, mBEndContBorderWidth);
 }
 
 /* ----- global methods ----- */
 
 nsTableColGroupFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableColGroupFrame(aStyle);
+  return new (aPresShell)
+      nsTableColGroupFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableColGroupFrame)
 
 void nsTableColGroupFrame::InvalidateFrame(uint32_t aDisplayItemKey,
                                            bool aRebuildDisplayItems) {
   nsIFrame::InvalidateFrame(aDisplayItemKey, aRebuildDisplayItems);
   if (GetTableFrame()->IsBorderCollapse()) {
--- a/layout/tables/nsTableColGroupFrame.h
+++ b/layout/tables/nsTableColGroupFrame.h
@@ -199,35 +199,39 @@ class nsTableColGroupFrame final : publi
   virtual void InvalidateFrameWithRect(
       const nsRect& aRect, uint32_t aDisplayItemKey = 0,
       bool aRebuildDisplayItems = true) override;
   virtual void InvalidateFrameForRemoval() override {
     InvalidateFrameSubtree();
   }
 
  protected:
-  explicit nsTableColGroupFrame(ComputedStyle* aStyle);
+  explicit nsTableColGroupFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext);
 
   void InsertColsReflow(int32_t aColIndex, const nsFrameList::Slice& aCols);
 
   virtual LogicalSides GetLogicalSkipSides(
       const ReflowInput* aReflowInput = nullptr) const override;
 
   // data members
   int32_t mColCount;
   // the starting column index this col group represents. Must be >= 0.
   int32_t mStartColIndex;
 
   // border width in pixels
   BCPixelSize mBStartContBorderWidth;
   BCPixelSize mBEndContBorderWidth;
 };
 
-inline nsTableColGroupFrame::nsTableColGroupFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID), mColCount(0), mStartColIndex(0) {}
+inline nsTableColGroupFrame::nsTableColGroupFrame(ComputedStyle* aStyle,
+                                                  nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID),
+      mColCount(0),
+      mStartColIndex(0) {}
 
 inline int32_t nsTableColGroupFrame::GetStartColumnIndex() {
   return mStartColIndex;
 }
 
 inline void nsTableColGroupFrame::SetStartColumnIndex(int32_t aIndex) {
   mStartColIndex = aIndex;
 }
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -145,18 +145,19 @@ ComputedStyle* nsTableFrame::GetParentCo
     // We're the root.  We have no ComputedStyle parent.
     *aProviderFrame = nullptr;
     return nullptr;
   }
 
   return GetParent()->DoGetParentComputedStyle(aProviderFrame);
 }
 
-nsTableFrame::nsTableFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsContainerFrame(aStyle, aID),
+nsTableFrame::nsTableFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                           ClassID aID)
+    : nsContainerFrame(aStyle, aPresContext, aID),
       mCellMap(nullptr),
       mTableLayoutStrategy(nullptr) {
   memset(&mBits, 0, sizeof(mBits));
 }
 
 void nsTableFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                         nsIFrame* aPrevInFlow) {
   MOZ_ASSERT(!mCellMap, "Init called twice");
@@ -3846,17 +3847,17 @@ nscoord nsTableFrame::GetRowSpacing(int3
   }
   return false;
 }
 
 /* ----- global methods ----- */
 
 nsTableFrame* NS_NewTableFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableFrame(aStyle);
+  return new (aPresShell) nsTableFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableFrame)
 
 nsTableFrame* nsTableFrame::GetTableFrame(nsIFrame* aFrame) {
   for (nsIFrame* ancestor = aFrame->GetParent(); ancestor;
        ancestor = ancestor->GetParent()) {
     if (ancestor->IsTableFrame()) {
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -562,17 +562,18 @@ class nsTableFrame : public nsContainerF
  protected:
   static void UpdateStyleOfOwnedAnonBoxesForTableWrapper(
       nsIFrame* aOwningFrame, nsIFrame* aWrapperFrame,
       mozilla::ServoRestyleState& aRestyleState);
 
   /** protected constructor.
    * @see NewFrame
    */
-  explicit nsTableFrame(ComputedStyle* aStyle, ClassID aID = kClassID);
+  explicit nsTableFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                        ClassID aID = kClassID);
 
   /** destructor, responsible for mColumnLayoutData */
   virtual ~nsTableFrame();
 
   void InitChildReflowInput(ReflowInput& aReflowInput);
 
   virtual LogicalSides GetLogicalSkipSides(
       const ReflowInput* aReflowInput = nullptr) const override;
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -112,18 +112,19 @@ void nsTableRowFrame::SetPctBSize(float 
 }
 
 /* ----------- nsTableRowFrame ---------- */
 
 NS_QUERYFRAME_HEAD(nsTableRowFrame)
   NS_QUERYFRAME_ENTRY(nsTableRowFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
-nsTableRowFrame::nsTableRowFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsContainerFrame(aStyle, aID),
+nsTableRowFrame::nsTableRowFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext, ClassID aID)
+    : nsContainerFrame(aStyle, aPresContext, aID),
       mContentBSize(0),
       mStylePctBSize(0),
       mStyleFixedBSize(0),
       mMaxCellAscent(0),
       mMaxCellDescent(0),
       mBStartBorderWidth(0),
       mBEndBorderWidth(0),
       mIEndContBorderWidth(0),
@@ -1367,17 +1368,17 @@ void nsTableRowFrame::InvalidateFrameWit
   GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey,
                                        false);
 }
 
 /* ----- global methods ----- */
 
 nsTableRowFrame* NS_NewTableRowFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableRowFrame(aStyle);
+  return new (aPresShell) nsTableRowFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableRowFrame)
 
 #ifdef DEBUG_FRAME_DUMP
 nsresult nsTableRowFrame::GetFrameName(nsAString& aResult) const {
   return MakeFrameName(NS_LITERAL_STRING("TableRow"), aResult);
 }
--- a/layout/tables/nsTableRowFrame.h
+++ b/layout/tables/nsTableRowFrame.h
@@ -249,17 +249,18 @@ class nsTableRowFrame : public nsContain
 #ifdef ACCESSIBILITY
   virtual mozilla::a11y::AccType AccessibleType() override;
 #endif
 
  protected:
   /** protected constructor.
    * @see NewFrame
    */
-  explicit nsTableRowFrame(ComputedStyle* aStyle, ClassID aID = kClassID);
+  explicit nsTableRowFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                           ClassID aID = kClassID);
 
   void InitChildReflowInput(nsPresContext& aPresContext,
                             const mozilla::LogicalSize& aAvailSize,
                             bool aBorderCollapse,
                             TableCellReflowInput& aReflowInput);
 
   virtual LogicalSides GetLogicalSkipSides(
       const ReflowInput* aReflowInput = nullptr) const override;
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -44,18 +44,19 @@ struct TableRowGroupReflowInput {
         availSize(aReflowInput.AvailableSize()),
         bCoord(0) {}
 
   ~TableRowGroupReflowInput() {}
 };
 
 }  // namespace mozilla
 
-nsTableRowGroupFrame::nsTableRowGroupFrame(ComputedStyle* aStyle)
-    : nsContainerFrame(aStyle, kClassID) {
+nsTableRowGroupFrame::nsTableRowGroupFrame(ComputedStyle* aStyle,
+                                           nsPresContext* aPresContext)
+    : nsContainerFrame(aStyle, aPresContext, kClassID) {
   SetRepeatable(false);
 }
 
 nsTableRowGroupFrame::~nsTableRowGroupFrame() {}
 
 void nsTableRowGroupFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                        PostDestroyData& aPostDestroyData) {
   if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
@@ -1622,17 +1623,18 @@ bool nsTableRowGroupFrame::HasInternalBr
   nsIFrame* lastChild = mFrames.LastChild();
   if (!lastChild) return false;
   return lastChild->StyleDisplay()->BreakAfter();
 }
 /* ----- global methods ----- */
 
 nsTableRowGroupFrame* NS_NewTableRowGroupFrame(nsIPresShell* aPresShell,
                                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableRowGroupFrame(aStyle);
+  return new (aPresShell)
+      nsTableRowGroupFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableRowGroupFrame)
 
 #ifdef DEBUG_FRAME_DUMP
 nsresult nsTableRowGroupFrame::GetFrameName(nsAString& aResult) const {
   return MakeFrameName(NS_LITERAL_STRING("TableRowGroup"), aResult);
 }
--- a/layout/tables/nsTableRowGroupFrame.h
+++ b/layout/tables/nsTableRowGroupFrame.h
@@ -326,17 +326,18 @@ class nsTableRowGroupFrame final : publi
   virtual void InvalidateFrameWithRect(
       const nsRect& aRect, uint32_t aDisplayItemKey = 0,
       bool aRebuildDisplayItems = true) override;
   virtual void InvalidateFrameForRemoval() override {
     InvalidateFrameSubtree();
   }
 
  protected:
-  explicit nsTableRowGroupFrame(ComputedStyle* aStyle);
+  explicit nsTableRowGroupFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext);
 
   void InitChildReflowInput(nsPresContext& aPresContext, bool aBorderCollapse,
                             ReflowInput& aReflowInput);
 
   virtual LogicalSides GetLogicalSkipSides(
       const ReflowInput* aReflowInput = nullptr) const override;
 
   void PlaceChild(nsPresContext* aPresContext,
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -35,18 +35,20 @@ using namespace mozilla::layout;
     MOZ_ASSERT_UNREACHABLE("no inner table");
     return nsContainerFrame::GetLogicalBaseline(aWritingMode);
   }
 
   return kid->GetLogicalBaseline(aWritingMode) +
          kid->BStart(aWritingMode, mRect.Size());
 }
 
-nsTableWrapperFrame::nsTableWrapperFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsContainerFrame(aStyle, aID) {}
+nsTableWrapperFrame::nsTableWrapperFrame(ComputedStyle* aStyle,
+                                         nsPresContext* aPresContext,
+                                         ClassID aID)
+    : nsContainerFrame(aStyle, aPresContext, aID) {}
 
 nsTableWrapperFrame::~nsTableWrapperFrame() {}
 
 NS_QUERYFRAME_HEAD(nsTableWrapperFrame)
   NS_QUERYFRAME_ENTRY(nsTableWrapperFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 #ifdef ACCESSIBILITY
@@ -996,17 +998,18 @@ nsIContent* nsTableWrapperFrame::GetCell
     return nullptr;
   }
 
   return cell->GetContent();
 }
 
 nsTableWrapperFrame* NS_NewTableWrapperFrame(nsIPresShell* aPresShell,
                                              ComputedStyle* aStyle) {
-  return new (aPresShell) nsTableWrapperFrame(aStyle);
+  return new (aPresShell)
+      nsTableWrapperFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTableWrapperFrame)
 
 #ifdef DEBUG_FRAME_DUMP
 nsresult nsTableWrapperFrame::GetFrameName(nsAString& aResult) const {
   return MakeFrameName(NS_LITERAL_STRING("TableWrapper"), aResult);
 }
--- a/layout/tables/nsTableWrapperFrame.h
+++ b/layout/tables/nsTableWrapperFrame.h
@@ -171,17 +171,19 @@ class nsTableWrapperFrame : public nsCon
 
   /**
    * The CB size to use for the inner table frame if we're a grid item.
    */
   NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridItemCBSizeProperty,
                                       mozilla::LogicalSize);
 
  protected:
-  explicit nsTableWrapperFrame(ComputedStyle* aStyle, ClassID aID = kClassID);
+  explicit nsTableWrapperFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext,
+                               ClassID aID = kClassID);
   virtual ~nsTableWrapperFrame();
 
   void InitChildReflowInput(nsPresContext& aPresContext,
                             const ReflowInput& aOuterRS,
                             ReflowInput& aReflowInput);
 
   // Get a NS_STYLE_CAPTION_SIDE_* value, or NO_SIDE if no caption is present.
   // (Remember that caption-side values are interpreted logically, despite
--- a/layout/xul/grid/nsGridRowGroupFrame.cpp
+++ b/layout/xul/grid/nsGridRowGroupFrame.cpp
@@ -19,17 +19,18 @@
 
 using namespace mozilla;
 
 already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout();
 
 nsIFrame* NS_NewGridRowGroupFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle) {
   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout();
-  return new (aPresShell) nsGridRowGroupFrame(aStyle, layout);
+  return new (aPresShell)
+      nsGridRowGroupFrame(aStyle, aPresShell->GetPresContext(), layout);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)
 
 /**
  * This is redefined because row groups have a funny property. If they are
  * flexible then their flex must be equal to the sum of their children's flexes.
  */
--- a/layout/xul/grid/nsGridRowGroupFrame.h
+++ b/layout/xul/grid/nsGridRowGroupFrame.h
@@ -29,16 +29,17 @@ class nsGridRowGroupFrame final : public
   NS_DECL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("nsGridRowGroup"), aResult);
   }
 #endif
 
-  nsGridRowGroupFrame(ComputedStyle* aStyle, nsBoxLayout* aLayoutManager)
-      : nsBoxFrame(aStyle, kClassID, false, aLayoutManager) {}
+  nsGridRowGroupFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                      nsBoxLayout* aLayoutManager)
+      : nsBoxFrame(aStyle, aPresContext, kClassID, false, aLayoutManager) {}
 
   virtual nscoord GetXULFlex() override;
 
 };  // class nsGridRowGroupFrame
 
 #endif
--- a/layout/xul/grid/nsGridRowLeafFrame.cpp
+++ b/layout/xul/grid/nsGridRowLeafFrame.cpp
@@ -19,17 +19,18 @@
 
 using namespace mozilla;
 
 already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
 
 nsIFrame* NS_NewGridRowLeafFrame(nsIPresShell* aPresShell,
                                  ComputedStyle* aStyle) {
   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
-  return new (aPresShell) nsGridRowLeafFrame(aStyle, false, layout);
+  return new (aPresShell)
+      nsGridRowLeafFrame(aStyle, aPresShell->GetPresContext(), false, layout);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame)
 
 /*
  * Our border and padding could be affected by our columns or rows.
  * Let's go check it out.
  */
--- a/layout/xul/grid/nsGridRowLeafFrame.h
+++ b/layout/xul/grid/nsGridRowLeafFrame.h
@@ -33,17 +33,18 @@ class nsGridRowLeafFrame : public nsBoxF
                                           ComputedStyle* aStyle);
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("nsGridRowLeaf"), aResult);
   }
 #endif
 
-  nsGridRowLeafFrame(ComputedStyle* aStyle, bool aIsRoot,
-                     nsBoxLayout* aLayoutManager, ClassID aID = kClassID)
-      : nsBoxFrame(aStyle, aID, aIsRoot, aLayoutManager) {}
+  nsGridRowLeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                     bool aIsRoot, nsBoxLayout* aLayoutManager,
+                     ClassID aID = kClassID)
+      : nsBoxFrame(aStyle, aPresContext, aID, aIsRoot, aLayoutManager) {}
 
   virtual nsresult GetXULBorderAndPadding(nsMargin& aBorderAndPadding) override;
 
 };  // class nsGridRowLeafFrame
 
 #endif
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -52,17 +52,18 @@ nsBox::DoXULLayout(nsBoxLayoutState& aSt
 
 nsresult nsBox::EndXULLayout(nsBoxLayoutState& aState) {
   return SyncLayout(aState);
 }
 
 bool nsBox::gGotTheme = false;
 StaticRefPtr<nsITheme> nsBox::gTheme;
 
-nsBox::nsBox(ClassID aID) : nsIFrame(aID) {
+nsBox::nsBox(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
+    : nsIFrame(aStyle, aPresContext, aID) {
   MOZ_COUNT_CTOR(nsBox);
   if (!gGotTheme) {
     gTheme = do_GetNativeTheme();
     if (gTheme) {
       gGotTheme = true;
     }
   }
 }
--- a/layout/xul/nsBox.h
+++ b/layout/xul/nsBox.h
@@ -38,17 +38,17 @@ class nsBox : public nsIFrame {
   virtual nsresult GetXULPadding(nsMargin& aBorderAndPadding) override;
   virtual nsresult GetXULMargin(nsMargin& aMargin) override;
 
   virtual Valignment GetXULVAlign() const override { return vAlign_Top; }
   virtual Halignment GetXULHAlign() const override { return hAlign_Left; }
 
   virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;
 
-  nsBox(ClassID aID);
+  nsBox(ComputedStyle*, nsPresContext*, ClassID);
   virtual ~nsBox();
 
   /**
    * Returns true if this box clips its children, e.g., if this box is an
    * scrollbox.
    */
   virtual bool DoesClipChildren();
   virtual bool ComputesOwnOverflowArea() = 0;
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -83,34 +83,35 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle,
                          bool aIsRoot, nsBoxLayout* aLayoutManager) {
   return new (aPresShell)
-      nsBoxFrame(aStyle, nsBoxFrame::kClassID, aIsRoot, aLayoutManager);
+      nsBoxFrame(aStyle, aPresShell->GetPresContext(), nsBoxFrame::kClassID,
+                 aIsRoot, aLayoutManager);
 }
 
 nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsBoxFrame(aStyle);
+  return new (aPresShell) nsBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsBoxFrame)
 
 #ifdef DEBUG
 NS_QUERYFRAME_HEAD(nsBoxFrame)
   NS_QUERYFRAME_ENTRY(nsBoxFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 #endif
 
-nsBoxFrame::nsBoxFrame(ComputedStyle* aStyle, ClassID aID, bool aIsRoot,
-                       nsBoxLayout* aLayoutManager)
-    : nsContainerFrame(aStyle, aID), mFlex(0), mAscent(0) {
+nsBoxFrame::nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                       ClassID aID, bool aIsRoot, nsBoxLayout* aLayoutManager)
+    : nsContainerFrame(aStyle, aPresContext, aID), mFlex(0), mAscent(0) {
   AddStateBits(NS_STATE_IS_HORIZONTAL | NS_STATE_AUTO_STRETCH);
 
   if (aIsRoot) AddStateBits(NS_STATE_IS_ROOT);
 
   mValign = vAlign_Top;
   mHalign = hAlign_Left;
 
   // if no layout manager specified us the static sprocket layout
--- a/layout/xul/nsBoxFrame.h
+++ b/layout/xul/nsBoxFrame.h
@@ -148,22 +148,22 @@ class nsBoxFrame : public nsContainerFra
                              const nsDisplayListSet& aOut);
 
   /**
    * Return our wrapper block, if any.
    */
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
  private:
-  explicit nsBoxFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID, false, nullptr) {}
+  explicit nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID, false, nullptr) {}
 
  protected:
-  nsBoxFrame(ComputedStyle* aStyle, ClassID aID, bool aIsRoot = false,
-             nsBoxLayout* aLayoutManager = nullptr);
+  nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID,
+             bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
   virtual ~nsBoxFrame();
 
   virtual bool GetInitialEqualSize(bool& aEqualSize);
   virtual void GetInitialOrientation(bool& aIsHorizontal);
   virtual void GetInitialDirection(bool& aIsNormal);
   virtual bool GetInitialHAlignment(Halignment& aHalign);
   virtual bool GetInitialVAlignment(Valignment& aValign);
   virtual bool GetInitialAutoStretch(bool& aStretch);
--- a/layout/xul/nsButtonBoxFrame.cpp
+++ b/layout/xul/nsButtonBoxFrame.cpp
@@ -46,23 +46,25 @@ nsresult nsButtonBoxFrame::nsButtonBoxLi
 
 //
 // NS_NewXULButtonFrame
 //
 // Creates a new Button frame and returns it
 //
 nsIFrame* NS_NewButtonBoxFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsButtonBoxFrame(aStyle);
+  return new (aPresShell)
+      nsButtonBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsButtonBoxFrame)
 
-nsButtonBoxFrame::nsButtonBoxFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsBoxFrame(aStyle, aID, false),
+nsButtonBoxFrame::nsButtonBoxFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext, ClassID aID)
+    : nsBoxFrame(aStyle, aPresContext, aID, false),
       mButtonBoxListener(nullptr),
       mIsHandlingKeyEvent(false) {
   UpdateMouseThrough();
 }
 
 void nsButtonBoxFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                             nsIFrame* aPrevInFlow) {
   nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
--- a/layout/xul/nsButtonBoxFrame.h
+++ b/layout/xul/nsButtonBoxFrame.h
@@ -11,17 +11,17 @@
 #include "nsBoxFrame.h"
 
 class nsButtonBoxFrame : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsButtonBoxFrame)
 
   friend nsIFrame* NS_NewButtonBoxFrame(nsIPresShell* aPresShell);
 
-  explicit nsButtonBoxFrame(ComputedStyle* aStyle, ClassID = kClassID);
+  nsButtonBoxFrame(ComputedStyle*, nsPresContext*, ClassID = kClassID);
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   virtual void BuildDisplayListForChildren(
       nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override;
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
--- a/layout/xul/nsDeckFrame.cpp
+++ b/layout/xul/nsDeckFrame.cpp
@@ -31,27 +31,27 @@
 
 #ifdef ACCESSIBILITY
 #  include "nsAccessibilityService.h"
 #endif
 
 using namespace mozilla;
 
 nsIFrame* NS_NewDeckFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsDeckFrame(aStyle);
+  return new (aPresShell) nsDeckFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsDeckFrame)
 
 NS_QUERYFRAME_HEAD(nsDeckFrame)
   NS_QUERYFRAME_ENTRY(nsDeckFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
-nsDeckFrame::nsDeckFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID), mIndex(0) {
+nsDeckFrame::nsDeckFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID), mIndex(0) {
   nsCOMPtr<nsBoxLayout> layout;
   NS_NewStackLayout(layout);
   SetXULLayoutManager(layout);
 }
 
 nsresult nsDeckFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                        int32_t aModType) {
   nsresult rv =
--- a/layout/xul/nsDeckFrame.h
+++ b/layout/xul/nsDeckFrame.h
@@ -43,17 +43,17 @@ class nsDeckFrame final : public nsBoxFr
                     nsIFrame* aPrevInFlow) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("Deck"), aResult);
   }
 #endif
 
-  explicit nsDeckFrame(ComputedStyle* aStyle);
+  explicit nsDeckFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   nsIFrame* GetSelectedBox();
 
  protected:
   void IndexChanged();
   int32_t GetSelectedIndex();
   void HideBox(nsIFrame* aBox);
 
--- a/layout/xul/nsDocElementBoxFrame.cpp
+++ b/layout/xul/nsDocElementBoxFrame.cpp
@@ -30,18 +30,19 @@ class nsDocElementBoxFrame final : publi
                                    public nsIAnonymousContentCreator {
  public:
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle);
 
-  explicit nsDocElementBoxFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID, true) {}
+  explicit nsDocElementBoxFrame(ComputedStyle* aStyle,
+                                nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID, true) {}
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
 
   // nsIAnonymousContentCreator
   virtual nsresult CreateAnonymousContent(
       nsTArray<ContentInfo>& aElements) override;
   virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
@@ -61,17 +62,18 @@ class nsDocElementBoxFrame final : publi
   nsCOMPtr<Element> mPopupgroupContent;
   nsCOMPtr<Element> mTooltipContent;
 };
 
 //----------------------------------------------------------------------
 
 nsContainerFrame* NS_NewDocElementBoxFrame(nsIPresShell* aPresShell,
                                            ComputedStyle* aStyle) {
-  return new (aPresShell) nsDocElementBoxFrame(aStyle);
+  return new (aPresShell)
+      nsDocElementBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
 
 void nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                        PostDestroyData& aPostDestroyData) {
   aPostDestroyData.AddAnonymousContent(mPopupgroupContent.forget());
   aPostDestroyData.AddAnonymousContent(mTooltipContent.forget());
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -18,18 +18,18 @@
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 class nsGroupBoxFrame final : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsGroupBoxFrame)
 
-  explicit nsGroupBoxFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID) {}
+  explicit nsGroupBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID) {}
 
   virtual nsresult GetXULBorderAndPadding(nsMargin& aBorderAndPadding) override;
 
   virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                 const nsDisplayListSet& aLists) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
@@ -82,17 +82,17 @@ public:
 
   // we are always flexible
   virtual bool GetDefaultFlex(int32_t& aFlex) { aFlex = 1; return true; }
 
 };
 */
 
 nsIFrame* NS_NewGroupBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsGroupBoxFrame(aStyle);
+  return new (aPresShell) nsGroupBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsGroupBoxFrame)
 
 class nsDisplayXULGroupBorder final : public nsDisplayItem {
  public:
   nsDisplayXULGroupBorder(nsDisplayListBuilder* aBuilder,
                           nsGroupBoxFrame* aFrame)
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -115,17 +115,17 @@ static void FireImageDOMEvent(nsIContent
 }
 
 //
 // NS_NewImageBoxFrame
 //
 // Creates a new image frame and returns it
 //
 nsIFrame* NS_NewImageBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsImageBoxFrame(aStyle);
+  return new (aPresShell) nsImageBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsImageBoxFrame)
 
 nsresult nsImageBoxFrame::AttributeChanged(int32_t aNameSpaceID,
                                            nsAtom* aAttribute,
                                            int32_t aModType) {
   nsresult rv =
@@ -136,18 +136,19 @@ nsresult nsImageBoxFrame::AttributeChang
     PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                   NS_FRAME_IS_DIRTY);
   } else if (aAttribute == nsGkAtoms::validate)
     UpdateLoadFlags();
 
   return rv;
 }
 
-nsImageBoxFrame::nsImageBoxFrame(ComputedStyle* aStyle)
-    : nsLeafBoxFrame(aStyle, kClassID),
+nsImageBoxFrame::nsImageBoxFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsLeafBoxFrame(aStyle, aPresContext, kClassID),
       mIntrinsicSize(0, 0),
       mLoadFlags(nsIRequest::LOAD_NORMAL),
       mRequestRegistered(false),
       mUseSrcAttr(false),
       mSuppressStyleCheck(false) {
   MarkIntrinsicISizesDirty();
 }
 
--- a/layout/xul/nsImageBoxFrame.h
+++ b/layout/xul/nsImageBoxFrame.h
@@ -100,17 +100,17 @@ class nsImageBoxFrame final : public nsL
       mozilla::layers::RenderRootStateManager* aManager, nsDisplayItem* aItem,
       nsPoint aPt, uint32_t aFlags);
 
   bool CanOptimizeToImageLayer();
 
   nsRect GetDestRect(const nsPoint& aOffset, Maybe<nsPoint>& aAnchorPoint);
 
  protected:
-  explicit nsImageBoxFrame(ComputedStyle* aStyle);
+  explicit nsImageBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   virtual void GetImageSize();
 
  private:
   nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
   nsresult OnDecodeComplete(imgIRequest* aRequest);
   nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
   nsresult OnImageIsAnimated(imgIRequest* aRequest);
--- a/layout/xul/nsLeafBoxFrame.cpp
+++ b/layout/xul/nsLeafBoxFrame.cpp
@@ -29,17 +29,17 @@
 using namespace mozilla;
 
 //
 // NS_NewLeafBoxFrame
 //
 // Creates a new Toolbar frame and returns it
 //
 nsIFrame* NS_NewLeafBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsLeafBoxFrame(aStyle);
+  return new (aPresShell) nsLeafBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsLeafBoxFrame)
 
 /**
  * Initialize us. This is a good time to get the alignment of the box
  */
 void nsLeafBoxFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/xul/nsLeafBoxFrame.h
+++ b/layout/xul/nsLeafBoxFrame.h
@@ -66,17 +66,18 @@ class nsLeafBoxFrame : public nsLeafFram
 
   virtual bool ComputesOwnOverflowArea() override { return false; }
 
  protected:
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aState) override;
 
   virtual nscoord GetIntrinsicISize() override;
 
-  explicit nsLeafBoxFrame(ComputedStyle* aStyle, ClassID aID = kClassID)
-      : nsLeafFrame(aStyle, aID) {}
+  explicit nsLeafBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                          ClassID aID = kClassID)
+      : nsLeafFrame(aStyle, aPresContext, aID) {}
 
  private:
   void UpdateMouseThrough();
 
 };  // class nsLeafBoxFrame
 
 #endif /* nsLeafBoxFrame_h___ */
--- a/layout/xul/nsMenuBarFrame.cpp
+++ b/layout/xul/nsMenuBarFrame.cpp
@@ -33,30 +33,31 @@ using namespace mozilla;
 using mozilla::dom::KeyboardEvent;
 
 //
 // NS_NewMenuBarFrame
 //
 // Wrapper for creating a new menu Bar container
 //
 nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsMenuBarFrame(aStyle);
+  return new (aPresShell) nsMenuBarFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMenuBarFrame)
 
 NS_QUERYFRAME_HEAD(nsMenuBarFrame)
   NS_QUERYFRAME_ENTRY(nsMenuBarFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
 //
 // nsMenuBarFrame cntr
 //
-nsMenuBarFrame::nsMenuBarFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID),
+nsMenuBarFrame::nsMenuBarFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID),
       mStayActive(false),
       mIsActive(false),
       mActiveByKeyboard(false),
       mCurrentMenu(nullptr) {}  // cntr
 
 void nsMenuBarFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                           nsIFrame* aPrevInFlow) {
   nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
--- a/layout/xul/nsMenuBarFrame.h
+++ b/layout/xul/nsMenuBarFrame.h
@@ -30,17 +30,17 @@ class KeyboardEvent;
 nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell,
                              mozilla::ComputedStyle* aStyle);
 
 class nsMenuBarFrame final : public nsBoxFrame, public nsMenuParent {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsMenuBarFrame)
 
-  explicit nsMenuBarFrame(ComputedStyle* aStyle);
+  explicit nsMenuBarFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   // nsMenuParent interface
   virtual nsMenuFrame* GetCurrentMenuItem() override;
   NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) override;
   virtual void CurrentMenuIsBeingDestroyed() override;
   NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem,
                             bool aFromKey) override;
 
--- a/layout/xul/nsMenuFrame.cpp
+++ b/layout/xul/nsMenuFrame.cpp
@@ -137,35 +137,37 @@ class nsMenuAttributeChangedEvent : publ
 };
 
 //
 // NS_NewMenuFrame and NS_NewMenuItemFrame
 //
 // Wrappers for creating a new menu popup container
 //
 nsIFrame* NS_NewMenuFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  nsMenuFrame* it = new (aPresShell) nsMenuFrame(aStyle);
+  nsMenuFrame* it =
+      new (aPresShell) nsMenuFrame(aStyle, aPresShell->GetPresContext());
   it->SetIsMenu(true);
   return it;
 }
 
 nsIFrame* NS_NewMenuItemFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  nsMenuFrame* it = new (aPresShell) nsMenuFrame(aStyle);
+  nsMenuFrame* it =
+      new (aPresShell) nsMenuFrame(aStyle, aPresShell->GetPresContext());
   it->SetIsMenu(false);
   return it;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMenuFrame)
 
 NS_QUERYFRAME_HEAD(nsMenuFrame)
   NS_QUERYFRAME_ENTRY(nsMenuFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
-nsMenuFrame::nsMenuFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID),
+nsMenuFrame::nsMenuFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID),
       mIsMenu(false),
       mChecked(false),
       mIgnoreAccelTextChange(false),
       mReflowCallbackPosted(false),
       mType(eMenuType_Normal),
       mBlinkState(0) {}
 
 nsMenuParent* nsMenuFrame::GetMenuParent() const {
--- a/layout/xul/nsMenuFrame.h
+++ b/layout/xul/nsMenuFrame.h
@@ -72,17 +72,17 @@ class nsMenuTimerMediator final : public
   ~nsMenuTimerMediator();
 
   // Pointer to the wrapped frame.
   nsMenuFrame* mFrame;
 };
 
 class nsMenuFrame final : public nsBoxFrame, public nsIReflowCallback {
  public:
-  explicit nsMenuFrame(ComputedStyle* aStyle);
+  explicit nsMenuFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsMenuFrame)
 
   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
   virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
 
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -74,30 +74,32 @@ const char kPrefIncrementalSearchTimeout
     "ui.menu.incremental_search.timeout";
 
 // NS_NewMenuPopupFrame
 //
 // Wrapper for creating a new menu popup container
 //
 nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsMenuPopupFrame(aStyle);
+  return new (aPresShell)
+      nsMenuPopupFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsMenuPopupFrame)
 
 NS_QUERYFRAME_HEAD(nsMenuPopupFrame)
   NS_QUERYFRAME_ENTRY(nsMenuPopupFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
 //
 // nsMenuPopupFrame ctor
 //
-nsMenuPopupFrame::nsMenuPopupFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID),
+nsMenuPopupFrame::nsMenuPopupFrame(ComputedStyle* aStyle,
+                                   nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID),
       mCurrentMenu(nullptr),
       mView(nullptr),
       mPrefSize(-1, -1),
       mXPos(0),
       mYPos(0),
       mAlignmentOffset(0),
       mLastClientOffset(0, 0),
       mPopupType(ePopupTypePanel),
--- a/layout/xul/nsMenuPopupFrame.h
+++ b/layout/xul/nsMenuPopupFrame.h
@@ -168,17 +168,17 @@ class nsXULPopupShownEvent final : publi
 
 class nsMenuPopupFrame final : public nsBoxFrame,
                                public nsMenuParent,
                                public nsIReflowCallback {
  public:
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsMenuPopupFrame)
 
-  explicit nsMenuPopupFrame(ComputedStyle* aStyle);
+  explicit nsMenuPopupFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   // nsMenuParent interface
   virtual nsMenuFrame* GetCurrentMenuItem() override;
   NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) override;
   virtual void CurrentMenuIsBeingDestroyed() override;
   NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem,
                             bool aFromKey) override;
 
--- a/layout/xul/nsPopupSetFrame.cpp
+++ b/layout/xul/nsPopupSetFrame.cpp
@@ -13,17 +13,17 @@
 #include "nsBoxLayoutState.h"
 #include "nsIScrollableFrame.h"
 #include "nsIPopupContainer.h"
 #include "nsMenuPopupFrame.h"
 
 typedef mozilla::ComputedStyle ComputedStyle;
 
 nsIFrame* NS_NewPopupSetFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsPopupSetFrame(aStyle);
+  return new (aPresShell) nsPopupSetFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPopupSetFrame)
 
 void nsPopupSetFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
                            nsIFrame* aPrevInFlow) {
   nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
 
--- a/layout/xul/nsPopupSetFrame.h
+++ b/layout/xul/nsPopupSetFrame.h
@@ -13,18 +13,18 @@
 
 nsIFrame* NS_NewPopupSetFrame(nsIPresShell* aPresShell,
                               mozilla::ComputedStyle* aStyle);
 
 class nsPopupSetFrame final : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsPopupSetFrame)
 
-  explicit nsPopupSetFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID) {}
+  explicit nsPopupSetFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID) {}
 
   ~nsPopupSetFrame() {}
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   virtual void SetInitialChildList(ChildListID aListID,
                                    nsFrameList& aChildList) override;
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -33,23 +33,24 @@
 using namespace mozilla;
 
 //
 // NS_NewResizerFrame
 //
 // Creates a new Resizer frame and returns it
 //
 nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsResizerFrame(aStyle);
+  return new (aPresShell) nsResizerFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsResizerFrame)
 
-nsResizerFrame::nsResizerFrame(ComputedStyle* aStyle)
-    : nsTitleBarFrame(aStyle, kClassID) {}
+nsResizerFrame::nsResizerFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+    : nsTitleBarFrame(aStyle, aPresContext, kClassID) {}
 
 nsresult nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
                                      WidgetGUIEvent* aEvent,
                                      nsEventStatus* aEventStatus) {
   NS_ENSURE_ARG_POINTER(aEventStatus);
   if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
     return NS_OK;
   }
--- a/layout/xul/nsResizerFrame.h
+++ b/layout/xul/nsResizerFrame.h
@@ -23,17 +23,17 @@ class nsResizerFrame final : public nsTi
   };
 
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsResizerFrame)
 
   friend nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell,
                                       ComputedStyle* aStyle);
 
-  explicit nsResizerFrame(ComputedStyle* aStyle);
+  explicit nsResizerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   virtual nsresult HandleEvent(nsPresContext* aPresContext,
                                mozilla::WidgetGUIEvent* aEvent,
                                nsEventStatus* aEventStatus) override;
 
   virtual void MouseClicked(mozilla::WidgetMouseEvent* aEvent) override;
 
  protected:
--- a/layout/xul/nsRootBoxFrame.cpp
+++ b/layout/xul/nsRootBoxFrame.cpp
@@ -49,17 +49,17 @@ nsIPopupContainer* nsIPopupContainer::Ge
   return rootBox;
 }
 
 class nsRootBoxFrame final : public nsBoxFrame, public nsIPopupContainer {
  public:
   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
                                   ComputedStyle* aStyle);
 
-  explicit nsRootBoxFrame(ComputedStyle* aStyle);
+  explicit nsRootBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsRootBoxFrame)
 
   virtual nsPopupSetFrame* GetPopupSetFrame() override;
   virtual void SetPopupSetFrame(nsPopupSetFrame* aPopupSet) override;
   virtual Element* GetDefaultTooltip() override;
   virtual void SetDefaultTooltip(Element* aTooltip) override;
@@ -96,23 +96,24 @@ class nsRootBoxFrame final : public nsBo
  protected:
   Element* mDefaultTooltip;
 };
 
 //----------------------------------------------------------------------
 
 nsContainerFrame* NS_NewRootBoxFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsRootBoxFrame(aStyle);
+  return new (aPresShell) nsRootBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsRootBoxFrame)
 
-nsRootBoxFrame::nsRootBoxFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID, true),
+nsRootBoxFrame::nsRootBoxFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID, true),
       mPopupSetFrame(nullptr),
       mDefaultTooltip(nullptr) {
   nsCOMPtr<nsBoxLayout> layout;
   NS_NewStackLayout(layout);
   SetXULLayoutManager(layout);
 }
 
 void nsRootBoxFrame::AppendFrames(ChildListID aListID,
--- a/layout/xul/nsScrollbarButtonFrame.cpp
+++ b/layout/xul/nsScrollbarButtonFrame.cpp
@@ -29,17 +29,18 @@ using namespace mozilla;
 
 //
 // NS_NewToolbarFrame
 //
 // Creates a new Toolbar frame and returns it
 //
 nsIFrame* NS_NewScrollbarButtonFrame(nsIPresShell* aPresShell,
                                      ComputedStyle* aStyle) {
-  return new (aPresShell) nsScrollbarButtonFrame(aStyle);
+  return new (aPresShell)
+      nsScrollbarButtonFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsScrollbarButtonFrame)
 
 nsresult nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
                                              WidgetGUIEvent* aEvent,
                                              nsEventStatus* aEventStatus) {
   NS_ENSURE_ARG_POINTER(aEventStatus);
--- a/layout/xul/nsScrollbarButtonFrame.h
+++ b/layout/xul/nsScrollbarButtonFrame.h
@@ -18,18 +18,20 @@
 #include "nsButtonBoxFrame.h"
 #include "nsITimer.h"
 #include "nsRepeatService.h"
 
 class nsScrollbarButtonFrame final : public nsButtonBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsScrollbarButtonFrame)
 
-  explicit nsScrollbarButtonFrame(ComputedStyle* aStyle)
-      : nsButtonBoxFrame(aStyle, kClassID), mCursorOnThis(false) {}
+  explicit nsScrollbarButtonFrame(ComputedStyle* aStyle,
+                                  nsPresContext* aPresContext)
+      : nsButtonBoxFrame(aStyle, aPresContext, kClassID),
+        mCursorOnThis(false) {}
 
   // Overrides
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   friend nsIFrame* NS_NewScrollbarButtonFrame(nsIPresShell* aPresShell,
                                               ComputedStyle* aStyle);
 
--- a/layout/xul/nsScrollbarFrame.cpp
+++ b/layout/xul/nsScrollbarFrame.cpp
@@ -27,17 +27,18 @@ using namespace mozilla;
 
 //
 // NS_NewScrollbarFrame
 //
 // Creates a new scrollbar frame and returns it
 //
 nsIFrame* NS_NewScrollbarFrame(nsIPresShell* aPresShell,
                                ComputedStyle* aStyle) {
-  return new (aPresShell) nsScrollbarFrame(aStyle);
+  return new (aPresShell)
+      nsScrollbarFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsScrollbarFrame)
 
 NS_QUERYFRAME_HEAD(nsScrollbarFrame)
   NS_QUERYFRAME_ENTRY(nsScrollbarFrame)
   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
--- a/layout/xul/nsScrollbarFrame.h
+++ b/layout/xul/nsScrollbarFrame.h
@@ -18,18 +18,18 @@
 class nsIScrollbarMediator;
 
 nsIFrame* NS_NewScrollbarFrame(nsIPresShell* aPresShell,
                                mozilla::ComputedStyle* aStyle);
 
 class nsScrollbarFrame final : public nsBoxFrame,
                                public nsIAnonymousContentCreator {
  public:
-  explicit nsScrollbarFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID),
+  explicit nsScrollbarFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID),
         mIncrement(0),
         mSmoothScroll(false),
         mScrollbarMediator(nullptr),
         mUpTopButton(nullptr),
         mDownTopButton(nullptr),
         mSlider(nullptr),
         mThumb(nullptr),
         mUpBottomButton(nullptr),
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -63,27 +63,27 @@ int32_t nsSliderFrame::gSnapMultiplier;
 #undef DEBUG_SLIDER
 
 static already_AddRefed<nsIContent> GetContentOfBox(nsIFrame* aBox) {
   nsCOMPtr<nsIContent> content = aBox->GetContent();
   return content.forget();
 }
 
 nsIFrame* NS_NewSliderFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSliderFrame(aStyle);
+  return new (aPresShell) nsSliderFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSliderFrame)
 
 NS_QUERYFRAME_HEAD(nsSliderFrame)
   NS_QUERYFRAME_ENTRY(nsSliderFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
-nsSliderFrame::nsSliderFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID),
+nsSliderFrame::nsSliderFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID),
       mRatio(0.0f),
       mDragStart(0),
       mThumbStart(0),
       mCurPos(0),
       mChange(0),
       mDragFinished(true),
       mUserChanged(false),
       mScrollingWithAPZ(false),
--- a/layout/xul/nsSliderFrame.h
+++ b/layout/xul/nsSliderFrame.h
@@ -39,17 +39,17 @@ class nsSliderMediator final : public ns
 
 class nsSliderFrame final : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSliderFrame)
   NS_DECL_QUERYFRAME
 
   friend class nsSliderMediator;
 
-  explicit nsSliderFrame(ComputedStyle* aStyle);
+  explicit nsSliderFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual ~nsSliderFrame();
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("SliderFrame"), aResult);
   }
 #endif
 
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -191,23 +191,24 @@ nsSplitterFrameInner::State nsSplitterFr
 }
 
 //
 // NS_NewSplitterFrame
 //
 // Creates a new Toolbar frame and returns it
 //
 nsIFrame* NS_NewSplitterFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsSplitterFrame(aStyle);
+  return new (aPresShell) nsSplitterFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSplitterFrame)
 
-nsSplitterFrame::nsSplitterFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID), mInner(0) {}
+nsSplitterFrame::nsSplitterFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID), mInner(0) {}
 
 void nsSplitterFrame::DestroyFrom(nsIFrame* aDestructRoot,
                                   PostDestroyData& aPostDestroyData) {
   if (mInner) {
     mInner->RemoveListener();
     mInner->Disconnect();
     mInner->Release();
     mInner = nullptr;
--- a/layout/xul/nsSplitterFrame.h
+++ b/layout/xul/nsSplitterFrame.h
@@ -18,17 +18,17 @@ class nsSplitterFrameInner;
 
 nsIFrame* NS_NewSplitterFrame(nsIPresShell* aPresShell,
                               mozilla::ComputedStyle* aStyle);
 
 class nsSplitterFrame final : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsSplitterFrame)
 
-  explicit nsSplitterFrame(ComputedStyle* aStyle);
+  explicit nsSplitterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override {
     return MakeFrameName(NS_LITERAL_STRING("SplitterFrame"), aResult);
   }
 #endif
--- a/layout/xul/nsStackFrame.cpp
+++ b/layout/xul/nsStackFrame.cpp
@@ -20,23 +20,23 @@
 #include "nsCSSRendering.h"
 #include "nsBoxLayoutState.h"
 #include "nsStackLayout.h"
 #include "nsDisplayList.h"
 
 using namespace mozilla;
 
 nsIFrame* NS_NewStackFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsStackFrame(aStyle);
+  return new (aPresShell) nsStackFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsStackFrame)
 
-nsStackFrame::nsStackFrame(ComputedStyle* aStyle)
-    : nsBoxFrame(aStyle, kClassID) {
+nsStackFrame::nsStackFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+    : nsBoxFrame(aStyle, aPresContext, kClassID) {
   nsCOMPtr<nsBoxLayout> layout;
   NS_NewStackLayout(layout);
   SetXULLayoutManager(layout);
 }
 
 // REVIEW: The old code put everything in the background layer. To be more
 // consistent with the way other frames work, I'm putting everything in the
 // Content() (i.e., foreground) layer (see nsFrame::BuildDisplayListForChild,
--- a/layout/xul/nsStackFrame.h
+++ b/layout/xul/nsStackFrame.h
@@ -30,12 +30,12 @@ class nsStackFrame final : public nsBoxF
     return MakeFrameName(NS_LITERAL_STRING("Stack"), aResult);
   }
 #endif
 
   virtual void BuildDisplayListForChildren(
       nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override;
 
  protected:
-  explicit nsStackFrame(ComputedStyle* aStyle);
+  explicit nsStackFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 };  // class nsStackFrame
 
 #endif
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -54,17 +54,17 @@ class nsAccessKeyInfo {
 };
 
 bool nsTextBoxFrame::gAlwaysAppendAccessKey = false;
 bool nsTextBoxFrame::gAccessKeyPrefInitialized = false;
 bool nsTextBoxFrame::gInsertSeparatorBeforeAccessKey = false;
 bool nsTextBoxFrame::gInsertSeparatorPrefInitialized = false;
 
 nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsTextBoxFrame(aStyle);
+  return new (aPresShell) nsTextBoxFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTextBoxFrame)
 
 NS_QUERYFRAME_HEAD(nsTextBoxFrame)
   NS_QUERYFRAME_ENTRY(nsTextBoxFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame)
 
@@ -87,18 +87,19 @@ nsresult nsTextBoxFrame::AttributeChange
   // If the accesskey changed, register for the new value
   // The old value has been unregistered in nsXULElement::SetAttr
   if (aAttribute == nsGkAtoms::accesskey || aAttribute == nsGkAtoms::control)
     RegUnregAccessKey(true);
 
   return NS_OK;
 }
 
-nsTextBoxFrame::nsTextBoxFrame(ComputedStyle* aStyle)
-    : nsLeafBoxFrame(aStyle, kClassID),
+nsTextBoxFrame::nsTextBoxFrame(ComputedStyle* aStyle,
+                               nsPresContext* aPresContext)
+    : nsLeafBoxFrame(aStyle, aPresContext, kClassID),
       mAccessKeyInfo(nullptr),
       mCropType(CropRight),
       mAscent(0),
       mNeedsReflowCallback(false) {
   MarkIntrinsicISizesDirty();
 }
 
 nsTextBoxFrame::~nsTextBoxFrame() { delete mAccessKeyInfo; }
--- a/layout/xul/nsTextBoxFrame.h
+++ b/layout/xul/nsTextBoxFrame.h
@@ -78,17 +78,17 @@ class nsTextBoxFrame final : public nsLe
                    const nsRect& aRect);
 
   void CalculateUnderline(DrawTarget* aDrawTarget, nsFontMetrics& aFontMetrics);
 
   void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);
 
   void CalcDrawRect(gfxContext& aRenderingContext);
 
-  explicit nsTextBoxFrame(ComputedStyle* aStyle);
+  explicit nsTextBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   nscoord CalculateTitleForWidth(gfxContext& aRenderingContext, nscoord aWidth);
 
   void GetTextSize(gfxContext& aRenderingContext, const nsString& aString,
                    nsSize& aSize, nscoord& aAscent);
 
   nsresult RegUnregAccessKey(bool aDoReg);
 
--- a/layout/xul/nsTitleBarFrame.cpp
+++ b/layout/xul/nsTitleBarFrame.cpp
@@ -22,23 +22,24 @@
 using namespace mozilla;
 
 //
 // NS_NewTitleBarFrame
 //
 // Creates a new TitleBar frame and returns it
 //
 nsIFrame* NS_NewTitleBarFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsTitleBarFrame(aStyle);
+  return new (aPresShell) nsTitleBarFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTitleBarFrame)
 
-nsTitleBarFrame::nsTitleBarFrame(ComputedStyle* aStyle, ClassID aID)
-    : nsBoxFrame(aStyle, aID, false) {
+nsTitleBarFrame::nsTitleBarFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext, ClassID aID)
+    : nsBoxFrame(aStyle, aPresContext, aID, false) {
   mTrackingMouseMove = false;
   UpdateMouseThrough();
 }
 
 void nsTitleBarFrame::BuildDisplayListForChildren(
     nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
   // override, since we don't want children to get events
   if (aBuilder->IsForEventDelivery()) {
--- a/layout/xul/nsTitleBarFrame.h
+++ b/layout/xul/nsTitleBarFrame.h
@@ -12,17 +12,18 @@
 
 class nsTitleBarFrame : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsTitleBarFrame)
 
   friend nsIFrame* NS_NewTitleBarFrame(nsIPresShell* aPresShell,
                                        ComputedStyle* aStyle);
 
-  explicit nsTitleBarFrame(ComputedStyle* aStyle, ClassID = kClassID);
+  explicit nsTitleBarFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
+                           ClassID = kClassID);
 
   virtual void BuildDisplayListForChildren(
       nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override;
 
   virtual nsresult HandleEvent(nsPresContext* aPresContext,
                                mozilla::WidgetGUIEvent* aEvent,
                                nsEventStatus* aEventStatus) override;
 
--- a/layout/xul/nsXULLabelFrame.cpp
+++ b/layout/xul/nsXULLabelFrame.cpp
@@ -9,17 +9,18 @@
 #include "mozilla/EventStateManager.h"
 #include "nsXULLabelFrame.h"
 #include "nsHTMLParts.h"
 #include "nsNameSpaceManager.h"
 
 using namespace mozilla;
 
 nsIFrame* NS_NewXULLabelFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aStyle);
+  nsXULLabelFrame* it =
+      new (aPresShell) nsXULLabelFrame(aStyle, aPresShell->GetPresContext());
   it->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS);
   return it;
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsXULLabelFrame)
 
 // If you make changes to this function, check its counterparts
 // in nsBoxFrame and nsTextBoxFrame
--- a/layout/xul/nsXULLabelFrame.h
+++ b/layout/xul/nsXULLabelFrame.h
@@ -29,18 +29,18 @@ class nsXULLabelFrame final : public nsB
   virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
                                     int32_t aModType) override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
  protected:
-  explicit nsXULLabelFrame(ComputedStyle* aStyle)
-      : nsBlockFrame(aStyle, kClassID) {}
+  explicit nsXULLabelFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBlockFrame(aStyle, aPresContext, kClassID) {}
 
   nsresult RegUnregAccessKey(bool aDoReg);
 };
 
 nsIFrame* NS_NewXULLabelFrame(nsIPresShell* aPresShell,
                               mozilla::ComputedStyle* aStyle);
 
 #endif /* !defined(nsXULLabelFrame_h_) */
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -91,29 +91,30 @@ void nsTreeBodyFrame::CancelImageRequest
 }
 
 //
 // NS_NewTreeFrame
 //
 // Creates a new tree frame
 //
 nsIFrame* NS_NewTreeBodyFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsTreeBodyFrame(aStyle);
+  return new (aPresShell) nsTreeBodyFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTreeBodyFrame)
 
 NS_QUERYFRAME_HEAD(nsTreeBodyFrame)
   NS_QUERYFRAME_ENTRY(nsIScrollbarMediator)
   NS_QUERYFRAME_ENTRY(nsTreeBodyFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame)
 
 // Constructor
-nsTreeBodyFrame::nsTreeBodyFrame(ComputedStyle* aStyle)
-    : nsLeafBoxFrame(aStyle, kClassID),
+nsTreeBodyFrame::nsTreeBodyFrame(ComputedStyle* aStyle,
+                                 nsPresContext* aPresContext)
+    : nsLeafBoxFrame(aStyle, aPresContext, kClassID),
       mSlots(nullptr),
       mImageCache(),
       mTopRowIndex(0),
       mPageLength(0),
       mHorzPosition(0),
       mOriginalHorzWidth(-1),
       mHorzWidth(0),
       mAdjustWidth(0),
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -49,17 +49,17 @@ struct nsTreeImageCacheEntry {
 // The actual frame that paints the cells and rows.
 class nsTreeBodyFrame final : public nsLeafBoxFrame,
                               public nsIScrollbarMediator,
                               public nsIReflowCallback {
   typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
   typedef mozilla::image::ImgDrawResult ImgDrawResult;
 
  public:
-  explicit nsTreeBodyFrame(ComputedStyle* aStyle);
+  explicit nsTreeBodyFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
   ~nsTreeBodyFrame();
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsTreeBodyFrame)
 
   // Callback handler methods for refresh driver based animations.
   // Calls to these functions are forwarded from nsTreeImageListener. These
   // mirror how nsImageFrame works.
--- a/layout/xul/tree/nsTreeColFrame.cpp
+++ b/layout/xul/tree/nsTreeColFrame.cpp
@@ -19,17 +19,17 @@
 using namespace mozilla;
 
 //
 // NS_NewTreeColFrame
 //
 // Creates a new col frame
 //
 nsIFrame* NS_NewTreeColFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
-  return new (aPresShell) nsTreeColFrame(aStyle);
+  return new (aPresShell) nsTreeColFrame(aStyle, aPresShell->GetPresContext());
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsTreeColFrame)
 
 // Destructor
 nsTreeColFrame::~nsTreeColFrame() {}
 
 void nsTreeColFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
--- a/layout/xul/tree/nsTreeColFrame.h
+++ b/layout/xul/tree/nsTreeColFrame.h
@@ -16,18 +16,18 @@ class XULTreeElement;
 
 nsIFrame* NS_NewTreeColFrame(nsIPresShell* aPresShell,
                              mozilla::ComputedStyle* aStyle);
 
 class nsTreeColFrame final : public nsBoxFrame {
  public:
   NS_DECL_FRAMEARENA_HELPERS(nsTreeColFrame)
 
-  explicit nsTreeColFrame(ComputedStyle* aStyle)
-      : nsBoxFrame(aStyle, kClassID) {}
+  explicit nsTreeColFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
+      : nsBoxFrame(aStyle, aPresContext, kClassID) {}
 
   virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                     nsIFrame* aPrevInFlow) override;
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot,
                            PostDestroyData& aPostDestroyData) override;
 
   virtual void BuildDisplayListForChildren(