Bug 1035394 - Fix dangerous public destructors in widget - r=roc
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 Jul 2014 17:23:18 -0400
changeset 193006 d070ae6e63cb7e538b6deee90c30b698fd380995
parent 193005 bb3aaa6cdaa7cff15abea980e7b1ac34e5c0645e
child 193007 5821b55a574cfd078b7f3f9eeba2d497c2993254
push id27103
push usercbook@mozilla.com
push dateWed, 09 Jul 2014 13:55:18 +0000
treeherdermozilla-central@f945d50e50fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1035394
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1035394 - Fix dangerous public destructors in widget - r=roc
widget/cocoa/GfxInfo.h
widget/cocoa/nsChildView.h
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsDragService.h
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsPrintSettingsX.h
widget/gtk/nsDragService.h
widget/gtk/nsNativeThemeGTK.h
widget/gtk/nsPrintSettingsGTK.h
widget/gtk/nsWindow.h
widget/xpwidgets/GfxInfoX11.h
widget/xpwidgets/PuppetWidget.h
--- a/widget/cocoa/GfxInfo.h
+++ b/widget/cocoa/GfxInfo.h
@@ -52,16 +52,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIGFXINFODEBUG
 #endif
 
   virtual uint32_t OperatingSystemVersion() MOZ_OVERRIDE { return mOSXVersion; }
 
 protected:
 
+  virtual ~GfxInfo() {}
+
   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, 
                                         int32_t *aStatus, 
                                         nsAString & aSuggestedDriverVersion, 
                                         const nsTArray<GfxDriverInfo>& aDriverInfo,
                                         OperatingSystem* aOS = nullptr);
   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo();
 
 private:
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -399,19 +399,18 @@ public:
 class nsChildView : public nsBaseWidget,
                     public nsIPluginWidget
 {
 private:
   typedef nsBaseWidget Inherited;
   typedef mozilla::layers::APZCTreeManager APZCTreeManager;
 
 public:
-                          nsChildView();
-  virtual                 ~nsChildView();
-  
+  nsChildView();
+
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIWidget interface
   NS_IMETHOD              Create(nsIWidget *aParent,
                                  nsNativeWidget aNativeParent,
                                  const nsIntRect &aRect,
                                  nsDeviceContext *aContext,
                                  nsWidgetInitData *aInitData = nullptr);
@@ -590,16 +589,17 @@ public:
 
   mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() MOZ_OVERRIDE;
   void EndRemoteDrawing() MOZ_OVERRIDE;
   void CleanupRemoteDrawing() MOZ_OVERRIDE;
 
   APZCTreeManager* APZCTM() { return mAPZCTreeManager; }
 
 protected:
+  virtual ~nsChildView();
 
   void              ReportMoveEvent();
   void              ReportSizeEvent();
 
   // override to create different kinds of child views. Autoreleases, so
   // caller must retain.
   virtual NSView*   CreateCocoaView(NSRect inFrame);
   void              TearDownView();
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -231,17 +231,16 @@ class nsCocoaWindow : public nsBaseWidge
 {
 private:
   
   typedef nsBaseWidget Inherited;
 
 public:
 
     nsCocoaWindow();
-    virtual ~nsCocoaWindow();
 
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSPIWIDGETCOCOA
       
     NS_IMETHOD              Create(nsIWidget* aParent,
                                    nsNativeWidget aNativeParent,
                                    const nsIntRect &aRect,
                                    nsDeviceContext *aContext,
@@ -347,16 +346,17 @@ public:
                         const mozilla::WidgetKeyboardEvent& aEvent,
                         DoCommandCallback aCallback,
                         void* aCallbackData) MOZ_OVERRIDE;
 
     void SetPopupWindowLevel();
 
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
 protected:
+  virtual ~nsCocoaWindow();
 
   nsresult             CreateNativeWindow(const NSRect &aRect,
                                           nsBorderStyle aBorderStyle,
                                           bool aRectIsFrameRect);
   nsresult             CreatePopupContentView(const nsIntRect &aRect,
                                               nsDeviceContext *aContext);
   void                 DestroyNativeWindow();
   void                 AdjustWindowShadow();
--- a/widget/cocoa/nsDragService.h
+++ b/widget/cocoa/nsDragService.h
@@ -14,28 +14,30 @@ extern NSString* const kWildcardPboardTy
 extern NSString* const kCorePboardType_url;
 extern NSString* const kCorePboardType_urld;
 extern NSString* const kCorePboardType_urln;
 
 class nsDragService : public nsBaseDragService
 {
 public:
   nsDragService();
-  virtual ~nsDragService();
 
   // nsIDragService
   NS_IMETHOD InvokeDragSession(nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables,
                                nsIScriptableRegion * aRegion, uint32_t aActionType);
   NS_IMETHOD EndDragSession(bool aDoneDrag);
 
   // nsIDragSession
   NS_IMETHOD GetData(nsITransferable * aTransferable, uint32_t aItemIndex);
   NS_IMETHOD IsDataFlavorSupported(const char *aDataFlavor, bool *_retval);
   NS_IMETHOD GetNumDropItems(uint32_t * aNumItems);
 
+protected:
+  virtual ~nsDragService();
+
 private:
 
   NSImage* ConstructDragImage(nsIDOMNode* aDOMNode,
                               nsIntRect* aDragRect,
                               nsIScriptableRegion* aRegion);
 
   nsCOMPtr<nsISupportsArray> mDataItems; // only valid for a drag started within gecko
   NSView* mNativeDragView;
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -24,17 +24,16 @@ namespace mozilla {
 class EventStates;
 } // namespace mozilla
 
 class nsNativeThemeCocoa : private nsNativeTheme,
                            public nsITheme
 {
 public:
   nsNativeThemeCocoa();
-  virtual ~nsNativeThemeCocoa();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
                                   nsIFrame* aFrame,
                                   uint8_t aWidgetType,
                                   const nsRect& aRect,
@@ -64,17 +63,18 @@ public:
   bool ThemeNeedsComboboxDropmarker();
   virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) MOZ_OVERRIDE;
   virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType);
 
   void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
                     bool inIsIndeterminate, bool inIsHorizontal,
                     double inValue, double inMaxValue, nsIFrame* aFrame);
 
-protected:  
+protected:
+  virtual ~nsNativeThemeCocoa();
 
   nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
   nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
   CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
                                nsIFrame* aCurrent, nsIFrame* aRight);
 
   // HITheme drawing routines
   void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
