Bug 1084421 - Only Events with a wrapper should trigger GC more likely, r=mccr8
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sat, 18 Oct 2014 02:16:58 +0300
changeset 211091 cde524d5ce6411c5183342dda8442a2be564dfcf
parent 211090 f10b55f5a819fab24b11c9c58a43ef951014a2db
child 211092 4701a7ff7279da046154b22062ea8f60c9b8a9b3
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmccr8
bugs1084421
milestone36.0a1
Bug 1084421 - Only Events with a wrapper should trigger GC more likely, r=mccr8
content/media/eme/MediaEncryptedEvent.cpp
content/media/eme/MediaEncryptedEvent.h
content/media/eme/MediaKeyError.cpp
content/media/eme/MediaKeyError.h
content/media/eme/MediaKeyMessageEvent.cpp
content/media/eme/MediaKeyMessageEvent.h
content/media/webaudio/AudioProcessingEvent.cpp
content/media/webaudio/AudioProcessingEvent.h
content/media/webaudio/OfflineAudioCompletionEvent.cpp
content/media/webaudio/OfflineAudioCompletionEvent.h
content/svg/content/src/SVGZoomEvent.h
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/CustomEvent.cpp
dom/events/CustomEvent.h
dom/events/DataContainerEvent.h
dom/events/DeviceMotionEvent.h
dom/events/DragEvent.h
dom/events/Event.cpp
dom/events/Event.h
dom/events/FocusEvent.h
dom/events/InputEvent.h
dom/events/KeyboardEvent.h
dom/events/MessageEvent.cpp
dom/events/MessageEvent.h
dom/events/MouseEvent.h
dom/events/MouseScrollEvent.h
dom/events/MutationEvent.h
dom/events/NotifyPaintEvent.h
dom/events/PointerEvent.h
dom/events/ScrollAreaEvent.h
dom/events/SimpleGestureEvent.h
dom/events/SpeechRecognitionError.h
dom/events/StorageEvent.cpp
dom/events/StorageEvent.h
dom/events/TouchEvent.h
dom/events/TransitionEvent.h
dom/events/UIEvent.h
dom/events/WheelEvent.h
dom/events/XULCommandEvent.h
dom/indexedDB/IDBEvents.cpp
dom/indexedDB/IDBEvents.h
dom/smil/TimeEvent.h
dom/workers/ServiceWorkerEvents.h
--- a/content/media/eme/MediaEncryptedEvent.cpp
+++ b/content/media/eme/MediaEncryptedEvent.cpp
@@ -41,17 +41,17 @@ MediaEncryptedEvent::MediaEncryptedEvent
 
 MediaEncryptedEvent::~MediaEncryptedEvent()
 {
   mInitData = nullptr;
   mozilla::DropJSObjects(this);
 }
 
 JSObject*
-MediaEncryptedEvent::WrapObject(JSContext* aCx)
+MediaEncryptedEvent::WrapObjectInternal(JSContext* aCx)
 {
   return MediaEncryptedEventBinding::Wrap(aCx, this);
 }
 
 already_AddRefed<MediaEncryptedEvent>
 MediaEncryptedEvent::Constructor(EventTarget* aOwner,
                                  const nsAString& aInitDataType,
                                  const nsTArray<uint8_t>& aInitData)
--- a/content/media/eme/MediaEncryptedEvent.h
+++ b/content/media/eme/MediaEncryptedEvent.h
@@ -31,17 +31,17 @@ protected:
   virtual ~MediaEncryptedEvent();
   explicit MediaEncryptedEvent(EventTarget* aOwner);
 
   nsString mInitDataType;
   JS::Heap<JSObject*> mInitData;
 
 public:
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   static already_AddRefed<MediaEncryptedEvent>
   Constructor(EventTarget* aOwner,
               const nsAString& aInitDataType,
               const nsTArray<uint8_t>& aInitData);
 
   static already_AddRefed<MediaEncryptedEvent>
   Constructor(const GlobalObject& aGlobal,
--- a/content/media/eme/MediaKeyError.cpp
+++ b/content/media/eme/MediaKeyError.cpp
@@ -24,16 +24,16 @@ MediaKeyError::~MediaKeyError()
 
 uint32_t
 MediaKeyError::SystemCode() const
 {
   return mSystemCode;
 }
 
 JSObject*
-MediaKeyError::WrapObject(JSContext* aCx)
+MediaKeyError::WrapObjectInternal(JSContext* aCx)
 {
   return MediaKeyErrorBinding::Wrap(aCx, this);
 }
 
 
 } // namespace dom
 } // namespace mozilla
