Bug 1484966 - Part 1: Fix most clang-tidy warnings for layout/painting/ r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Tue, 04 Sep 2018 17:19:36 +0000
changeset 483056 fe8d9d97dd2601df5727415a19770203597003fa
parent 483032 2fe00c411c46f90a7c5dc7b2fd49ba4b14ab8134
child 483057 399158a0a9b3871b358cbbcb50d8c097b1422514
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersmattwoodrow
bugs1484966
milestone63.0a1
Bug 1484966 - Part 1: Fix most clang-tidy warnings for layout/painting/ r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D3869
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/painting/BorderCache.h
layout/painting/FrameLayerBuilder.cpp
layout/painting/FrameLayerBuilder.h
layout/painting/MaskLayerImageCache.h
layout/painting/RetainedDisplayListBuilder.cpp
layout/painting/RetainedDisplayListHelpers.h
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsCSSRenderingGradients.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
layout/painting/nsImageRenderer.cpp
layout/painting/nsImageRenderer.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2875,27 +2875,27 @@ TransformGfxPointFromAncestor(nsIFrame *
 }
 
 static Rect
 TransformGfxRectToAncestor(const nsIFrame *aFrame,
                            const Rect &aRect,
                            const nsIFrame *aAncestor,
                            bool* aPreservesAxisAlignedRectangles = nullptr,
                            Maybe<Matrix4x4Flagged>* aMatrixCache = nullptr,
-                           bool aStopAtStackingContextAndDisplayPort = false,
+                           bool aStopAtStackingContextAndDisplayPortAndOOFFrame = false,
                            nsIFrame** aOutAncestor = nullptr)
 {
   Matrix4x4Flagged ctm;
   if (aMatrixCache && *aMatrixCache) {
     // We are given a matrix to use, so use it
     ctm = aMatrixCache->value();
   } else {
     // Else, compute it
     uint32_t flags = 0;
-    if (aStopAtStackingContextAndDisplayPort) {
+    if (aStopAtStackingContextAndDisplayPortAndOOFFrame) {
       flags |= nsIFrame::STOP_AT_STACKING_CONTEXT_AND_DISPLAY_PORT;
     }
     ctm = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestor, flags, aOutAncestor);
     if (aMatrixCache) {
       // and put it in the cache, if provided
       *aMatrixCache = Some(ctm);
     }
   }
@@ -2952,41 +2952,41 @@ nsLayoutUtils::TransformAncestorPointToF
 }
 
 nsRect
 nsLayoutUtils::TransformFrameRectToAncestor(const nsIFrame* aFrame,
                                             const nsRect& aRect,
                                             const nsIFrame* aAncestor,
                                             bool* aPreservesAxisAlignedRectangles /* = nullptr */,
                                             Maybe<Matrix4x4Flagged>* aMatrixCache /* = nullptr */,
-                                            bool aStopAtStackingContextAndDisplayPort /* = false */,
+                                            bool aStopAtStackingContextAndDisplayPortAndOOFFrame /* = false */,
                                             nsIFrame** aOutAncestor /* = nullptr */)
 {
   SVGTextFrame* text = GetContainingSVGTextFrame(aFrame);
 
   float srcAppUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   Rect result;
 
   if (text) {
     result = ToRect(text->TransformFrameRectFromTextChild(aRect, aFrame));
     result = TransformGfxRectToAncestor(text, result, aAncestor,
                                         nullptr, aMatrixCache,
-                                        aStopAtStackingContextAndDisplayPort, aOutAncestor);
+                                        aStopAtStackingContextAndDisplayPortAndOOFFrame, aOutAncestor);
     // TransformFrameRectFromTextChild could involve any kind of transform, we
     // could drill down into it to get an answer out of it but we don't yet.
     if (aPreservesAxisAlignedRectangles)
       *aPreservesAxisAlignedRectangles = false;
   } else {
     result = Rect(NSAppUnitsToFloatPixels(aRect.x, srcAppUnitsPerDevPixel),
                   NSAppUnitsToFloatPixels(aRect.y, srcAppUnitsPerDevPixel),
                   NSAppUnitsToFloatPixels(aRect.width, srcAppUnitsPerDevPixel),
                   NSAppUnitsToFloatPixels(aRect.height, srcAppUnitsPerDevPixel));
     result = TransformGfxRectToAncestor(aFrame, result, aAncestor,
                                         aPreservesAxisAlignedRectangles, aMatrixCache,
-                                        aStopAtStackingContextAndDisplayPort, aOutAncestor);
+                                        aStopAtStackingContextAndDisplayPortAndOOFFrame, aOutAncestor);
   }
 
   float destAppUnitsPerDevPixel = aAncestor->PresContext()->AppUnitsPerDevPixel();
   return nsRect(NSFloatPixelsToAppUnits(float(result.x), destAppUnitsPerDevPixel),
                 NSFloatPixelsToAppUnits(float(result.y), destAppUnitsPerDevPixel),
                 NSFloatPixelsToAppUnits(float(result.width), destAppUnitsPerDevPixel),
                 NSFloatPixelsToAppUnits(float(result.height), destAppUnitsPerDevPixel));
 }
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -865,17 +865,17 @@ public:
    * non-null pointer to a non-empty Matrix4x4 - The provided matrix will be used
    *   as the transform matrix and applied to the rect.
    */
   static nsRect TransformFrameRectToAncestor(const nsIFrame* aFrame,
                                              const nsRect& aRect,
                                              const nsIFrame* aAncestor,
                                              bool* aPreservesAxisAlignedRectangles = nullptr,
                                              mozilla::Maybe<Matrix4x4Flagged>* aMatrixCache = nullptr,
-                                             bool aStopAtStackingContextAndDisplayPort = false,
+                                             bool aStopAtStackingContextAndDisplayPortAndOOFFrame = false,
                                              nsIFrame** aOutAncestor = nullptr);
 
 
   /**
    * Gets the transform for aFrame relative to aAncestor. Pass null for
    * aAncestor to go up to the root frame. aInCSSUnits set to true will
    * return CSS units, set to false (the default) will return App units.
    */
