Bug 1028588 - Fix dangerous public destructors in widget/ - r=roc
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 24 Jun 2014 12:36:44 -0400
changeset 200489 6a0a566bc00389559e06ad263a1d827af6d73243
parent 200488 831eb6e6ce071d354246116229dab72f87000a70
child 200490 20428bf68d89af418789f85b0aceef8bdc9b7e6e
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs1028588
milestone33.0a1
Bug 1028588 - Fix dangerous public destructors in widget/ - r=roc
widget/gtk/nsClipboard.h
widget/gtk/nsDeviceContextSpecG.h
widget/gtk/nsFilePicker.h
widget/gtk/nsPrintDialogGTK.h
widget/gtk/nsScreenManagerGtk.h
widget/gtk/nsSound.h
widget/tests/TestAppShellSteadyState.cpp
widget/xpwidgets/GfxInfoBase.cpp
widget/xpwidgets/GfxInfoBase.h
widget/xpwidgets/PuppetWidget.h
widget/xpwidgets/nsBaseDragService.h
widget/xpwidgets/nsBaseFilePicker.cpp
widget/xpwidgets/nsBaseScreen.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
widget/xpwidgets/nsClipboardHelper.h
widget/xpwidgets/nsClipboardPrivacyHandler.h
widget/xpwidgets/nsClipboardProxy.h
widget/xpwidgets/nsColorPickerProxy.h
widget/xpwidgets/nsHTMLFormatConverter.h
widget/xpwidgets/nsIdleService.h
widget/xpwidgets/nsNativeTheme.h
widget/xpwidgets/nsPrintOptionsImpl.h
widget/xpwidgets/nsPrintSession.h
widget/xpwidgets/nsPrintSettingsImpl.h
widget/xpwidgets/nsTransferable.h
--- a/widget/gtk/nsClipboard.h
+++ b/widget/gtk/nsClipboard.h
@@ -13,33 +13,34 @@
 #include "nsAutoPtr.h"
 #include <gtk/gtk.h>
 
 class nsClipboard : public nsIClipboard,
                     public nsIObserver
 {
 public:
     nsClipboard();
-    virtual ~nsClipboard();
     
     NS_DECL_ISUPPORTS
     
     NS_DECL_NSICLIPBOARD
     NS_DECL_NSIOBSERVER
 
     // Make sure we are initialized, called from the factory
     // constructor
     nsresult  Init              (void);
 
     // Someone requested the selection
     void   SelectionGetEvent    (GtkClipboard     *aGtkClipboard,
                                  GtkSelectionData *aSelectionData);
     void   SelectionClearEvent  (GtkClipboard     *aGtkClipboard);
 
 private:
+    virtual ~nsClipboard();
+
     // Utility methods
     static GdkAtom               GetSelectionAtom (int32_t aWhichClipboard);
     static GtkSelectionData     *GetTargets       (GdkAtom aWhichClipboard);
 
     // Save global clipboard content to gtk
     nsresult                     Store            (void);
 
     // Get our hands on the correct transferable, given a specific
--- a/widget/gtk/nsDeviceContextSpecG.h
+++ b/widget/gtk/nsDeviceContextSpecG.h
@@ -44,19 +44,19 @@ public:
   NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, bool aIsPrintPreview);
   NS_IMETHOD BeginDocument(const nsAString& aTitle, char16_t * aPrintToFileName, int32_t aStartPage, int32_t aEndPage);
   NS_IMETHOD EndDocument();
   NS_IMETHOD BeginPage() { return NS_OK; }
   NS_IMETHOD EndPage() { return NS_OK; }
 
   NS_IMETHOD GetPath (const char **aPath);    
   static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
-  virtual ~nsDeviceContextSpecGTK();
   
 protected:
+  virtual ~nsDeviceContextSpecGTK();
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
   bool mToPrinter : 1;      /* If true, print to printer */
   bool mIsPPreview : 1;     /* If true, is print preview */
   char   mPath[PATH_MAX];     /* If toPrinter = false, dest file */
   char   mPrinter[256];       /* Printer name */
   GtkPrintJob*      mPrintJob;
   GtkPrinter*       mGtkPrinter;
   GtkPrintSettings* mGtkPrintSettings;
@@ -67,15 +67,16 @@ protected:
 
 };
 
 //-------------------------------------------------------------------------
 // Printer Enumerator
 //-------------------------------------------------------------------------
 class nsPrinterEnumeratorGTK MOZ_FINAL : public nsIPrinterEnumerator
 {
+  ~nsPrinterEnumeratorGTK() {}
 public:
   nsPrinterEnumeratorGTK();
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRINTERENUMERATOR
 };
 
 #endif /* !nsDeviceContextSpecGTK_h___ */