--- a/content/media/eme/MediaKeyError.h
+++ b/content/media/eme/MediaKeyError.h
@@ -19,17 +19,17 @@ namespace dom {
 class MediaKeyError MOZ_FINAL : public Event
 {
 public:
   NS_FORWARD_TO_EVENT
 
   MediaKeyError(EventTarget* aOwner, uint32_t aSystemCode);
   ~MediaKeyError();
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   uint32_t SystemCode() const;
 
 private:
   uint32_t mSystemCode;
 };
 
 } // namespace dom
--- a/content/media/eme/MediaKeyMessageEvent.cpp
+++ b/content/media/eme/MediaKeyMessageEvent.cpp
@@ -51,17 +51,17 @@ MediaKeyMessageEvent::~MediaKeyMessageEv
 
 MediaKeyMessageEvent*
 MediaKeyMessageEvent::AsMediaKeyMessageEvent()
 {
   return this;
 }
 
 JSObject*
-MediaKeyMessageEvent::WrapObject(JSContext* aCx)
+MediaKeyMessageEvent::WrapObjectInternal(JSContext* aCx)
 {
   return MediaKeyMessageEventBinding::Wrap(aCx, this);
 }
 
 already_AddRefed<MediaKeyMessageEvent>
 MediaKeyMessageEvent::Constructor(EventTarget* aOwner,
                                   const nsAString& aURL,
                                   const nsTArray<uint8_t>& aMessage)
--- a/content/media/eme/MediaKeyMessageEvent.h
+++ b/content/media/eme/MediaKeyMessageEvent.h
@@ -32,17 +32,17 @@ protected:
   explicit MediaKeyMessageEvent(EventTarget* aOwner);
 
   JS::Heap<JSObject*> mMessage;
   nsString mDestinationURL;
 
 public:
   virtual MediaKeyMessageEvent* AsMediaKeyMessageEvent();
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   static already_AddRefed<MediaKeyMessageEvent>
     Constructor(EventTarget* aOwner,
                 const nsAString& aURL,
                 const nsTArray<uint8_t>& aMessage);
 
   static already_AddRefed<MediaKeyMessageEvent>
   Constructor(const GlobalObject& aGlobal,
--- a/content/media/webaudio/AudioProcessingEvent.cpp
+++ b/content/media/webaudio/AudioProcessingEvent.cpp
@@ -30,17 +30,17 @@ AudioProcessingEvent::AudioProcessingEve
 {
 }
 
 AudioProcessingEvent::~AudioProcessingEvent()
 {
 }
 
 JSObject*
-AudioProcessingEvent::WrapObject(JSContext* aCx)
+AudioProcessingEvent::WrapObjectInternal(JSContext* aCx)
 {
   return AudioProcessingEventBinding::Wrap(aCx, this);
 }
 
 already_AddRefed<AudioBuffer>
 AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels,
                                          ErrorResult& aRv)
 {
--- a/content/media/webaudio/AudioProcessingEvent.h
+++ b/content/media/webaudio/AudioProcessingEvent.h
@@ -20,17 +20,17 @@ public:
   AudioProcessingEvent(ScriptProcessorNode* aOwner,
                        nsPresContext* aPresContext,
                        WidgetEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_EVENT
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioProcessingEvent, Event)
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   void InitEvent(AudioBuffer* aInputBuffer,
                  uint32_t aNumberOfInputChannels,
                  double aPlaybackTime)
   {
     InitEvent(NS_LITERAL_STRING("audioprocess"), false, false);
     mInputBuffer = aInputBuffer;
     mNumberOfInputChannels = aNumberOfInputChannels;
--- a/content/media/webaudio/OfflineAudioCompletionEvent.cpp
+++ b/content/media/webaudio/OfflineAudioCompletionEvent.cpp
@@ -27,16 +27,16 @@ OfflineAudioCompletionEvent::OfflineAudi
 {
 }
 
 OfflineAudioCompletionEvent::~OfflineAudioCompletionEvent()
 {
 }
 
 JSObject*
-OfflineAudioCompletionEvent::WrapObject(JSContext* aCx)
+OfflineAudioCompletionEvent::WrapObjectInternal(JSContext* aCx)
 {
   return OfflineAudioCompletionEventBinding::Wrap(aCx, this);
 }
 
 }
 }
 
