Bug 1035394 - Fix dangerous public destructors in dom/events - r=smaug
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 Jul 2014 17:23:17 -0400
changeset 213794 ad2e6df5024093e92e8d4befd34733b7f1b00066
parent 213793 e5f8bd650ef1a7a0bfbee817a5e434b9fc5c62a0
child 213795 cddfa382a2ba29ce71e828c793dab227e1515114
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)
reviewerssmaug
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 dom/events - r=smaug
dom/bindings/Codegen.py
dom/events/AnimationEvent.h
dom/events/BeforeUnloadEvent.h
dom/events/ClipboardEvent.h
dom/events/CommandEvent.h
dom/events/CompositionEvent.h
dom/events/DataContainerEvent.h
dom/events/DeviceMotionEvent.h
dom/events/DragEvent.h
dom/events/FocusEvent.h
dom/events/InputEvent.h
dom/events/KeyboardEvent.h
dom/events/MessageEvent.h
dom/events/MouseEvent.h
dom/events/MouseScrollEvent.h
dom/events/MutationEvent.h
dom/events/NotifyPaintEvent.h
dom/events/ScrollAreaEvent.h
dom/events/SimpleGestureEvent.h
dom/events/StorageEvent.h
dom/events/TouchEvent.h
dom/events/TransitionEvent.h
dom/events/UIEvent.h
dom/events/WheelEvent.h
dom/events/XULCommandEvent.h
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -13872,18 +13872,18 @@ class CGEventClass(CGBindingImplClass):
 
         parent = self.descriptor.interface.parent
         self.parentType = self.descriptor.getDescriptor(parent.identifier.name).nativeType.split('::')[-1]
         baseDeclarations = fill(
             """
             public:
               NS_DECL_ISUPPORTS_INHERITED
               NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(${nativeType}, ${parentType})
+            protected:
               virtual ~${nativeType}();
-            protected:
               ${nativeType}(mozilla::dom::EventTarget* aOwner);
 
             """,
             nativeType=self.descriptor.nativeType.split('::')[-1],
             parentType=self.parentType)
 
         className = descriptor.nativeType.split('::')[-1]
         asConcreteTypeMethod = ClassMethod("As%s" % className,
--- a/dom/events/AnimationEvent.h
+++ b/dom/events/AnimationEvent.h
@@ -38,14 +38,17 @@ public:
     return AnimationEventBinding::Wrap(aCx, this);
   }
 
   // xpidl implementation
   // GetAnimationName(nsAString& aAnimationName);
   // GetPseudoElement(nsAString& aPseudoElement);
 
   float ElapsedTime();
+
+protected:
+  ~AnimationEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_AnimationEvent_h_
--- a/dom/events/BeforeUnloadEvent.h
+++ b/dom/events/BeforeUnloadEvent.h
@@ -33,15 +33,17 @@ public:
 
   // Forward to Event
   NS_FORWARD_TO_EVENT
 
   // nsIDOMBeforeUnloadEvent Interface
   NS_DECL_NSIDOMBEFOREUNLOADEVENT
 
 protected:
+  ~BeforeUnloadEvent() {}
+
   nsString mText;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_BeforeUnloadEvent_h_
--- a/dom/events/ClipboardEvent.h
+++ b/dom/events/ClipboardEvent.h
@@ -42,14 +42,17 @@ public:
               ErrorResult& aRv);
 
   DataTransfer* GetClipboardData();
 
   void InitClipboardEvent(const nsAString& aType, bool aCanBubble,
                           bool aCancelable,
                           DataTransfer* aClipboardData,
                           ErrorResult& aError);
+
+protected:
+  ~ClipboardEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ClipboardEvent_h_
--- a/dom/events/CommandEvent.h
+++ b/dom/events/CommandEvent.h
@@ -37,14 +37,17 @@ public:
   void InitCommandEvent(const nsAString& aType,
                         bool aCanBubble,
                         bool aCancelable,
                         const nsAString& aCommand,
                         ErrorResult& aRv)
   {
     aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aCommand);
   }
