Backed out changeset 734559c25cb1 (bug 1251995)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 07 Mar 2016 12:18:11 +0100
changeset 310856 b7008b66f2d885f89ce6c71086f7585e8309001c
parent 310855 383555f19d02c54833b5f5caeec721663a8ce5c6
child 310857 0ffb1b561ddeecff0c8000c86c1273ad7d454283
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1251995
milestone47.0a1
backs out734559c25cb12f85ceb282b454b65114490e1834
Backed out changeset 734559c25cb1 (bug 1251995)
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5831,19 +5831,25 @@ AddHyphenToMetrics(nsTextFrame* aTextFra
     hyphenTextRun->MeasureText(aBoundingBoxType, aDrawTarget);
   if (aTextFrame->GetWritingMode().IsLineInverted()) {
     hyphenMetrics.mBoundingBox.y = -hyphenMetrics.mBoundingBox.YMost();
   }
   aMetrics->CombineWith(hyphenMetrics, aBaseTextRun->IsRightToLeft());
 }
 
 void
-nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams,
+nsTextFrame::PaintOneShadow(Range aRange,
                             nsCSSShadowItem* aShadowDetails,
-                            gfxRect& aBoundingBox, uint32_t aBlurFlags)
+                            PropertyProvider* aProvider,
+                            const LayoutDeviceRect& aDirtyRect,
+                            const gfxPoint& aFramePt, const gfxPoint& aTextBaselinePt,
+                            gfxContext* aCtx, const nscolor& aForegroundColor,
+                            const nsCharClipDisplayItem::ClipEdges& aClipEdges,
+                            nscoord aLeftSideOffset, gfxRect& aBoundingBox,
+                            uint32_t aBlurFlags)
 {
   PROFILER_LABEL("nsTextFrame", "PaintOneShadow",
     js::ProfileEntry::Category::GRAPHICS);
 
   gfxPoint shadowOffset(aShadowDetails->mXOffset, aShadowDetails->mYOffset);
   nscoord blurRadius = std::max(aShadowDetails->mRadius, 0);
 
   // This rect is the box which is equivalent to where the shadow will be painted.
@@ -5854,72 +5860,71 @@ nsTextFrame::PaintOneShadow(const PaintS
   gfxRect shadowGfxRect;
   WritingMode wm = GetWritingMode();
   if (wm.IsVertical()) {
     shadowGfxRect = aBoundingBox;
     if (wm.IsVerticalRL()) {
       // for vertical-RL, reverse direction of x-coords of bounding box
       shadowGfxRect.x = -shadowGfxRect.XMost();
     }
-    shadowGfxRect += gfxPoint(aParams.textBaselinePt.x,
-                              aParams.framePt.y + aParams.leftSideOffset);
+    shadowGfxRect +=
+      gfxPoint(aTextBaselinePt.x, aFramePt.y + aLeftSideOffset);
   } else {
     shadowGfxRect =
-      aBoundingBox + gfxPoint(aParams.framePt.x + aParams.leftSideOffset,
-                              aParams.textBaselinePt.y);
+      aBoundingBox + gfxPoint(aFramePt.x + aLeftSideOffset,
+                              aTextBaselinePt.y);
   }
   shadowGfxRect += shadowOffset;
 
   nsRect shadowRect(NSToCoordRound(shadowGfxRect.X()),
                     NSToCoordRound(shadowGfxRect.Y()),
                     NSToCoordRound(shadowGfxRect.Width()),
                     NSToCoordRound(shadowGfxRect.Height()));
 
   nsContextBoxBlur contextBoxBlur;
   const auto A2D = PresContext()->AppUnitsPerDevPixel();
   gfxContext* shadowContext = contextBoxBlur.Init(
-    shadowRect, 0, blurRadius, A2D, aParams.context,
-    LayoutDevicePixel::ToAppUnits(aParams.dirtyRect, A2D), nullptr, aBlurFlags);
+    shadowRect, 0, blurRadius, A2D, aCtx,
+    LayoutDevicePixel::ToAppUnits(aDirtyRect, A2D), nullptr, aBlurFlags);
   if (!shadowContext)
     return;
 
   nscolor shadowColor;
   const nscolor* decorationOverrideColor;
   if (aShadowDetails->mHasColor) {
     shadowColor = aShadowDetails->mColor;
     decorationOverrideColor = &shadowColor;
   } else {
-    shadowColor = aParams.foregroundColor;
+    shadowColor = aForegroundColor;
     decorationOverrideColor = nullptr;
   }
 
-  aParams.context->Save();
-  aParams.context->NewPath();
-  aParams.context->SetColor(Color::FromABGR(shadowColor));
+  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;
   nsTextPaintStyle textPaintStyle(this);
   DrawTextParams params(shadowContext);
   params.advanceWidth = &advanceWidth;
-  params.dirtyRect = aParams.dirtyRect;
-  params.framePt = aParams.framePt + shadowOffset;
-  params.provider = aParams.provider;
+  params.dirtyRect = aDirtyRect;
+  params.framePt = aFramePt + shadowOffset;
+  params.provider = aProvider;
   params.textStyle = &textPaintStyle;
-  params.textColor =
-    aParams.context == shadowContext ? shadowColor : NS_RGB(0, 0, 0);
-  params.clipEdges = aParams.clipEdges;
+  params.textColor = aCtx == shadowContext ? shadowColor : NS_RGB(0, 0, 0);
+  params.clipEdges = &aClipEdges;
   params.drawSoftHyphen = (GetStateBits() & TEXT_HYPHEN_BREAK) != 0;
   params.decorationOverrideColor = decorationOverrideColor;
-  DrawText(aParams.range, aParams.textBaselinePt + shadowOffset, params);
+  DrawText(aRange, aTextBaselinePt + shadowOffset, params);
 
   contextBoxBlur.DoPaint();
-  aParams.context->Restore();
+  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
 nsTextFrame::PaintTextWithSelectionColors(
     const PaintTextSelectionParams& aParams,
     SelectionDetails* aDetails, SelectionType* aAllTypes,
@@ -6021,20 +6026,16 @@ nsTextFrame::PaintTextWithSelectionColor
   params.dirtyRect = aParams.dirtyRect;
   params.framePt = aParams.framePt;
   params.provider = aParams.provider;
   params.textStyle = aParams.textPaintStyle;
   params.clipEdges = &aClipEdges;
   params.advanceWidth = &advance;
   params.callbacks = aParams.callbacks;
 
-  PaintShadowParams shadowParams(aParams);
-  shadowParams.provider = aParams.provider;
-  shadowParams.clipEdges = &aClipEdges;
-
   // Draw text
   const nsStyleText* textStyle = StyleText();
   SelectionIterator iterator(prevailingSelections, contentRange,
                              *aParams.provider, mTextRun, startIOffset);
   while (iterator.GetNextSegment(&iOffset, &range, &hyphenWidth,
                                  &type, &rangeStyle)) {
     nscolor foreground, background;
     GetSelectionTextColors(type, *aParams.textPaintStyle, rangeStyle,
@@ -6048,21 +6049,19 @@ nsTextFrame::PaintTextWithSelectionColor
     nsCSSShadowArray* shadow = textStyle->GetTextShadow();
     GetSelectionTextShadow(this, type, *aParams.textPaintStyle, &shadow);
     if (shadow) {
       nscoord startEdge = iOffset;
       if (mTextRun->IsInlineReversed()) {
         startEdge -= hyphenWidth +
           mTextRun->GetAdvanceWidth(range, aParams.provider);
       }
-      shadowParams.range = range;
-      shadowParams.textBaselinePt = textBaselinePt;
-      shadowParams.foregroundColor = foreground;
-      shadowParams.leftSideOffset = startEdge;
-      PaintShadows(shadow, shadowParams);
+      PaintShadows(
+        shadow, range, aParams.dirtyRect, aParams.framePt, textBaselinePt,
+        startEdge, *aParams.provider, foreground, aClipEdges, aParams.context);
     }
 
     // Draw text segment
     params.textColor = foreground;
     params.drawSoftHyphen = hyphenWidth > 0;
     DrawText(range, textBaselinePt, params);
     advance += hyphenWidth;
     iterator.UpdateWithAdvance(advance);
@@ -6398,33 +6397,40 @@ nsTextFrame::MeasureCharClippedText(Prop
     *snappedEndEdge = NSToCoordFloor(gfxFloat(frameISize) - advanceWidth);
   }
   *aMaxLength = maxLength;
   return maxLength != 0;
 }
 
 void
 nsTextFrame::PaintShadows(nsCSSShadowArray* aShadow,
-                          const PaintShadowParams& aParams)
+                          Range aRange,
+                          const LayoutDeviceRect& aDirtyRect,
+                          const gfxPoint& aFramePt,
+                          const gfxPoint& aTextBaselinePt,
+                          nscoord aLeftEdgeOffset,
+                          PropertyProvider& aProvider,
+                          nscolor aForegroundColor,
+                          const nsCharClipDisplayItem::ClipEdges& aClipEdges,
+                          gfxContext* aCtx)
 {
   if (!aShadow) {
     return;
   }
 
   gfxTextRun::Metrics shadowMetrics =
-    mTextRun->MeasureText(aParams.range, gfxFont::LOOSE_INK_EXTENTS,
-                          nullptr, aParams.provider);
+    mTextRun->MeasureText(aRange, gfxFont::LOOSE_INK_EXTENTS,
+                          nullptr, &aProvider);
   if (GetWritingMode().IsLineInverted()) {
     Swap(shadowMetrics.mAscent, shadowMetrics.mDescent);
     shadowMetrics.mBoundingBox.y = -shadowMetrics.mBoundingBox.YMost();
   }
   if (GetStateBits() & TEXT_HYPHEN_BREAK) {
     AddHyphenToMetrics(this, mTextRun, &shadowMetrics,
-                       gfxFont::LOOSE_INK_EXTENTS,
-                       aParams.context->GetDrawTarget());
+                       gfxFont::LOOSE_INK_EXTENTS, aCtx->GetDrawTarget());
   }
   // Add bounds of text decorations
   gfxRect decorationRect(0, -shadowMetrics.mAscent,
       shadowMetrics.mAdvanceWidth, shadowMetrics.mAscent + shadowMetrics.mDescent);
   shadowMetrics.mBoundingBox.UnionRect(shadowMetrics.mBoundingBox,
                                        decorationRect);
 
   // If the textrun uses any color or SVG fonts, we need to force use of a mask
@@ -6441,18 +6447,22 @@ nsTextFrame::PaintShadows(nsCSSShadowArr
   }
 
   if (mTextRun->IsVertical()) {
     Swap(shadowMetrics.mBoundingBox.x, shadowMetrics.mBoundingBox.y);
     Swap(shadowMetrics.mBoundingBox.width, shadowMetrics.mBoundingBox.height);
   }
 
   for (uint32_t i = aShadow->Length(); i > 0; --i) {
-    PaintOneShadow(aParams, aShadow->ShadowAt(i - 1),
-                   shadowMetrics.mBoundingBox, blurFlags);
+    PaintOneShadow(aRange, aShadow->ShadowAt(i - 1), &aProvider,
+                   aDirtyRect, aFramePt, aTextBaselinePt, aCtx,
+                   aForegroundColor, aClipEdges,
+                   aLeftEdgeOffset,
+                   shadowMetrics.mBoundingBox,
+                   blurFlags);
   }
 }
 
 void
 nsTextFrame::PaintText(const PaintTextParams& aParams,
                        const nsCharClipDisplayItem& aItem,
                        float aOpacity /* = 1.0f */)
 {
@@ -6535,24 +6545,19 @@ nsTextFrame::PaintText(const PaintTextPa
     gfx::Color gfxColor = gfx::Color::FromABGR(foregroundColor);
     gfxColor.a *= aOpacity;
     foregroundColor = gfxColor.ToABGR();
   }
 
   range = Range(startOffset, startOffset + maxLength);
   if (!aParams.callbacks) {
     const nsStyleText* textStyle = StyleText();
-    PaintShadowParams shadowParams(aParams);
-    shadowParams.range = range;
-    shadowParams.textBaselinePt = textBaselinePt;
-    shadowParams.leftSideOffset = snappedStartEdge;
-    shadowParams.provider = &provider;
-    shadowParams.foregroundColor = foregroundColor;
-    shadowParams.clipEdges = &clipEdges;
-    PaintShadows(textStyle->mTextShadow, shadowParams);
+    PaintShadows(textStyle->mTextShadow, range, aParams.dirtyRect,
+                 aParams.framePt, textBaselinePt, snappedStartEdge,
+                 provider, foregroundColor, clipEdges, aParams.context);
   }
 
   gfxFloat advanceWidth;
   DrawTextParams params(aParams.context);
   params.dirtyRect = aParams.dirtyRect;
   params.framePt = aParams.framePt;
   params.provider = &provider;
   params.advanceWidth = &advanceWidth;
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -612,40 +612,39 @@ protected:
                                nsRect* aVisualOverflowRect,
                                bool aIncludeTextDecorations);
 
   // Update information of emphasis marks, and return the visial
   // overflow rect of the emphasis marks.
   nsRect UpdateTextEmphasis(mozilla::WritingMode aWM,
                             PropertyProvider& aProvider);
 
-  struct PaintShadowParams
-  {
-    gfxTextRun::Range range;
-    LayoutDeviceRect dirtyRect;
-    gfxPoint framePt;
-    gfxPoint textBaselinePt;
-    gfxContext* context;
-    nscolor foregroundColor = NS_RGBA(0, 0, 0, 0);
-    const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
-    PropertyProvider* provider = nullptr;
-    nscoord leftSideOffset = 0;
-    explicit PaintShadowParams(const PaintTextParams& aParams)
-      : dirtyRect(aParams.dirtyRect)
-      , framePt(aParams.framePt)
-      , context(aParams.context) {}
-  };
-
-  void PaintOneShadow(const PaintShadowParams& aParams,
+  void PaintOneShadow(Range aRange,
                       nsCSSShadowItem* aShadowDetails,
+                      PropertyProvider* aProvider,
+                      const LayoutDeviceRect& aDirtyRect,
+                      const gfxPoint& aFramePt,
+                      const gfxPoint& aTextBaselinePt,
+                      gfxContext* aCtx,
+                      const nscolor& aForegroundColor,
+                      const nsCharClipDisplayItem::ClipEdges& aClipEdges,
+                      nscoord aLeftSideOffset,
                       gfxRect& aBoundingBox,
                       uint32_t aBlurFlags);
 
   void PaintShadows(nsCSSShadowArray* aShadow,
-                    const PaintShadowParams& aParams);
+                    Range aRange,
+                    const LayoutDeviceRect& aDirtyRect,
+                    const gfxPoint& aFramePt,
+                    const gfxPoint& aTextBaselinePt,
+                    nscoord aLeftEdgeOffset,
+                    PropertyProvider& aProvider,
+                    nscolor aForegroundColor,
+                    const nsCharClipDisplayItem::ClipEdges& aClipEdges,
+                    gfxContext* aCtx);
 
   struct LineDecoration {
     nsIFrame* mFrame;
 
     // This is represents the offset from our baseline to mFrame's baseline;
     // positive offsets are *above* the baseline and negative offsets below
     nscoord mBaselineOffset;