--- a/layout/painting/BorderCache.h
+++ b/layout/painting/BorderCache.h
@@ -50,17 +50,17 @@ struct FourFloats
 class FourFloatsHashKey : public PLDHashEntryHdr
 {
 public:
   typedef const FourFloats& KeyType;
   typedef const FourFloats* KeyTypePointer;
 
   explicit FourFloatsHashKey(KeyTypePointer aKey) : mValue(*aKey) {}
   FourFloatsHashKey(const FourFloatsHashKey& aToCopy) : mValue(aToCopy.mValue) {}
-  ~FourFloatsHashKey() {}
+  ~FourFloatsHashKey() = default;
 
   KeyType GetKey() const { return mValue; }
   bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
 
   static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
   static PLDHashNumber HashKey(KeyTypePointer aKey)
   {
     return HashBytes(aKey->n, sizeof(mozilla::gfx::Float) * 4);
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -3138,17 +3138,19 @@ PaintedLayerDataNode::FindPaintedLayerFo
       // can't possibly use any of the layers below it, so stop the search
       // now.
       //
       // If we're trying to minimize painted layer size and we don't
       // intersect the current visible region, then make sure we don't
       // use this painted layer.
       if (data.mVisibleRegion.Intersects(aVisibleRect)) {
         break;
-      } else if (gfxPrefs::LayoutSmallerPaintedLayers()) {
+      }
+
+      if (gfxPrefs::LayoutSmallerPaintedLayers()) {
         lowestUsableLayer = nullptr;
       }
     }
     if (lowestUsableLayer) {
       return lowestUsableLayer;
     }
   }
   PaintedLayerData* data = mPaintedLayerDataStack.AppendElement();
@@ -6073,19 +6075,19 @@ ComputeDesiredDisplaySizeForAnimation(ns
   // Use the size of the nearest widget as the maximum size.  This
   // is important since it might be a popup that is bigger than the
   // pres context's size.
   nsPresContext* presContext = aContainerFrame->PresContext();
   nsIWidget* widget = aContainerFrame->GetNearestWidget();
   if (widget) {
     return LayoutDevicePixel::ToAppUnits(widget->GetClientSize(),
                                          presContext->AppUnitsPerDevPixel());
-  } else {
-    return presContext->GetVisibleArea().Size();
-  }
+  }
+
+  return presContext->GetVisibleArea().Size();
 }
 
 static bool
 ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
                            nsDisplayListBuilder* aDisplayListBuilder,
                            nsIFrame* aContainerFrame,
                            nsDisplayItem* aContainerItem,
                            const nsRect& aVisibleRect,
--- a/layout/painting/FrameLayerBuilder.h
+++ b/layout/painting/FrameLayerBuilder.h
@@ -207,17 +207,17 @@ private:
     */
   bool            mUsed;
   bool            mIsInvalid;
   bool            mReusedItem;
 };
 
 class RefCountedRegion {
 private:
-  ~RefCountedRegion() {}
+  ~RefCountedRegion() = default;
 public:
   NS_INLINE_DECL_REFCOUNTING(RefCountedRegion)
 
   RefCountedRegion() : mIsInfinite(false) {}
   nsRegion mRegion;
   bool mIsInfinite;
 };
 
--- a/layout/painting/MaskLayerImageCache.h
+++ b/layout/painting/MaskLayerImageCache.h
@@ -43,28 +43,31 @@ public:
   /**
    * Representation of a rounded rectangle in device pixel coordinates, in
    * contrast to DisplayItemClip::RoundedRect, which uses app units.
    * In particular, our internal representation uses a gfxRect, rather than
    * an nsRect, so this class is easier to use with transforms.
    */
   struct PixelRoundedRect
   {
+    PixelRoundedRect() = delete;
+
     PixelRoundedRect(const DisplayItemClip::RoundedRect& aRRect,
                      nsPresContext* aPresContext)
       : mRect(aPresContext->AppUnitsToGfxUnits(aRRect.mRect.x),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.y),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height))
     {
       MOZ_COUNT_CTOR(PixelRoundedRect);
       NS_FOR_CSS_HALF_CORNERS(corner) {
         mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]);
       }
     }
+
     PixelRoundedRect(const PixelRoundedRect& aPRR)
       : mRect(aPRR.mRect)
     {
       MOZ_COUNT_CTOR(PixelRoundedRect);
       NS_FOR_CSS_HALF_CORNERS(corner) {
         mRadii[corner] = aPRR.mRadii[corner];
       }
     }
@@ -113,19 +116,16 @@ public:
       hash = AddToHash(hash, HashBytes(mRadii, 8*sizeof(gfxFloat)));
 
       return hash;
     }
 
     gfx::Rect mRect;
     // Indices into mRadii are the enum HalfCorner constants in gfx/2d/Types.h
     gfxFloat mRadii[8];