+
+protected:
+  ~CommandEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CommandEvent_h_
--- a/dom/events/CompositionEvent.h
+++ b/dom/events/CompositionEvent.h
@@ -40,16 +40,18 @@ public:
                             const nsAString& aLocale,
                             ErrorResult& aRv)
   {
     aRv = InitCompositionEvent(aType, aCanBubble, aCancelable, aView,
                                aData, aLocale);
   }
 
 protected:
+  ~CompositionEvent() {}
+
   nsString mData;
   nsString mLocale;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CompositionEvent_h_
--- a/dom/events/DataContainerEvent.h
+++ b/dom/events/DataContainerEvent.h
@@ -41,16 +41,19 @@ public:
     nsCOMPtr<nsIVariant> val;
     GetData(aKey, getter_AddRefs(val));
     return val.forget();
   }
 
   void SetData(JSContext* aCx, const nsAString& aKey,
                JS::Handle<JS::Value> aVal, ErrorResult& aRv);
 
+protected:
+  ~DataContainerEvent() {}
+
 private:
   static PLDHashOperator
     TraverseEntry(const nsAString& aKey, nsIVariant* aDataItem, void* aUserArg);
 
   nsInterfaceHashtable<nsStringHashKey, nsIVariant> mData;
 };
 
 } // namespace dom
--- a/dom/events/DeviceMotionEvent.h
+++ b/dom/events/DeviceMotionEvent.h
@@ -131,16 +131,18 @@ public:
 
   static already_AddRefed<DeviceMotionEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const DeviceMotionEventInit& aEventInitDict,
               ErrorResult& aRv);
 
 protected:
+  ~DeviceMotionEvent() {}
+
   nsRefPtr<DeviceAcceleration> mAcceleration;
   nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
   nsRefPtr<DeviceRotationRate> mRotationRate;
   Nullable<double> mInterval;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/events/DragEvent.h
+++ b/dom/events/DragEvent.h
@@ -42,14 +42,17 @@ public:
                      nsIDOMWindow* aView, int32_t aDetail,
                      int32_t aScreenX, int32_t aScreenY,
                      int32_t aClientX, int32_t aClientY,
                      bool aCtrlKey, bool aAltKey, bool aShiftKey,
                      bool aMetaKey, uint16_t aButton,
                      EventTarget* aRelatedTarget,
                      DataTransfer* aDataTransfer,
                      ErrorResult& aError);
+
+protected:
+  ~DragEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_DragEvent_h_
--- a/dom/events/FocusEvent.h
+++ b/dom/events/FocusEvent.h
@@ -34,16 +34,18 @@ public:
 
   EventTarget* GetRelatedTarget();
 
   static already_AddRefed<FocusEvent> Constructor(const GlobalObject& aGlobal,
                                                   const nsAString& aType,
                                                   const FocusEventInit& aParam,
                                                   ErrorResult& aRv);
 protected:
+  ~FocusEvent() {}
+
   nsresult InitFocusEvent(const nsAString& aType,
                           bool aCanBubble,
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
                           EventTarget* aRelatedTarget);
 };
 
--- a/dom/events/InputEvent.h
+++ b/dom/events/InputEvent.h
@@ -32,14 +32,17 @@ public:
                                                   ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
   {
     return InputEventBinding::Wrap(aCx, this);
   }
 
   bool IsComposing();
+
+protected:
+  ~InputEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_InputEvent_h_
--- a/dom/events/KeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -66,16 +66,19 @@ public:
                     uint32_t aKeyCode, uint32_t aCharCode,
                     ErrorResult& aRv)
   {
     aRv = InitKeyEvent(aType, aCanBubble, aCancelable, aView,
                        aCtrlKey, aAltKey, aShiftKey,aMetaKey,
                        aKeyCode, aCharCode);
   }
 
