Bug 1028588 - Fix dangerous public destructors in layout/ - r=dbaron
authorBenoit Jacob <bjacob@mozilla.com>
Mon, 23 Jun 2014 18:40:01 -0400
changeset 190356 2d4b9bc5d6f50ee3ea353a3d982e6caea40425b5
parent 190355 e3858c50afba19807775b48e883b896352f266cf
child 190357 438751141e7c3e7c6a8c4eb419eb99b1f7464cf2
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs1028588
milestone33.0a1
Bug 1028588 - Fix dangerous public destructors in layout/ - r=dbaron
layout/base/SelectionCarets.h
layout/base/TouchCaret.h
layout/base/nsCaret.h
layout/base/nsDocumentViewer.cpp
layout/base/nsFrameTraversal.cpp
layout/base/nsFrameTraversal.h
layout/base/nsLayoutDebugger.cpp
layout/base/nsPresShell.cpp
layout/base/nsStyleSheetService.h
layout/build/nsContentDLF.h
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFileControlFrame.h
layout/forms/nsListControlFrame.cpp
layout/generic/ScrollbarActivity.h
layout/generic/Selection.h
layout/generic/nsAutoCopyListener.h
layout/generic/nsBulletFrame.h
layout/generic/nsFrameSelection.h
layout/generic/nsFrameUtil.cpp
layout/generic/nsImageFrame.h
layout/generic/nsSelection.cpp
layout/inspector/inCSSValueSearch.h
layout/inspector/inDOMUtils.h
layout/inspector/inDOMView.h
layout/inspector/inDeepTreeWalker.h
layout/inspector/inFlasher.h
layout/inspector/nsFontFace.h
layout/inspector/nsFontFaceList.h
layout/mathml/nsMathMLChar.cpp
layout/mathml/nsMathMLmactionFrame.h
layout/printing/nsPrintEngine.h
layout/printing/nsPrintPreviewListener.h
layout/style/AnimationCommon.h
layout/style/CSSRuleList.h
layout/style/ImageLoader.h
layout/style/Loader.cpp
layout/style/StyleRule.cpp
layout/style/nsCSSRuleProcessor.h
layout/style/nsCSSRules.h
layout/style/nsComputedDOMStyle.h
layout/style/nsDOMCSSAttrDeclaration.h
layout/style/nsDOMCSSRGBColor.h
layout/style/nsDOMCSSRect.h
layout/style/nsDOMCSSValueList.h
layout/style/nsFontFaceLoader.h
layout/style/nsHTMLCSSStyleSheet.h
layout/style/nsHTMLStyleSheet.h
layout/style/nsROCSSPrimitiveValue.h
layout/style/nsStyleSet.h
layout/svg/SVGTextFrame.h
layout/svg/nsSVGEffects.h
layout/svg/nsSVGImageFrame.cpp
layout/tools/layout-debug/src/nsLayoutDebugCLH.h
layout/tools/layout-debug/src/nsLayoutDebuggingTools.h
layout/tools/layout-debug/src/nsRegressionTester.h
layout/xul/nsBoxLayout.h
layout/xul/nsBoxObject.h
layout/xul/nsImageBoxFrame.h
layout/xul/nsListBoxBodyFrame.cpp
layout/xul/nsMenuBarListener.h
layout/xul/nsMenuFrame.h
layout/xul/nsRepeatService.h
layout/xul/nsSliderFrame.h
layout/xul/nsSplitterFrame.cpp
layout/xul/nsXULPopupManager.cpp
layout/xul/tree/nsTreeColumns.h
layout/xul/tree/nsTreeContentView.h
layout/xul/tree/nsTreeImageListener.h
layout/xul/tree/nsTreeSelection.h
--- a/layout/base/SelectionCarets.h
+++ b/layout/base/SelectionCarets.h
@@ -52,17 +52,16 @@ public:
    */
   enum DragMode {
     NONE,
     START_FRAME,
     END_FRAME
   };
 
   explicit SelectionCarets(nsIPresShell *aPresShell);
-  virtual ~SelectionCarets();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISELECTIONLISTENER
 
   // nsIScrollObserver
   virtual void ScrollPositionChanged() MOZ_OVERRIDE;
 
   void Terminate()
@@ -87,16 +86,18 @@ public:
    * caret frame when we checking if user click on caret or not. In app units.
    */
   static int32_t SelectionCaretsInflateSize()
   {
     return sSelectionCaretsInflateSize;
   }
 
 private:
+  virtual ~SelectionCarets();
+
   SelectionCarets() MOZ_DELETE;
 
   /**
    * Update selection caret position base on current selection range.
    */
   void UpdateSelectionCarets();
 
   /**
--- a/layout/base/TouchCaret.h
+++ b/layout/base/TouchCaret.h
@@ -21,19 +21,21 @@ namespace mozilla {
 /**
  * The TouchCaret places a touch caret according to caret postion when the
  * caret is shown.
  * TouchCaret is also responsible for touch caret visibility. Touch caret
  * won't be shown when timer expires or while key event causes selection change.
  */
 class TouchCaret MOZ_FINAL : public nsISelectionListener
 {
+private:
+  ~TouchCaret();
+
 public:
   explicit TouchCaret(nsIPresShell* aPresShell);
-  ~TouchCaret();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISELECTIONLISTENER
 
   void Terminate()
   {
     mPresShell = nullptr;
   }
--- a/layout/base/nsCaret.h
+++ b/layout/base/nsCaret.h
@@ -18,28 +18,28 @@
 class nsRenderingContext;
 class nsDisplayListBuilder;
 class nsITimer;
 
 //-----------------------------------------------------------------------------
 class nsCaret : public nsISelectionListener
 {
   public:
+    nsCaret();
 
-                  nsCaret();
-    virtual       ~nsCaret();
+  protected:
+    virtual ~nsCaret();
 
+  public:
     enum EViewCoordinates {
       eTopLevelWindowCoordinates,
       eRenderingViewCoordinates,
       eClosestViewCoordinates
     };
 
-  public:
-
     NS_DECL_ISUPPORTS
 
     nsresult    Init(nsIPresShell *inPresShell);
     void    Terminate();
 
     nsISelection*    GetCaretDOMSelection();
     nsresult    SetCaretDOMSelection(nsISelection *inDOMSel);
 
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -175,46 +175,48 @@ public:
 
                        nsDocViewerSelectionListener()
                        : mDocViewer(nullptr)
                        , mGotSelectionState(false)
                        , mSelectionWasCollapsed(false)
                        {
                        }
 
-  virtual              ~nsDocViewerSelectionListener() {}
-
   nsresult             Init(nsDocumentViewer *aDocViewer);
 
 protected:
 
+  virtual              ~nsDocViewerSelectionListener() {}
+
   nsDocumentViewer*  mDocViewer;
   bool                 mGotSelectionState;
   bool                 mSelectionWasCollapsed;
 
 };
 
 
 /** editor Implementation of the FocusListener interface
  */
 class nsDocViewerFocusListener : public nsIDOMEventListener
 {
 public:
   /** default constructor
    */
   nsDocViewerFocusListener();
-  /** default destructor
-   */
-  virtual ~nsDocViewerFocusListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
   nsresult             Init(nsDocumentViewer *aDocViewer);
 
+protected:
+  /** default destructor
+   */
+  virtual ~nsDocViewerFocusListener();
+
 private:
     nsDocumentViewer*  mDocViewer;
 };
 
 
 //-------------------------------------------------------------
 class nsDocumentViewer : public nsIContentViewer,
                            public nsIContentViewerEdit,
--- a/layout/base/nsFrameTraversal.cpp
+++ b/layout/base/nsFrameTraversal.cpp
@@ -13,30 +13,30 @@
 
 class nsFrameIterator : public nsIFrameEnumerator
 {
 public:
   typedef nsIFrame::ChildListID ChildListID;
 
   NS_DECL_ISUPPORTS
 
-  virtual ~nsFrameIterator() {}
-
   virtual void First() MOZ_OVERRIDE;
   virtual void Next() MOZ_OVERRIDE;
   virtual nsIFrame* CurrentItem() MOZ_OVERRIDE;
   virtual bool IsDone() MOZ_OVERRIDE;
 
   virtual void Last() MOZ_OVERRIDE;
   virtual void Prev() MOZ_OVERRIDE;
 
   nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
                   nsIteratorType aType, bool aLockScroll, bool aFollowOOFs);
 
 protected:
+  virtual ~nsFrameIterator() {}
+
   void      setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
   nsIFrame *getCurrent(){return mCurrent;}
   nsIFrame *getStart(){return mStart;}
   nsIFrame *getLast(){return mLast;}
   void      setLast(nsIFrame *aFrame){mLast = aFrame;}
   int8_t    getOffEdge(){return mOffEdge;}
   void      setOffEdge(int8_t aOffEdge){mOffEdge = aOffEdge;}
 
--- a/layout/base/nsFrameTraversal.h
+++ b/layout/base/nsFrameTraversal.h
@@ -19,22 +19,24 @@ nsresult NS_NewFrameTraversal(nsIFrameEn
                               bool aFollowOOFs);
 
 nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
 
 class nsFrameTraversal : public nsIFrameTraversal
 {
 public:
   nsFrameTraversal();
-  virtual ~nsFrameTraversal();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
                                nsPresContext* aPresContext,
                                nsIFrame *aStart,
                                int32_t aType,
                                bool aVisual,
                                bool aLockInScrollView,
                                bool aFollowOOFs) MOZ_OVERRIDE;
+
+protected:
+  virtual ~nsFrameTraversal();
 };
 
 #endif //NSFRAMETRAVERSAL_H
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -18,17 +18,16 @@
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 #ifdef DEBUG
 class nsLayoutDebugger : public nsILayoutDebugger {
 public:
   nsLayoutDebugger();
-  virtual ~nsLayoutDebugger();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD SetShowFrameBorders(bool aEnable) MOZ_OVERRIDE;
 
   NS_IMETHOD GetShowFrameBorders(bool* aResult) MOZ_OVERRIDE;
 
   NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable) MOZ_OVERRIDE;