-
-  private:
-    PixelRoundedRect() = delete;
   };
 
   struct MaskLayerImageKeyRef;
 
   /**
    * A key to identify cached image containers.
    * The const-ness of this class is with respect to its use as a key into a
    * hashtable, so anything not used to create the hash is mutable.
--- a/layout/painting/RetainedDisplayListBuilder.cpp
+++ b/layout/painting/RetainedDisplayListBuilder.cpp
@@ -342,41 +342,50 @@ public:
     // fix. In these cases we just always use the new item to be safe.
     DisplayItemType type = aNewItem->GetType();
     if (type == DisplayItemType::TYPE_CANVAS_BACKGROUND_COLOR ||
         type == DisplayItemType::TYPE_SOLID_COLOR) {
       // The canvas background color item can paint the color from another
       // frame, and even though we schedule a paint, we don't mark the canvas
       // frame as invalid.
       return true;
-    } else if (type == DisplayItemType::TYPE_TABLE_BORDER_COLLAPSE) {
+    }
+
+    if (type == DisplayItemType::TYPE_TABLE_BORDER_COLLAPSE) {
       // We intentionally don't mark the root table frame as modified when a subframe
       // changes, even though the border collapse item for the root frame is what paints
       // the changed border. Marking the root frame as modified would rebuild display
       // items for the whole table area, and we don't want that.
       return true;
-    } else if (type == DisplayItemType::TYPE_TEXT_OVERFLOW) {
+    }
+
+    if (type == DisplayItemType::TYPE_TEXT_OVERFLOW) {
       // Text overflow marker items are created with the wrapping block as their frame,
       // and have an index value to note which line they are created for. Their rendering
       // can change if the items on that line change, which may not mark the block as modified.
       // We rebuild them if we build any item on the line, so we should always get new items
       // if they might have changed rendering, and it's easier to just use the new items
       // rather than computing if we actually need them.
       return true;
-    } else if (type == DisplayItemType::TYPE_SUBDOCUMENT) {
+    }
+
+    if (type == DisplayItemType::TYPE_SUBDOCUMENT) {
       // nsDisplaySubDocument::mShouldFlatten can change without an invalidation
       // (and is the reason we unconditionally build the subdocument item), so always
       // use the new one to make sure we get the right value.
       return true;
-    } else if (type == DisplayItemType::TYPE_CARET) {
+    }
+
+    if (type == DisplayItemType::TYPE_CARET) {
       // The caret can change position while still being owned by the same frame
       // and we don't invalidate in that case. Use the new version since the changed
       // bounds are needed for DLBI.
       return true;
     }
+
     return false;
   }
 
   RetainedDisplayList Finalize() {
     for (size_t i = 0; i < mOldDAG.Length(); i++) {
       if (mOldItems[i].IsUsed()) {
         continue;
       }
@@ -501,21 +510,22 @@ public:
 
     while (true) {
       if (mStack.LastElement().IsFinished()) {
         // If we've finished processing all the entries in the current set, then pop
         // it off the processing stack and process it.
         PredecessorStackItem item = mStack.PopLastElement();
         AutoTArray<MergedListIndex,2> result =
           ResolveNodeIndexesOldToMerged(item.mDirectPredecessors);
+
         if (mStack.IsEmpty()) {
           return result;
-        } else {
-          ProcessOldNode(item.mNode, std::move(result));
         }
+
+        ProcessOldNode(item.mNode, std::move(result));
       } else {
         // Grab the current predecessor, push predecessors of that onto the processing
         // stack (if it hasn't already been processed), and then advance to the next entry.
         OldListIndex currentIndex = mStack.LastElement().GetAndIncrementCurrentPredecessor();
         if (!mOldItems[currentIndex.val].IsUsed()) {
           mStack.AppendElement(
             PredecessorStackItem(currentIndex, mOldDAG.GetDirectPredecessors(currentIndex)));
         }
--- a/layout/painting/RetainedDisplayListHelpers.h
+++ b/layout/painting/RetainedDisplayListHelpers.h
@@ -83,17 +83,17 @@ struct Index {
 };
 typedef Index<OldListUnits> OldListIndex;
 typedef Index<MergedListUnits> MergedListIndex;
 
 
 template <typename T>
 class DirectedAcyclicGraph {
 public:
-  DirectedAcyclicGraph() {}
+  DirectedAcyclicGraph() = default;
   DirectedAcyclicGraph(DirectedAcyclicGraph&& aOther)
     : mNodesInfo(std::move(aOther.mNodesInfo))
     , mDirectPredecessorList(std::move(aOther.mDirectPredecessorList))
   {}
 
   DirectedAcyclicGraph& operator=(DirectedAcyclicGraph&& aOther)
   {
     mNodesInfo = std::move(aOther.mNodesInfo);
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -79,19 +79,17 @@ struct InlineBackgroundData
   InlineBackgroundData()
       : mFrame(nullptr), mLineContainer(nullptr),
         mContinuationPoint(0), mUnbrokenMeasure(0), 
         mLineContinuationPoint(0), mPIStartBorderData{},
         mBidiEnabled(false), mVertical(false)
   {
   }
 
-  ~InlineBackgroundData()
-  {
-  }
+  ~InlineBackgroundData() = default;
 
   void Reset()
   {
     mBoundingBox.SetRect(0,0,0,0);
     mContinuationPoint = mLineContinuationPoint = mUnbrokenMeasure = 0;
     mFrame = mLineContainer = nullptr;
     mPIStartBorderData.Reset();
   }
@@ -1460,20 +1458,20 @@ bool
 nsCSSRendering::FindBackgroundFrame(nsIFrame* aForFrame,
                                     nsIFrame** aBackgroundFrame)
 {
   nsIFrame* rootElementFrame =
     aForFrame->PresShell()->FrameConstructor()->GetRootElementStyleFrame();
   if (IsCanvasFrame(aForFrame)) {
     *aBackgroundFrame = FindCanvasBackgroundFrame(aForFrame, rootElementFrame);
     return true;
-  } else {
-    *aBackgroundFrame = aForFrame;
-    return FindElementBackground(aForFrame, rootElementFrame);
   }
+
+  *aBackgroundFrame = aForFrame;
+  return FindElementBackground(aForFrame, rootElementFrame);
 }
 
 bool
 nsCSSRendering::FindBackground(nsIFrame* aForFrame,
                                ComputedStyle** aBackgroundSC)
 {
   nsIFrame *backgroundFrame = nullptr;
   if (FindBackgroundFrame(aForFrame, &backgroundFrame)) {
@@ -1524,17 +1522,17 @@ nsCSSRendering::GetShadowColor(nsCSSShad
   // Get the shadow color; if not specified, use the foreground color
   nscolor shadowColor = aShadow->mColor.CalcColor(aFrame);
   Color color = Color::FromABGR(shadowColor);
   color.a *= aOpacity;
   return color;
 }
 
 nsRect
-nsCSSRendering::GetShadowRect(const nsRect aFrameArea,
+nsCSSRendering::GetShadowRect(const nsRect& aFrameArea,
                               bool aNativeTheme,
                               nsIFrame* aForFrame)
 {
   nsRect frameRect = aNativeTheme ?
     aForFrame->GetVisualOverflowRectRelativeToSelf() + aFrameArea.TopLeft() :
     aFrameArea;
   Sides skipSides = aForFrame->GetSkipSides();
   frameRect = BoxDecorationRectForBorder(aForFrame, frameRect, skipSides);
@@ -1819,22 +1817,24 @@ nsCSSRendering::GetShadowInnerRadii(nsIF
 {
   // Get any border radius, since box-shadow must also have rounded corners
   // if the frame does.
   nscoord twipsRadii[8];
   nsRect frameRect =
     BoxDecorationRectForBorder(aFrame, aFrameArea, aFrame->GetSkipSides());
   nsSize sz = frameRect.Size();
   nsMargin border = aFrame->GetUsedBorder();
-  bool hasBorderRadius = aFrame->GetBorderRadii(sz, sz, Sides(), twipsRadii);
+  aFrame->GetBorderRadii(sz, sz, Sides(), twipsRadii);
   const nscoord oneDevPixel = aFrame->PresContext()->DevPixelsToAppUnits(1);
 
   RectCornerRadii borderRadii;
 
-  hasBorderRadius = GetBorderRadii(frameRect, aFrameArea, aFrame, borderRadii);
+  const bool hasBorderRadius =
+    GetBorderRadii(frameRect, aFrameArea, aFrame, borderRadii);
+
   if (hasBorderRadius) {
     ComputePixelRadii(twipsRadii, oneDevPixel, &borderRadii);
 
     Float borderSizes[4] = {
       Float(border.top) / oneDevPixel,
       Float(border.right) / oneDevPixel,
       Float(border.bottom) / oneDevPixel,
       Float(border.left) / oneDevPixel
@@ -3195,20 +3195,20 @@ static nscoord
 ComputeSpacedRepeatSize(nscoord aImageDimension,
                         nscoord aAvailableSpace,
                         bool& aRepeat) {
   float ratio = static_cast<float>(aAvailableSpace) / aImageDimension;
 
   if (ratio < 2.0f) { // If you can't repeat at least twice, then don't repeat.
     aRepeat = false;
     return aImageDimension;
-  } else {
-    aRepeat = true;
-    return (aAvailableSpace - aImageDimension) / (NSToIntFloor(ratio) - 1);
   }
+
+  aRepeat = true;
+  return (aAvailableSpace - aImageDimension) / (NSToIntFloor(ratio) - 1);
 }
 
 /* static */ nscoord
 nsCSSRendering::ComputeBorderSpacedRepeatSize(nscoord aImageDimension,
                                               nscoord aAvailableSpace,
                                               nscoord& aSpace)
 {
   int32_t count = aImageDimension ? (aAvailableSpace / aImageDimension) : 0;
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -143,17 +143,17 @@ struct nsCSSRendering {
                                   gfxContext& aRenderingContext,
                                   nsIFrame* aForFrame,
                                   const nsRect& aFrameArea);
 
   static bool GetBorderRadii(const nsRect& aFrameRect,
                              const nsRect& aBorderRect,
                              nsIFrame* aFrame,
                              RectCornerRadii& aOutRadii);
-  static nsRect GetShadowRect(const nsRect aFrameArea,
+  static nsRect GetShadowRect(const nsRect& aFrameArea,
                               bool aNativeTheme,
                               nsIFrame* aForFrame);
   static mozilla::gfx::Color GetShadowColor(nsCSSShadowItem* aShadow,
                                    nsIFrame* aFrame,
                                    float aOpacity);
   // Returns if the frame has a themed frame.
   // aMaybeHasBorderRadius will return false if we can early detect
   // that we don't have a border radius.
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -362,31 +362,31 @@ static void ResolveMidpoints(nsTArray<Co
       newStops[1].mPosition = offset1 + (offset - offset1) * 2 / 3;
 
       for (size_t y = 0; y < 7; y++) {
         newStops[y+2].mPosition = offset + (offset2 - offset) * y / 13;
       }
     }
     // calculate colors
 
-    for (size_t y = 0; y < 9; y++) {
+    for (auto& newStop : newStops) {
       // Calculate the intermediate color stops per the formula of the CSS images
       // spec. http://dev.w3.org/csswg/css-images/#color-stop-syntax
       // 9 points were chosen since it is the minimum number of stops that always
       // give the smoothest appearace regardless of midpoint position and difference
       // in luminance of the end points.
-      float relativeOffset = (newStops[y].mPosition - offset1) / (offset2 - offset1);
+      float relativeOffset = (newStop.mPosition - offset1) / (offset2 - offset1);
       float multiplier = powf(relativeOffset, logf(.5f) / logf(midpoint));
 
       gfx::Float red = color1.r + multiplier * (color2.r - color1.r);
       gfx::Float green = color1.g + multiplier * (color2.g - color1.g);
       gfx::Float blue = color1.b + multiplier * (color2.b - color1.b);
       gfx::Float alpha = color1.a + multiplier * (color2.a - color1.a);
 
-      newStops[y].mColor = Color(red, green, blue, alpha);
+      newStop.mColor = Color(red, green, blue, alpha);
     }
 
     stops.ReplaceElementsAt(x, 1, newStops, 9);
     x += 9;
   }
 }
 
 static Color
@@ -839,17 +839,16 @@ nsCSSGradientRenderer::Paint(gfxContext&
     // Stops are all at the same place. Map all stops to 0.0.
     // For repeating radial gradients, or for any radial gradients with
     // a zero radius, we need to fill with the last stop color, so just set
     // both radii to 0.
     if (mGradient->mRepeating || zeroRadius) {
       mRadiusX = mRadiusY = 0.0;
     }
     stopDelta = 0.0;
-    lastStop = firstStop;
   }
 
   // Don't normalize non-repeating or degenerate gradients below 0..1
   // This keeps the gradient line as large as the box and doesn't
   // lets us avoiding having to get padding correct for stops
   // at 0 and 1
   if (!mGradient->mRepeating || stopDelta == 0.0) {
     stopOrigin = std::min(stopOrigin, 0.0);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2679,17 +2679,18 @@ already_AddRefed<LayerManager> nsDisplay
     if (presContext->RefreshDriver()->HasScheduleFlush()) {
       presContext->NotifyInvalidation(layerManager->GetLastTransactionId(), frame->GetRect());
     }
 
     return layerManager.forget();
   }
 
   NotifySubDocInvalidationFunc computeInvalidFunc =
-    presContext->MayHavePaintEventListenerInSubDocument() ? nsPresContext::NotifySubDocInvalidation : 0;
+    presContext->MayHavePaintEventListenerInSubDocument()
+    ? nsPresContext::NotifySubDocInvalidation : nullptr;
 
   UniquePtr<LayerProperties> props;
 
   bool computeInvalidRect = (computeInvalidFunc ||
                              (!layerManager->IsCompositingCheap() && layerManager->NeedsWidgetInvalidation())) &&
                             widgetTransaction;
 
   if (computeInvalidRect) {
@@ -2833,17 +2834,18 @@ GetMouseThrough(const nsIFrame* aFrame)
 {
   if (!aFrame->IsXULBoxFrame())
     return false;
 
   const nsIFrame* frame = aFrame;
   while (frame) {
     if (frame->GetStateBits() & NS_FRAME_MOUSE_THROUGH_ALWAYS) {
       return true;
-    } else if (frame->GetStateBits() & NS_FRAME_MOUSE_THROUGH_NEVER) {
+    }
+    if (frame->GetStateBits() & NS_FRAME_MOUSE_THROUGH_NEVER) {
       return false;
     }
     frame = nsBox::GetParentXULBox(frame);
   }
   return false;
 }
 
 static bool
@@ -4388,23 +4390,16 @@ nsDisplayThemedBackground::nsDisplayThem
                                                      nsIFrame* aFrame,
                                                      const nsRect& aBackgroundRect)
   : nsDisplayItem(aBuilder, aFrame)
   , mBackgroundRect(aBackgroundRect)
 {
   MOZ_COUNT_CTOR(nsDisplayThemedBackground);
 }
 
-nsDisplayThemedBackground::~nsDisplayThemedBackground()
-{
-#ifdef NS_BUILD_REFCNT_LOGGING
-  MOZ_COUNT_DTOR(nsDisplayThemedBackground);
-#endif
-}
-
 void
 nsDisplayThemedBackground::Init(nsDisplayListBuilder* aBuilder)
 {
   const nsStyleDisplay* disp = StyleFrame()->StyleDisplay();
   mAppearance = disp->mAppearance;
   StyleFrame()->IsThemed(disp, &mThemeTransparency);
 
   // Perform necessary RegisterThemeGeometry
@@ -5509,17 +5504,17 @@ nsDisplayBoxShadowOuter::CreateWebRender
 
       float blurRadius = float(shadow->mRadius) / float(appUnitsPerDevPixel);
       gfx::Color shadowColor = nsCSSRendering::GetShadowColor(shadow,
                                                               mFrame,
                                                               mOpacity);
 
       // We don't move the shadow rect here since WR does it for us
       // Now translate everything to device pixels.
-      nsRect shadowRect = frameRect;
+      const nsRect& shadowRect = frameRect;
       LayoutDevicePoint shadowOffset = LayoutDevicePoint::FromAppUnits(
           nsPoint(shadow->mXOffset, shadow->mYOffset),
           appUnitsPerDevPixel);
 
       LayoutDeviceRect deviceBox = LayoutDeviceRect::FromAppUnits(
           shadowRect, appUnitsPerDevPixel);
       wr::LayoutRect deviceBoxRect = wr::ToRoundedLayoutRect(deviceBox);
       wr::LayoutRect deviceClipRect = wr::ToRoundedLayoutRect(clipRect);
@@ -5602,17 +5597,17 @@ nsDisplayBoxShadowInner::Paint(nsDisplay
     nsCSSRendering::PaintBoxShadowInner(presContext, *aCtx, mFrame, borderRect);
     gfx->Restore();
   }
 }
 
 bool
 nsDisplayBoxShadowInner::CanCreateWebRenderCommands(nsDisplayListBuilder* aBuilder,
                                                     nsIFrame* aFrame,
-                                                    nsPoint aReferenceOffset)
+                                                    const nsPoint& aReferenceOffset)
 {
   nsCSSShadowArray *shadows = aFrame->StyleEffects()->mBoxShadow;
   if (!shadows) {
     // Means we don't have to paint anything
     return true;
   }
 
   bool hasBorderRadius;
@@ -5628,17 +5623,17 @@ nsDisplayBoxShadowInner::CanCreateWebRen
   return true;
 }
 
 /* static */ void
 nsDisplayBoxShadowInner::CreateInsetBoxShadowWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                                                const StackingContextHelper& aSc,
                                                                nsRegion& aVisibleRegion,
                                                                nsIFrame* aFrame,
