Bug 1251995 part 4 - Use struct to pass params for nsTextFrame::DrawText* functions. r=jfkthame
authorXidorn Quan <quanxunzhen@gmail.com>
Tue, 08 Mar 2016 15:56:18 +0800
changeset 287151 788178d64bf45b07070fffc96ea9d1640363f7a3
parent 287150 8dcad93e1045080c6f2476e296e8f52c1549cf7d
child 287152 b5a5660267aeb4254d0dd9cc15ff2d1980790e4e
push id73077
push userxquan@mozilla.com
push dateTue, 08 Mar 2016 07:57:02 +0000
treeherdermozilla-inbound@ffce50b96ca9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1251995
milestone47.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 1251995 part 4 - Use struct to pass params for nsTextFrame::DrawText* functions. r=jfkthame MozReview-Commit-ID: LYshkPDrqYl
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5910,24 +5910,29 @@ nsTextFrame::PaintOneShadow(Range aRange
   aCtx->Save();
   aCtx->NewPath();
   aCtx->SetColor(Color::FromABGR(shadowColor));
 
   // Draw the text onto our alpha-only surface to capture the alpha values.
   // Remember that the box blur context has a device offset on it, so we don't need to
   // translate any coordinates to fit on the surface.
   gfxFloat advanceWidth;
-  gfxRect dirtyRect(aDirtyRect.x, aDirtyRect.y,
-                    aDirtyRect.width, aDirtyRect.height);
-  DrawText(shadowContext, dirtyRect, aFramePt + shadowOffset,
-           aTextBaselinePt + shadowOffset, aRange, *aProvider,
-           nsTextPaintStyle(this),
-           aCtx == shadowContext ? shadowColor : NS_RGB(0, 0, 0), aClipEdges,
-           advanceWidth, (GetStateBits() & TEXT_HYPHEN_BREAK) != 0,
-           decorationOverrideColor);
+  nsTextPaintStyle textPaintStyle(this);
+  DrawTextParams params(shadowContext);
+  params.advanceWidth = &advanceWidth;
+  params.dirtyRect = gfxRect(aDirtyRect.x, aDirtyRect.y,
+                             aDirtyRect.width, aDirtyRect.height);
+  params.framePt = aFramePt + shadowOffset;
+  params.provider = aProvider;
+  params.textStyle = &textPaintStyle;
+  params.textColor = aCtx == shadowContext ? shadowColor : NS_RGB(0, 0, 0);
+  params.clipEdges = &aClipEdges;
+  params.drawSoftHyphen = (GetStateBits() & TEXT_HYPHEN_BREAK) != 0;
+  params.decorationOverrideColor = decorationOverrideColor;
+  DrawText(aRange, aTextBaselinePt + shadowOffset, params);
 
   contextBoxBlur.DoPaint();
   aCtx->Restore();
 }
 
 // Paints selection backgrounds and text in the correct colors. Also computes
 // aAllTypes, the union of all selection types that are applying to this text.
 bool
@@ -6021,16 +6026,26 @@ nsTextFrame::PaintTextWithSelectionColor
         }
         PaintSelectionBackground(*aCtx->GetDrawTarget(), background, dirtyRect,
                                  AppUnitGfxRectToDevRect(bgRect, appUnitsPerDevPixel),
                                  aCallbacks);
       }
       iterator.UpdateWithAdvance(advance);
     }
   }
+
+  gfxFloat advance;
+  DrawTextParams params(aCtx);
+  params.dirtyRect = aDirtyRect;
+  params.framePt = aFramePt;
+  params.provider = &aProvider;
+  params.textStyle = &aTextPaintStyle;
+  params.clipEdges = &aClipEdges;
+  params.advanceWidth = &advance;
+  params.callbacks = aCallbacks;
   
   // Draw text
   const nsStyleText* textStyle = StyleText();
   nsRect dirtyRect(aDirtyRect.x, aDirtyRect.y,
                    aDirtyRect.width, aDirtyRect.height);
   SelectionIterator iterator(prevailingSelections, aContentRange,
                              aProvider, mTextRun, startIOffset);
   while (iterator.GetNextSegment(&iOffset, &range, &hyphenWidth,
@@ -6052,20 +6067,19 @@ nsTextFrame::PaintTextWithSelectionColor
         startEdge -= hyphenWidth +
           mTextRun->GetAdvanceWidth(range, &aProvider);
       }
       PaintShadows(shadow, range, dirtyRect, aFramePt, textBaselinePt,
           startEdge, aProvider, foreground, aClipEdges, aCtx);
     }
 
     // Draw text segment
