Bug 1453795 - XPToolkit - Initialize member fields in classes/ structures. r=jvarga
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Fri, 15 Jun 2018 14:12:46 +0300
changeset 423669 71e4328d15abe687fdd7db20e4d0bcc4d821f407
parent 423668 064e448df638efc4a99fdf9f400d1eac2b7505ca
child 423670 f0f5158db88c8a9712b7e09fccaf10d004343e85
push id34190
push userebalazs@mozilla.com
push dateTue, 26 Jun 2018 14:53:39 +0000
treeherdermozilla-central@348090c6b5c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjvarga
bugs1453795
milestone63.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 1453795 - XPToolkit - Initialize member fields in classes/ structures. r=jvarga
dom/xul/nsXULContentSink.cpp
dom/xul/nsXULContentSink.h
layout/xul/nsImageBoxFrame.cpp
layout/xul/nsImageBoxFrame.h
layout/xul/nsMenuPopupFrame.h
layout/xul/nsSplitterFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
layout/xul/tree/nsTreeColumns.cpp
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -69,20 +69,17 @@ XULContentSinkImpl::ContextStack::~Conte
         mTop = mTop->mNext;
         delete doomed;
     }
 }
 
 nsresult
 XULContentSinkImpl::ContextStack::Push(nsXULPrototypeNode* aNode, State aState)
 {
-    Entry* entry = new Entry;
-    entry->mNode  = aNode;
-    entry->mState = aState;
-    entry->mNext  = mTop;
+    Entry* entry = new Entry(aNode, aState, mTop);
 
     mTop = entry;
 
     ++mDepth;
     return NS_OK;
 }
 
 nsresult