--- a/content/media/webaudio/OfflineAudioCompletionEvent.h
+++ b/content/media/webaudio/OfflineAudioCompletionEvent.h
@@ -21,17 +21,17 @@ public:
   OfflineAudioCompletionEvent(AudioContext* aOwner,
                               nsPresContext* aPresContext,
                               WidgetEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_EVENT
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(OfflineAudioCompletionEvent, Event)
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   void InitEvent(AudioBuffer* aRenderedBuffer)
   {
     InitEvent(NS_LITERAL_STRING("complete"), false, false);
     mRenderedBuffer = aRenderedBuffer;
   }
 
   AudioBuffer* RenderedBuffer() const
--- a/content/svg/content/src/SVGZoomEvent.h
+++ b/content/svg/content/src/SVGZoomEvent.h
@@ -28,17 +28,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   SVGZoomEvent(EventTarget* aOwner, nsPresContext* aPresContext,
                InternalSVGZoomEvent* aEvent);
 
   // Forward to base class
   NS_FORWARD_TO_UIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return SVGZoomEventBinding::Wrap(aCx, this);
   }
 
   float PreviousScale() const
   {
     return mPreviousScale;
   }
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -12860,17 +12860,17 @@ class CGExampleSetter(CGNativeMember):
     def define(self, cgClass):
         return ''
 
 
 class CGBindingImplClass(CGClass):
     """
     Common codegen for generating a C++ implementation of a WebIDL interface
     """
-    def __init__(self, descriptor, cgMethod, cgGetter, cgSetter, wantGetParent=True):
+    def __init__(self, descriptor, cgMethod, cgGetter, cgSetter, wantGetParent=True, wrapMethodName="WrapObject"):
         """
         cgMethod, cgGetter and cgSetter are classes used to codegen methods,
         getters and setters.
         """
         self.descriptor = descriptor
         self._deps = descriptor.interface.getDeps()
 
         iface = descriptor.interface