-    gfxFloat advance;
-    DrawText(aCtx, aDirtyRect, aFramePt, textBaselinePt,
-             range, aProvider, aTextPaintStyle, foreground, aClipEdges,
-             advance, hyphenWidth > 0, nullptr, nullptr, aCallbacks);
+    params.textColor = foreground;
+    params.drawSoftHyphen = hyphenWidth > 0;
+    DrawText(range, textBaselinePt, params);
     advance += hyphenWidth;
     iterator.UpdateWithAdvance(advance);
   }
   return true;
 }
 
 void
 nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
@@ -6212,17 +6226,17 @@ nsTextFrame::PaintTextWithSelection(gfxC
   return true;
 }
 
 void
 nsTextFrame::DrawEmphasisMarks(gfxContext* aContext, WritingMode aWM,
                                const gfxPoint& aTextBaselinePt,
                                Range aRange,
                                const nscolor* aDecorationOverrideColor,
-                               PropertyProvider& aProvider)
+                               PropertyProvider* aProvider)
 {
   const auto info = Properties().Get(EmphasisMarkProperty());
   if (!info) {
     return;
   }
 
   nscolor color = aDecorationOverrideColor ? *aDecorationOverrideColor :
     nsLayoutUtils::GetColor(this, eCSSProperty_text_emphasis_color);
@@ -6233,17 +6247,17 @@ nsTextFrame::DrawEmphasisMarks(gfxContex
   } else {
     if (aWM.IsVerticalRL()) {
       pt.x -= info->baselineOffset;
     } else {
       pt.x += info->baselineOffset;
     }
   }
   mTextRun->DrawEmphasisMarks(aContext, info->textRun, info->advance,
-                              pt, aRange, &aProvider);
+                              pt, aRange, aProvider);
 }
 
 nscolor
 nsTextFrame::GetCaretColorAt(int32_t aOffset)
 {
   NS_PRECONDITION(aOffset >= 0, "aOffset must be positive");
 
   nscolor result = nsFrame::GetCaretColorAt(aOffset);
@@ -6564,139 +6578,131 @@ nsTextFrame::PaintText(nsRenderingContex
   if (!aCallbacks) {
     const nsStyleText* textStyle = StyleText();
     PaintShadows(
         textStyle->mTextShadow, range, aDirtyRect, framePt, textBaselinePt,
         snappedStartEdge, provider, foregroundColor, clipEdges, ctx);
   }
 
   gfxFloat advanceWidth;
-  DrawText(ctx, dirtyRect, framePt, textBaselinePt, range, provider,
-           textPaintStyle, foregroundColor, clipEdges, advanceWidth,
-           (GetStateBits() & TEXT_HYPHEN_BREAK) != 0,
-           nullptr, aContextPaint, aCallbacks);
+  DrawTextParams params(ctx);
+  params.dirtyRect = dirtyRect;
+  params.framePt = framePt;
+  params.provider = &provider;
+  params.advanceWidth = &advanceWidth;
+  params.textStyle = &textPaintStyle;
+  params.textColor = foregroundColor;
+  params.clipEdges = &clipEdges;
+  params.drawSoftHyphen = (GetStateBits() & TEXT_HYPHEN_BREAK) != 0;
+  params.contextPaint = aContextPaint;
+  params.callbacks = aCallbacks;
+  DrawText(range, textBaselinePt, params);
 }
 
 static void
 DrawTextRun(gfxTextRun* aTextRun,
-            gfxContext* const aCtx,
             const gfxPoint& aTextBaselinePt,
             gfxTextRun::Range aRange,
-            PropertyProvider* aProvider,
-            nscolor aTextColor,
-            gfxFloat* aAdvanceWidth,
-            gfxTextContextPaint* aContextPaint,
-            nsTextFrame::DrawPathCallbacks* aCallbacks)
-{
-  gfxTextRun::DrawParams params(aCtx);
-  params.drawMode = aCallbacks ? DrawMode::GLYPH_PATH
-                               : DrawMode::GLYPH_FILL;
-  params.provider = aProvider;
-  params.advanceWidth = aAdvanceWidth;
-  params.contextPaint = aContextPaint;
-  params.callbacks = aCallbacks;
-  if (aCallbacks) {
-    aCallbacks->NotifyBeforeText(aTextColor);
+            const nsTextFrame::DrawTextRunParams& aParams)
+{
+  gfxTextRun::DrawParams params(aParams.context);
+  params.drawMode = aParams.callbacks ? DrawMode::GLYPH_PATH
+                                      : DrawMode::GLYPH_FILL;
+  params.provider = aParams.provider;
+  params.advanceWidth = aParams.advanceWidth;
+  params.contextPaint = aParams.contextPaint;
+  params.callbacks = aParams.callbacks;
+  if (aParams.callbacks) {
+    aParams.callbacks->NotifyBeforeText(aParams.textColor);
     aTextRun->Draw(aRange, aTextBaselinePt, params);
-    aCallbacks->NotifyAfterText();
+    aParams.callbacks->NotifyAfterText();
   } else {
-    aCtx->SetColor(Color::FromABGR(aTextColor));
+    aParams.context->SetColor(Color::FromABGR(aParams.textColor));
     aTextRun->Draw(aRange, aTextBaselinePt, params);
   }
 }
 
 void
-nsTextFrame::DrawTextRun(gfxContext* const aCtx,
-                         const gfxPoint& aTextBaselinePt,
-                         Range aRange,
-                         PropertyProvider& aProvider,
-                         nscolor aTextColor,
-                         gfxFloat& aAdvanceWidth,
-                         bool aDrawSoftHyphen,
-                         gfxTextContextPaint* aContextPaint,
-                         nsTextFrame::DrawPathCallbacks* aCallbacks)
-{
-  ::DrawTextRun(mTextRun, aCtx, aTextBaselinePt, aRange, &aProvider,
-                aTextColor, &aAdvanceWidth, aContextPaint, aCallbacks);
-
-  if (aDrawSoftHyphen) {
+nsTextFrame::DrawTextRun(Range aRange, const gfxPoint& aTextBaselinePt,
+                         const DrawTextRunParams& aParams)
+{
+  MOZ_ASSERT(aParams.advanceWidth, "Must provide advanceWidth");
+  ::DrawTextRun(mTextRun, aTextBaselinePt, aRange, aParams);
+
+  if (aParams.drawSoftHyphen) {
     // Don't use ctx as the context, because we need a reference context here,
     // ctx may be transformed.
     nsAutoPtr<gfxTextRun> hyphenTextRun(GetHyphenTextRun(mTextRun, nullptr, this));
     if (hyphenTextRun.get()) {
       // For right-to-left text runs, the soft-hyphen is positioned at the left
       // of the text, minus its own width
-      gfxFloat hyphenBaselineX = aTextBaselinePt.x + mTextRun->GetDirection() * aAdvanceWidth -
+      gfxFloat hyphenBaselineX = aTextBaselinePt.x +
+        mTextRun->GetDirection() * (*aParams.advanceWidth) -
         (mTextRun->IsRightToLeft() ? hyphenTextRun->GetAdvanceWidth() : 0);
-      ::DrawTextRun(hyphenTextRun.get(), aCtx,
+      DrawTextRunParams params = aParams;
+      params.provider = nullptr;
+      params.advanceWidth = nullptr;
+      ::DrawTextRun(hyphenTextRun.get(),
                     gfxPoint(hyphenBaselineX, aTextBaselinePt.y),
-                    Range(hyphenTextRun.get()),
-                    nullptr, aTextColor, nullptr, aContextPaint, aCallbacks);
+                    Range(hyphenTextRun.get()), params);
     }
   }
 }
 
 void
-nsTextFrame::DrawTextRunAndDecorations(
-    gfxContext* const aCtx, const gfxRect& aDirtyRect,
-    const gfxPoint& aFramePt, const gfxPoint& aTextBaselinePt,
-    Range aRange,
-    PropertyProvider& aProvider,
-    const nsTextPaintStyle& aTextStyle,
-    nscolor aTextColor,
-    const nsCharClipDisplayItem::ClipEdges& aClipEdges,
-    gfxFloat& aAdvanceWidth,
-    bool aDrawSoftHyphen,
-    const TextDecorations& aDecorations,
-    const nscolor* const aDecorationOverrideColor,
-    gfxTextContextPaint* aContextPaint,
-    nsTextFrame::DrawPathCallbacks* aCallbacks)
-{
-    const gfxFloat app = aTextStyle.PresContext()->AppUnitsPerDevPixel();
+nsTextFrame::DrawTextRunAndDecorations(Range aRange,
+                                       const gfxPoint& aTextBaselinePt,
+                                       const DrawTextParams& aParams,
+                                       const TextDecorations& aDecorations)
+{
+    const gfxFloat app =
+      aParams.textStyle->PresContext()->AppUnitsPerDevPixel();
     bool verticalRun = mTextRun->IsVertical();
     bool useVerticalMetrics = verticalRun && mTextRun->UseCenterBaseline();
 
     // XXX aFramePt is in AppUnits, shouldn't it be nsFloatPoint?
-    nscoord x = NSToCoordRound(aFramePt.x);
-    nscoord y = NSToCoordRound(aFramePt.y);
+    nscoord x = NSToCoordRound(aParams.framePt.x);
+    nscoord y = NSToCoordRound(aParams.framePt.y);
 
     // 'measure' here is textrun-relative, so for a horizontal run it's the
     // width, while for a vertical run it's the height of the decoration
     const nsSize frameSize = GetSize();
     nscoord measure = verticalRun ? frameSize.height : frameSize.width;
 
     if (verticalRun) {
-      aClipEdges.Intersect(&y, &measure);
+      aParams.clipEdges->Intersect(&y, &measure);
     } else {
-      aClipEdges.Intersect(&x, &measure);
+      aParams.clipEdges->Intersect(&x, &measure);
     }
 
     // decPt is the physical point where the decoration is to be drawn,
     // relative to the frame; one of its coordinates will be updated below.
     Point decPt(x / app, y / app);
     Float& bCoord = verticalRun ? decPt.x : decPt.y;
 
     // decSize is a textrun-relative size, so its 'width' field is actually
     // the run-relative measure, and 'height' will be the line thickness
     Size decSize(measure / app, 0);
     gfxFloat ascent = gfxFloat(mAscent) / app;
 
     // The starting edge of the frame in block direction
-    gfxFloat frameBStart = verticalRun ? aFramePt.x : aFramePt.y;
+    gfxFloat frameBStart = verticalRun ? aParams.framePt.x : aParams.framePt.y;
 
     // In vertical-rl mode, block coordinates are measured from the right,
     // so we need to adjust here.
     const WritingMode wm = GetWritingMode();
     if (wm.IsVerticalRL()) {
       frameBStart += frameSize.width;
       ascent = -ascent;
     }
 
-    gfxRect dirtyRect(aDirtyRect.x / app, aDirtyRect.y / app,
-                      aDirtyRect.Width() / app, aDirtyRect.Height() / app);
+    gfxRect dirtyRect(aParams.dirtyRect.x / app,
+                      aParams.dirtyRect.y / app,
+                      aParams.dirtyRect.Width() / app,
+                      aParams.dirtyRect.Height() / app);
 
     nscoord inflationMinFontSize =
       nsLayoutUtils::InflationMinFontSizeFor(this);
 
     // The decoration-line offsets need to be reversed for sideways-lr mode,
     // so we will multiply the values from metrics by this factor.
     gfxFloat decorationOffsetDir = mTextRun->IsSidewaysLeft() ? -1.0 : 1.0;
 
@@ -6711,21 +6717,21 @@ nsTextFrame::DrawTextRunAndDecorations(
         GetInflationForTextDecorations(dec.mFrame, inflationMinFontSize);
       const gfxFont::Metrics metrics =
         GetFirstFontMetrics(GetFontGroupForFrame(dec.mFrame, inflation),
                             useVerticalMetrics);
 
       decSize.height = metrics.underlineSize;
       bCoord = (frameBStart - dec.mBaselineOffset) / app;
 
-      PaintDecorationLine(aCtx, dirtyRect, dec.mColor,
-        aDecorationOverrideColor, decPt, 0.0, decSize, ascent,
+      PaintDecorationLine(aParams.context, dirtyRect, dec.mColor,
+        aParams.decorationOverrideColor, decPt, 0.0, decSize, ascent,
         decorationOffsetDir * metrics.underlineOffset,
         NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE,
-        dec.mStyle, eNormalDecoration, aCallbacks, verticalRun);
+        dec.mStyle, eNormalDecoration, aParams.callbacks, verticalRun);
     }
     // Overlines
     for (uint32_t i = aDecorations.mOverlines.Length(); i-- > 0; ) {
       const LineDecoration& dec = aDecorations.mOverlines[i];
       if (dec.mStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE) {
         continue;
       }
 
@@ -6733,31 +6739,30 @@ nsTextFrame::DrawTextRunAndDecorations(
         GetInflationForTextDecorations(dec.mFrame, inflationMinFontSize);
       const gfxFont::Metrics metrics =
         GetFirstFontMetrics(GetFontGroupForFrame(dec.mFrame, inflation),
                             useVerticalMetrics);
 
       decSize.height = metrics.underlineSize;
       bCoord = (frameBStart - dec.mBaselineOffset) / app;
 
-      PaintDecorationLine(aCtx, dirtyRect, dec.mColor,
-        aDecorationOverrideColor, decPt, 0.0, decSize, ascent,
+      PaintDecorationLine(aParams.context, dirtyRect, dec.mColor,
+        aParams.decorationOverrideColor, decPt, 0.0, decSize, ascent,
         decorationOffsetDir * metrics.maxAscent,
         NS_STYLE_TEXT_DECORATION_LINE_OVERLINE, dec.mStyle,
-        eNormalDecoration, aCallbacks, verticalRun);
+        eNormalDecoration, aParams.callbacks, verticalRun);
     }
 
     // CSS 2.1 mandates that text be painted after over/underlines, and *then*
     // line-throughs
-    DrawTextRun(aCtx, aTextBaselinePt, aRange, aProvider, aTextColor,
-                aAdvanceWidth, aDrawSoftHyphen, aContextPaint, aCallbacks);
+    DrawTextRun(aRange, aTextBaselinePt, aParams);
 
     // Emphasis marks
-    DrawEmphasisMarks(aCtx, wm, aTextBaselinePt, aRange,
-                      aDecorationOverrideColor, aProvider);
+    DrawEmphasisMarks(aParams.context, wm, aTextBaselinePt, aRange,
+                      aParams.decorationOverrideColor, aParams.provider);
 
     // Line-throughs
     for (uint32_t i = aDecorations.mStrikes.Length(); i-- > 0; ) {
       const LineDecoration& dec = aDecorations.mStrikes[i];
       if (dec.mStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE) {
         continue;
       }
 
@@ -6765,56 +6770,41 @@ nsTextFrame::DrawTextRunAndDecorations(
         GetInflationForTextDecorations(dec.mFrame, inflationMinFontSize);
       const gfxFont::Metrics metrics =
         GetFirstFontMetrics(GetFontGroupForFrame(dec.mFrame, inflation),
                             useVerticalMetrics);
 
       decSize.height = metrics.strikeoutSize;
       bCoord = (frameBStart - dec.mBaselineOffset) / app;
 
-      PaintDecorationLine(aCtx, dirtyRect, dec.mColor,
-        aDecorationOverrideColor, decPt, 0.0, decSize, ascent,
+      PaintDecorationLine(aParams.context, dirtyRect, dec.mColor,
+        aParams.decorationOverrideColor, decPt, 0.0, decSize, ascent,
         decorationOffsetDir * metrics.strikeoutOffset,
         NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH,
-        dec.mStyle, eNormalDecoration, aCallbacks, verticalRun);
+        dec.mStyle, eNormalDecoration, aParams.callbacks, verticalRun);
     }
 }
 
 void
-nsTextFrame::DrawText(
-    gfxContext* const aCtx, const gfxRect& aDirtyRect,
-    const gfxPoint& aFramePt, const gfxPoint& aTextBaselinePt,
-    Range aRange,
-    PropertyProvider& aProvider,
-    const nsTextPaintStyle& aTextStyle,
-    nscolor aTextColor,
-    const nsCharClipDisplayItem::ClipEdges& aClipEdges,
-    gfxFloat& aAdvanceWidth,
-    bool aDrawSoftHyphen,
-    const nscolor* const aDecorationOverrideColor,
-    gfxTextContextPaint* aContextPaint,
-    nsTextFrame::DrawPathCallbacks* aCallbacks)
+nsTextFrame::DrawText(Range aRange, const gfxPoint& aTextBaselinePt,
+                      const DrawTextParams& aParams)
 {
   TextDecorations decorations;
-  GetTextDecorations(aTextStyle.PresContext(),
-                     aCallbacks ? eUnresolvedColors : eResolvedColors,
+  GetTextDecorations(aParams.textStyle->PresContext(),
+                     aParams.callbacks ? eUnresolvedColors : eResolvedColors,
                      decorations);
 
   // Hide text decorations if we're currently hiding @font-face fallback text
-  const bool drawDecorations = !aProvider.GetFontGroup()->ShouldSkipDrawing() &&
-                               (decorations.HasDecorationLines() ||
-                                StyleText()->HasTextEmphasis());
+  const bool drawDecorations =
+    !aParams.provider->GetFontGroup()->ShouldSkipDrawing() &&
+    (decorations.HasDecorationLines() || StyleText()->HasTextEmphasis());
   if (drawDecorations) {
-    DrawTextRunAndDecorations(aCtx, aDirtyRect, aFramePt, aTextBaselinePt, aRange,
-                              aProvider, aTextStyle, aTextColor, aClipEdges, aAdvanceWidth,
-                              aDrawSoftHyphen, decorations,
-                              aDecorationOverrideColor, aContextPaint, aCallbacks);
+    DrawTextRunAndDecorations(aRange, aTextBaselinePt, aParams, decorations);
   } else {
-    DrawTextRun(aCtx, aTextBaselinePt, aRange, aProvider,
-                aTextColor, aAdvanceWidth, aDrawSoftHyphen, aContextPaint, aCallbacks);
+    DrawTextRun(aRange, aTextBaselinePt, aParams);
   }
 }
 
 int16_t
 nsTextFrame::GetSelectionStatus(int16_t* aSelectionFlags)
 {
   // get the selection controller
   nsCOMPtr<nsISelectionController> selectionController;
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -385,16 +385,40 @@ public:
 
     /**
      * Called just after a path corresponding to a selection decoration line
      * has been emitted to the gfxContext.
      */
     virtual void NotifySelectionDecorationLinePathEmitted() { }
   };
 
+  struct DrawTextRunParams
+  {
+    gfxContext* context;
+    PropertyProvider* provider = nullptr;
+    gfxFloat* advanceWidth = nullptr;
+    gfxTextContextPaint* contextPaint = nullptr;
+    DrawPathCallbacks* callbacks = nullptr;
+    nscolor textColor = NS_RGBA(0, 0, 0, 0);
+    bool drawSoftHyphen = false;
+    explicit DrawTextRunParams(gfxContext* aContext)
+      : context(aContext) {}
+  };
+
+  struct DrawTextParams : DrawTextRunParams
+  {
+    gfxPoint framePt;
+    gfxRect dirtyRect;
+    const nsTextPaintStyle* textStyle = nullptr;
+    const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
+    const nscolor* decorationOverrideColor = nullptr;
+    explicit DrawTextParams(gfxContext* aContext)
+      : DrawTextRunParams(aContext) {}
+  };
+
   // Primary frame paint method called from nsDisplayText.  Can also be used
   // to generate paths rather than paint the frame's text by passing a callback
   // object.  The private DrawText() is what applies the text to a graphics
   // context.
   void PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
                  const nsRect& aDirtyRect, const nsCharClipDisplayItem& aItem,
                  gfxTextContextPaint* aContextPaint = nullptr,
                  DrawPathCallbacks* aCallbacks = nullptr,
@@ -440,17 +464,17 @@ public:
                                      SelectionType aSelectionType,
                                      DrawPathCallbacks* aCallbacks);
 
   void DrawEmphasisMarks(gfxContext* aContext,
                          mozilla::WritingMode aWM,
                          const gfxPoint& aTextBaselinePt,
                          Range aRange,
                          const nscolor* aDecorationOverrideColor,
-                         PropertyProvider& aProvider);
+                         PropertyProvider* aProvider);
 
   virtual nscolor GetCaretColorAt(int32_t aOffset) override;
 
   int16_t GetSelectionStatus(int16_t* aSelectionFlags);
 
   int32_t GetContentOffset() const { return mContentOffset; }
   int32_t GetContentLength() const
   {
@@ -689,56 +713,25 @@ protected:
   enum TextDecorationColorResolution {
     eResolvedColors,
     eUnresolvedColors
   };
   void GetTextDecorations(nsPresContext* aPresContext,
                           TextDecorationColorResolution aColorResolution,
                           TextDecorations& aDecorations);
 
-  void DrawTextRun(gfxContext* const aCtx,
-                   const gfxPoint& aTextBaselinePt,
-                   Range aRange,
-                   PropertyProvider& aProvider,
-                   nscolor aTextColor,
-                   gfxFloat& aAdvanceWidth,
-                   bool aDrawSoftHyphen,
-                   gfxTextContextPaint* aContextPaint,
-                   DrawPathCallbacks* aCallbacks);
+  void DrawTextRun(Range aRange, const gfxPoint& aTextBaselinePt,
+                   const DrawTextRunParams& aParams);
 
-  void DrawTextRunAndDecorations(gfxContext* const aCtx,
-                                 const gfxRect& aDirtyRect,
-                                 const gfxPoint& aFramePt,
-                                 const gfxPoint& aTextBaselinePt,
-                                 Range aRange,
-                                 PropertyProvider& aProvider,
-                                 const nsTextPaintStyle& aTextStyle,
-                                 nscolor aTextColor,
-                             const nsCharClipDisplayItem::ClipEdges& aClipEdges,
-                                 gfxFloat& aAdvanceWidth,
-                                 bool aDrawSoftHyphen,
-                                 const TextDecorations& aDecorations,
-                                 const nscolor* const aDecorationOverrideColor,
-                                 gfxTextContextPaint* aContextPaint,
-                                 DrawPathCallbacks* aCallbacks);
+  void DrawTextRunAndDecorations(Range aRange, const gfxPoint& aTextBaselinePt,
+                                 const DrawTextParams& aParams,
+                                 const TextDecorations& aDecorations);
 
-  void DrawText(gfxContext* const aCtx,
-                const gfxRect& aDirtyRect,
-                const gfxPoint& aFramePt,
-                const gfxPoint& aTextBaselinePt,
-                Range aRange,
-                PropertyProvider& aProvider,
-                const nsTextPaintStyle& aTextStyle,
-                nscolor aTextColor,
-                const nsCharClipDisplayItem::ClipEdges& aClipEdges,
-                gfxFloat& aAdvanceWidth,
-                bool aDrawSoftHyphen,
-                const nscolor* const aDecorationOverrideColor = nullptr,
-                gfxTextContextPaint* aContextPaint = nullptr,
-                DrawPathCallbacks* aCallbacks = nullptr);
+  void DrawText(Range aRange, const gfxPoint& aTextBaselinePt,
+                const DrawTextParams& aParams);
 
   // Set non empty rect to aRect, it should be overflow rect or frame rect.
   // If the result rect is larger than the given rect, this returns true.
   bool CombineSelectionUnderlineRect(nsPresContext* aPresContext,
                                        nsRect& aRect);
 
   /**
    * Utility methods to paint selection.