@@ -39,16 +38,18 @@ public:
                             int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
 
   NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
                           int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
 
   NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
                           int32_t* aSizeInBytesResult) MOZ_OVERRIDE;
 
+protected:
+  virtual ~nsLayoutDebugger();
 };
 
 nsresult
 NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
 {
   NS_PRECONDITION(aResult, "null OUT ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3732,16 +3732,18 @@ public:
   {
     mShell->SetNextPaintCompressed();
     mShell->AddInvalidateHiddenPresShellObserver(mShell->GetPresContext()->RefreshDriver());
     mShell->ScheduleViewManagerFlush();
     return NS_OK;
   }
 
 private:
+  ~PaintTimerCallBack() {}
+
   PresShell* mShell;
 };
 
 NS_IMPL_ISUPPORTS(PaintTimerCallBack, nsITimerCallback)
 
 void
 PresShell::ScheduleViewManagerFlush(PaintType aType)
 {
--- a/layout/base/nsStyleSheetService.h
+++ b/layout/base/nsStyleSheetService.h
@@ -28,17 +28,16 @@ class nsIStyleSheet;
   "@mozilla.org/content/style-sheet-service;1"
 
 class nsStyleSheetService MOZ_FINAL
   : public nsIStyleSheetService
   , public nsIMemoryReporter
 {
  public:
   nsStyleSheetService();
-  ~nsStyleSheetService();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTYLESHEETSERVICE
   NS_DECL_NSIMEMORYREPORTER
 
   nsresult Init();
 
   nsCOMArray<nsIStyleSheet>* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
@@ -46,16 +45,17 @@ class nsStyleSheetService MOZ_FINAL
   nsCOMArray<nsIStyleSheet>* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
   static nsStyleSheetService *GetInstance();
   static nsStyleSheetService *gInstance;
 
  private:
+  ~nsStyleSheetService();
 
   void RegisterFromEnumerator(nsICategoryManager  *aManager,
                                           const char          *aCategory,
                                           nsISimpleEnumerator *aEnumerator,
                                           uint32_t             aSheetType);
 
   int32_t FindSheetByURI(const nsCOMArray<nsIStyleSheet> &sheets,
                                      nsIURI *sheetURI);
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -16,19 +16,21 @@ class nsIInputStream;
 class nsILoadGroup;
 class nsIStreamListener;
 
 #define CONTENT_DLF_CONTRACTID "@mozilla.org/content/document-loader-factory;1"
 #define PLUGIN_DLF_CONTRACTID "@mozilla.org/content/plugin/document-loader-factory;1"
 
 class nsContentDLF : public nsIDocumentLoaderFactory
 {
+protected:
+  virtual ~nsContentDLF();
+
 public:
   nsContentDLF();
-  virtual ~nsContentDLF();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOCUMENTLOADERFACTORY
 
   nsresult InitUAStyleSheet();
 
   nsresult CreateDocument(const char* aCommand,
                           nsIChannel* aChannel,
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -69,32 +69,33 @@ class nsPresState;
 
 /**
  * Helper class that listens to the combo boxes button. If the button is pressed the
  * combo box is toggled to open or close. this is used by Accessibility which presses
  * that button Programmatically.
  */
 class nsComboButtonListener : public nsIDOMEventListener
 {
+private:
+  virtual ~nsComboButtonListener() {}
+
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD HandleEvent(nsIDOMEvent*) MOZ_OVERRIDE
   {
     mComboBox->ShowDropDown(!mComboBox->IsDroppedDown());
     return NS_OK;
   }
 
   nsComboButtonListener(nsComboboxControlFrame* aCombobox)
   {
     mComboBox = aCombobox;
   }
 
-  virtual ~nsComboButtonListener() {}
-
   nsComboboxControlFrame* mComboBox;
 };
 
 NS_IMPL_ISUPPORTS(nsComboButtonListener,
                   nsIDOMEventListener)
 
 // static class data member for Bug 32920
 nsComboboxControlFrame* nsComboboxControlFrame::sFocused = nullptr;
--- a/layout/forms/nsFileControlFrame.h
+++ b/layout/forms/nsFileControlFrame.h
@@ -72,23 +72,24 @@ protected:
   friend class MouseListener;
   class MouseListener : public nsIDOMEventListener {
   public:
     NS_DECL_ISUPPORTS
 
     MouseListener(nsFileControlFrame* aFrame)
      : mFrame(aFrame)
     {}
-    virtual ~MouseListener() {}
 
     void ForgetFrame() {
       mFrame = nullptr;
     }
 
   protected:
+    virtual ~MouseListener() {}
+
     nsFileControlFrame* mFrame;
   };
 
   class SyncDisabledStateEvent;
   friend class SyncDisabledStateEvent;
   class SyncDisabledStateEvent : public nsRunnable
   {
   public:
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -66,16 +66,18 @@ public:
     : mFrame(aFrame) { }
 
   void SetFrame(nsListControlFrame *aFrame) { mFrame = aFrame; }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
 private:
+  ~nsListEventListener() {}
+
   nsListControlFrame  *mFrame;
 };
 
 //---------------------------------------------------------
 nsContainerFrame*
 NS_NewListControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   nsListControlFrame* it =
--- a/layout/generic/ScrollbarActivity.h
+++ b/layout/generic/ScrollbarActivity.h
@@ -72,33 +72,32 @@ public:
    , mScrollbarFadeDuration(0)
   {
     QueryLookAndFeelVals();
   }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
-  virtual ~ScrollbarActivity() {}
-
   void Destroy();
 
   void ActivityOccurred();
   void ActivityStarted();
   void ActivityStopped();
 
   virtual void WillRefresh(TimeStamp aTime) MOZ_OVERRIDE;
 
   static void FadeBeginTimerFired(nsITimer* aTimer, void* aSelf) {
     nsRefPtr<ScrollbarActivity> scrollbarActivity(
       reinterpret_cast<ScrollbarActivity*>(aSelf));
     scrollbarActivity->BeginFade();
   }
 
 protected:
+  virtual ~ScrollbarActivity() {}
 
   bool IsActivityOngoing()
   { return mNestedActivityCounter > 0; }
   bool IsStillFading(TimeStamp aTime);
   void QueryLookAndFeelVals();
 
   void HandleEventForScrollbar(const nsAString& aType,
                                nsIContent* aTarget,
--- a/layout/generic/Selection.h
+++ b/layout/generic/Selection.h
@@ -45,20 +45,22 @@ struct RangeData
 // is never deleted before its Selections.
 namespace mozilla {
 namespace dom {
 
 class Selection : public nsISelectionPrivate,
                   public nsWrapperCache,
                   public nsSupportsWeakReference
 {
+protected:
+  virtual ~Selection();
+
 public:
   Selection();
   Selection(nsFrameSelection *aList);
-  virtual ~Selection();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Selection, nsISelectionPrivate)
   NS_DECL_NSISELECTION
   NS_DECL_NSISELECTIONPRIVATE
 
   nsIDocument* GetParentObject() const;
 
--- a/layout/generic/nsAutoCopyListener.h
+++ b/layout/generic/nsAutoCopyListener.h
@@ -34,12 +34,14 @@ public:
   }
 
   static void Shutdown()
   {
     NS_IF_RELEASE(sInstance);
   }
 
 private:
+  ~nsAutoCopyListener() {}
+
   static nsAutoCopyListener* sInstance;
 };
 
 #endif
--- a/layout/generic/nsBulletFrame.h
+++ b/layout/generic/nsBulletFrame.h
@@ -17,24 +17,25 @@ class imgIContainer;
 class imgRequestProxy;
 
 class nsBulletFrame;
 
 class nsBulletListener : public imgINotificationObserver
 {
 public:
   nsBulletListener();
-  virtual ~nsBulletListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
   void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
 
 private:
+  virtual ~nsBulletListener();
+
   nsBulletFrame *mFrame;
 };
 
 /**
  * A simple class that manages the layout and rendering of html bullets.
  * This class also supports the CSS list-style properties.
  */
 class nsBulletFrame : public nsFrame {
--- a/layout/generic/nsFrameSelection.h
+++ b/layout/generic/nsFrameSelection.h
@@ -588,17 +588,20 @@ public:
   nsresult DeleteFromDocument();
 
   nsIPresShell *GetShell()const  { return mShell; }
 
   void DisconnectFromPresShell();
   nsresult ClearNormalSelection();
 
   static HINT GetHintForPosition(nsIContent* aContent, int32_t aOffset);
+
 private:
+  ~nsFrameSelection() {}
+
   nsresult TakeFocus(nsIContent *aNewFocus,
                      uint32_t aContentOffset,
                      uint32_t aContentEndOffset,
                      HINT aHint,
                      bool aContinueSelection,
                      bool aMultipleSelection);
 
   void BidiLevelFromMove(nsIPresShell* aPresShell,
--- a/layout/generic/nsFrameUtil.cpp
+++ b/layout/generic/nsFrameUtil.cpp
@@ -10,19 +10,21 @@
 #include "nsString.h"
 #include "nsRect.h"
 #include <stdlib.h>
 #include "plstr.h"
 
 
 #ifdef DEBUG
 class nsFrameUtil : public nsIFrameUtil {
+protected:
+  virtual ~nsFrameUtil();
+
 public:
   nsFrameUtil();
-  virtual ~nsFrameUtil();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD CompareRegressionData(FILE* aFile1, FILE* aFile2,int32_t aRegressionOutput=0);
   NS_IMETHOD DumpRegressionData(FILE* aInputFile, FILE* aOutputFile);
 
   struct Node;
   struct Tag;
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -36,19 +36,21 @@ namespace layers {
   class ImageContainer;
   class ImageLayer;
   class LayerManager;
 }
 }
 
 class nsImageListener : public imgINotificationObserver
 {
+protected:
+  virtual ~nsImageListener();
+
 public:
   nsImageListener(nsImageFrame *aFrame);
-  virtual ~nsImageListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
   void SetFrame(nsImageFrame *frame) { mFrame = frame; }
 
 private:
   nsImageFrame *mFrame;
@@ -326,16 +328,18 @@ private:
     }
 
     void RemoveIconObserver(nsImageFrame *frame) {
       mozilla::DebugOnly<bool> didRemove = mIconObservers.RemoveElement(frame);
       NS_ABORT_IF_FALSE(didRemove, "Observer not in array");
     }
 
   private:
+    ~IconLoad() {}
+
     void GetPrefs();
     nsTObserverArray<nsImageFrame*> mIconObservers;
 
 
   public:
     nsRefPtr<imgRequestProxy> mLoadingImage;
     nsRefPtr<imgRequestProxy> mBrokenImage;
     bool             mPrefForceInlineAltText;
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -142,22 +142,16 @@ public:
 
   NS_DECL_ISUPPORTS
 
   nsAutoScrollTimer()
   : mFrameSelection(0), mSelection(0), mPresContext(0), mPoint(0,0), mDelay(30)
   {
   }
 
-  virtual ~nsAutoScrollTimer()
-  {
-   if (mTimer)
-       mTimer->Cancel();
-  }
-
   // aPoint is relative to aPresContext's root frame
   nsresult Start(nsPresContext *aPresContext, nsPoint &aPoint)
   {
     mPoint = aPoint;
 
     // Store the presentation context. The timer will be
     // stopped by the selection if the prescontext is destroyed.
     mPresContext = aPresContext;
@@ -217,16 +211,25 @@ public:
       if (!frame.IsAlive())
         return NS_OK;
 
       NS_ASSERTION(frame->PresContext() == mPresContext, "document mismatch?");
       mSelection->DoAutoScroll(frame, pt);
     }
     return NS_OK;
   }
+
+protected:
+  virtual ~nsAutoScrollTimer()
+  {
+   if (mTimer) {
+     mTimer->Cancel();
+   }
+  }
+
 private:
   nsFrameSelection *mFrameSelection;
   Selection* mSelection;
   nsPresContext *mPresContext;
   // relative to mPresContext's root frame
   nsPoint mPoint;
   nsCOMPtr<nsITimer> mTimer;
   nsCOMPtr<nsIContent> mContent;
--- a/layout/inspector/inCSSValueSearch.h
+++ b/layout/inspector/inCSSValueSearch.h
@@ -22,19 +22,19 @@ class nsIURI;
 class inCSSValueSearch : public inICSSValueSearch
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INISEARCHPROCESS
   NS_DECL_INICSSVALUESEARCH
 
   inCSSValueSearch();
-  virtual ~inCSSValueSearch();
 
 protected:
+  virtual ~inCSSValueSearch();
   nsCOMPtr<inISearchObserver> mObserver;
   nsCOMPtr<nsIDOMDocument> mDocument;
   nsTArray<nsAutoString *>* mResults;
   nsCSSProperty* mProperties;
   nsString mLastResult;
   nsString mBaseURL;
   nsString mTextCriteria;
   int32_t mResultCount;
--- a/layout/inspector/inDOMUtils.h
+++ b/layout/inspector/inDOMUtils.h
@@ -19,19 +19,20 @@ class Element;
 
 class inDOMUtils : public inIDOMUtils
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INIDOMUTILS
 
   inDOMUtils();
+
+private:
   virtual ~inDOMUtils();
 
-private:
   // aStyleContext must be released by the caller once he's done with aRuleNode.
   static nsresult GetRuleNodeForElement(mozilla::dom::Element* aElement,
                                         nsIAtom* aPseudo,
                                         nsStyleContext** aStyleContext,
                                         nsRuleNode** aRuleNode);
 };
 
 // {0a499822-a287-4089-ad3f-9ffcd4f40263}
--- a/layout/inspector/inDOMView.h
+++ b/layout/inspector/inDOMView.h
@@ -25,26 +25,27 @@ class inDOMView : public inIDOMView,
                   public nsStubMutationObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INIDOMVIEW
   NS_DECL_NSITREEVIEW
 
   inDOMView();
-  virtual ~inDOMView();
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
 protected:
+  virtual ~inDOMView();
+
   nsCOMPtr<nsITreeBoxObject> mTree;
   nsCOMPtr<nsITreeSelection> mSelection;
   nsCOMPtr<inIDOMUtils> mDOMUtils;
 
   bool mShowAnonymous;
   bool mShowSubDocuments;
   bool mShowWhitespaceNodes;
   bool mShowAccessibleNodes;
--- a/layout/inspector/inDeepTreeWalker.h
+++ b/layout/inspector/inDeepTreeWalker.h
@@ -27,19 +27,20 @@ struct DeepTreeStackItem
 
 class inDeepTreeWalker : public inIDeepTreeWalker
 {
 public:
 	NS_DECL_ISUPPORTS
 	NS_DECL_INIDEEPTREEWALKER
 
   inDeepTreeWalker();
+
+protected:
   virtual ~inDeepTreeWalker();
 
-protected:
   void PushNode(nsIDOMNode* aNode);
 
   bool mShowAnonymousContent;
   bool mShowSubDocuments;
   nsCOMPtr<nsIDOMNode> mRoot;
   nsCOMPtr<nsIDOMNode> mCurrentNode;
   uint32_t mWhatToShow;
   
--- a/layout/inspector/inFlasher.h
+++ b/layout/inspector/inFlasher.h
@@ -19,19 +19,20 @@ class nsRenderingContext;
 
 class inFlasher : public inIFlasher
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INIFLASHER
 
   inFlasher();
+
+protected:
   virtual ~inFlasher();
 
-protected:
   void DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
                    nsRenderingContext* aRenderContext,
                    bool aDrawBegin, bool aDrawEnd);
   void DrawLine(nscoord aX, nscoord aY, nscoord aLength,
                 bool aDir, bool aBounds,
                 nsRenderingContext* aRenderContext);
 
   nscolor mColor;
--- a/layout/inspector/nsFontFace.h
+++ b/layout/inspector/nsFontFace.h
@@ -16,23 +16,24 @@ class nsFontFace : public nsIDOMFontFace
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMFONTFACE
 
   nsFontFace(gfxFontEntry*      aFontEntry,
              gfxFontGroup*      aFontGroup,
              uint8_t            aMatchInfo);
-  virtual ~nsFontFace();
 
   gfxFontEntry* GetFontEntry() const { return mFontEntry.get(); }
 
   void AddMatchType(uint8_t aMatchType) {
     mMatchType |= aMatchType;
   }
 
 protected:
+  virtual ~nsFontFace();
+
   nsRefPtr<gfxFontEntry> mFontEntry;
   nsRefPtr<gfxFontGroup> mFontGroup;
   uint8_t mMatchType;
 };
 
 #endif // __nsFontFace_h__
--- a/layout/inspector/nsFontFaceList.h
+++ b/layout/inspector/nsFontFaceList.h
@@ -16,18 +16,19 @@ class gfxTextRun;
 
 class nsFontFaceList : public nsIDOMFontFaceList
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMFONTFACELIST
 
   nsFontFaceList();
-  virtual ~nsFontFaceList();
 
   nsresult AddFontsFromTextRun(gfxTextRun* aTextRun,
                                uint32_t aOffset, uint32_t aLength);
 
 protected:
+  virtual ~nsFontFaceList();
+
   nsInterfaceHashtable<nsPtrHashKey<gfxFontEntry>,nsIDOMFontFace> mFontFaces;
 };
 
 #endif // __nsFontFaceList_h__
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -611,16 +611,24 @@ private:
   }
   int32_t PropertiesTableCount() {
     return mPropertiesTableList.Length();
   }
   // List of glyph tables;
   nsTArray<nsPropertiesTable> mPropertiesTableList;
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<nsGlyphTableList>
+{
+  static const bool value = true;
+};
+}
+
 NS_IMPL_ISUPPORTS(nsGlyphTableList, nsIObserver)
 
 // -----------------------------------------------------------------------------
 // Here is the global list of applicable glyph tables that we will be using
 static nsGlyphTableList* gGlyphTableList = nullptr;
 
 static bool gGlyphTableInitialized = false;
 
--- a/layout/mathml/nsMathMLmactionFrame.h
+++ b/layout/mathml/nsMathMLmactionFrame.h
@@ -40,16 +40,20 @@ public:
 
 private:
   void MouseClick();
   void MouseOver();
   void MouseOut();
 
   class MouseListener MOZ_FINAL : public nsIDOMEventListener
   {
+  private:
+    ~MouseListener() {}
+
+  public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIDOMEVENTLISTENER
 
     MouseListener(nsMathMLmactionFrame* aOwner) : mOwner(aOwner) { }
 
     nsMathMLmactionFrame* mOwner;
   };
 
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -71,17 +71,16 @@ public:
   // This enum tells indicates what the default should be for the title
   // if the title from the document is null
   enum eDocTitleDefault {
     eDocTitleDefBlank,
     eDocTitleDefURLDoc
   };
 
   nsPrintEngine();
-  ~nsPrintEngine();
 
   void Destroy();
   void DestroyPrintingData();
 
   nsresult Initialize(nsIDocumentViewerPrint* aDocViewerPrint, 
                       nsIDocShell*            aContainer,
                       nsIDocument*            aDocument,
                       float                   aScreenDPI,
@@ -208,16 +207,17 @@ public:
     mDisallowSelectionPrint = aDisallowSelectionPrint;
   }
 
   void SetNoMarginBoxes(bool aNoMarginBoxes) {
     mNoMarginBoxes = aNoMarginBoxes;
   }
 
 protected:
+  ~nsPrintEngine();
 
   nsresult CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
                        nsIWebProgressListener* aWebProgressListener,
                        nsIDOMDocument* aDoc);
 
   nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
                          nsIWebProgressListener* aWebProgressListener,
                          nsIDOMDocument* aDoc);