+protected:
+  ~KeyboardEvent() {}
+
 private:
   // True, if the instance is created with Constructor().
   bool mInitializedByCtor;
   // If the instance is created with Constructor(), which may have independent
   // value.  mInitializedWhichValue stores it.  I.e., this is invalid when
   // mInitializedByCtor is false.
   uint32_t mInitialzedWhichValue;
 };
--- a/dom/events/MessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -29,17 +29,16 @@ class OwningWindowProxyOrMessagePort;
  */
 class MessageEvent : public Event,
                      public nsIDOMMessageEvent
 {
 public:
   MessageEvent(EventTarget* aOwner,
                nsPresContext* aPresContext,
                WidgetEvent* aEvent);
-  ~MessageEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event)
 
   NS_DECL_NSIDOMMESSAGEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_EVENT
@@ -70,16 +69,19 @@ public:
   }
 
   static already_AddRefed<MessageEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const MessageEventInit& aEventInit,
               ErrorResult& aRv);
 
+protected:
+  ~MessageEvent();
+
 private:
   JS::Heap<JS::Value> mData;
   nsString mOrigin;
   nsString mLastEventId;
   nsCOMPtr<nsIDOMWindow> mWindowSource;
   nsRefPtr<MessagePortBase> mPortSource;
   nsRefPtr<MessagePortList> mPorts;
 };
--- a/dom/events/MouseEvent.h
+++ b/dom/events/MouseEvent.h
@@ -97,16 +97,18 @@ public:
     aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable,
                            aView, aDetail, aScreenX, aScreenY,
                            aClientX, aClientY, aCtrlKey, aAltKey,
                            aShiftKey, aMetaKey, aButton,
                            aRelatedTarget, aPressure, aInputSource);
   }
 
 protected:
+  ~MouseEvent() {}
+
   nsresult InitMouseEvent(const nsAString& aType,
                           bool aCanBubble,
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
                           int32_t aScreenX,
                           int32_t aScreenY,
                           int32_t aClientX,
--- a/dom/events/MouseScrollEvent.h
+++ b/dom/events/MouseScrollEvent.h
@@ -45,14 +45,17 @@ public:
                             nsIDOMEventTarget* aRelatedTarget, int32_t aAxis,
                             ErrorResult& aRv)
   {
     aRv = InitMouseScrollEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
                                aRelatedTarget, aAxis);
   }
+
+protected:
+  ~MouseScrollEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MouseScrollEvent_h_
--- a/dom/events/MutationEvent.h
+++ b/dom/events/MutationEvent.h
@@ -51,14 +51,17 @@ public:
                          const nsAString& aNewValue,
                          const nsAString& aAttrName,
                          uint16_t& aAttrChange, ErrorResult& aRv)
   {
     aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
                             aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
                             aPrevValue, aNewValue, aAttrName, aAttrChange);
   }
+
+protected:
+  ~MutationEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MutationEvent_h_
--- a/dom/events/NotifyPaintEvent.h
+++ b/dom/events/NotifyPaintEvent.h
@@ -48,16 +48,20 @@ public:
     return NotifyPaintEventBinding::Wrap(aCx, this);
   }
 
   already_AddRefed<DOMRectList> ClientRects();
 
   already_AddRefed<DOMRect> BoundingClientRect();
 
   already_AddRefed<PaintRequestList> PaintRequests();
+
+protected:
+  ~NotifyPaintEvent() {}
+
 private:
   nsRegion GetRegion();
 
   nsTArray<nsInvalidateRequestList::Request> mInvalidateRequests;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/events/ScrollAreaEvent.h
+++ b/dom/events/ScrollAreaEvent.h
@@ -72,15 +72,17 @@ public:
                            float aWidth, float aHeight,
                            ErrorResult& aRv)
   {
     aRv = InitScrollAreaEvent(aType, aCanBubble, aCancelable, aView,
                               aDetail, aX, aY, aWidth, aHeight);
   }
 
 protected:
+  ~ScrollAreaEvent() {}
+
   DOMRect mClientArea;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ScrollAreaEvent_h_