@@ -12983,17 +12983,17 @@ class CGBindingImplClass(CGClass):
                     (BuiltinTypes[IDLBuiltinType.Types.boolean],
                      [FakeArgument(BuiltinTypes[IDLBuiltinType.Types.domstring],
                                    FakeMember(),
                                    name="aName")]),
                     { "infallible": True }))
 
         wrapArgs = [Argument('JSContext*', 'aCx')]
         self.methodDecls.insert(0,
-                                ClassMethod("WrapObject", "JSObject*",
+                                ClassMethod(wrapMethodName, "JSObject*",
                                             wrapArgs, virtual=descriptor.wrapperCache,
                                             breakAfterReturnDecl=" ",
                                             override=descriptor.wrapperCache,
                                             body=self.getWrapObjectBody()))
         if wantGetParent:
             self.methodDecls.insert(0,
                                     ClassMethod("GetParentObject",
                                                 self.getGetParentObjectReturnType(),
@@ -14830,17 +14830,17 @@ class CGEventMethod(CGNativeMember):
         return constructorForNativeCaller + CGNativeMember.define(self, cgClass)
 
 
 class CGEventClass(CGBindingImplClass):
     """
     Codegen for the actual Event class implementation for this descriptor
     """
     def __init__(self, descriptor):
-        CGBindingImplClass.__init__(self, descriptor, CGEventMethod, CGEventGetter, CGEventSetter, False)
+        CGBindingImplClass.__init__(self, descriptor, CGEventMethod, CGEventGetter, CGEventSetter, False, "WrapObjectInternal")
         members = []
         for m in descriptor.interface.members:
             if m.isAttr():
                 if getattr(m, "originatingInterface",
                            descriptor.interface) != descriptor.interface:
                     continue
                 nativeType = self.getNativeTypeForIDLType(m.type).define()
                 members.append(ClassMember(CGDictionary.makeMemberName(m.identifier.name),
--- a/dom/events/AnimationEvent.h
+++ b/dom/events/AnimationEvent.h
@@ -28,17 +28,17 @@ public:
   NS_DECL_NSIDOMANIMATIONEVENT
 
   static already_AddRefed<AnimationEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const AnimationEventInit& aParam,
               ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return AnimationEventBinding::Wrap(aCx, this);
   }
 
   // xpidl implementation
   // GetAnimationName(nsAString& aAnimationName);
   // GetPseudoElement(nsAString& aPseudoElement);
 
--- a/dom/events/BeforeUnloadEvent.h
+++ b/dom/events/BeforeUnloadEvent.h
@@ -19,17 +19,17 @@ class BeforeUnloadEvent : public Event,
 public:
   BeforeUnloadEvent(EventTarget* aOwner,
                     nsPresContext* aPresContext,
                     WidgetEvent* aEvent)
     : Event(aOwner, aPresContext, aEvent)
   {
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return BeforeUnloadEventBinding::Wrap(aCx, this);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to Event
   NS_FORWARD_TO_EVENT
--- a/dom/events/ClipboardEvent.h
+++ b/dom/events/ClipboardEvent.h
@@ -25,17 +25,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMCLIPBOARDEVENT
 
   // Forward to base class
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return ClipboardEventBinding::Wrap(aCx, this);
   }
 
   static already_AddRefed<ClipboardEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const ClipboardEventInit& aParam,
--- a/dom/events/CommandEvent.h
+++ b/dom/events/CommandEvent.h
@@ -24,17 +24,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMCOMMANDEVENT
 
   // Forward to base class
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return CommandEventBinding::Wrap(aCx, this);
   }
 
   void InitCommandEvent(const nsAString& aType,
                         bool aCanBubble,
                         bool aCancelable,
                         const nsAString& aCommand,
--- a/dom/events/CompositionEvent.h
+++ b/dom/events/CompositionEvent.h
@@ -22,17 +22,17 @@ public:
   CompositionEvent(EventTarget* aOwner,
                    nsPresContext* aPresContext,
                    WidgetCompositionEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_UIEVENT
   NS_DECL_NSIDOMCOMPOSITIONEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return CompositionEventBinding::Wrap(aCx, this);
   }
 
   void InitCompositionEvent(const nsAString& aType,
                             bool aCanBubble,
                             bool aCancelable,
                             nsIDOMWindow* aView,
--- a/dom/events/CustomEvent.cpp
+++ b/dom/events/CustomEvent.cpp
@@ -48,17 +48,17 @@ CustomEvent::Constructor(const GlobalObj
   bool trusted = e->Init(t);
   JS::Rooted<JS::Value> detail(aGlobal.Context(), aParam.mDetail);
   e->InitCustomEvent(aGlobal.Context(), aType, aParam.mBubbles, aParam.mCancelable, detail, aRv);
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 JSObject*
-CustomEvent::WrapObject(JSContext* aCx)
+CustomEvent::WrapObjectInternal(JSContext* aCx)
 {
   return mozilla::dom::CustomEventBinding::Wrap(aCx, this);
 }
 
 NS_IMETHODIMP
 CustomEvent::InitCustomEvent(const nsAString& aType,
                              bool aCanBubble,
                              bool aCancelable,
--- a/dom/events/CustomEvent.h
+++ b/dom/events/CustomEvent.h
@@ -33,17 +33,17 @@ public:
 
   static already_AddRefed<CustomEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const CustomEventInit& aParam,
               ErrorResult& aRv);
 
   virtual JSObject*
-  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   void
   GetDetail(JSContext* aCx,
             JS::MutableHandle<JS::Value> aRetval);
 
   void
   InitCustomEvent(JSContext* aCx,
                   const nsAString& aType,
--- a/dom/events/DataContainerEvent.h
+++ b/dom/events/DataContainerEvent.h
@@ -26,17 +26,17 @@ public:
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataContainerEvent, Event)
 
   NS_FORWARD_TO_EVENT
 
   NS_DECL_NSIDOMDATACONTAINEREVENT
 
   virtual JSObject*
-  WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return DataContainerEventBinding::Wrap(aCx, this);
   }
 
   already_AddRefed<nsIVariant> GetData(const nsAString& aKey)
   {
     nsCOMPtr<nsIVariant> val;
     GetData(aKey, getter_AddRefs(val));
--- a/dom/events/DeviceMotionEvent.h
+++ b/dom/events/DeviceMotionEvent.h
@@ -89,17 +89,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to Event
   NS_FORWARD_TO_EVENT
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event)
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return DeviceMotionEventBinding::Wrap(aCx, this);
   }
 
   DeviceAcceleration* GetAcceleration() const
   {
     return mAcceleration;
   }
--- a/dom/events/DragEvent.h
+++ b/dom/events/DragEvent.h
@@ -25,17 +25,17 @@ public:
             WidgetDragEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMDRAGEVENT
 
   NS_FORWARD_TO_MOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return DragEventBinding::Wrap(aCx, this);
   }
 
   DataTransfer* GetDataTransfer();
 
   void InitDragEvent(const nsAString& aType,
                      bool aCanBubble, bool aCancelable,
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -59,19 +59,16 @@ Event::Event(nsPIDOMWindow* aParent)
 
 void
 Event::ConstructorInit(EventTarget* aOwner,
                        nsPresContext* aPresContext,
                        WidgetEvent* aEvent)
 {
   SetOwner(aOwner);
   mIsMainThreadEvent = mOwner || NS_IsMainThread();
-  if (mIsMainThreadEvent) {
-    nsJSContext::LikelyShortLivingObjectCreated();
-  }
 
   if (mIsMainThreadEvent && !sReturnHighResTimeStampIsSet) {
     Preferences::AddBoolVarCache(&sReturnHighResTimeStamp,
                                  "dom.event.highrestimestamp.enabled",
                                  sReturnHighResTimeStamp);
     sReturnHighResTimeStampIsSet = true;
   }
 
@@ -230,16 +227,32 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
     }
   }
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExplicitOriginalTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
+
+JSObject*
+Event::WrapObject(JSContext* aCx)
+{
+  if (mIsMainThreadEvent && !GetWrapperPreserveColor()) {
+    nsJSContext::LikelyShortLivingObjectCreated();
+  }
+  return WrapObjectInternal(aCx);
+}
+
+JSObject*
+Event::WrapObjectInternal(JSContext* aCx)
+{
+  return EventBinding::Wrap(aCx, this);
+}
+
 bool
 Event::IsChrome(JSContext* aCx) const
 {
   return mIsMainThreadEvent ?
     xpc::AccessCheck::isChrome(js::GetContextCompartment(aCx)) :
     mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
 }
 
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -86,20 +86,19 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Event)
 
   nsISupports* GetParentObject()
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
-  {
-    return EventBinding::Wrap(aCx, this);
-  }
+  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_FINAL;
+
+  virtual JSObject* WrapObjectInternal(JSContext* aCx);
 
   virtual ErrorEvent* AsErrorEvent()
   {
     return nullptr;
   }
 
   virtual ProgressEvent* AsProgressEvent()
   {
--- a/dom/events/FocusEvent.h
+++ b/dom/events/FocusEvent.h
@@ -18,17 +18,17 @@ class FocusEvent : public UIEvent,
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMFOCUSEVENT
 
   // Forward to base class
   NS_FORWARD_TO_UIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return FocusEventBinding::Wrap(aCx, this);
   }
 
   FocusEvent(EventTarget* aOwner,
              nsPresContext* aPresContext,
              InternalFocusEvent* aEvent);
 
--- a/dom/events/InputEvent.h
+++ b/dom/events/InputEvent.h
@@ -26,17 +26,17 @@ public:
   NS_FORWARD_TO_UIEVENT
 
 
   static already_AddRefed<InputEvent> Constructor(const GlobalObject& aGlobal,
                                                   const nsAString& aType,
                                                   const InputEventInit& aParam,
                                                   ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return InputEventBinding::Wrap(aCx, this);
   }
 
   bool IsComposing();
 
 protected:
   ~InputEvent() {}
--- a/dom/events/KeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -31,17 +31,17 @@ public:
   NS_FORWARD_TO_UIEVENT
 
   static already_AddRefed<KeyboardEvent> Constructor(
                                            const GlobalObject& aGlobal,
                                            const nsAString& aType,
                                            const KeyboardEventInit& aParam,
                                            ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return KeyboardEventBinding::Wrap(aCx, this);
   }
 
   bool AltKey();
   bool CtrlKey();
   bool ShiftKey();
   bool MetaKey();
--- a/dom/events/MessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -52,17 +52,17 @@ MessageEvent::MessageEvent(EventTarget* 
 
 MessageEvent::~MessageEvent()
 {
   mData = JSVAL_VOID;
   DropJSObjects(this);
 }
 
 JSObject*
-MessageEvent::WrapObject(JSContext* aCx)
+MessageEvent::WrapObjectInternal(JSContext* aCx)
 {
   return mozilla::dom::MessageEventBinding::Wrap(aCx, this);
 }
 
 NS_IMETHODIMP
 MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
 {
   ErrorResult rv;
--- a/dom/events/MessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -38,17 +38,17 @@ public:
   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
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
                ErrorResult& aRv);
 
   void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
   MessagePortList* GetPorts()
   {
--- a/dom/events/MouseEvent.h
+++ b/dom/events/MouseEvent.h
@@ -25,17 +25,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseEvent Interface
   NS_DECL_NSIDOMMOUSEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_UIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return MouseEventBinding::Wrap(aCx, this);
   }
 
   // Web IDL binding methods
   virtual uint32_t Which() MOZ_OVERRIDE
   {
     return Button() + 1;
--- a/dom/events/MouseScrollEvent.h
+++ b/dom/events/MouseScrollEvent.h
@@ -24,17 +24,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseScrollEvent Interface
   NS_DECL_NSIDOMMOUSESCROLLEVENT
 
   // Forward to base class
   NS_FORWARD_TO_MOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return MouseScrollEventBinding::Wrap(aCx, this);
   }
 
   int32_t Axis();
 
   void InitMouseScrollEvent(const nsAString& aType, bool aCanBubble,
                             bool aCancelable, nsIDOMWindow* aView,
--- a/dom/events/MutationEvent.h
+++ b/dom/events/MutationEvent.h
@@ -25,17 +25,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMMUTATIONEVENT
 
   // Forward to base class
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return MutationEventBinding::Wrap(aCx, this);
   }
 
   // xpidl implementation
   // GetPrevValue(nsAString& aPrevValue);
   // GetNewValue(nsAString& aNewValue);
   // GetAttrName(nsAString& aAttrName);
--- a/dom/events/NotifyPaintEvent.h
+++ b/dom/events/NotifyPaintEvent.h
@@ -38,17 +38,17 @@ public:
   NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION
   NS_IMETHOD DuplicatePrivateData() MOZ_OVERRIDE
   {
     return Event::DuplicatePrivateData();
   }
   NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
   NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return NotifyPaintEventBinding::Wrap(aCx, this);
   }
 
   already_AddRefed<DOMRectList> ClientRects();
 
   already_AddRefed<DOMRect> BoundingClientRect();
 
--- a/dom/events/PointerEvent.h
+++ b/dom/events/PointerEvent.h
@@ -17,17 +17,17 @@ namespace dom {
 
 class PointerEvent : public MouseEvent
 {
 public:
   PointerEvent(EventTarget* aOwner,
                nsPresContext* aPresContext,
                WidgetPointerEvent* aEvent);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return PointerEventBinding::Wrap(aCx, this);
   }
 
   static already_AddRefed<PointerEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const PointerEventInit& aParam,
--- a/dom/events/ScrollAreaEvent.h
+++ b/dom/events/ScrollAreaEvent.h
@@ -33,17 +33,17 @@ public:
   NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION
   NS_IMETHOD DuplicatePrivateData()
   {
     return Event::DuplicatePrivateData();
   }
   NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
   NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return ScrollAreaEventBinding::Wrap(aCx, this);
   }
 
   float X() const
   {
     return mClientArea->Left();
   }
--- a/dom/events/SimpleGestureEvent.h
+++ b/dom/events/SimpleGestureEvent.h
@@ -25,17 +25,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMSIMPLEGESTUREEVENT
 
   // Forward to base class
   NS_FORWARD_TO_MOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return SimpleGestureEventBinding::Wrap(aCx, this);
   }
 
   uint32_t AllowedDirections();
   uint32_t Direction();
   double Delta();
   uint32_t ClickCount();
--- a/dom/events/SpeechRecognitionError.h
+++ b/dom/events/SpeechRecognitionError.h
@@ -21,17 +21,17 @@ public:
   virtual ~SpeechRecognitionError();
 
   static already_AddRefed<SpeechRecognitionError>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const SpeechRecognitionErrorInit& aParam,
               ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return mozilla::dom::SpeechRecognitionErrorBinding::Wrap(aCx, this);
   }
 
   void
   GetMessage(nsAString& aString)
   {
     aString = mMessage;
--- a/dom/events/StorageEvent.cpp
+++ b/dom/events/StorageEvent.cpp
@@ -40,17 +40,17 @@ StorageEvent::~StorageEvent()
 
 StorageEvent*
 StorageEvent::AsStorageEvent()
 {
   return this;
 }
 
 JSObject*
-StorageEvent::WrapObject(JSContext* aCx)
+StorageEvent::WrapObjectInternal(JSContext* aCx)
 {
   return StorageEventBinding::Wrap(aCx, this);
 }
 
 already_AddRefed<StorageEvent>
 StorageEvent::Constructor(EventTarget* aOwner,
                           const nsAString& aType,
                           const StorageEventInit& aEventInitDict)
--- a/dom/events/StorageEvent.h
+++ b/dom/events/StorageEvent.h
@@ -37,17 +37,17 @@ protected:
   nsString mOldValue;
   nsString mNewValue;
   nsString mUrl;
   nsRefPtr<DOMStorage> mStorageArea;
 
 public:
   virtual StorageEvent* AsStorageEvent();
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
   static already_AddRefed<StorageEvent>
   Constructor(EventTarget* aOwner, const nsAString& aType,
               const StorageEventInit& aEventInitDict);
 
   static already_AddRefed<StorageEvent>
   Constructor(const GlobalObject& aGlobal, const nsAString& aType,
               const StorageEventInit& aEventInitDict, ErrorResult& aRv);
--- a/dom/events/TouchEvent.h
+++ b/dom/events/TouchEvent.h
@@ -84,17 +84,17 @@ class TouchEvent : public UIEvent
 public:
   TouchEvent(EventTarget* aOwner,
              nsPresContext* aPresContext,
              WidgetTouchEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TouchEvent, UIEvent)
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return TouchEventBinding::Wrap(aCx, this);
   }
 
   TouchList* Touches();
   TouchList* TargetTouches();
   TouchList* ChangedTouches();
 