--- a/layout/printing/nsPrintPreviewListener.h
+++ b/layout/printing/nsPrintPreviewListener.h
@@ -30,24 +30,24 @@ class EventTarget;
 class nsPrintPreviewListener MOZ_FINAL : public nsIDOMEventListener
 
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
   nsPrintPreviewListener(mozilla::dom::EventTarget* aTarget);
-  ~nsPrintPreviewListener();
 
   // Add/remove the relevant listeners, based on what interfaces
   // the embedding chrome implements.
   nsresult AddListeners();
   nsresult RemoveListeners();
 
 private:
+  ~nsPrintPreviewListener();
 
   nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
 
 }; // class nsPrintPreviewListener
 
 
 
 #endif /* nsPrintPreviewListener_h__ */
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -32,17 +32,16 @@ namespace css {
 bool IsGeometricProperty(nsCSSProperty aProperty);
 
 struct CommonElementAnimationData;
 
 class CommonAnimationManager : public nsIStyleRuleProcessor,
                                public nsARefreshObserver {
 public:
   CommonAnimationManager(nsPresContext *aPresContext);
-  virtual ~CommonAnimationManager();
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIStyleRuleProcessor (parts)
   virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
   virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) MOZ_OVERRIDE;
   virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
@@ -64,16 +63,18 @@ public:
     Cannot_Throttle
   };
 
   static bool ExtractComputedValueForTransition(
                   nsCSSProperty aProperty,
                   nsStyleContext* aStyleContext,
                   nsStyleAnimation::Value& aComputedValue);
 protected:
+  virtual ~CommonAnimationManager();
+
   friend struct CommonElementAnimationData; // for ElementDataRemoved
 
   virtual void AddElementData(CommonElementAnimationData* aData) = 0;
   virtual void ElementDataRemoved() = 0;
   void RemoveAllElementData();
 
   // When this returns a value other than nullptr, it also,
   // as a side-effect, notifies the ActiveLayerTracker.
@@ -188,16 +189,18 @@ public:
   }
 
   struct PropertyValuePair {
     nsCSSProperty mProperty;
     nsStyleAnimation::Value mValue;
   };
 
 private:
+  ~AnimValuesStyleRule() {}
+
   InfallibleTArray<PropertyValuePair> mPropertyValuePairs;
 };
 
 class ComputedTimingFunction {
 public:
   typedef nsTimingFunction::Type Type;
   void Init(const nsTimingFunction &aFunction);
   double GetValue(double aPortion) const;
--- a/layout/style/CSSRuleList.h
+++ b/layout/style/CSSRuleList.h
@@ -23,17 +23,16 @@ namespace dom {
 class CSSRuleList : public nsIDOMCSSRuleList
                   , public nsWrapperCache
 {
 public:
   CSSRuleList()
   {
     SetIsDOMBinding();
   }
-  virtual ~CSSRuleList() {}
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSRULELIST_IID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CSSRuleList)
 
   virtual CSSStyleSheet* GetParentObject() = 0;
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_FINAL;
@@ -55,16 +54,19 @@ public:
   nsIDOMCSSRule* Item(uint32_t aIndex)
   {
     bool unused;
     return IndexedGetter(aIndex, unused);
   }
 
   virtual nsIDOMCSSRule* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
   virtual uint32_t Length() = 0;
+
+protected:
+  virtual ~CSSRuleList() {}
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(CSSRuleList, NS_ICSSRULELIST_IID)
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_CSSRuleList_h */
--- a/layout/style/ImageLoader.h
+++ b/layout/style/ImageLoader.h
@@ -62,16 +62,18 @@ public:
   void ClearFrames();
 
   void LoadImage(nsIURI* aURI, nsIPrincipal* aPrincipal, nsIURI* aReferrer,
                  Image* aCSSValue);
 
   void DestroyRequest(imgIRequest* aRequest);
 
 private:
+  ~ImageLoader() {}
+
   // We need to be able to look up the frames associated with a request (for
   // delivering notifications) and the requests associated with a frame (when
   // the frame goes away). Thus we maintain hashtables going both ways.  These
   // should always be in sync.
 
   typedef nsTArray<nsIFrame*> FrameSet;
   typedef nsTArray<nsCOMPtr<imgIRequest> > RequestSet;
   typedef nsTHashtable<nsPtrHashKey<Image> > ImageHashSet;
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -102,18 +102,20 @@ namespace css {
 /*********************************************
  * Data needed to properly load a stylesheet *
  *********************************************/
 
 class SheetLoadData : public nsIRunnable,
                       public nsIUnicharStreamLoaderObserver,
                       public nsIThreadObserver
 {
+protected:
+  virtual ~SheetLoadData(void);
+
 public:
-  virtual ~SheetLoadData(void);
   // Data for loading a sheet linked from a document
   SheetLoadData(Loader* aLoader,
                 const nsSubstring& aTitle,
                 nsIURI* aURI,
                 CSSStyleSheet* aSheet,
                 nsIStyleSheetLinkingElement* aOwningElement,
                 bool aIsAlternate,
                 nsICSSLoaderObserver* aObserver,
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -977,19 +977,21 @@ ImportantRule::List(FILE* out, int32_t a
 namespace mozilla {
 namespace css {
 class DOMCSSStyleRule;
 }
 }
 
 class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration
 {
+protected:
+  virtual ~DOMCSSDeclarationImpl(void);
+
 public:
   DOMCSSDeclarationImpl(css::StyleRule *aRule);
-  virtual ~DOMCSSDeclarationImpl(void);
 
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE;
   void DropReference(void);
   virtual css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE;
   virtual nsresult SetCSSDeclaration(css::Declaration* aDecl) MOZ_OVERRIDE;
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE;
   virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE;
 
@@ -1021,31 +1023,32 @@ private:
 
 namespace mozilla {
 namespace css {
 
 class DOMCSSStyleRule : public nsICSSStyleRuleDOMWrapper
 {
 public:
   DOMCSSStyleRule(StyleRule *aRule);
-  virtual ~DOMCSSStyleRule();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCSSStyleRule)
   NS_DECL_NSIDOMCSSRULE
   NS_DECL_NSIDOMCSSSTYLERULE
 
   // nsICSSStyleRuleDOMWrapper
   NS_IMETHOD GetCSSStyleRule(StyleRule **aResult);
 
   DOMCSSDeclarationImpl* DOMDeclaration() { return &mDOMDeclaration; }
 
   friend class ::DOMCSSDeclarationImpl;
 
 protected:
+  virtual ~DOMCSSStyleRule();
+
   DOMCSSDeclarationImpl mDOMDeclaration;
 
   StyleRule* Rule() {
     return mDOMDeclaration.mRule;
   }
 };
 
 } // namespace css
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -49,17 +49,16 @@ class nsCSSRuleProcessor: public nsIStyl
 public:
   typedef nsTArray<nsRefPtr<mozilla::CSSStyleSheet>> sheet_array_type;
 
   // aScopeElement must be non-null iff aSheetType is
   // nsStyleSet::eScopedDocSheet.
   nsCSSRuleProcessor(const sheet_array_type& aSheets,
                      uint8_t aSheetType,
                      mozilla::dom::Element* aScopeElement);
-  virtual ~nsCSSRuleProcessor();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsCSSRuleProcessor)
 
 public:
   nsresult ClearRuleCascades();
 
   static nsresult Startup();
@@ -170,16 +169,19 @@ public:
       : mStates(aStates),
         mSelector(aSelector)
     {}
 
     mozilla::EventStates mStates;
     nsCSSSelector* mSelector;
   };
 
+protected:
+  virtual ~nsCSSRuleProcessor();
+
 private:
   static bool CascadeSheet(mozilla::CSSStyleSheet* aSheet,
                            CascadeEnumData* aData);
 
   RuleCascadeData* GetRuleCascade(nsPresContext* aPresContext);
   void RefreshRuleCascade(nsPresContext* aPresContext);
 
   nsRestyleHint HasStateDependentStyle(ElementDependentRuleProcessorData* aData,
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -204,16 +204,18 @@ public:
   virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) MOZ_OVERRIDE;
 
   nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
                             nsAString & aResult) const;
 
   virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
 
 protected:
+  ~nsCSSFontFaceStyleDecl() {}
+
   friend class nsCSSFontFaceRule;
 #define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_;
 #include "nsCSSFontDescList.h"
 #undef CSS_FONT_DESC
 
   static nsCSSValue nsCSSFontFaceStyleDecl::* const Fields[];
   inline nsCSSFontFaceRule* ContainingRule();
   inline const nsCSSFontFaceRule* ContainingRule() const;
@@ -257,16 +259,18 @@ public:
   NS_DECL_NSIDOMCSSFONTFACERULE
 
   void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue);
   void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue);
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
+  ~nsCSSFontFaceRule() {}
+
   friend class nsCSSFontFaceStyleDecl;
   nsCSSFontFaceStyleDecl mDecl;
 };
 
 // nsFontFaceRuleContainer - used for associating sheet type with
 // specific @font-face rules
 struct nsFontFaceRuleContainer {
   nsRefPtr<nsCSSFontFaceRule> mRule;
@@ -337,16 +341,18 @@ public:
     // font-variant-alternates enabled ==> layout.css.font-features.enabled is true
     bool fontFeaturesEnabled =
       nsCSSProps::IsEnabled(eCSSProperty_font_variant_alternates);
 
     return fontFeaturesEnabled;
   }
 
 protected:
+  ~nsCSSFontFeatureValuesRule() {}
+
   mozilla::FontFamilyList mFamilyList;
   nsTArray<gfxFontFeatureValueSet::FeatureValues> mFeatureValues;
 };
 
 namespace mozilla {
 namespace css {
 
 class CharsetRule MOZ_FINAL : public Rule,
@@ -390,32 +396,33 @@ private:
 } // namespace mozilla
 
 class nsCSSKeyframeRule;
 
 class nsCSSKeyframeStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration
 {
 public:
   nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule);
-  virtual ~nsCSSKeyframeStyleDeclaration();
 
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE;
   void DropReference() { mRule = nullptr; }
   virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE;
   virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE;
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE;
   virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSKeyframeStyleDeclaration,
                                                          nsICSSDeclaration)
 
   virtual nsINode* GetParentObject() MOZ_OVERRIDE;
 
 protected:
+  virtual ~nsCSSKeyframeStyleDeclaration();
+
   // This reference is not reference-counted. The rule object tells us
   // when it's about to go away.
   nsCSSKeyframeRule *mRule;
 };
 
 class nsCSSKeyframeRule MOZ_FINAL : public mozilla::css::Rule,
                                     public nsIDOMMozCSSKeyframeRule
 {
@@ -518,32 +525,33 @@ private:
 };
 
 class nsCSSPageRule;
 
 class nsCSSPageStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration
 {
 public:
   nsCSSPageStyleDeclaration(nsCSSPageRule *aRule);
-  virtual ~nsCSSPageStyleDeclaration();
 
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE;
   void DropReference() { mRule = nullptr; }
   virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE;
   virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE;
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE;
   virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSPageStyleDeclaration,
                                                          nsICSSDeclaration)
 
   virtual nsINode *GetParentObject() MOZ_OVERRIDE;
 
 protected:
+  virtual ~nsCSSPageStyleDeclaration();
+
   // This reference is not reference-counted. The rule object tells us
   // when it's about to go away.
   nsCSSPageRule *mRule;
 };
 
 class nsCSSPageRule MOZ_FINAL : public mozilla::css::Rule,
                                 public nsIDOMCSSPageRule
 {
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -618,16 +618,24 @@ private:
 
   bool mExposeVisitedStyle;
 
 #ifdef DEBUG
   bool mFlushedPendingReflows;
 #endif
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<nsComputedDOMStyle>
+{
+  static const bool value = true;
+};
+}
+
 already_AddRefed<nsComputedDOMStyle>
 NS_NewComputedDOMStyle(mozilla::dom::Element* aElement,
                        const nsAString& aPseudoElt,
                        nsIPresShell* aPresShell,
                        nsComputedDOMStyle::StyleType aStyleType =
                          nsComputedDOMStyle::eAll);
 
 #endif /* nsComputedDOMStyle_h__ */
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -19,17 +19,16 @@ class Element;
 }
 }
 
 class nsDOMCSSAttributeDeclaration MOZ_FINAL : public nsDOMCSSDeclaration
 {
 public:
   typedef mozilla::dom::Element Element;
   nsDOMCSSAttributeDeclaration(Element* aContent, bool aIsSMILOverride);
-  ~nsDOMCSSAttributeDeclaration();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCSSAttributeDeclaration,
                                                                    nsICSSDeclaration)
 
   // If GetCSSDeclaration returns non-null, then the decl it returns
   // is owned by our current style rule.
   virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate);
@@ -37,16 +36,18 @@ public:
   NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE;
 
   virtual nsINode* GetParentObject() MOZ_OVERRIDE;
 
   NS_IMETHOD SetPropertyValue(const nsCSSProperty aPropID,
                               const nsAString& aValue) MOZ_OVERRIDE;
 
 protected:
+  ~nsDOMCSSAttributeDeclaration();
+
   virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE;
   virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE;
 
   nsRefPtr<Element> mElement;
 
   /* If true, this indicates that this nsDOMCSSAttributeDeclaration
    * should interact with mContent's SMIL override style rule (rather
    * than the inline style rule).
--- a/layout/style/nsDOMCSSRGBColor.h
+++ b/layout/style/nsDOMCSSRGBColor.h
@@ -18,18 +18,16 @@ class nsDOMCSSRGBColor : public nsWrappe
 {
 public:
   nsDOMCSSRGBColor(nsROCSSPrimitiveValue* aRed,
                    nsROCSSPrimitiveValue* aGreen,
                    nsROCSSPrimitiveValue* aBlue,
                    nsROCSSPrimitiveValue* aAlpha,
                    bool aHasAlpha);
 
-  virtual ~nsDOMCSSRGBColor(void);
-
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMCSSRGBColor)
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMCSSRGBColor)
 
   bool HasAlpha() const { return mHasAlpha; }
 
   // RGBColor webidl interface
   nsROCSSPrimitiveValue* Red() const
@@ -53,16 +51,18 @@ public:
   {
     return nullptr;
   }
 
   virtual JSObject *WrapObject(JSContext *cx)
     MOZ_OVERRIDE MOZ_FINAL;
 
 private:
+  virtual ~nsDOMCSSRGBColor(void);
+
   nsRefPtr<nsROCSSPrimitiveValue> mRed;
   nsRefPtr<nsROCSSPrimitiveValue> mGreen;
   nsRefPtr<nsROCSSPrimitiveValue> mBlue;
   nsRefPtr<nsROCSSPrimitiveValue> mAlpha;
   bool mHasAlpha;
 };
 
 #endif // nsDOMCSSRGBColor_h__
--- a/layout/style/nsDOMCSSRect.h
+++ b/layout/style/nsDOMCSSRect.h
@@ -19,33 +19,35 @@ class nsROCSSPrimitiveValue;
 class nsDOMCSSRect : public nsIDOMRect,
                      public nsWrapperCache
 {
 public:
   nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
                nsROCSSPrimitiveValue* aRight,
                nsROCSSPrimitiveValue* aBottom,
                nsROCSSPrimitiveValue* aLeft);
-  virtual ~nsDOMCSSRect(void);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIDOMRECT
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCSSRect)
 
   nsROCSSPrimitiveValue* Top() const { return mTop; }
   nsROCSSPrimitiveValue* Right() const { return mRight; }
   nsROCSSPrimitiveValue* Bottom() const { return mBottom; }
   nsROCSSPrimitiveValue* Left() const { return mLeft; }
 
   nsISupports* GetParentObject() const { return nullptr; }
 
   virtual JSObject* WrapObject(JSContext* cx)
     MOZ_OVERRIDE MOZ_FINAL;
 
+protected:
+  virtual ~nsDOMCSSRect(void);
+
 private:
   nsRefPtr<nsROCSSPrimitiveValue> mTop;
   nsRefPtr<nsROCSSPrimitiveValue> mRight;
   nsRefPtr<nsROCSSPrimitiveValue> mBottom;
   nsRefPtr<nsROCSSPrimitiveValue> mLeft;
 };
 
 #endif /* nsDOMCSSRect_h_ */