--- a/dom/events/SimpleGestureEvent.h
+++ b/dom/events/SimpleGestureEvent.h
@@ -63,14 +63,17 @@ public:
   {
     aRv = InitSimpleGestureEvent(aType, aCanBubble, aCancelable,
                                  aView, aDetail, aScreenX, aScreenY,
                                  aClientX, aClientY, aCtrlKey, aAltKey,
                                  aShiftKey, aMetaKey, aButton,
                                  aRelatedTarget, aAllowedDirections,
                                  aDirection, aDelta, aClickCount);
   }
+
+protected:
+  ~SimpleGestureEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_SimpleGestureEvent_h_
--- a/dom/events/StorageEvent.h
+++ b/dom/events/StorageEvent.h
@@ -24,19 +24,20 @@ namespace dom {
 
 class StorageEvent : public Event
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StorageEvent, Event)
 
   StorageEvent(EventTarget* aOwner);
+
+protected:
   virtual ~StorageEvent();
 
-protected:
   nsString mKey;
   nsString mOldValue;
   nsString mNewValue;
   nsString mUrl;
   nsCOMPtr<nsIDOMStorage> mStorageArea;
 
 public:
   virtual StorageEvent* AsStorageEvent();
--- a/dom/events/TouchEvent.h
+++ b/dom/events/TouchEvent.h
@@ -116,17 +116,20 @@ public:
                       bool aMetaKey,
                       TouchList* aTouches,
                       TouchList* aTargetTouches,
                       TouchList* aChangedTouches,
                       ErrorResult& aRv);
 
   static bool PrefEnabled(JSContext* aCx = nullptr,
                           JSObject* aGlobal = nullptr);
+
 protected:
+  ~TouchEvent() {}
+
   nsRefPtr<TouchList> mTouches;
   nsRefPtr<TouchList> mTargetTouches;
   nsRefPtr<TouchList> mChangedTouches;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/events/TransitionEvent.h
+++ b/dom/events/TransitionEvent.h
@@ -38,14 +38,17 @@ public:
     return TransitionEventBinding::Wrap(aCx, this);
   }
 
   // xpidl implementation
   // GetPropertyName(nsAString& aPropertyName)
   // GetPseudoElement(nsAString& aPreudoElement)
 
   float ElapsedTime();
+
+protected:
+  ~TransitionEvent() {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TransitionEvent_h_
--- a/dom/events/UIEvent.h
+++ b/dom/events/UIEvent.h
@@ -146,16 +146,18 @@ public:
   bool CancelBubble() const
   {
     return mEvent->mFlags.mPropagationStopped;
   }
 
   bool IsChar() const;
 
 protected:
+  ~UIEvent() {}
+
   // Internal helper functions
   nsIntPoint GetMovementPoint();
   nsIntPoint GetLayerPoint() const;
 
   nsCOMPtr<nsIDOMWindow> mView;
   int32_t mDetail;
   CSSIntPoint mClientPoint;
   // Screenpoint is mEvent->refPoint.
--- a/dom/events/WheelEvent.h
+++ b/dom/events/WheelEvent.h
@@ -45,16 +45,19 @@ public:
   // NOTE: DeltaX(), DeltaY() and DeltaZ() return CSS pixels when deltaMode is
   //       DOM_DELTA_PIXEL. (The internal event's delta values are device pixels
   //       if it's dispatched by widget)
   double DeltaX();
   double DeltaY();
   double DeltaZ();
   uint32_t DeltaMode();
 
+protected:
+  ~WheelEvent() {}
+
 private:
   int32_t mAppUnitsPerDevPixel;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_WheelEvent_h_
--- a/dom/events/XULCommandEvent.h
+++ b/dom/events/XULCommandEvent.h
@@ -58,15 +58,17 @@ public:
                         ErrorResult& aRv)
   {
     aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aView, aDetail,
                            aCtrlKey, aAltKey, aShiftKey, aMetaKey,
                            aSourceEvent);
   }
 
 protected:
+  ~XULCommandEvent() {}
+
   nsCOMPtr<nsIDOMEvent> mSourceEvent;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_XULCommandEvent_h_