--- a/dom/events/TransitionEvent.h
+++ b/dom/events/TransitionEvent.h
@@ -28,17 +28,17 @@ public:
   NS_DECL_NSIDOMTRANSITIONEVENT
 
   static already_AddRefed<TransitionEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const TransitionEventInit& aParam,
               ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return TransitionEventBinding::Wrap(aCx, this);
   }
 
   // xpidl implementation
   // GetPropertyName(nsAString& aPropertyName)
   // GetPseudoElement(nsAString& aPreudoElement)
 
--- a/dom/events/UIEvent.h
+++ b/dom/events/UIEvent.h
@@ -97,17 +97,17 @@ public:
     return CSSIntPoint::FromAppUnitsRounded(pt);
   }
 
   static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal,
                                                const nsAString& aType,
                                                const UIEventInit& aParam,
                                                ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return UIEventBinding::Wrap(aCx, this);
   }
 
   nsIDOMWindow* GetView() const
   {
     return mView;
   }
--- a/dom/events/WheelEvent.h
+++ b/dom/events/WheelEvent.h
@@ -32,17 +32,17 @@ public:
   NS_FORWARD_TO_MOUSEEVENT
 
   static
   already_AddRefed<WheelEvent> Constructor(const GlobalObject& aGlobal,
                                            const nsAString& aType,
                                            const WheelEventInit& aParam,
                                            ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return WheelEventBinding::Wrap(aCx, this);
   }
 
   // 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();