--- a/widget/cocoa/nsPrintSettingsX.h
+++ b/widget/cocoa/nsPrintSettingsX.h
@@ -15,29 +15,30 @@
 
 class nsPrintSettingsX : public nsPrintSettings
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSX_IID)
   NS_DECL_ISUPPORTS_INHERITED
 
   nsPrintSettingsX();
-  virtual ~nsPrintSettingsX();
   nsresult Init();
   NSPrintInfo* GetCocoaPrintInfo() { return mPrintInfo; }
   void SetCocoaPrintInfo(NSPrintInfo* aPrintInfo);
   virtual nsresult ReadPageFormatFromPrefs();
   virtual nsresult WritePageFormatToPrefs();
 
   PMPrintSettings GetPMPrintSettings();
   PMPrintSession GetPMPrintSession();
   PMPageFormat GetPMPageFormat();
   void SetPMPageFormat(PMPageFormat aPageFormat);
 
 protected:
+  virtual ~nsPrintSettingsX();
+
   nsPrintSettingsX(const nsPrintSettingsX& src);
   nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
 
   nsresult _Clone(nsIPrintSettings **_retval);
   nsresult _Assign(nsIPrintSettings *aPS);
 
   // Re-initialize mUnwriteableMargin with values from mPageFormat.
   // Should be called whenever mPageFormat is initialized or overwritten.
--- a/widget/gtk/nsDragService.h
+++ b/widget/gtk/nsDragService.h
@@ -48,17 +48,16 @@ class nsAutoRefTraits<GdkDragContext> :
  * Native GTK DragService wrapper
  */
 
 class nsDragService : public nsBaseDragService,
                       public nsIObserver
 {
 public:
     nsDragService();
-    virtual ~nsDragService();
 
     NS_DECL_ISUPPORTS_INHERITED
 
     NS_DECL_NSIOBSERVER
 
     // nsIDragService
     NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
                                   nsISupportsArray * anArrayTransferables,
@@ -114,16 +113,19 @@ public:
     void           SourceDataGet(GtkWidget        *widget,
                                  GdkDragContext   *context,
                                  GtkSelectionData *selection_data,
                                  guint32           aTime);
 
     // set the drag icon during drag-begin
     void SetDragIcon(GdkDragContext* aContext);
 
+protected:
+    virtual ~nsDragService();
+
 private:
 
     // mScheduledTask indicates what signal has been received from GTK and
     // so what needs to be dispatched when the scheduled task is run.  It is
     // eDragTaskNone when there is no task scheduled (but the
     // previous task may still not have finished running).
     enum DragTask {
         eDragTaskNone,
--- a/widget/gtk/nsNativeThemeGTK.h
+++ b/widget/gtk/nsNativeThemeGTK.h
@@ -57,16 +57,18 @@ public:
   NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) MOZ_OVERRIDE;
 
   bool ThemeNeedsComboboxDropmarker();
 
   virtual Transparency GetWidgetTransparency(nsIFrame* aFrame,
                                              uint8_t aWidgetType);
 
   nsNativeThemeGTK();
+
+protected:
   virtual ~nsNativeThemeGTK();
 
 private:
   gint GetTabMarginPixels(nsIFrame* aFrame);
   bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
                               GtkThemeWidgetType& aGtkWidgetType,
                               GtkWidgetState* aState, gint* aWidgetFlags);
   bool GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType,
