Bug 1028588 - Fix dangerous public destructors in accessible/ - r=tbsaunde
authorBenoit Jacob <bjacob@mozilla.com>
Mon, 23 Jun 2014 15:56:09 -0400
changeset 211102 967e19ae406cba0b46ad8cb57d38c765012c3c9b
parent 211101 1679e9d569c36fa32df9977f13464f4325c9303a
child 211103 72d774431043a161ad79472c37822d5fc8502372
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1028588
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 1028588 - Fix dangerous public destructors in accessible/ - r=tbsaunde
accessible/src/base/AccEvent.h
accessible/src/base/DocManager.h
accessible/src/base/NotificationController.h
accessible/src/base/nsAccessiblePivot.cpp
accessible/src/base/nsAccessiblePivot.h
accessible/src/generic/Accessible.h
accessible/src/xpcom/nsAccessibleRelation.cpp
accessible/src/xpcom/nsAccessibleRelation.h
accessible/src/xpcom/xpcAccessibleTextRange.h
--- a/accessible/src/base/AccEvent.h
+++ b/accessible/src/base/AccEvent.h
@@ -74,17 +74,16 @@ public:
      // eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
     eDoNotEmit
   };
 
   // Initialize with an nsIAccessible
   AccEvent(uint32_t aEventType, Accessible* aAccessible,
            EIsFromUserInput aIsFromUserInput = eAutoDetect,
            EEventRule aEventRule = eRemoveDupes);
-  virtual ~AccEvent() {}
 
   // AccEvent
   uint32_t GetEventType() const { return mEventType; }
   EEventRule GetEventRule() const { return mEventRule; }
   bool IsFromUserInput() const { return mIsFromUserInput; }
   EIsFromUserInput FromUserInput() const
     { return static_cast<EIsFromUserInput>(mIsFromUserInput); }
 
@@ -117,16 +116,18 @@ public:
 
   /**
    * Reference counting and cycle collection.
    */
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AccEvent)
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
 
 protected:
+  virtual ~AccEvent() {}
+
   bool mIsFromUserInput;
   uint32_t mEventType;
   EEventRule mEventRule;
   nsRefPtr<Accessible> mAccessible;
 
   friend class EventQueue;
   friend class AccReorderEvent;
 };
--- a/accessible/src/base/DocManager.h
+++ b/accessible/src/base/DocManager.h
@@ -21,18 +21,16 @@ class DocAccessible;
 /**
  * Manage the document accessible life cycle.
  */
 class DocManager : public nsIWebProgressListener,
                    public nsIDOMEventListener,
                    public nsSupportsWeakReference
 {
 public:
-  virtual ~DocManager() { }
-
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSIDOMEVENTLISTENER
 
   /**
    * Return document accessible for the given DOM node.
    */
   DocAccessible* GetDocAccessible(nsIDocument* aDocument);
@@ -68,16 +66,17 @@ public:
   }
 
 #ifdef DEBUG
   bool IsProcessingRefreshDriverNotification() const;
 #endif
 
 protected:
   DocManager();
+  virtual ~DocManager() { }
 
   /**
    * Initialize the manager.
    */
   bool Init();
 
   /**
    * Shutdown the manager.
--- a/accessible/src/base/NotificationController.h
+++ b/accessible/src/base/NotificationController.h
@@ -85,17 +85,16 @@ private:
 /**
  * Used to process notifications from core for the document accessible.
  */
 class NotificationController : public EventQueue,
                                public nsARefreshObserver
 {
 public:
   NotificationController(DocAccessible* aDocument, nsIPresShell* aPresShell);
-  virtual ~NotificationController();
 
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
   NS_IMETHOD_(MozExternalRefCountType) Release(void);
 
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(NotificationController)
 
   /**
    * Shutdown the notification controller.
@@ -178,16 +177,18 @@ public:
   }
 
 #ifdef DEBUG
   bool IsUpdating() const
     { return mObservingState == eRefreshProcessingForUpdate; }
 #endif
 
 protected:
+  virtual ~NotificationController();
+
   nsCycleCollectingAutoRefCnt mRefCnt;
   NS_DECL_OWNINGTHREAD
 
   /**
    * Start to observe refresh to make notifications and events processing after
    * layout.
    */
   void ScheduleProcessing();
@@ -229,24 +230,26 @@ private:
 
   /**
    * Storage for content inserted notification information.
    */
   class ContentInsertion
   {
   public:
     ContentInsertion(DocAccessible* aDocument, Accessible* aContainer);
-    virtual ~ContentInsertion() { mDocument = nullptr; }
 
     NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ContentInsertion)
     NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ContentInsertion)
 
     bool InitChildList(nsIContent* aStartChildNode, nsIContent* aEndChildNode);
     void Process();
 
+  protected:
+    virtual ~ContentInsertion() { mDocument = nullptr; }
+
   private:
     ContentInsertion();
     ContentInsertion(const ContentInsertion&);
     ContentInsertion& operator = (const ContentInsertion&);
 
     // The document used to process content insertion, matched to document of
     // the notification controller that this notification belongs to, therefore
     // it's ok to keep it as weak ref.