--- a/layout/style/nsDOMCSSValueList.h
+++ b/layout/style/nsDOMCSSValueList.h
@@ -64,9 +64,17 @@ private:
                                                 // as the delimiter, some just use
                                                 // spaces.
 
   bool                        mReadonly;    // Are we read-only?
 
   InfallibleTArray<nsRefPtr<CSSValue> > mCSSValues;
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<nsDOMCSSValueList>
+{
+  static const bool value = true;
+};
+}
+
 #endif /* nsDOMCSSValueList_h___ */
--- a/layout/style/nsFontFaceLoader.h
+++ b/layout/style/nsFontFaceLoader.h
@@ -101,18 +101,16 @@ protected:
 
 class nsFontFaceLoader : public nsIStreamLoaderObserver
 {
 public:
   nsFontFaceLoader(gfxMixedFontFamily* aFontFamily,
                    gfxProxyFontEntry* aFontToLoad, nsIURI* aFontURI, 
                    nsUserFontSet* aFontSet, nsIChannel* aChannel);
 
-  virtual ~nsFontFaceLoader();
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTREAMLOADEROBSERVER 
 
   // initiate the load
   nsresult Init();
   // cancel the load and remove its reference to mFontSet
   void Cancel();
 
@@ -121,16 +119,19 @@ public:
   void StartedLoading(nsIStreamLoader* aStreamLoader);
 
   static void LoadTimerCallback(nsITimer* aTimer, void* aClosure);
 
   static nsresult CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
                                    nsIURI* aTargetURI,
                                    nsISupports* aContext);
 
+protected:
+  virtual ~nsFontFaceLoader();
+
 private:
   nsRefPtr<gfxMixedFontFamily> mFontFamily;
   nsRefPtr<gfxProxyFontEntry>  mFontEntry;
   nsCOMPtr<nsIURI>        mFontURI;
   nsRefPtr<nsUserFontSet> mFontSet;
   nsCOMPtr<nsIChannel>    mChannel;
   nsCOMPtr<nsITimer>      mLoadTimer;
 
--- a/layout/style/nsHTMLCSSStyleSheet.h
+++ b/layout/style/nsHTMLCSSStyleSheet.h
@@ -17,17 +17,16 @@
 #include "nsIStyleRuleProcessor.h"
 
 struct MiscContainer;
 
 class nsHTMLCSSStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor
 {
 public:
   nsHTMLCSSStyleSheet();
-  ~nsHTMLCSSStyleSheet();
 
   NS_DECL_ISUPPORTS
 
   // nsIStyleRuleProcessor
   virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;
   virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE;
   virtual void RulesMatching(AnonBoxRuleProcessorData* aData) MOZ_OVERRIDE;
 #ifdef MOZ_XUL
@@ -44,16 +43,18 @@ public:
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
     const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
 
   void CacheStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
   void EvictStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
   MiscContainer* LookupStyleAttr(const nsAString& aSerialized);
 
 private: 
+  ~nsHTMLCSSStyleSheet();
+
   nsHTMLCSSStyleSheet(const nsHTMLCSSStyleSheet& aCopy) MOZ_DELETE;
   nsHTMLCSSStyleSheet& operator=(const nsHTMLCSSStyleSheet& aCopy) MOZ_DELETE;
 
 protected:
   nsDataHashtable<nsStringHashKey, MiscContainer*> mCachedStyleAttrs;
 };
 
 #endif /* !defined(nsHTMLCSSStyleSheet_h_) */
--- a/layout/style/nsHTMLStyleSheet.h
+++ b/layout/style/nsHTMLStyleSheet.h
@@ -69,16 +69,18 @@ private:
   nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
   nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
 
   ~nsHTMLStyleSheet();
 
   class HTMLColorRule;
   friend class HTMLColorRule;
   class HTMLColorRule MOZ_FINAL : public nsIStyleRule {
+  private:
+    ~HTMLColorRule() {}
   public:
     HTMLColorRule() {}
 
     NS_DECL_ISUPPORTS
 
     // nsIStyleRule interface
     virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
   #ifdef DEBUG
@@ -89,19 +91,20 @@ private:
   };
 
   // Implementation of SetLink/VisitedLink/ActiveLinkColor
   nsresult ImplLinkColorSetter(nsRefPtr<HTMLColorRule>& aRule, nscolor aColor);
 
   class GenericTableRule;
   friend class GenericTableRule;
   class GenericTableRule : public nsIStyleRule {
+  protected:
+    virtual ~GenericTableRule() {}
   public:
     GenericTableRule() {}
-    virtual ~GenericTableRule() {}
 
     NS_DECL_ISUPPORTS
 
     // nsIStyleRule interface
     virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE = 0;
   #ifdef DEBUG
     virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
   #endif
@@ -125,16 +128,18 @@ private:
     virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
   };
 
 public: // for mLangRuleTable structures only
 
   // Rule to handle xml:lang attributes, of which we have exactly one
   // per language string, maintained in mLangRuleTable.
   class LangRule MOZ_FINAL : public nsIStyleRule {
+  private:
+    ~LangRule() {}
   public:
     LangRule(const nsSubstring& aLang) : mLang(aLang) {}
 
     NS_DECL_ISUPPORTS
 
     // nsIStyleRule interface
     virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
   #ifdef DEBUG
--- a/layout/style/nsROCSSPrimitiveValue.h
+++ b/layout/style/nsROCSSPrimitiveValue.h
@@ -118,16 +118,24 @@ private:
     nsDOMCSSRGBColor* mColor;
     nsDOMCSSRect*     mRect;
     char16_t*      mString;
     nsIURI*         mURI;
     nsCSSKeyword    mKeyword;
   } mValue;
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<nsROCSSPrimitiveValue>
+{
+  static const bool value = true;
+};
+}
+
 inline nsROCSSPrimitiveValue *mozilla::dom::CSSValue::AsPrimitiveValue()
 {
   return CssValueType() == nsIDOMCSSValue::CSS_PRIMITIVE_VALUE ?
     static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
 }
 
 #endif /* nsROCSSPrimitiveValue_h___ */
 
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -36,34 +36,46 @@ struct ElementDependentRuleProcessorData
 struct TreeMatchContext;
 
 namespace mozilla {
 class EventStates;
 } // namespace mozilla
 
 class nsEmptyStyleRule MOZ_FINAL : public nsIStyleRule
 {
+private:
+  ~nsEmptyStyleRule() {}
+
+public:
   NS_DECL_ISUPPORTS
   virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 };
 
 class nsInitialStyleRule MOZ_FINAL : public nsIStyleRule
 {
+private:
+  ~nsInitialStyleRule() {}
+
+public:
   NS_DECL_ISUPPORTS
   virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 };
 
 class nsDisableTextZoomStyleRule MOZ_FINAL : public nsIStyleRule
 {
+private:
+  ~nsDisableTextZoomStyleRule() {}
+
+public:
   NS_DECL_ISUPPORTS
   virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 };
 
 // The style set object is created by the document viewer and ownership is
--- a/layout/svg/SVGTextFrame.h
+++ b/layout/svg/SVGTextFrame.h
@@ -260,16 +260,18 @@ protected:
     : SVGTextFrameBase(aContext),
       mFontSizeScaleFactor(1.0f),
       mLastContextScale(1.0f),
       mLengthAdjustScaleFactor(1.0f)
   {
     AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
   }
 