--- a/widget/gtk/nsPrintSettingsGTK.h
+++ b/widget/gtk/nsPrintSettingsGTK.h
@@ -29,17 +29,16 @@ extern "C" {
 
 class nsPrintSettingsGTK : public nsPrintSettings
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID)
 
   nsPrintSettingsGTK();
-  virtual ~nsPrintSettingsGTK();
 
   // We're overriding these methods because we want to read/write with GTK objects,
   // not local variables. This allows a simpler settings implementation between
   // Gecko and GTK.
 
   GtkPageSetup* GetGtkPageSetup() { return mPageSetup; };
   void SetGtkPageSetup(GtkPageSetup *aPageSetup);
 
@@ -115,16 +114,18 @@ public:
 
   NS_IMETHOD GetResolution(int32_t *aResolution);
   NS_IMETHOD SetResolution(int32_t aResolution);
 
   NS_IMETHOD GetDuplex(int32_t *aDuplex);
   NS_IMETHOD SetDuplex(int32_t aDuplex);
 
 protected:
+  virtual ~nsPrintSettingsGTK();
+
   nsPrintSettingsGTK(const nsPrintSettingsGTK& src);
   nsPrintSettingsGTK& operator=(const nsPrintSettingsGTK& rhs);
 
   virtual nsresult _Clone(nsIPrintSettings **_retval);
   virtual nsresult _Assign(nsIPrintSettings *aPS);
 
   GtkUnit GetGTKUnit(int16_t aGeckoUnit);
   void SaveNewPageSize();
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -70,17 +70,16 @@ class nsDragService;
 
 class nsShmImage;
 #endif
 
 class nsWindow : public nsBaseWidget, public nsSupportsWeakReference
 {
 public:
     nsWindow();
-    virtual ~nsWindow();
 
     static void ReleaseGlobals();
 
     NS_DECL_ISUPPORTS_INHERITED
     
     void CommonCreate(nsIWidget *aParent, bool aListenForResizes);
     
     virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
@@ -293,16 +292,18 @@ public:
     virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
                                                 uint32_t aNativeMessage,
                                                 uint32_t aModifierFlags);
 
     virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint)
     { return SynthesizeNativeMouseEvent(aPoint, GDK_MOTION_NOTIFY, 0); }
 
 protected:
+    virtual ~nsWindow();
+
     // event handling code
     void DispatchActivateEvent(void);
     void DispatchDeactivateEvent(void);
     void DispatchResized(int32_t aWidth, int32_t aHeight);
 
     // Helper for SetParent and ReparentNativeWidget.
     void ReparentNativeWidgetInternal(nsIWidget* aNewParent,
                                       GtkWidget* aNewContainer,
--- a/widget/xpwidgets/GfxInfoX11.h
+++ b/widget/xpwidgets/GfxInfoX11.h
@@ -47,16 +47,17 @@ public:
   NS_IMETHOD_(void) GetData();
 
 #ifdef DEBUG
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIGFXINFODEBUG
 #endif
 
 protected:
+  ~GfxInfo() {}
 
   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, 
                                         int32_t *aStatus, 
                                         nsAString & aSuggestedDriverVersion, 
                                         const nsTArray<GfxDriverInfo>& aDriverInfo, 
                                         OperatingSystem* aOS = nullptr);
   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo();
 
--- a/widget/xpwidgets/PuppetWidget.h
+++ b/widget/xpwidgets/PuppetWidget.h
@@ -43,18 +43,21 @@ class PuppetWidget : public nsBaseWidget
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef nsBaseWidget Base;
 
   // The width and height of the "widget" are clamped to this.
   static const size_t kMaxDimension;
 
 public:
   PuppetWidget(TabChild* aTabChild);
+
+protected:
   virtual ~PuppetWidget();
 
+public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_IMETHOD Create(nsIWidget*        aParent,
                     nsNativeWidget    aNativeParent,
                     const nsIntRect&  aRect,
                     nsDeviceContext*  aContext,
                     nsWidgetInitData* aInitData = nullptr);