Bug 1035394 - Fix dangerous public destructors in layout - r=dbaron
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 Jul 2014 17:23:18 -0400
changeset 193008 2f5b2fbae4fbfb698ce38a841cc9c694335921db
parent 193007 5821b55a574cfd078b7f3f9eeba2d497c2993254
child 193009 cd28b3d3a4bda887166adc0242e9fea16e7d84ca
push id27103
push usercbook@mozilla.com
push dateWed, 09 Jul 2014 13:55:18 +0000
treeherdermozilla-central@f945d50e50fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1035394
milestone33.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 1035394 - Fix dangerous public destructors in layout - r=dbaron
layout/printing/nsPagePrintTimer.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
layout/svg/nsSVGEffects.h
layout/xul/grid/nsGridLayout2.cpp
layout/xul/grid/nsGridLayout2.h
layout/xul/grid/nsGridRowLayout.cpp
layout/xul/grid/nsGridRowLayout.h
layout/xul/nsContainerBoxObject.cpp
layout/xul/nsListBoxObject.cpp
layout/xul/nsMenuBoxObject.cpp
layout/xul/nsMenuPopupFrame.h
layout/xul/nsScrollBoxObject.cpp
layout/xul/tree/nsTreeBoxObject.h
--- a/layout/printing/nsPagePrintTimer.h
+++ b/layout/printing/nsPagePrintTimer.h
@@ -33,27 +33,28 @@ public:
     , mDelay(aDelay)
     , mFiringCount(0)
     , mPrintObj(nullptr)
     , mWatchDogCount(0)
     , mDone(false)
   {
     mDocViewerPrint->IncrementDestroyRefCount();
   }
-  ~nsPagePrintTimer();
 
   NS_DECL_NSITIMERCALLBACK
 
   nsresult Start(nsPrintObject* aPO);
 
   NS_IMETHOD Run() MOZ_OVERRIDE;
 
   void Stop();
 
 private:
+  ~nsPagePrintTimer();
+
   nsresult StartTimer(bool aUseDelay);
   nsresult StartWatchDogTimer();
   void     StopWatchDogTimer();
   void     Fail();
 
   nsPrintEngine*             mPrintEngine;
   nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
   nsCOMPtr<nsITimer>         mTimer;
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -2856,16 +2856,20 @@ namespace mozilla {
 
 CSSSupportsRule::CSSSupportsRule(bool aConditionMet,
                                  const nsString& aCondition)
   : mUseGroup(aConditionMet),
     mCondition(aCondition)
 {
 }
 
+CSSSupportsRule::~CSSSupportsRule()
+{
+}
+
 CSSSupportsRule::CSSSupportsRule(const CSSSupportsRule& aCopy)
   : css::GroupRule(aCopy),
     mUseGroup(aCopy.mUseGroup),
     mCondition(aCopy.mCondition)
 {
 }
 
 #ifdef DEBUG
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -639,16 +639,18 @@ public:
   NS_DECL_NSIDOMCSSCONDITIONRULE
 
   // nsIDOMCSSSupportsRule interface
   NS_DECL_NSIDOMCSSSUPPORTSRULE
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 protected:
+  virtual ~CSSSupportsRule();
+
   bool mUseGroup;
   nsString mCondition;
 };
 
 } // namespace mozilla
 
 class nsCSSCounterStyleRule MOZ_FINAL : public mozilla::css::Rule,
                                         public nsIDOMCSSCounterStyleRule
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -178,16 +178,19 @@ public:
   nsSVGFilterFrame *GetFilterFrame();
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsISVGFilterReference
   virtual void Invalidate() MOZ_OVERRIDE { DoUpdate(); };
 
+protected:
+  virtual ~nsSVGFilterReference() {}
+
 private:
   // nsSVGIDRenderingObserver
   virtual void DoUpdate() MOZ_OVERRIDE;
 };
 
 /**
  * This class manages a list of nsSVGFilterReferences, which represent SVG
  * reference filters in a filter chain.
--- a/layout/xul/grid/nsGridLayout2.cpp
+++ b/layout/xul/grid/nsGridLayout2.cpp
@@ -27,16 +27,20 @@ NS_NewGridLayout2( nsIPresShell* aPresSh
   return NS_OK;
   
 } 
 
 nsGridLayout2::nsGridLayout2(nsIPresShell* aPresShell):nsStackLayout()
 {
 }
 
+nsGridLayout2::~nsGridLayout2()
+{
+}
+
 // static
 void
 nsGridLayout2::AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize)
 {
   nsMargin offset;
   GetOffset(aState, aChild, offset);
   aSize.width += offset.left;
   aSize.height += offset.top;
--- a/layout/xul/grid/nsGridLayout2.h
+++ b/layout/xul/grid/nsGridLayout2.h
@@ -61,16 +61,17 @@ public:
 
   virtual nsIGridPart* AsGridPart() MOZ_OVERRIDE { return this; }
 
   static void AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize);
 
 protected:
 
   nsGridLayout2(nsIPresShell* aShell);
+  virtual ~nsGridLayout2();
   nsGrid mGrid;
 
 private:
   void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
 
 
 }; // class nsGridLayout2
 
--- a/layout/xul/grid/nsGridRowLayout.cpp
+++ b/layout/xul/grid/nsGridRowLayout.cpp
@@ -16,16 +16,20 @@
 #include "nsBox.h"
 #include "nsStackLayout.h"
 #include "nsGrid.h"
 
 nsGridRowLayout::nsGridRowLayout():nsSprocketLayout()
 {
 }
 
+nsGridRowLayout::~nsGridRowLayout()
+{
+}
+
 void
 nsGridRowLayout::ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
                                   nsIFrame* aPrevBox,
                                   const nsFrameList::Slice& aNewChildren)
 {
   ChildAddedOrRemoved(aBox, aState);
 }
 
--- a/layout/xul/grid/nsGridRowLayout.h
+++ b/layout/xul/grid/nsGridRowLayout.h
@@ -48,12 +48,13 @@ public:
   virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) MOZ_OVERRIDE;
 
   virtual nsIGridPart* AsGridPart() MOZ_OVERRIDE { return this; }
 
 protected:
   virtual void ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState)=0;
 
   nsGridRowLayout();
+  virtual ~nsGridRowLayout();
 };
 
 #endif
 
--- a/layout/xul/nsContainerBoxObject.cpp
+++ b/layout/xul/nsContainerBoxObject.cpp
@@ -21,16 +21,18 @@
  * backward compatibility.
  */
 
 class nsContainerBoxObject : public nsBoxObject,
                              public nsIBrowserBoxObject,
                              public nsIEditorBoxObject,
                              public nsIIFrameBoxObject
 {
+protected:
+  virtual ~nsContainerBoxObject() {}
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSICONTAINERBOXOBJECT
   NS_DECL_NSIBROWSERBOXOBJECT
   NS_DECL_NSIEDITORBOXOBJECT
   NS_DECL_NSIIFRAMEBOXOBJECT
 };
 