--- a/accessible/src/base/nsAccessiblePivot.cpp
+++ b/accessible/src/base/nsAccessiblePivot.cpp
@@ -40,16 +40,20 @@ private:
 
 nsAccessiblePivot::nsAccessiblePivot(Accessible* aRoot) :
   mRoot(aRoot), mModalRoot(nullptr), mPosition(nullptr),
   mStartOffset(-1), mEndOffset(-1)
 {
   NS_ASSERTION(aRoot, "A root accessible is required");
 }
 
+nsAccessiblePivot::~nsAccessiblePivot()
+{
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_CYCLE_COLLECTION(nsAccessiblePivot, mRoot, mPosition, mObservers)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAccessiblePivot)
   NS_INTERFACE_MAP_ENTRY(nsIAccessiblePivot)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessiblePivot)
--- a/accessible/src/base/nsAccessiblePivot.h
+++ b/accessible/src/base/nsAccessiblePivot.h
@@ -33,16 +33,17 @@ public:
   NS_DECL_NSIACCESSIBLEPIVOT
 
   /*
    * A simple getter for the pivot's position.
    */
   Accessible* Position() { return mPosition; }
 
 private:
+  ~nsAccessiblePivot();
   nsAccessiblePivot() MOZ_DELETE;
   nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE;
   void operator = (const nsAccessiblePivot&) MOZ_DELETE;
 
   /*
    * Notify all observers on a pivot change. Return true if it has changed and
    * observers have been notified.
    */
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -124,17 +124,16 @@ typedef nsRefPtrHashtable<nsPtrHashKey<c
 
 class Accessible : public nsIAccessible,
                    public nsIAccessibleHyperLink,
                    public xpcAccessibleSelectable,
                    public xpcAccessibleValue
 {
 public:
   Accessible(nsIContent* aContent, DocAccessible* aDoc);
-  virtual ~Accessible();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
 
   NS_DECL_NSIACCESSIBLE
   NS_DECL_NSIACCESSIBLEHYPERLINK
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
 
@@ -818,16 +817,18 @@ public:
    * Return true if this accessible has a parent whose name depends on this
    * accessible.
    */
   bool HasNameDependentParent() const
     { return mContextFlags & eHasNameDependentParent; }
 
 protected:
 
+  virtual ~Accessible();
+
   /**
    * Return the accessible name provided by native markup. It doesn't take
    * into account ARIA markup used to specify the name.
    */
   virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName);
 
   /**
    * Return object attributes provided by native markup. It doesn't take into
--- a/accessible/src/xpcom/nsAccessibleRelation.cpp
+++ b/accessible/src/xpcom/nsAccessibleRelation.cpp
@@ -18,16 +18,20 @@ nsAccessibleRelation::nsAccessibleRelati
   mType(aType)
 {
   mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
   nsIAccessible* targetAcc = nullptr;
   while ((targetAcc = aRel->Next()))
     mTargets->AppendElement(targetAcc, false);
 }
 
+nsAccessibleRelation::~nsAccessibleRelation()
+{
+}
+
 // nsISupports
 NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
 
 // nsIAccessibleRelation
 NS_IMETHODIMP
 nsAccessibleRelation::GetRelationType(uint32_t *aType)
 {
   NS_ENSURE_ARG_POINTER(aType);
--- a/accessible/src/xpcom/nsAccessibleRelation.h
+++ b/accessible/src/xpcom/nsAccessibleRelation.h
@@ -25,16 +25,18 @@ class nsAccessibleRelation MOZ_FINAL : p
 public:
   nsAccessibleRelation(uint32_t aType, Relation* aRel);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIACCESSIBLERELATION
 
 private:
   nsAccessibleRelation();
+  ~nsAccessibleRelation();
+
   nsAccessibleRelation(const nsAccessibleRelation&);
   nsAccessibleRelation& operator = (const nsAccessibleRelation&);
   
   uint32_t mType;
   nsCOMPtr<nsIMutableArray> mTargets;
 };
 
 } // namespace a11y
--- a/accessible/src/xpcom/xpcAccessibleTextRange.h
+++ b/accessible/src/xpcom/xpcAccessibleTextRange.h
@@ -59,16 +59,19 @@ public:
   NS_IMETHOD ScrollIntoView(uint32_t aHow) MOZ_FINAL MOZ_OVERRIDE;
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLETEXTRANGE_IMPL_IID)
 
 private:
   xpcAccessibleTextRange(TextRange&& aRange) :
     mRange(Forward<TextRange>(aRange)) {}
   xpcAccessibleTextRange() {}
+
+  ~xpcAccessibleTextRange() {}
+
   friend class xpcAccessibleHyperText;
 
   xpcAccessibleTextRange(const xpcAccessibleTextRange&) MOZ_DELETE;
   xpcAccessibleTextRange& operator =(const xpcAccessibleTextRange&) MOZ_DELETE;
 
   TextRange mRange;
 };