--- a/dom/events/XULCommandEvent.h
+++ b/dom/events/XULCommandEvent.h
@@ -26,17 +26,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
   NS_DECL_NSIDOMXULCOMMANDEVENT
 
   // Forward our inherited virtual methods to the base class
   NS_FORWARD_TO_UIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return XULCommandEventBinding::Wrap(aCx, this);
   }
 
   bool AltKey();
   bool CtrlKey();
   bool ShiftKey();
   bool MetaKey();
--- a/dom/indexedDB/IDBEvents.cpp
+++ b/dom/indexedDB/IDBEvents.cpp
@@ -91,16 +91,16 @@ IDBVersionChangeEvent::Constructor(const
 NS_IMPL_ADDREF_INHERITED(IDBVersionChangeEvent, Event)
 NS_IMPL_RELEASE_INHERITED(IDBVersionChangeEvent, Event)
 
 NS_INTERFACE_MAP_BEGIN(IDBVersionChangeEvent)
   NS_INTERFACE_MAP_ENTRY(IDBVersionChangeEvent)
 NS_INTERFACE_MAP_END_INHERITING(Event)
 
 JSObject*
-IDBVersionChangeEvent::WrapObject(JSContext* aCx)
+IDBVersionChangeEvent::WrapObjectInternal(JSContext* aCx)
 {
   return IDBVersionChangeEventBinding::Wrap(aCx, this);
 }
 
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
--- a/dom/indexedDB/IDBEvents.h
+++ b/dom/indexedDB/IDBEvents.h
@@ -99,17 +99,17 @@ public:
   }
 
   NS_DECLARE_STATIC_IID_ACCESSOR(IDBVERSIONCHANGEEVENT_IID)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_EVENT
 
   virtual JSObject*