--- a/widget/gtk/nsFilePicker.h
+++ b/widget/gtk/nsFilePicker.h
@@ -15,17 +15,16 @@
 
 class nsIWidget;
 class nsIFile;
 
 class nsFilePicker : public nsBaseFilePicker
 {
 public:
   nsFilePicker();
-  virtual ~nsFilePicker();
 
   NS_DECL_ISUPPORTS
 
   // nsIFilePicker (less what's in nsBaseFilePicker)
   NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback);
   NS_IMETHODIMP AppendFilters(int32_t aFilterMask);
   NS_IMETHODIMP AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
   NS_IMETHODIMP SetDefaultString(const nsAString& aString);
@@ -40,16 +39,17 @@ public:
   NS_IMETHODIMP Show(int16_t *aReturn);
 
   // nsBaseFilePicker
   virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle);
 
   static void Shutdown();
 
 protected:
+  virtual ~nsFilePicker();
 
   void ReadValuesFromFileChooser(GtkWidget *file_chooser);
 
   static void OnResponse(GtkWidget* dialog, gint response_id,
                          gpointer user_data);
   static void OnDestroy(GtkWidget* dialog, gpointer user_data);
   void Done(GtkWidget* dialog, gint response_id);
 
--- a/widget/gtk/nsPrintDialogGTK.h
+++ b/widget/gtk/nsPrintDialogGTK.h
@@ -17,19 +17,20 @@ typedef enum
   _GTK_PRINT_PAGES_ALL,
   _GTK_PRINT_PAGES_CURRENT,
   _GTK_PRINT_PAGES_RANGES,
   _GTK_PRINT_PAGES_SELECTION
 } _GtkPrintPages;
 
 class nsPrintDialogServiceGTK : public nsIPrintDialogService
 {
+  virtual ~nsPrintDialogServiceGTK();
+
 public:
   nsPrintDialogServiceGTK();
-  virtual ~nsPrintDialogServiceGTK();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHODIMP Init();
   NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
                      nsIWebBrowserPrint *aWebBrowserPrint);
   NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
                               nsIPrintSettings *aSettings);