--- a/layout/xul/nsListBoxObject.cpp
+++ b/layout/xul/nsListBoxObject.cpp
@@ -24,18 +24,20 @@ public:
   // nsPIListBoxObject
   virtual nsListBoxBodyFrame* GetListBoxBody(bool aFlush) MOZ_OVERRIDE;
 
   nsListBoxObject();
 
   // nsPIBoxObject
   virtual void Clear() MOZ_OVERRIDE;
   virtual void ClearCachedValues() MOZ_OVERRIDE;
-  
+
 protected:
+  virtual ~nsListBoxObject() {}
+
   nsListBoxBodyFrame *mListBoxBody;
 };
 
 NS_IMPL_ISUPPORTS_INHERITED(nsListBoxObject, nsBoxObject, nsIListBoxObject,
                             nsPIListBoxObject)
 
 nsListBoxObject::nsListBoxObject()
   : mListBoxBody(nullptr)
--- a/layout/xul/nsMenuBoxObject.cpp
+++ b/layout/xul/nsMenuBoxObject.cpp
@@ -15,16 +15,17 @@
 class nsMenuBoxObject : public nsIMenuBoxObject,
                         public nsBoxObject
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIMENUBOXOBJECT
 
   nsMenuBoxObject();
+protected:
   virtual ~nsMenuBoxObject();
 };
 
 nsMenuBoxObject::nsMenuBoxObject()
 {
 }
 
 nsMenuBoxObject::~nsMenuBoxObject()
--- a/layout/xul/nsMenuPopupFrame.h
+++ b/layout/xul/nsMenuPopupFrame.h
@@ -122,24 +122,25 @@ class nsMenuPopupFrame;
 class nsXULPopupShownEvent : public nsRunnable, public nsIDOMEventListener
 {
 public:
   nsXULPopupShownEvent(nsIContent *aPopup, nsPresContext* aPresContext)
     : mPopup(aPopup), mPresContext(aPresContext)
   {
   }
 
-  virtual ~nsXULPopupShownEvent() { }
-
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSIDOMEVENTLISTENER
 
   void CancelListener();
 
+protected:
+  virtual ~nsXULPopupShownEvent() { }
+
 private:
   nsCOMPtr<nsIContent> mPopup;
   nsRefPtr<nsPresContext> mPresContext;
 };
 
 class nsMenuPopupFrame : public nsBoxFrame, public nsMenuParent
 {
 public:
--- a/layout/xul/nsScrollBoxObject.cpp
+++ b/layout/xul/nsScrollBoxObject.cpp
@@ -17,23 +17,23 @@ using namespace mozilla;
 
 class nsScrollBoxObject : public nsIScrollBoxObject, public nsBoxObject
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSISCROLLBOXOBJECT
 
   nsScrollBoxObject();
-  virtual ~nsScrollBoxObject();
 
   virtual nsIScrollableFrame* GetScrollFrame() {
     return do_QueryFrame(GetFrame(false));
   }
 
-  /* additional members */
+protected:
+  virtual ~nsScrollBoxObject();
 };
 
 /* Implementation file */
 
 NS_INTERFACE_MAP_BEGIN(nsScrollBoxObject)
   NS_INTERFACE_MAP_ENTRY(nsIScrollBoxObject)
 NS_INTERFACE_MAP_END_INHERITING(nsBoxObject)
 
--- a/layout/xul/tree/nsTreeBoxObject.h
+++ b/layout/xul/tree/nsTreeBoxObject.h
@@ -16,23 +16,23 @@ class nsTreeBodyFrame;
 class nsTreeBoxObject : public nsITreeBoxObject, public nsBoxObject
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsTreeBoxObject, nsBoxObject)
   NS_DECL_NSITREEBOXOBJECT
 
   nsTreeBoxObject();
-  ~nsTreeBoxObject();
 
   nsTreeBodyFrame* GetTreeBody(bool aFlushLayout = false);
   nsTreeBodyFrame* GetCachedTreeBody() { return mTreeBody; }
 
   //NS_PIBOXOBJECT interfaces
   virtual void Clear() MOZ_OVERRIDE;
   virtual void ClearCachedValues() MOZ_OVERRIDE;
 
 protected:
+  ~nsTreeBoxObject();
   nsTreeBodyFrame* mTreeBody;
   nsCOMPtr<nsITreeView> mView;
 };
 
 #endif