-  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
 
 private:
   IDBVersionChangeEvent(EventTarget* aOwner, uint64_t aOldVersion)
     : Event(aOwner, nullptr, nullptr)
     , mOldVersion(aOldVersion)
   {
   }
 
--- a/dom/smil/TimeEvent.h
+++ b/dom/smil/TimeEvent.h
@@ -26,17 +26,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TimeEvent, Event)
 
   // nsIDOMTimeEvent interface:
   NS_DECL_NSIDOMTIMEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return TimeEventBinding::Wrap(aCx, this);
   }
 
   int32_t Detail() const
   {
     return mDetail;
   }
--- a/dom/workers/ServiceWorkerEvents.h
+++ b/dom/workers/ServiceWorkerEvents.h
@@ -31,17 +31,17 @@ protected:
   explicit InstallPhaseEvent(mozilla::dom::EventTarget* aOwner);
   ~InstallPhaseEvent() {}
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallPhaseEvent, Event)
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return mozilla::dom::InstallPhaseEventBinding_workers::Wrap(aCx, this);
   }
 
   static already_AddRefed<InstallPhaseEvent>
   Constructor(mozilla::dom::EventTarget* aOwner,
               const nsAString& aType,
               const EventInit& aOptions)
@@ -83,17 +83,17 @@ protected:
   explicit InstallEvent(mozilla::dom::EventTarget* aOwner);
   ~InstallEvent() {}
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallEvent, InstallPhaseEvent)
   NS_FORWARD_TO_EVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
+  virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE
   {
     return mozilla::dom::InstallEventBinding_workers::Wrap(aCx, this);
   }
 
   static already_AddRefed<InstallEvent>
   Constructor(mozilla::dom::EventTarget* aOwner,
               const nsAString& aType,
               const InstallEventInit& aOptions)