--- a/widget/gtk/nsScreenManagerGtk.h
+++ b/widget/gtk/nsScreenManagerGtk.h
@@ -17,29 +17,29 @@
 #endif
 
 //------------------------------------------------------------------------
 
 class nsScreenManagerGtk : public nsIScreenManager
 {
 public:
   nsScreenManagerGtk ( );
-  virtual ~nsScreenManagerGtk();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISCREENMANAGER
 
 #ifdef MOZ_X11
   Atom NetWorkareaAtom() { return mNetWorkareaAtom; }
 #endif
   
   // For internal use, or reinitialization from change notification.
   nsresult Init();
 
 private:
+  virtual ~nsScreenManagerGtk();
 
   nsresult EnsureInit();
 
   // Cached screen array.  Its length is the number of screens we have.
   nsCOMArray<nsIScreen> mCachedScreenArray;
 
   PRLibrary *mXineramalib;
 
--- a/widget/gtk/nsSound.h
+++ b/widget/gtk/nsSound.h
@@ -13,22 +13,23 @@
 
 #include <gtk/gtk.h>
 
 class nsSound : public nsISound, 
                 public nsIStreamLoaderObserver
 { 
 public: 
     nsSound(); 
-    virtual ~nsSound();
 
     static void Shutdown();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISOUND
     NS_DECL_NSISTREAMLOADEROBSERVER
 
 private:
+    virtual ~nsSound();
+
     bool mInited;
 
 };
 
 #endif /* __nsSound_h__ */
--- a/widget/tests/TestAppShellSteadyState.cpp
+++ b/widget/tests/TestAppShellSteadyState.cpp
@@ -161,16 +161,18 @@ public:
 
 class EventListener MOZ_FINAL : public nsIDOMEventListener
 {
   nsCOMPtr<nsIAppShell> mAppShell;
 
   static nsIDOMWindowUtils* sWindowUtils;
   static nsIAppShell* sAppShell;
 
+  ~EventListener() {}
+
 public:
   NS_DECL_ISUPPORTS
 
   EventListener(nsIAppShell* aAppShell)
   : mAppShell(aAppShell)
   { }
 
   NS_IMETHOD
--- a/widget/xpwidgets/GfxInfoBase.cpp
+++ b/widget/xpwidgets/GfxInfoBase.cpp
@@ -38,19 +38,20 @@ using namespace mozilla;
 using mozilla::MutexAutoLock;
 
 nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo;
 bool GfxInfoBase::mDriverInfoObserverInitialized;
 
 // Observes for shutdown so that the child GfxDriverInfo list is freed.
 class ShutdownObserver : public nsIObserver
 {
+  virtual ~ShutdownObserver() {}
+
 public:
   ShutdownObserver() {}
-  virtual ~ShutdownObserver() {}
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Observe(nsISupports *subject, const char *aTopic,
                      const char16_t *aData)
   {
     MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
 
--- a/widget/xpwidgets/GfxInfoBase.h
+++ b/widget/xpwidgets/GfxInfoBase.h
@@ -28,17 +28,16 @@ class GfxInfoBase : public nsIGfxInfo,
                     public nsIObserver,
                     public nsSupportsWeakReference
 #ifdef DEBUG
                   , public nsIGfxInfoDebug
 #endif
 {
 public:
   GfxInfoBase();
-  virtual ~GfxInfoBase();
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   // We only declare a subset of the nsIGfxInfo interface. It's up to derived
   // classes to implement the rest of the interface.  
   // Derived classes need to use
   // using GfxInfoBase::GetFeatureStatus;
@@ -74,16 +73,18 @@ public:
   virtual nsString Model() { return EmptyString(); }
   virtual nsString Hardware() { return EmptyString(); }
   virtual nsString Product() { return EmptyString(); }
   virtual nsString Manufacturer() { return EmptyString(); }
   virtual uint32_t OperatingSystemVersion() { return 0; }
 
 protected:
 
+  virtual ~GfxInfoBase();
+
   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
                                         nsAString& aSuggestedDriverVersion,
                                         const nsTArray<GfxDriverInfo>& aDriverInfo,
                                         OperatingSystem* aOS = nullptr);
 
   // Gets the driver info table. Used by GfxInfoBase to check for general cases
   // (while subclasses check for more specific ones).
   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
--- a/widget/xpwidgets/PuppetWidget.h
+++ b/widget/xpwidgets/PuppetWidget.h
@@ -307,19 +307,20 @@ public:
     NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) MOZ_OVERRIDE;
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth) MOZ_OVERRIDE;
     NS_IMETHOD GetRotation(uint32_t* aRotation) MOZ_OVERRIDE;
     NS_IMETHOD SetRotation(uint32_t  aRotation) MOZ_OVERRIDE;
 };
 
 class PuppetScreenManager MOZ_FINAL : public nsIScreenManager
 {
+    ~PuppetScreenManager();
+
 public:
     PuppetScreenManager();
-    ~PuppetScreenManager();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISCREENMANAGER
 
 protected:
     nsCOMPtr<nsIScreen> mOneScreen;
 };
 
--- a/widget/xpwidgets/nsBaseDragService.h
+++ b/widget/xpwidgets/nsBaseDragService.h
@@ -40,30 +40,30 @@ class SourceSurface;
 class nsBaseDragService : public nsIDragService,
                           public nsIDragSession
 {
 
 public:
   typedef mozilla::gfx::SourceSurface SourceSurface;
 
   nsBaseDragService();
-  virtual ~nsBaseDragService();
 
   //nsISupports
   NS_DECL_ISUPPORTS
 
   //nsIDragSession and nsIDragService
   NS_DECL_NSIDRAGSERVICE
   NS_DECL_NSIDRAGSESSION
 
   void SetDragEndPoint(nsIntPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; }
 
   uint16_t GetInputSource() { return mInputSource; }
 
 protected:
+  virtual ~nsBaseDragService();
 
   /**
    * Draw the drag image, if any, to a surface and return it. The drag image
    * is constructed from mImage if specified, or aDOMNode if mImage is null.
    *
    * aRegion may be used to draw only a subset of the element. This region
    * should be supplied using x and y coordinates measured in css pixels
    * that are relative to the upper-left corner of the window.
--- a/widget/xpwidgets/nsBaseFilePicker.cpp
+++ b/widget/xpwidgets/nsBaseFilePicker.cpp
@@ -72,19 +72,16 @@ class nsBaseFilePickerEnumerator : publi
 {
 public:
   NS_DECL_ISUPPORTS
 
   nsBaseFilePickerEnumerator(nsISimpleEnumerator* iterator)
     : mIterator(iterator)
   {}
 
-  virtual ~nsBaseFilePickerEnumerator()
-  {}
-
   NS_IMETHOD
   GetNext(nsISupports** aResult)
   {
     nsCOMPtr<nsISupports> tmp;
     nsresult rv = mIterator->GetNext(getter_AddRefs(tmp));
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!tmp) {
@@ -102,16 +99,20 @@ public:
   }
 
   NS_IMETHOD
   HasMoreElements(bool* aResult)
   {
     return mIterator->HasMoreElements(aResult);
   }
 
+protected:
+  virtual ~nsBaseFilePickerEnumerator()
+  {}
+
 private:
   nsCOMPtr<nsISimpleEnumerator> mIterator;
 };
 
 NS_IMPL_ISUPPORTS(nsBaseFilePickerEnumerator, nsISimpleEnumerator)
 
 nsBaseFilePicker::nsBaseFilePicker()
   : mAddToRecentDocs(true)
--- a/widget/xpwidgets/nsBaseScreen.h
+++ b/widget/xpwidgets/nsBaseScreen.h
@@ -10,18 +10,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsIScreen.h"
 
 class nsBaseScreen : public nsIScreen
 {
 public:
   nsBaseScreen();
-  virtual ~nsBaseScreen();
-  
+
   NS_DECL_ISUPPORTS
 
   // nsIScreen interface
 
   // These simply forward to the device-pixel versions;
   // implementations where global display pixels may not correspond
   // to per-screen device pixels must override.
   NS_IMETHOD GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
@@ -40,16 +39,18 @@ public:
     *aRotation = nsIScreen::ROTATION_0_DEG;
     return NS_OK;
   }
   NS_IMETHOD SetRotation(uint32_t aRotation) { return NS_ERROR_NOT_AVAILABLE; }
 
   NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor);
 
 protected:
+  virtual ~nsBaseScreen();
+
   /**
    * Manually set the current level of brightness locking. This is called after
    * we determine, based on the current active locks, what the strongest
    * lock is. You should normally not call this function - it will be
    * called automatically by this class.
    *
    * Each widget implementation should implement this in a way that
    * makes sense there. This is normally the only function that
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -1709,16 +1709,18 @@ static void debug_SetCachedBoolPref(cons
     }
   }
 
   NS_ASSERTION(false, "cmon, this code is not reached dude.");
 }
 
 //////////////////////////////////////////////////////////////
 class Debug_PrefObserver MOZ_FINAL : public nsIObserver {
+    ~Debug_PrefObserver() {}
+
   public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOBSERVER
 };
 
 NS_IMPL_ISUPPORTS(Debug_PrefObserver, nsIObserver)
 
 NS_IMETHODIMP
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -45,16 +45,18 @@ class Thread;
 // inject api will allow. This also sets the maximum numerical value for touch
 // ids we can use when injecting touch points on Windows.
 #define TOUCH_INJECT_MAX_POINTS 256
 
 class nsBaseWidget;
 
 class WidgetShutdownObserver MOZ_FINAL : public nsIObserver
 {
+  ~WidgetShutdownObserver() {}
+
 public:
   WidgetShutdownObserver(nsBaseWidget* aWidget)
     : mWidget(aWidget)
   { }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
@@ -77,19 +79,20 @@ class nsBaseWidget : public nsIWidget
 protected:
   typedef base::Thread Thread;
   typedef mozilla::layers::BasicLayerManager BasicLayerManager;
   typedef mozilla::layers::BufferMode BufferMode;
   typedef mozilla::layers::CompositorChild CompositorChild;
   typedef mozilla::layers::CompositorParent CompositorParent;
   typedef mozilla::ScreenRotation ScreenRotation;
 
+  virtual ~nsBaseWidget();
+
 public:
   nsBaseWidget();
-  virtual ~nsBaseWidget();
 
   NS_DECL_ISUPPORTS
 
   // nsIWidget interface
   NS_IMETHOD              CaptureMouse(bool aCapture);
   virtual nsIWidgetListener*  GetWidgetListener();
   virtual void            SetWidgetListener(nsIWidgetListener* alistener);
   NS_IMETHOD              Destroy();
--- a/widget/xpwidgets/nsClipboardHelper.h
+++ b/widget/xpwidgets/nsClipboardHelper.h
@@ -14,20 +14,19 @@
 #include "nsString.h"
 
 /**
  * impl class for nsIClipboardHelper, a helper for common uses of nsIClipboard.
  */
 
 class nsClipboardHelper : public nsIClipboardHelper
 {
+  virtual ~nsClipboardHelper();
 
 public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICLIPBOARDHELPER
 
   nsClipboardHelper();
-  virtual ~nsClipboardHelper();
-
 };
 
 #endif // nsClipboardHelper_h__
--- a/widget/xpwidgets/nsClipboardPrivacyHandler.h
+++ b/widget/xpwidgets/nsClipboardPrivacyHandler.h
@@ -18,16 +18,17 @@ class nsITransferable;
 // In order to ensure this, callers should store an object of this class
 // for their lifetime, and call PrepareDataForClipboard in their
 // nsIClipboard::SetData implementation before starting to use the
 // nsITransferable object in any way.
 
 class nsClipboardPrivacyHandler MOZ_FINAL : public nsIObserver,
                                             public nsSupportsWeakReference
 {
+  ~nsClipboardPrivacyHandler() {}
 
 public:
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIObserver  
   NS_DECL_NSIOBSERVER
--- a/widget/xpwidgets/nsClipboardProxy.h
+++ b/widget/xpwidgets/nsClipboardProxy.h
@@ -5,16 +5,18 @@
 
 #ifndef NS_CLIPBOARD_PROXY_H
 #define NS_CLIPBOARD_PROXY_H
 
 #include "nsIClipboard.h"
 
 class nsClipboardProxy MOZ_FINAL : public nsIClipboard
 {
+  ~nsClipboardProxy() {}
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICLIPBOARD
 
   nsClipboardProxy();
 };
 
 #endif
--- a/widget/xpwidgets/nsColorPickerProxy.h
+++ b/widget/xpwidgets/nsColorPickerProxy.h
@@ -13,20 +13,21 @@
 class nsColorPickerProxy MOZ_FINAL : public nsIColorPicker,
                                      public mozilla::dom::PColorPickerChild
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICOLORPICKER
 
   nsColorPickerProxy() {}
-  ~nsColorPickerProxy() {}
 
   virtual bool RecvUpdate(const nsString& aColor) MOZ_OVERRIDE;
   virtual bool Recv__delete__(const nsString& aColor) MOZ_OVERRIDE;
 
 private:
+  ~nsColorPickerProxy() {}
+
   nsCOMPtr<nsIColorPickerShownCallback> mCallback;
   nsString mTitle;
   nsString mInitialColor;
 };
 
 #endif // nsColorPickerProxy_h
--- a/widget/xpwidgets/nsHTMLFormatConverter.h
+++ b/widget/xpwidgets/nsHTMLFormatConverter.h
@@ -9,23 +9,23 @@
 #include "nsIFormatConverter.h"
 #include "nsString.h"
 
 class nsHTMLFormatConverter : public nsIFormatConverter
 {
 public:
 
   nsHTMLFormatConverter();
-  virtual ~nsHTMLFormatConverter();
 
-    // nsISupports
+  // nsISupports
   NS_DECL_ISUPPORTS
   NS_DECL_NSIFORMATCONVERTER
 
 protected:
+  virtual ~nsHTMLFormatConverter();
 
   nsresult AddFlavorToList ( nsISupportsArray* inList, const char* inFlavor ) ;
 
   NS_IMETHOD ConvertFromHTMLToUnicode(const nsAutoString & aFromStr, nsAutoString & aToStr);
   NS_IMETHOD ConvertFromHTMLToAOLMail(const nsAutoString & aFromStr, nsAutoString & aToStr);
 
 };
 
--- a/widget/xpwidgets/nsIdleService.h
+++ b/widget/xpwidgets/nsIdleService.h
@@ -50,19 +50,19 @@ public:
 
   /**
    * Initializes the daily idle observer.
    * Keep this separated from the constructor, since it could cause pointer
    * corruption due to AddRef/Release of "this".
    */
   void Init();
 
+private:
   virtual ~nsIdleServiceDaily();
 
-private:
   /**
    * StageIdleDaily is the interim call made when an idle-daily event is due.
    * However we don't want to fire idle-daily until the user is idle for this
    * session, so this sets up a short wait for an idle event which triggers
    * the actual idle-daily event.
    *
    * @param aHasBeenLongWait Pass true indicating nsIdleServiceDaily is having
    * trouble getting the idle-daily event fired. If true StageIdleDaily will
--- a/widget/xpwidgets/nsNativeTheme.h
+++ b/widget/xpwidgets/nsNativeTheme.h
@@ -22,16 +22,17 @@ class nsPresContext;
 
 namespace mozilla {
 class EventStates;
 } // namespace mozilla
 
 class nsNativeTheme : public nsITimerCallback
 {
  protected:
+  virtual ~nsNativeTheme() {}
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
   enum ScrollbarButtonType {
     eScrollbarButton_UpTop   = 0,
     eScrollbarButton_Down    = 1 << 0,
     eScrollbarButton_Bottom  = 1 << 1
@@ -39,17 +40,16 @@ class nsNativeTheme : public nsITimerCal
 
   enum TreeSortDirection {
     eTreeSortDirection_Descending,
     eTreeSortDirection_Natural,
     eTreeSortDirection_Ascending
   };
 
   nsNativeTheme();
-  virtual ~nsNativeTheme() {}
 
   // Returns the content state (hover, focus, etc), see EventStateManager.h
   mozilla::EventStates GetContentState(nsIFrame* aFrame, uint8_t aWidgetType);
 
   // Returns whether the widget is already styled by content
   // Normally called from ThemeSupportsWidget to turn off native theming
   // for elements that are already styled.
   bool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
--- a/widget/xpwidgets/nsPrintOptionsImpl.h
+++ b/widget/xpwidgets/nsPrintOptionsImpl.h
@@ -28,19 +28,20 @@ public:
    * method Init
    *  Initializes member variables. Every consumer that does manual
    *  creation (instead of do_CreateInstance) needs to call this method
    *  immediately after instantiation.
    */
   virtual nsresult Init();
 
   nsPrintOptions();
+
+protected:
   virtual ~nsPrintOptions();
 
-protected:
   void ReadBitFieldPref(const char * aPrefId, int32_t anOption);
   void WriteBitFieldPref(const char * aPrefId, int32_t anOption);
   void ReadJustification(const char * aPrefId, int16_t& aJust,
                          int16_t aInitValue);
   void WriteJustification(const char * aPrefId, int16_t aJust);
   void ReadInchesToTwipsPref(const char * aPrefId, int32_t&  aTwips,
                              const char * aMarginPref);
   void WriteInchesFromTwipsPref(const char * aPrefId, int32_t aTwips);
--- a/widget/xpwidgets/nsPrintSession.h
+++ b/widget/xpwidgets/nsPrintSession.h
@@ -12,19 +12,20 @@
 
 //*****************************************************************************
 //***    nsPrintSession
 //*****************************************************************************
 
 class nsPrintSession : public nsIPrintSession,
                        public nsSupportsWeakReference
 {
+  virtual ~nsPrintSession();
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRINTSESSION
 
   nsPrintSession();
-  virtual ~nsPrintSession();
   
   virtual nsresult Init();
 };
 
 #endif // nsPrintSession_h__
--- a/widget/xpwidgets/nsPrintSettingsImpl.h
+++ b/widget/xpwidgets/nsPrintSettingsImpl.h
@@ -22,21 +22,22 @@
 class nsPrintSettings : public nsIPrintSettings
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRINTSETTINGS
 
   nsPrintSettings();
   nsPrintSettings(const nsPrintSettings& aPS);
-  virtual ~nsPrintSettings();
 
   nsPrintSettings& operator=(const nsPrintSettings& rhs);
 
 protected:
+  virtual ~nsPrintSettings();
+
   // May be implemented by the platform-specific derived class                       
   virtual nsresult _Clone(nsIPrintSettings **_retval);
   virtual nsresult _Assign(nsIPrintSettings *aPS);
   
   typedef enum {
     eHeader,
     eFooter
   } nsHeaderFooterEnum;
--- a/widget/xpwidgets/nsTransferable.h
+++ b/widget/xpwidgets/nsTransferable.h
@@ -54,23 +54,23 @@ protected:
  * XP Transferable wrapper
  */
 
 class nsTransferable : public nsITransferable
 {
 public:
 
   nsTransferable();
-  virtual ~nsTransferable();
 
     // nsISupports
   NS_DECL_ISUPPORTS
   NS_DECL_NSITRANSFERABLE
 
 protected:
+  virtual ~nsTransferable();
 
     // get flavors w/out converter
   nsresult GetTransferDataFlavors(nsISupportsArray** aDataFlavorList);
  
   nsTArray<DataStruct> mDataArray;
   nsCOMPtr<nsIFormatConverter> mFormatConv;
   bool mPrivateData;
 #if DEBUG