Remove some unnecessary differences between us and m-c
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 14 Sep 2017 11:03:29 -0400
changeset 685635 1f3de1eeb35499aa75d48ae786945b87452b8eb3
parent 685634 10d6b57d34593860a58812fdab8ec0d4c815b114
child 685636 145dbc4727d3bb2d964765a1738ecdfac782a24a
push id86010
push userbmo:ethlin@mozilla.com
push dateWed, 25 Oct 2017 00:44:42 +0000
milestone57.0a1
Remove some unnecessary differences between us and m-c
layout/base/nsLayoutUtils.cpp
layout/generic/TextOverflow.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/painting/FrameLayerBuilder.cpp
mfbt/SmallPointerArray.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3053,18 +3053,16 @@ nsLayoutUtils::GetLayerTransformForFrame
   nsDisplayTransform* item =
     new (&builder) nsDisplayTransform(&builder, aFrame, &list, nsRect());
 
   *aTransform = item->GetTransform();
   item->Destroy(&builder);
 
   builder.EndFrame();
 
-  builder.EndFrame();
-
   return true;
 }
 
 static bool
 TransformGfxPointFromAncestor(nsIFrame *aFrame,
                               const Point &aPoint,
                               nsIFrame *aAncestor,
                               Point* aOut)
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -172,62 +172,49 @@ public:
       mStyle(aStyle), mAscent(aAscent), mIndex((aLineNumber << 1) + aIndex) {
     MOZ_COUNT_CTOR(nsDisplayTextOverflowMarker);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
   virtual ~nsDisplayTextOverflowMarker() {
     MOZ_COUNT_DTOR(nsDisplayTextOverflowMarker);
   }
 #endif
-
-  nsIFrame* StyleFrame() const override { return mStyleFrame; }
-
   virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
                            bool* aSnap) const override
   {
     *aSnap = false;
     nsRect shadowRect =
-      nsLayoutUtils::GetTextShadowRectsUnion(mRect, mStyleFrame);
+      nsLayoutUtils::GetTextShadowRectsUnion(mRect, mFrame);
     return mRect.Union(shadowRect);
   }
 
   virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) const override
   {
     if (gfxPlatform::GetPlatform()->RespectsFontStyleSmoothing()) {
       // On OS X, web authors can turn off subpixel text rendering using the
       // CSS property -moz-osx-font-smoothing. If they do that, we don't need
       // to use component alpha layers for the affected text.
-      if (mStyleFrame->StyleFont()->mFont.smoothing == NS_FONT_SMOOTHING_GRAYSCALE) {
+      if (mFrame->StyleFont()->mFont.smoothing == NS_FONT_SMOOTHING_GRAYSCALE) {
         return nsRect();
       }
     }
     bool snap;
     return GetBounds(aBuilder, &snap);
   }
 
-  virtual bool IsInvalid(nsRect& aRect) const override
-  {
-    if (mStyleFrame->IsInvalid(aRect) && aRect.IsEmpty()) {
-      return true;
-    }
-    aRect += ToReferenceFrame();
-    return !aRect.IsEmpty();
-  }
-
   virtual void Paint(nsDisplayListBuilder* aBuilder,
                      gfxContext* aCtx) override;
 
   virtual uint32_t GetPerFrameKey() const override {
     return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey();
   }
   void PaintTextToContext(gfxContext* aCtx,
                           nsPoint aOffsetFromRect);
   NS_DISPLAY_DECL_NAME("TextOverflow", TYPE_TEXT_OVERFLOW)
 private:
-  nsIFrame*       mStyleFrame;
   nsRect          mRect;   // in reference frame coordinates
   const nsStyleTextOverflowSide* mStyle;
   nscoord         mAscent; // baseline for the marker text in mRect
   uint32_t        mIndex;
 };
 
 static void
 PaintTextShadowCallback(gfxContext* aCtx,
@@ -239,59 +226,59 @@ PaintTextShadowCallback(gfxContext* aCtx
            PaintTextToContext(aCtx, aShadowOffset);
 }
 
 void
 nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder,
                                    gfxContext*           aCtx)
 {
   nscolor foregroundColor = nsLayoutUtils::
-    GetColor(mStyleFrame, &nsStyleText::mWebkitTextFillColor);
+    GetColor(mFrame, &nsStyleText::mWebkitTextFillColor);
 
   // Paint the text-shadows for the overflow marker
-  nsLayoutUtils::PaintTextShadow(mStyleFrame, aCtx, mRect, mVisibleRect,
+  nsLayoutUtils::PaintTextShadow(mFrame, aCtx, mRect, mVisibleRect,
                                  foregroundColor, PaintTextShadowCallback,
                                  (void*)this);
   aCtx->SetColor(gfx::Color::FromABGR(foregroundColor));
   PaintTextToContext(aCtx, nsPoint(0, 0));
 }
 
 void
 nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
                                                 nsPoint aOffsetFromRect)
 {
-  WritingMode wm = mStyleFrame->GetWritingMode();
+  WritingMode wm = mFrame->GetWritingMode();
   nsPoint pt(mRect.x, mRect.y);
   if (wm.IsVertical()) {
     if (wm.IsVerticalLR()) {
       pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX(
-        mStyleFrame, aCtx, pt.x, mAscent));
+        mFrame, aCtx, pt.x, mAscent));
     } else {
       pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX(
-        mStyleFrame, aCtx, pt.x + mRect.width, -mAscent));
+        mFrame, aCtx, pt.x + mRect.width, -mAscent));
     }
   } else {
     pt.y = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineY(
-      mStyleFrame, aCtx, pt.y, mAscent));
+      mFrame, aCtx, pt.y, mAscent));
   }
   pt += aOffsetFromRect;
 
   if (mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) {
-    gfxTextRun* textRun = GetEllipsisTextRun(mStyleFrame);
+    gfxTextRun* textRun = GetEllipsisTextRun(mFrame);
     if (textRun) {
       NS_ASSERTION(!textRun->IsRightToLeft(),
                    "Ellipsis textruns should always be LTR!");
       gfxPoint gfxPt(pt.x, pt.y);
       textRun->Draw(gfxTextRun::Range(textRun), gfxPt,
                     gfxTextRun::DrawParams(aCtx));
     }
   } else {
     RefPtr<nsFontMetrics> fm =
-      nsLayoutUtils::GetInflatedFontMetricsForFrame(mStyleFrame);
-    nsLayoutUtils::DrawString(mStyleFrame, *fm, aCtx, mStyle->mString.get(),
+      nsLayoutUtils::GetInflatedFontMetricsForFrame(mFrame);
+    nsLayoutUtils::DrawString(mFrame, *fm, aCtx, mStyle->mString.get(),
                               mStyle->mString.Length(), pt);
   }
 }
 
 TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder,
                            nsIFrame* aBlockFrame)
   : mContentArea(aBlockFrame->GetWritingMode(),
                  aBlockFrame->GetContentRectRelativeToSelf(),
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3225,18 +3225,17 @@ ShouldBeClippedByFrame(nsIFrame* aClipFr
   return nsLayoutUtils::IsProperAncestorFrame(aClipFrame, aClippedFrame);
 }
 
 static void
 ClipItemsExceptCaret(nsDisplayList* aList,
                      nsDisplayListBuilder* aBuilder,
                      nsIFrame* aClipFrame,
                      const DisplayItemClipChain* aExtraClip,
-                     nsDataHashtable<nsPtrHashKey<const DisplayItemClipChain>,
-                     const DisplayItemClipChain*>& aCache)
+                     nsDataHashtable<nsPtrHashKey<const DisplayItemClipChain>, const DisplayItemClipChain*>& aCache)
 {
   for (nsDisplayItem* i = aList->GetBottom(); i; i = i->GetAbove()) {
     if (!ShouldBeClippedByFrame(aClipFrame, i->Frame())) {
       continue;
     }
 
     if (i->GetType() != DisplayItemType::TYPE_CARET) {
       const DisplayItemClipChain* clip = i->GetClipChain();
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -5376,17 +5376,17 @@ ContainerState::Finish(uint32_t* aTextCo
       }
     }
 
     if (!layer->GetParent()) {
       // This is not currently a child of the container, so just add it
       // now.
       mContainerLayer->InsertAfter(layer, prevChild);
     } else {
-      MOZ_ASSERT(layer->GetParent() == mContainerLayer,
+      NS_ASSERTION(layer->GetParent() == mContainerLayer,
                    "Layer shouldn't be the child of some other container");
       if (layer->GetPrevSibling() != prevChild) {
         mContainerLayer->RepositionChild(layer, prevChild);
       }
     }
   }
 
   // Remove old layers that have become unused.
@@ -5884,18 +5884,17 @@ FrameLayerBuilder::GetDedicatedLayer(nsI
     }
     if (GetDisplayItemTypeFromKey(element->mDisplayItemKey) == aDisplayItemKey) {
       if (element->mOptLayer) {
         return element->mOptLayer;
       }
 
 
       Layer* layer = element->mLayer;
-      if (layer &&
-          !layer->HasUserData(&gColorLayerUserData) &&
+      if (!layer->HasUserData(&gColorLayerUserData) &&
           !layer->HasUserData(&gImageLayerUserData) &&
           !layer->HasUserData(&gPaintedDisplayItemLayerUserData)) {
         return layer;
       }
     }
   }
   return nullptr;
 }
--- a/mfbt/SmallPointerArray.h
+++ b/mfbt/SmallPointerArray.h
@@ -4,16 +4,17 @@
 * 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/. */
 
 /* A vector of pointers space-optimized for a small number of elements. */
 #ifndef mozilla_SmallPointerArray_h
 #define mozilla_SmallPointerArray_h
 
 #include "mozilla/Assertions.h"
+#include <algorithm>
 #include <iterator>
 #include <vector>
 
 namespace mozilla {
 
 // Array class for situations where a small number of elements (<= 2) is
 // expected, a large number of elements must be accomodated if necessary,
 // and the size of the class must be minimal. Typical vector implementations