-                                                               const nsRect aBorderRect)
+                                                               const nsRect& aBorderRect)
 {
   if (!nsCSSRendering::ShouldPaintBoxShadowInner(aFrame)) {
     return;
   }
 
   int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
 
   AutoTArray<nsRect,10> rects;
@@ -8106,18 +8101,21 @@ nsDisplayTransform::ShouldPrerenderTrans
     gfxRect::MaxIntRect());
   const nsSize frameSize = nsSize(transformedBounds.width, transformedBounds.height);
 
   uint64_t maxLimitArea = uint64_t(maxSize.width) * maxSize.height;
   uint64_t frameArea = uint64_t(frameSize.width) * frameSize.height;
   if (frameArea <= maxLimitArea && frameSize <= absoluteLimit) {
     *aDirtyRect = overflow;
     return FullPrerender;
-  } else if (gfxPrefs::PartiallyPrerenderAnimatedContent()) {
-    *aDirtyRect = nsLayoutUtils::ComputePartialPrerenderArea(*aDirtyRect, overflow, maxSize);
+  }
+
+  if (gfxPrefs::PartiallyPrerenderAnimatedContent()) {
+    *aDirtyRect = nsLayoutUtils::ComputePartialPrerenderArea(*aDirtyRect,
+                                                             overflow, maxSize);
     return PartialPrerender;
   }
 
   if (frameArea > maxLimitArea) {
     uint64_t appUnitsPerPixel = AppUnitsPerCSSPixel();
     EffectCompositor::SetPerformanceWarning(
       aFrame, eCSSProperty_transform,
       AnimationPerformanceWarning(
@@ -9858,19 +9856,19 @@ nsDisplaySVGWrapper::CreateWebRenderComm
                                              nsDisplayListBuilder* aDisplayListBuilder)
 {
   if (gfxPrefs::WebRenderBlobInvalidation()) {
     return nsDisplayWrapList::CreateWebRenderCommands(aBuilder,
                                              aResources,
                                              aSc,
                                              aManager,
                                              aDisplayListBuilder);
-  } else {
-    return false;
-  }
+  }
+
+  return false;
 }
 
 namespace mozilla {
 
 uint32_t PaintTelemetry::sPaintLevel = 0;
 uint32_t PaintTelemetry::sMetricLevel = 0;
 EnumeratedArray<PaintTelemetry::Metric,
                 PaintTelemetry::Metric::COUNT,
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -2104,16 +2104,18 @@ public:
     , mPaintRectValid(false)
 #ifdef MOZ_DUMP_PAINTING
     , mPainted(false)
 #endif
   {
     MOZ_COUNT_CTOR(nsDisplayItem);
   }
 
+  nsDisplayItem() = delete;
+
 protected:
   virtual ~nsDisplayItem() {
     MOZ_COUNT_DTOR(nsDisplayItem);
     SetDisplayItemData(nullptr, nullptr);
     if (mFrame) {
       mFrame->RemoveDisplayItem(this);
     }
   }
@@ -2909,18 +2911,16 @@ public:
     return true;
   }
 
   const nsRect& GetPaintRect() const {
     return mPaintRect;
   }
 
 protected:
-  nsDisplayItem() = delete;
-
   typedef bool (*PrefFunc)(void);
   bool ShouldUseAdvancedLayer(LayerManager* aManager, PrefFunc aFunc) const;
   bool CanUseAdvancedLayer(LayerManager* aManager) const;
 
   nsIFrame* mFrame;
   RefPtr<const DisplayItemClipChain> mClipChain;
   const DisplayItemClip* mClip;
   RefPtr<const ActiveScrolledRoot> mActiveScrolledRoot;
@@ -3402,18 +3402,18 @@ struct nsDisplayListCollection : public 
   explicit nsDisplayListCollection(nsDisplayListBuilder* aBuilder, nsDisplayList* aBorderBackground) :
     nsDisplayListSet(aBorderBackground, &mLists[1], &mLists[2], &mLists[3], &mLists[4],
                      &mLists[5]) {}
 
   /**
    * Sort all lists by content order.
    */
   void SortAllByContentOrder(nsIContent* aCommonAncestor) {
-    for (int32_t i = 0; i < 6; ++i) {
-      mLists[i].SortByContentOrder(aCommonAncestor);
+    for (auto& mList : mLists) {
+      mList.SortByContentOrder(aCommonAncestor);
     }
   }
 
 private:
   // This class is only used on stack, so we don't have to worry about leaking
   // it.  Don't let us be heap-allocated!
   void* operator new(size_t sz) CPP_THROW_NEW;
 
@@ -3426,17 +3426,17 @@ private:
  *
  * Display lists built from a partial list aren't necessarily
  * in the same order as a full build, and the DAG retains
  * the information needing to interpret the current
  * order correctly.
  */
 class RetainedDisplayList : public nsDisplayList {
 public:
-  RetainedDisplayList() {}
+  RetainedDisplayList() = default;
   RetainedDisplayList(RetainedDisplayList&& aOther)
   {
     AppendToTop(&aOther);
     mDAG = std::move(aOther.mDAG);
   }
   ~RetainedDisplayList()
   {
     MOZ_ASSERT(mOldItems.IsEmpty(), "Must empty list before destroying");
@@ -3823,53 +3823,53 @@ public:
 protected:
   template<typename T>
   T CalculateBounds(const nsStyleBorder& aStyleBorder) const
   {
     nsRect borderBounds(ToReferenceFrame(), mFrame->GetSize());
     if (aStyleBorder.IsBorderImageLoaded()) {
       borderBounds.Inflate(aStyleBorder.GetImageOutset());
       return borderBounds;
-    } else {
-      nsMargin border = aStyleBorder.GetComputedBorder();
-      T result;
-      if (border.top > 0) {
-        result = nsRect(borderBounds.X(), borderBounds.Y(), borderBounds.Width(), border.top);
-      }
-      if (border.right > 0) {
-        result.OrWith(nsRect(borderBounds.XMost() - border.right, borderBounds.Y(), border.right, borderBounds.Height()));
-      }
-      if (border.bottom > 0) {
-        result.OrWith(nsRect(borderBounds.X(), borderBounds.YMost() - border.bottom, borderBounds.Width(), border.bottom));
-      }
-      if (border.left > 0) {
-        result.OrWith(nsRect(borderBounds.X(), borderBounds.Y(), border.left, borderBounds.Height()));
+    }
+
+    nsMargin border = aStyleBorder.GetComputedBorder();
+    T result;
+    if (border.top > 0) {
+      result = nsRect(borderBounds.X(), borderBounds.Y(), borderBounds.Width(), border.top);
+    }
+    if (border.right > 0) {
+      result.OrWith(nsRect(borderBounds.XMost() - border.right, borderBounds.Y(), border.right, borderBounds.Height()));
+    }
+    if (border.bottom > 0) {
+      result.OrWith(nsRect(borderBounds.X(), borderBounds.YMost() - border.bottom, borderBounds.Width(), border.bottom));
+    }
+    if (border.left > 0) {
+      result.OrWith(nsRect(borderBounds.X(), borderBounds.Y(), border.left, borderBounds.Height()));
+    }
+
+    nscoord radii[8];
+    if (mFrame->GetBorderRadii(radii)) {
+      if (border.left > 0 || border.top > 0) {
+        nsSize cornerSize(radii[mozilla::eCornerTopLeftX], radii[mozilla::eCornerTopLeftY]);
+        result.OrWith(nsRect(borderBounds.TopLeft(), cornerSize));
       }
-
-      nscoord radii[8];
-      if (mFrame->GetBorderRadii(radii)) {
-        if (border.left > 0 || border.top > 0) {
-          nsSize cornerSize(radii[mozilla::eCornerTopLeftX], radii[mozilla::eCornerTopLeftY]);
-          result.OrWith(nsRect(borderBounds.TopLeft(), cornerSize));
-        }
-        if (border.top > 0 || border.right > 0) {
-          nsSize cornerSize(radii[mozilla::eCornerTopRightX], radii[mozilla::eCornerTopRightY]);
-          result.OrWith(nsRect(borderBounds.TopRight() - nsPoint(cornerSize.width, 0), cornerSize));
-        }
-        if (border.right > 0 || border.bottom > 0) {
-          nsSize cornerSize(radii[mozilla::eCornerBottomRightX], radii[mozilla::eCornerBottomRightY]);
-          result.OrWith(nsRect(borderBounds.BottomRight() - nsPoint(cornerSize.width, cornerSize.height), cornerSize));
-        }
-        if (border.bottom > 0 || border.left > 0) {
-          nsSize cornerSize(radii[mozilla::eCornerBottomLeftX], radii[mozilla::eCornerBottomLeftY]);
-          result.OrWith(nsRect(borderBounds.BottomLeft() - nsPoint(0, cornerSize.height), cornerSize));
-        }
+      if (border.top > 0 || border.right > 0) {
+        nsSize cornerSize(radii[mozilla::eCornerTopRightX], radii[mozilla::eCornerTopRightY]);
+        result.OrWith(nsRect(borderBounds.TopRight() - nsPoint(cornerSize.width, 0), cornerSize));
       }
-      return result;
+      if (border.right > 0 || border.bottom > 0) {
+        nsSize cornerSize(radii[mozilla::eCornerBottomRightX], radii[mozilla::eCornerBottomRightY]);
+        result.OrWith(nsRect(borderBounds.BottomRight() - nsPoint(cornerSize.width, cornerSize.height), cornerSize));
+      }
+      if (border.bottom > 0 || border.left > 0) {
+        nsSize cornerSize(radii[mozilla::eCornerBottomLeftX], radii[mozilla::eCornerBottomLeftY]);
+        result.OrWith(nsRect(borderBounds.BottomLeft() - nsPoint(0, cornerSize.height), cornerSize));
+      }
     }
+    return result;
   }
 
   nsRect mBounds;
 };
 
 /**
  * A simple display item that just renders a solid color across the
  * specified bounds. For canvas frames (in the CSS sense) we split off the
@@ -4307,17 +4307,25 @@ protected:
 
 /**
  * A display item to paint the native theme background for a frame.
  */
 class nsDisplayThemedBackground : public nsDisplayItem {
 public:
   nsDisplayThemedBackground(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                             const nsRect& aBackgroundRect);
-  virtual ~nsDisplayThemedBackground();
+
+#ifdef NS_BUILD_REFCNT_LOGGING
+  virtual ~nsDisplayThemedBackground() {
+    MOZ_COUNT_DTOR(nsDisplayThemedBackground);
+  }
+#else
+  virtual ~nsDisplayThemedBackground() = default;
+#endif
+
   void Init(nsDisplayListBuilder* aBuilder);
 
   void Destroy(nsDisplayListBuilder* aBuilder) override
   {
     aBuilder->UnregisterThemeGeometry(this);
     nsDisplayItem::Destroy(aBuilder);
   }
 
@@ -4755,22 +4763,22 @@ public:
       // touch pixels outside of this. We should invalidate the entire bounds.
       bool snap;
       aInvalidRegion->Or(geometry->mBounds, GetBounds(aBuilder, &snap));
     }
   }
 
   static bool CanCreateWebRenderCommands(nsDisplayListBuilder* aBuilder,
                                          nsIFrame* aFrame,
-                                         nsPoint aReferencePoint);
+                                         const nsPoint& aReferencePoint);
   static void CreateInsetBoxShadowWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                                     const StackingContextHelper& aSc,
                                                     nsRegion& aVisibleRegion,
                                                     nsIFrame* aFrame,
-                                                    const nsRect aBorderRect);
+                                                    const nsRect& aBorderRect);
   virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                        mozilla::wr::IpcResourceUpdateQueue& aResources,
                                        const StackingContextHelper& aSc,
                                        mozilla::layers::WebRenderLayerManager* aManager,
                                        nsDisplayListBuilder* aDisplayListBuilder) override;
 
 private:
   nsRegion mVisibleRegion;