+  ~SVGTextFrame() {}
+
 public:
   NS_DECL_QUERYFRAME_TARGET(SVGTextFrame)
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsIFrame:
   virtual void Init(nsIContent*       aContent,
                     nsContainerFrame* aParent,
@@ -690,9 +692,17 @@ private:
 
   /**
    * The amount that we need to scale each rendered run to account for
    * lengthAdjust="spacingAndGlyphs".
    */
   float mLengthAdjustScaleFactor;
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<SVGTextFrame::MutationObserver>
+{
+  static const bool value = true;
+};
+}
+
 #endif
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -37,23 +37,26 @@ class nsSVGMaskFrame;
  * Concrete implementations of this interface need to implement
  * "GetTarget()" to specify the piece of SVG content that they'd like to
  * monitor, and they need to implement "DoUpdate" to specify how we'll react
  * when that content gets re-rendered. They also need to implement a
  * constructor and destructor, which should call StartListening and
  * StopListening, respectively.
  */
 class nsSVGRenderingObserver : public nsStubMutationObserver {
+
+protected:
+  virtual ~nsSVGRenderingObserver()
+    {}
+
 public:
   typedef mozilla::dom::Element Element;
   nsSVGRenderingObserver()
     : mInObserverList(false)
     {}
-  virtual ~nsSVGRenderingObserver()
-    {}
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
@@ -194,26 +197,28 @@ private:
  * nsSVGFilterReferences, one for each SVG reference filter. CSS filters like
  * "blur(10px)" don't reference filter elements, so they don't need an
  * nsSVGFilterReference. The style system invalidates changes to CSS filters.
  */
 class nsSVGFilterProperty : public nsISupports {
 public:
   nsSVGFilterProperty(const nsTArray<nsStyleFilter> &aFilters,
                       nsIFrame *aFilteredFrame);
-  virtual ~nsSVGFilterProperty();
 
   const nsTArray<nsStyleFilter>& GetFilters() { return mFilters; }
   bool ReferencesValidResources();
   bool IsInObserverLists() const;
   void Invalidate();
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
+protected:
+  virtual ~nsSVGFilterProperty();
+
 private:
   nsTArray<nsSVGFilterReference*> mReferences;
   nsTArray<nsStyleFilter> mFilters;
 };
 
 class nsSVGMarkerProperty : public nsSVGIDRenderingObserver {
 public:
   nsSVGMarkerProperty(nsIURI *aURI, nsIFrame *aFrame, bool aReferenceImage)
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -35,16 +35,18 @@ public:
   nsSVGImageListener(nsSVGImageFrame *aFrame);
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
   void SetFrame(nsSVGImageFrame *frame) { mFrame = frame; }
 
 private:
+  ~nsSVGImageListener() {}
+
   nsSVGImageFrame *mFrame;
 };
 
 typedef nsSVGPathGeometryFrame nsSVGImageFrameBase;
 
 class nsSVGImageFrame : public nsSVGImageFrameBase,
                         public nsIReflowCallback
 {
--- a/layout/tools/layout-debug/src/nsLayoutDebugCLH.h
+++ b/layout/tools/layout-debug/src/nsLayoutDebugCLH.h
@@ -13,15 +13,17 @@
 #define NS_LAYOUTDEBUGCLH_CID \
  { 0xa8f52633, 0x5ecf, 0x424a, \
    { 0xa1, 0x47, 0x47, 0xc3, 0x22, 0xf7, 0xbc, 0xe2 }}
 
 class nsLayoutDebugCLH : public ICOMMANDLINEHANDLER
 {
 public:
     nsLayoutDebugCLH();
-    virtual ~nsLayoutDebugCLH();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSICOMMANDLINEHANDLER
+
+protected:
+    virtual ~nsLayoutDebugCLH();
 };
 
 #endif /* !defined(nsLayoutDebugCLH_h_) */
--- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.h
+++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.h
@@ -10,23 +10,24 @@
 #include "nsILayoutDebuggingTools.h"
 #include "nsIDocShell.h"
 #include "nsCOMPtr.h"
 
 class nsLayoutDebuggingTools : public nsILayoutDebuggingTools {
 
 public:
     nsLayoutDebuggingTools();
-    virtual ~nsLayoutDebuggingTools();
 
     NS_DECL_ISUPPORTS
 
     NS_DECL_NSILAYOUTDEBUGGINGTOOLS
 
 protected:
+    virtual ~nsLayoutDebuggingTools();
+
     void ForceRefresh();
     nsresult GetBoolPref(const char * aPrefName, bool *aValue);
     nsresult SetBoolPrefAndRefresh(const char * aPrefName, bool aNewValue);
 
     nsCOMPtr<nsIDocShell> mDocShell;
 
     bool mEditorMode;
     bool mVisualDebugging;
--- a/layout/tools/layout-debug/src/nsRegressionTester.h
+++ b/layout/tools/layout-debug/src/nsRegressionTester.h
@@ -20,17 +20,17 @@ class nsIDocShell;
 //*****************************************************************************
 class  nsRegressionTester : public nsILayoutRegressionTester
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSILAYOUTREGRESSIONTESTER
 
   nsRegressionTester();
-  virtual ~nsRegressionTester();
 
 protected:
+  virtual ~nsRegressionTester();
   nsresult    GetDocShellFromWindow(nsIDOMWindow* inWindow, nsIDocShell** outShell);
 };
 
 
 
 #endif /* nsRegressionTester_h__ */
--- a/layout/xul/nsBoxLayout.h
+++ b/layout/xul/nsBoxLayout.h
@@ -18,20 +18,22 @@ struct nsMargin;
 #define NS_BOX_LAYOUT_IID \
 { 0x09d522a7, 0x304c, 0x4137, \
  { 0xaf, 0xc9, 0xe0, 0x80, 0x2e, 0x89, 0xb7, 0xe8 } }
 
 class nsIGridPart;
 
 class nsBoxLayout : public nsISupports {
 
+protected:
+  virtual ~nsBoxLayout() {}
+
 public:
 
   nsBoxLayout() {}
-  virtual ~nsBoxLayout() {}
 
   NS_DECL_ISUPPORTS
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_BOX_LAYOUT_IID)
 
   NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState);
 
   virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
--- a/layout/xul/nsBoxObject.h
+++ b/layout/xul/nsBoxObject.h
@@ -23,17 +23,16 @@ class nsIPresShell;
 class nsBoxObject : public nsPIBoxObject
 {
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsBoxObject)
   NS_DECL_NSIBOXOBJECT
 
 public:
   nsBoxObject();
-  virtual ~nsBoxObject();
 
   // nsPIBoxObject
   virtual nsresult Init(nsIContent* aContent) MOZ_OVERRIDE;
   virtual void Clear() MOZ_OVERRIDE;
   virtual void ClearCachedValues() MOZ_OVERRIDE;
 
   nsIFrame* GetFrame(bool aFlushLayout);
   nsIPresShell* GetPresShell(bool aFlushLayout);
@@ -41,15 +40,16 @@ public:
   nsresult GetScreenPosition(nsIntPoint& aPoint);
 
   // Given a parent frame and a child frame, find the frame whose
   // next sibling is the given child frame and return its element
   static nsresult GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
                                      nsIDOMElement** aResult);
 
 protected:
+  virtual ~nsBoxObject();
 
   nsAutoPtr<nsInterfaceHashtable<nsStringHashKey,nsISupports> > mPropertyTable; //[OWNER]
 
   nsIContent* mContent; // [WEAK]
 };
 
 #endif