--- a/dom/xul/nsXULContentSink.h
+++ b/dom/xul/nsXULContentSink.h
@@ -107,17 +107,22 @@ protected:
     class ContextStack {
     protected:
         struct Entry {
             RefPtr<nsXULPrototypeNode> mNode;
             // a LOT of nodes have children; preallocate for 8
             nsPrototypeArray    mChildren;
             State               mState;
             Entry*              mNext;
-            Entry() : mChildren(8) {}
+            Entry(nsXULPrototypeNode* aNode, State aState, Entry* aNext)
+                : mNode(aNode)
+                , mChildren(8)
+                , mState(aState)
+                , mNext(aNext)
+            {}
         };
 
         Entry* mTop;
         int32_t mDepth;
 
     public:
         ContextStack();
         ~ContextStack();
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -182,30 +182,29 @@ nsImageBoxFrame::DestroyFrom(nsIFrame* a
     nsLayoutUtils::DeregisterImageRequest(PresContext(), mImageRequest,
                                           &mRequestRegistered);
 
     // Release image loader first so that it's refcnt can go to zero
     mImageRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
   }
 
   if (mListener)
-    reinterpret_cast<nsImageBoxListener*>(mListener.get())->SetFrame(nullptr); // set the frame to null so we don't send messages to a dead object.
+    reinterpret_cast<nsImageBoxListener*>(mListener.get())->ClearFrame(); // set the frame to null so we don't send messages to a dead object.
 
   nsLeafBoxFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
 }
 
 
 void
 nsImageBoxFrame::Init(nsIContent*       aContent,
                       nsContainerFrame* aParent,
                       nsIFrame*         aPrevInFlow)
 {
   if (!mListener) {
-    RefPtr<nsImageBoxListener> listener = new nsImageBoxListener();
-    listener->SetFrame(this);
+    RefPtr<nsImageBoxListener> listener = new nsImageBoxListener(this);
     mListener = listener.forget();
   }
 
   mSuppressStyleCheck = true;
   nsLeafBoxFrame::Init(aContent, aParent, aPrevInFlow);
   mSuppressStyleCheck = false;
 
   UpdateLoadFlags();
@@ -903,17 +902,18 @@ nsImageBoxFrame::OnFrameUpdate(imgIReque
 
   InvalidateLayer(DisplayItemType::TYPE_XUL_IMAGE);
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(nsImageBoxListener, imgINotificationObserver)
 
-nsImageBoxListener::nsImageBoxListener()
+nsImageBoxListener::nsImageBoxListener(nsImageBoxFrame *frame)
+  : mFrame(frame)
 {
 }
 
 nsImageBoxListener::~nsImageBoxListener()
 {
 }
 
 NS_IMETHODIMP
--- a/layout/xul/nsImageBoxFrame.h
+++ b/layout/xul/nsImageBoxFrame.h
@@ -16,22 +16,22 @@
 class imgRequestProxy;
 class nsImageBoxFrame;
 
 class nsDisplayXULImage;
 
 class nsImageBoxListener final : public imgINotificationObserver
 {
 public:
-  nsImageBoxListener();
+  explicit nsImageBoxListener(nsImageBoxFrame *frame);
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
-  void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
+  void ClearFrame() { mFrame = nullptr; }
 
 private:
   virtual ~nsImageBoxListener();
 
   nsImageBoxFrame *mFrame;
 };
 
 class nsImageBoxFrame final : public nsLeafBoxFrame
--- a/layout/xul/nsMenuPopupFrame.h
+++ b/layout/xul/nsMenuPopupFrame.h
@@ -602,17 +602,18 @@ protected:
   int8_t mPosition;
 
   FlipType mFlip; // Whether to flip
 
   struct ReflowCallbackData {
     ReflowCallbackData() :
       mPosted(false),
       mAnchor(nullptr),
-      mSizedToPopup(false)
+      mSizedToPopup(false),
+      mIsOpenChanged(false)
     {}
     void MarkPosted(nsIFrame* aAnchor, bool aSizedToPopup, bool aIsOpenChanged) {
       mPosted = true;
       mAnchor = aAnchor;
       mSizedToPopup = aSizedToPopup;
       mIsOpenChanged = aIsOpenChanged;
     }
     void Clear() {
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -57,16 +57,24 @@ protected:
   virtual ~nsSplitterFrameInner();
 
 public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
   explicit nsSplitterFrameInner(nsSplitterFrame* aSplitter)
+    : mDidDrag(false)
+    , mDragStart(0)
+    , mParentBox(nullptr)
+    , mChildInfosBeforeCount(0)
+    , mChildInfosAfterCount(0)
+    , mState(Open)
+    , mSplitterPos(0)
+    , mDragging(false)
   {
     mOuter = aSplitter;
     mPressed = false;
   }
 
   void Disconnect() { mOuter = nullptr; }
 
   nsresult MouseDown(Event* aMouseEvent);
@@ -108,17 +116,16 @@ public:
   bool SupportsCollapseDirection(CollapseDirection aDirection);
 
   void EnsureOrient();
   void SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize);
 
   nsSplitterFrame* mOuter;
   bool mDidDrag;
   nscoord mDragStart;
-  nscoord mCurrentPos;
   nsIFrame* mParentBox;
   bool mPressed;
   UniquePtr<nsSplitterInfo[]> mChildInfosBefore;
   UniquePtr<nsSplitterInfo[]> mChildInfosAfter;
   int32_t mChildInfosBeforeCount;
   int32_t mChildInfosAfterCount;
   State mState;
   nscoord mSplitterPos;
@@ -260,18 +267,16 @@ void
 nsSplitterFrame::Init(nsIContent*       aContent,
                       nsContainerFrame* aParent,
                       nsIFrame*         aPrevInFlow)
 {
   MOZ_ASSERT(!mInner);
   mInner = new nsSplitterFrameInner(this);
 
   mInner->AddRef();
-  mInner->mState = nsSplitterFrameInner::Open;
-  mInner->mDragging = false;
 
   // determine orientation of parent, and if vertical, set orient to vertical
   // on splitter content, then re-resolve style
   // XXXbz this is pretty messed up, since this can change whether we should
   // have a frame at all.  This really needs a better solution.
   if (aParent && aParent->IsXULBoxFrame()) {
     if (!aParent->IsXULHorizontal()) {
       if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
@@ -626,17 +631,16 @@ nsSplitterFrameInner::MouseDown(Event* a
   int32_t childCount = siblingList.GetLength();
   // if it's the last index then we need to allow for resizeafter="grow"
   if (childIndex == childCount - 1 && GetResizeAfter() != Grow)
     return NS_OK;
 
   RefPtr<gfxContext> rc =
     outerPresContext->PresShell()->CreateReferenceRenderingContext();
   nsBoxLayoutState state(outerPresContext, rc);
-  mCurrentPos = 0;
   mPressed = true;
 
   mDidDrag = false;
 
   EnsureOrient();
   bool isHorizontal = !mOuter->IsXULHorizontal();
 
   ResizeType resizeBefore = GetResizeBefore();
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -502,17 +502,23 @@ protected:
   void FireInvalidateEvent(int32_t aStartRow, int32_t aEndRow,
                            nsTreeColumn *aStartCol, nsTreeColumn *aEndCol);
 #endif
 
 protected: // Data Members
 
   class Slots {
     public:
-      Slots() {
+      Slots()
+        : mDropAllowed(false)
+        , mIsDragging(false)
+        , mDropRow(-1)
+        , mDropOrient(-1)
+        , mScrollLines(0)
+        , mDragAction(0) {
       }
 
       ~Slots() {
         if (mTimer)
           mTimer->Cancel();
       }
 
       friend class nsTreeBodyFrame;
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -18,16 +18,17 @@
 #include "mozilla/dom/TreeColumnsBinding.h"
 
 using namespace mozilla;
 
 // Column class that caches all the info about our column.
 nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, dom::Element* aElement)
   : mContent(aElement),
     mColumns(aColumns),
+    mIndex(0),
     mPrevious(nullptr)
 {
   NS_ASSERTION(aElement &&
                aElement->NodeInfo()->Equals(nsGkAtoms::treecol,
                                             kNameSpaceID_XUL),
                "nsTreeColumn's content must be a <xul:treecol>");
 
   Invalidate(IgnoreErrors());