@@ -4929,16 +4937,18 @@ public:
     , mIndex(0)
     , mHasZIndexOverride(false)
   {
     MOZ_COUNT_CTOR(nsDisplayWrapList);
     mBaseBuildingRect = GetBuildingRect();
     mListPtr = &mList;
   }
 
+  nsDisplayWrapList() = delete;
+
   /**
    * A custom copy-constructor that does not copy mList, as this would mutate
    * the other item.
    */
   nsDisplayWrapList(const nsDisplayWrapList& aOther) = delete;
   nsDisplayWrapList(nsDisplayListBuilder* aBuilder, const nsDisplayWrapList& aOther)
     : nsDisplayItem(aBuilder, aOther)
     , mListPtr(&mList)
@@ -5109,18 +5119,16 @@ public:
                                        mozilla::wr::IpcResourceUpdateQueue& aResources,
                                        const StackingContextHelper& aSc,
                                        mozilla::layers::WebRenderLayerManager* aManager,
                                        nsDisplayListBuilder* aDisplayListBuilder) override;
 
   const ActiveScrolledRoot* GetFrameActiveScrolledRoot() { return mFrameActiveScrolledRoot; }
 
 protected:
-  nsDisplayWrapList() = delete;
-
   void MergeFromTrackingMergedFrames(const nsDisplayWrapList* aOther)
   {
     mBounds.UnionRect(mBounds, aOther->mBounds);
     nsRect buildingRect;
     buildingRect.UnionRect(GetBuildingRect(), aOther->GetBuildingRect());
     SetBuildingRect(buildingRect);
     mMergedFrames.AppendElement(aOther->mFrame);
     mMergedFrames.AppendElements(aOther->mMergedFrames);
@@ -6770,19 +6778,17 @@ class nsDisplayPerspective : public nsDi
 {
   typedef mozilla::gfx::Point3D Point3D;
 
 public:
   NS_DISPLAY_DECL_NAME("nsDisplayPerspective", TYPE_PERSPECTIVE)
 
   nsDisplayPerspective(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                        nsDisplayList* aList);
-  ~nsDisplayPerspective()
-  {
-  }
+  ~nsDisplayPerspective() = default;
 
   virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
                        HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) override
   {
     return mList.HitTest(aBuilder, aRect, aState, aOutFrames);
   }
 
   virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -65,20 +65,16 @@ nsImageRenderer::nsImageRenderer(nsIFram
   , mPrepareResult(ImgDrawResult::NOT_READY)
   , mSize(0, 0)
   , mFlags(aFlags)
   , mExtendMode(ExtendMode::CLAMP)
   , mMaskOp(NS_STYLE_MASK_MODE_MATCH_SOURCE)
 {
 }
 
-nsImageRenderer::~nsImageRenderer()
-{
-}
-
 static bool
 ShouldTreatAsCompleteDueToSyncDecode(const nsStyleImage* aImage,
                                      uint32_t aFlags)
 {
   if (!(aFlags & nsImageRenderer::FLAG_SYNC_DECODE_IMAGES)) {
     return false;
   }
 
--- a/layout/painting/nsImageRenderer.h
+++ b/layout/painting/nsImageRenderer.h
@@ -114,17 +114,17 @@ public:
   };
   enum FitType
   {
     CONTAIN,
     COVER
   };
 
   nsImageRenderer(nsIFrame* aForFrame, const nsStyleImage* aImage, uint32_t aFlags);
-  ~nsImageRenderer();
+  ~nsImageRenderer() = default;
   /**
    * Populates member variables to get ready for rendering.
    * @return true iff the image is ready, and there is at least a pixel to
    * draw.
    */
   bool PrepareImage();
 
   /**