--- a/layout/xul/nsImageBoxFrame.h
+++ b/layout/xul/nsImageBoxFrame.h
@@ -19,25 +19,26 @@ class nsImageBoxFrame;
 
 class nsDisplayXULImage;
 
 class nsImageBoxListener : public imgINotificationObserver,
                            public imgIOnloadBlocker
 {
 public:
   nsImageBoxListener();
-  virtual ~nsImageBoxListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
   NS_DECL_IMGIONLOADBLOCKER
 
   void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
 
 private:
+  virtual ~nsImageBoxListener();
+
   nsImageBoxFrame *mFrame;
 };
 
 class nsImageBoxFrame : public nsLeafBoxFrame
 {
 public:
   typedef mozilla::layers::LayerManager LayerManager;
 
--- a/layout/xul/nsListBoxBodyFrame.cpp
+++ b/layout/xul/nsListBoxBodyFrame.cpp
@@ -61,21 +61,23 @@ using namespace mozilla::dom;
 #define TIME_PER_ROW_INITAL  50000
 
 // if we decide we can't layout the rows in the amount of time. How long
 // do we wait before checking again?
 #define SMOOTH_INTERVAL 100
 
 class nsListScrollSmoother : public nsITimerCallback
 {
+private:
+  virtual ~nsListScrollSmoother();
+
 public:
   NS_DECL_ISUPPORTS
 
   nsListScrollSmoother(nsListBoxBodyFrame* aOuter);
-  virtual ~nsListScrollSmoother();
 
   // nsITimerCallback
   NS_DECL_NSITIMERCALLBACK
 
   void Start();
   void Stop();
   bool IsRunning();
 
--- a/layout/xul/nsMenuBarListener.h
+++ b/layout/xul/nsMenuBarListener.h
@@ -20,19 +20,16 @@ class nsIDOMKeyEvent;
 /** editor Implementation of the DragListener interface
  */
 class nsMenuBarListener : public nsIDOMEventListener
 {
 public:
   /** default constructor
    */
   nsMenuBarListener(nsMenuBarFrame* aMenuBar);
-  /** default destructor
-   */
-  virtual ~nsMenuBarListener();
 
   static void InitializeStatics();
    
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
   
   nsresult KeyUp(nsIDOMEvent* aMouseEvent);
   nsresult KeyDown(nsIDOMEvent* aMouseEvent);
   nsresult KeyPress(nsIDOMEvent* aMouseEvent);
@@ -41,16 +38,20 @@ public:
 
   static nsresult GetMenuAccessKey(int32_t* aAccessKey);
   
   NS_DECL_ISUPPORTS
 
   static bool IsAccessKeyPressed(nsIDOMKeyEvent* event);
 
 protected:
+  /** default destructor
+   */
+  virtual ~nsMenuBarListener();
+
   static void InitAccessKey();
 
   static mozilla::Modifiers GetModifiersForAccessKey(nsIDOMKeyEvent* event);
 
   // This should only be called by the nsMenuBarListener during event dispatch,
   // thus ensuring that this doesn't get destroyed during the process.
   void ToggleMenuActiveState();
 
--- a/layout/xul/nsMenuFrame.h
+++ b/layout/xul/nsMenuFrame.h
@@ -54,24 +54,24 @@ class nsMenuFrame;
  * nsMenuFrame, so that it will exist as long as the timer holds a reference
  * to it. The callback is delegated to the contained nsMenuFrame as long as
  * the contained nsMenuFrame has not been destroyed.
  */
 class nsMenuTimerMediator MOZ_FINAL : public nsITimerCallback
 {
 public:
   nsMenuTimerMediator(nsMenuFrame* aFrame);
-  ~nsMenuTimerMediator();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
   void ClearFrame();
 
 private:
+  ~nsMenuTimerMediator();
 
   // Pointer to the wrapped frame.
   nsMenuFrame* mFrame;
 };
 
 class nsMenuFrame : public nsBoxFrame
 {
 public:
--- a/layout/xul/nsRepeatService.h
+++ b/layout/xul/nsRepeatService.h
@@ -39,20 +39,20 @@ public:
   // is not currently configured with the given callback and data, this
   // is just ignored.
   void Stop(Callback aCallback, void* aData);
 
   static nsRepeatService* GetInstance();
   static void Shutdown();
 
   NS_DECL_ISUPPORTS
-  virtual ~nsRepeatService();
 
 protected:
   nsRepeatService();
+  virtual ~nsRepeatService();
 
 private:
   Callback           mCallback;
   void*              mCallbackData;
   nsCOMPtr<nsITimer> mRepeatTimer;
   static nsRepeatService* gInstance;
 
 }; // class nsRepeatService
--- a/layout/xul/nsSliderFrame.h
+++ b/layout/xul/nsSliderFrame.h
@@ -24,21 +24,23 @@ class nsSliderMediator : public nsIDOMEv
 {
 public:
 
   NS_DECL_ISUPPORTS
 
   nsSliderFrame* mSlider;
 
   nsSliderMediator(nsSliderFrame* aSlider) {  mSlider = aSlider; }
-  virtual ~nsSliderMediator() {}
 
   virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; }
 
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
+
+protected:
+  virtual ~nsSliderMediator() {}
 };
 
 class nsSliderFrame : public nsBoxFrame
 {
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   friend class nsSliderMediator;
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -47,27 +47,29 @@ public:
   nscoord changed;
   nsCOMPtr<nsIContent> childElem;
   int32_t flex;
   int32_t index;
 };
 
 class nsSplitterFrameInner : public nsIDOMEventListener
 {
+protected:
+  virtual ~nsSplitterFrameInner();
+
 public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
   nsSplitterFrameInner(nsSplitterFrame* aSplitter)
   {
     mOuter = aSplitter;
     mPressed = false;
   }
-  virtual ~nsSplitterFrameInner();
 
   void Disconnect() { mOuter = nullptr; }
 
   nsresult MouseDown(nsIDOMEvent* aMouseEvent);
   nsresult MouseUp(nsIDOMEvent* aMouseEvent);
   nsresult MouseMove(nsIDOMEvent* aMouseEvent);
 
   void MouseDrag(nsPresContext* aPresContext, WidgetGUIEvent* aEvent);
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -927,31 +927,32 @@ nsXULPopupManager::HidePopup(nsIContent*
                            popupFrame->PresContext(), type, deselectMenu, aIsRollup);
     }
   }
 }
 
 // This is used to hide the popup after a transition finishes.
 class TransitionEnder : public nsIDOMEventListener
 {
+protected:
+  virtual ~TransitionEnder() { }
+
 public:
 
   nsCOMPtr<nsIContent> mContent;
   bool mDeselectMenu;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(TransitionEnder)
 
   TransitionEnder(nsIContent* aContent, bool aDeselectMenu)
     : mContent(aContent), mDeselectMenu(aDeselectMenu)
   {
   }
 
-  virtual ~TransitionEnder() { }
-
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
   {
     mContent->RemoveSystemEventListener(NS_LITERAL_STRING("transitionend"), this, false);
 
     nsMenuPopupFrame* popupFrame = do_QueryFrame(mContent->GetPrimaryFrame());
 
     // Now hide the popup. There could be other properties transitioning, but
     // we'll assume they all end at the same time and just hide the popup upon
--- a/layout/xul/tree/nsTreeColumns.h
+++ b/layout/xul/tree/nsTreeColumns.h
@@ -35,28 +35,28 @@ class Element;
     {0x92, 0x23, 0x81, 0x4d, 0x3a, 0xde, 0x93, 0xa3} \
 }
 
 // This class is our column info.  We use it to iterate our columns and to obtain
 // information about each column.
 class nsTreeColumn MOZ_FINAL : public nsITreeColumn {
 public:
   nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent);
-  ~nsTreeColumn();
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeColumn)
   NS_DECL_NSITREECOLUMN
 
   friend class nsTreeBodyFrame;
   friend class nsTreeColumns;
 
 protected:
+  ~nsTreeColumn();
   nsIFrame* GetFrame();
   nsIFrame* GetFrame(nsTreeBodyFrame* aBodyFrame);
   // Don't call this if GetWidthInTwips or GetRect fails
   bool IsLastVisible(nsTreeBodyFrame* aBodyFrame);
 
   /**
    * Returns a rect with x and width taken from the frame's rect and specified
    * y and height. May fail in case there's no frame for the column.
@@ -121,19 +121,21 @@ private:
   nsTreeColumn* mPrevious;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
 
 class nsTreeColumns MOZ_FINAL : public nsITreeColumns
                               , public nsWrapperCache
 {
+private:
+  ~nsTreeColumns();
+
 public:
   nsTreeColumns(nsTreeBodyFrame* aTree);
-  ~nsTreeColumns();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns)
   NS_DECL_NSITREECOLUMNS
 
   nsIContent* GetParentObject() const;
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
--- a/layout/xul/tree/nsTreeContentView.h
+++ b/layout/xul/tree/nsTreeContentView.h
@@ -24,18 +24,16 @@ nsresult NS_NewTreeContentView(nsITreeVi
 
 class nsTreeContentView MOZ_FINAL : public nsINativeTreeView,
                                     public nsITreeContentView,
                                     public nsStubDocumentObserver
 {
   public:
     nsTreeContentView(void);
 
-    ~nsTreeContentView(void);
-
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView,
                                              nsINativeTreeView)
 
     NS_DECL_NSITREEVIEW
     // nsINativeTreeView: Untrusted code can use us
     NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; }
 
@@ -46,16 +44,18 @@ class nsTreeContentView MOZ_FINAL : publ
     NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
     NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
     NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
     NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
     static bool CanTrustTreeSelection(nsISupports* aValue);
 
   protected:
+    ~nsTreeContentView(void);
+
     // Recursive methods which deal with serializing of nested content.
     void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex,
                    nsTArray<nsAutoPtr<Row> >& aRows);
 
     void SerializeItem(nsIContent* aContent, int32_t aParentIndex,
                        int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows);
 
     void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex,
--- a/layout/xul/tree/nsTreeImageListener.h
+++ b/layout/xul/tree/nsTreeImageListener.h
@@ -12,26 +12,27 @@
 #include "nsTreeBodyFrame.h"
 #include "mozilla/Attributes.h"
 
 // This class handles image load observation.
 class nsTreeImageListener MOZ_FINAL : public imgINotificationObserver
 {
 public:
   nsTreeImageListener(nsTreeBodyFrame *aTreeFrame);
-  ~nsTreeImageListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
   NS_IMETHOD ClearFrame();
 
   friend class nsTreeBodyFrame;
 
 protected:
+  ~nsTreeImageListener();
+
   void UnsuppressInvalidation() { mInvalidationSuppressed = false; }
   void Invalidate();
   void AddCell(int32_t aIndex, nsITreeColumn* aCol);
 
 private:
   nsTreeBodyFrame* mTreeFrame;
 
   // A guard that prevents us from recursive painting.
--- a/layout/xul/tree/nsTreeSelection.h
+++ b/layout/xul/tree/nsTreeSelection.h
@@ -15,28 +15,29 @@
 
 class nsITreeBoxObject;
 struct nsTreeRange;
 
 class nsTreeSelection MOZ_FINAL : public nsINativeTreeSelection
 {
 public:
   nsTreeSelection(nsITreeBoxObject* aTree);
-  ~nsTreeSelection();
    
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeSelection)
   NS_DECL_NSITREESELECTION
 
   // nsINativeTreeSelection: Untrusted code can use us
   NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; }
 
   friend struct nsTreeRange;
 
 protected:
+  ~nsTreeSelection();
+
   nsresult FireOnSelectHandler();
   static void SelectCallback(nsITimer *aTimer, void *aClosure);
 
 protected:
   // Members
   nsCOMPtr<nsITreeBoxObject> mTree; // The tree will hold on to us through the view and let go when it dies.
 
   bool mSuppressed; // Whether or not we should be firing onselect events.