Bug 1096328 - Remove nativeOwnership from Bindings.conf, make VRFieldOfView use a binding that owns its native. r=vlad.
☠☠ backed out by a7f64e53893e ☠ ☠
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 11 Dec 2014 20:15:32 +0100
changeset 249159 4a067de94f2256ba11041b6e7102a349c5b57e1b
parent 249158 676112a4f0921a9b5c9e7edcbaac36d26cd32e56
child 249160 12dd1ad43923ac63fa00cdf1484991d5624c4daf
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs1096328
milestone37.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 1096328 - Remove nativeOwnership from Bindings.conf, make VRFieldOfView use a binding that owns its native. r=vlad.
dom/bindings/Bindings.conf
dom/vr/VRDevice.cpp
dom/vr/VRDevice.h
dom/webidl/VRDevice.webidl
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1250,18 +1250,23 @@ DOMInterfaces = {
 'URL' : [{
     'wrapperCache': False,
 },
 {
     'workers': True,
     'wrapperCache': False,
 }],
 
+'VRFieldOfView': {
+    'wrapperCache': False,
+},
+
 'VRFieldOfViewReadOnly': {
-    'concrete': False
+    'concrete': False,
+    'wrapperCache': False,
 },
 
 'VRDevice': {
     'concrete': False
 },
 
 'VTTCue': {
     'nativeType': 'mozilla::dom::TextTrackCue'
--- a/dom/vr/VRDevice.cpp
+++ b/dom/vr/VRDevice.cpp
@@ -12,42 +12,32 @@
 #include "gfxVR.h"
 #include "nsIFrame.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRFieldOfView, mParent)
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(VRFieldOfView, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(VRFieldOfView, Release)
-
-already_AddRefed<VRFieldOfView>
+VRFieldOfView*
 VRFieldOfView::Constructor(const GlobalObject& aGlobal, const VRFieldOfViewInit& aParams,
                            ErrorResult& aRV)
 {
-  nsRefPtr<VRFieldOfView> obj =
-    new VRFieldOfView(aGlobal.GetAsSupports(),
-                      aParams.mUpDegrees, aParams.mRightDegrees,
-                      aParams.mDownDegrees, aParams.mLeftDegrees);
-  return obj.forget();
+  return new VRFieldOfView(aParams.mUpDegrees, aParams.mRightDegrees,
+                           aParams.mDownDegrees, aParams.mLeftDegrees);
 }
 
-already_AddRefed<VRFieldOfView>
+VRFieldOfView*
 VRFieldOfView::Constructor(const GlobalObject& aGlobal,
                            double aUpDegrees, double aRightDegrees,
                            double aDownDegrees, double aLeftDegrees,
                            ErrorResult& aRV)
 {
-  nsRefPtr<VRFieldOfView> obj =
-    new VRFieldOfView(aGlobal.GetAsSupports(),
-                      aUpDegrees, aRightDegrees,
-                      aDownDegrees, aLeftDegrees);
-  return obj.forget();
+  return new VRFieldOfView(aUpDegrees, aRightDegrees, aDownDegrees,
+                           aLeftDegrees);
 }
 
 JSObject*
 VRFieldOfView::WrapObject(JSContext* aCx)
 {
   return VRFieldOfViewBinding::Wrap(aCx, this);
 }
 
@@ -204,49 +194,47 @@ public:
   virtual already_AddRefed<DOMPoint> GetEyeTranslation(VREye aEye) MOZ_OVERRIDE
   {
     gfx::Point3D p = mHMD->GetEyeTranslation(EyeToEye(aEye));
 
     nsRefPtr<DOMPoint> obj = new DOMPoint(mParent, p.x, p.y, p.z, 0.0);
     return obj.forget();
   }
 
-  virtual already_AddRefed<VRFieldOfView> GetCurrentEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
+  virtual VRFieldOfView* GetCurrentEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
   {
     return CopyFieldOfView(mHMD->GetEyeFOV(EyeToEye(aEye)));
   }
 
-  virtual already_AddRefed<VRFieldOfView> GetRecommendedEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
+  virtual VRFieldOfView* GetRecommendedEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
   {
     return CopyFieldOfView(mHMD->GetRecommendedEyeFOV(EyeToEye(aEye)));
   }
 
-  virtual already_AddRefed<VRFieldOfView> GetMaximumEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
+  virtual VRFieldOfView* GetMaximumEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
   {
     return CopyFieldOfView(mHMD->GetMaximumEyeFOV(EyeToEye(aEye)));
   }
 
   virtual already_AddRefed<DOMRect> GetRecommendedEyeRenderRect(VREye aEye) MOZ_OVERRIDE
   {
     const IntSize& a(mHMD->SuggestedEyeResolution());
     nsRefPtr<DOMRect> obj =
       new DOMRect(mParent,
                   (aEye == VREye::Left) ? 0 : a.width, 0,
                   a.width, a.height);
     return obj.forget();
   }
 
 protected:
-  already_AddRefed<VRFieldOfView>
+  VRFieldOfView*
   CopyFieldOfView(const gfx::VRFieldOfView& aSrc)
   {
-    nsRefPtr<VRFieldOfView> obj =
-      new VRFieldOfView(mParent, aSrc.upDegrees, aSrc.rightDegrees,
-                        aSrc.downDegrees, aSrc.leftDegrees);
-    return obj.forget();
+    return new VRFieldOfView(aSrc.upDegrees, aSrc.rightDegrees,
+                             aSrc.downDegrees, aSrc.leftDegrees);
   }
 };
 
 class HMDPositionVRDevice : public PositionSensorVRDevice
 {
 public:
   HMDPositionVRDevice(nsISupports* aParent, gfx::VRHMDInfo* aHMD)
     : PositionSensorVRDevice(aParent)
--- a/dom/vr/VRDevice.h
+++ b/dom/vr/VRDevice.h
@@ -21,68 +21,59 @@
 
 #include "gfxVR.h"
 
 namespace mozilla {
 namespace dom {
 
 class Element;
 
-class VRFieldOfViewReadOnly : public nsWrapperCache
+class VRFieldOfViewReadOnly : public NonRefcountedDOMObject
 {
 public:
-  VRFieldOfViewReadOnly(nsISupports* aParent,
-                        double aUpDegrees, double aRightDegrees,
+  VRFieldOfViewReadOnly(double aUpDegrees, double aRightDegrees,
                         double aDownDegrees, double aLeftDegrees)
-    : mParent(aParent)
-    , mUpDegrees(aUpDegrees)
+    : mUpDegrees(aUpDegrees)
     , mRightDegrees(aRightDegrees)
     , mDownDegrees(aDownDegrees)
     , mLeftDegrees(aLeftDegrees)
   {
   }
 
   double UpDegrees() const { return mUpDegrees; }
   double RightDegrees() const { return mRightDegrees; }
   double DownDegrees() const { return mDownDegrees; }
   double LeftDegrees() const { return mLeftDegrees; }
 
 protected:
-  nsCOMPtr<nsISupports> mParent;
   double mUpDegrees;
   double mRightDegrees;
   double mDownDegrees;
   double mLeftDegrees;
 };
 
 class VRFieldOfView MOZ_FINAL : public VRFieldOfViewReadOnly
 {
-  ~VRFieldOfView() {}
 public:
-  explicit VRFieldOfView(nsISupports* aParent,
-                         double aUpDegrees = 0.0, double aRightDegrees = 0.0,
+  explicit VRFieldOfView(double aUpDegrees = 0.0, double aRightDegrees = 0.0,
                          double aDownDegrees = 0.0, double aLeftDegrees = 0.0)
-    : VRFieldOfViewReadOnly(aParent, aUpDegrees, aRightDegrees, aDownDegrees, aLeftDegrees)
+    : VRFieldOfViewReadOnly(aUpDegrees, aRightDegrees, aDownDegrees, aLeftDegrees)
   {}
 
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFieldOfView)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFieldOfView)
-
-  static already_AddRefed<VRFieldOfView>
+  static VRFieldOfView*
   Constructor(const GlobalObject& aGlobal, const VRFieldOfViewInit& aParams,
               ErrorResult& aRv);
 
-  static already_AddRefed<VRFieldOfView>
+  static VRFieldOfView*
   Constructor(const GlobalObject& aGlobal,
               double aUpDegrees, double aRightDegrees,
               double aDownDegrees, double aLeftDegrees,
               ErrorResult& aRv);
 
-  nsISupports* GetParentObject() const { return mParent; }
-  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+  JSObject* WrapObject(JSContext* aCx);
 
   void SetUpDegrees(double aVal) { mUpDegrees = aVal; }
   void SetRightDegrees(double aVal) { mRightDegrees = aVal; }
   void SetDownDegrees(double aVal) { mDownDegrees = aVal; }
   void SetLeftDegrees(double aVal) { mLeftDegrees = aVal; }
 };
 
 class VRPositionState MOZ_FINAL : public nsWrapperCache
@@ -185,19 +176,19 @@ protected:
 class HMDVRDevice : public VRDevice
 {
 public:
   virtual already_AddRefed<DOMPoint> GetEyeTranslation(VREye aEye) = 0;
 
   virtual void SetFieldOfView(const VRFieldOfViewInit& aLeftFOV,
                               const VRFieldOfViewInit& aRightFOV,
                               double zNear, double zFar) = 0;
-  virtual already_AddRefed<VRFieldOfView> GetCurrentEyeFieldOfView(VREye aEye) = 0;
-  virtual already_AddRefed<VRFieldOfView> GetRecommendedEyeFieldOfView(VREye aEye) = 0;
-  virtual already_AddRefed<VRFieldOfView> GetMaximumEyeFieldOfView(VREye aEye) = 0;
+  virtual VRFieldOfView* GetCurrentEyeFieldOfView(VREye aEye) = 0;
+  virtual VRFieldOfView* GetRecommendedEyeFieldOfView(VREye aEye) = 0;
+  virtual VRFieldOfView* GetMaximumEyeFieldOfView(VREye aEye) = 0;
   virtual already_AddRefed<DOMRect> GetRecommendedEyeRenderRect(VREye aEye) = 0;
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   void XxxToggleElementVR(Element& aElement);
 
   gfx::VRHMDInfo *GetHMD() { return mHMD.get(); }
 
--- a/dom/webidl/VRDevice.webidl
+++ b/dom/webidl/VRDevice.webidl
@@ -76,22 +76,25 @@ interface VRDevice {
 
 [Pref="dom.vr.enabled",
  HeaderFile="mozilla/dom/VRDevice.h"]
 interface HMDVRDevice : VRDevice {
   /* The translation that should be applied to the view matrix for rendering each eye */
   DOMPoint getEyeTranslation(VREye whichEye);
 
   // the FOV that the HMD was configured with
+  [NewObject]
   VRFieldOfView getCurrentEyeFieldOfView(VREye whichEye);
 
   // the recommended FOV, per eye.
+  [NewObject]
   VRFieldOfView getRecommendedEyeFieldOfView(VREye whichEye);
 
   // the maximum FOV, per eye.  Above this, rendering will look broken.
+  [NewObject]
   VRFieldOfView getMaximumEyeFieldOfView(VREye whichEye);
 
   // Set a field of view.  If either of the fields of view is null,
   // or if their values are all zeros, then the recommended field of view
   // for that eye will be used.
   void setFieldOfView(optional VRFieldOfViewInit leftFOV,
                       optional VRFieldOfViewInit rightFOV,
                       optional double zNear = 0.01,
@@ -114,15 +117,16 @@ interface PositionSensorVRDevice : VRDev
    * Return a VRPositionState dictionary containing the state of this position sensor,
    * at an optional past time or predicted for a future time if timeOffset is != 0.
    *
    * The VRPositionState will contain the position, orientation, and velocity
    * and acceleration of each of these properties.  Use "hasPosition" and "hasOrientation"
    * to check if the associated members are valid; if these are false, those members
    * will be null.
    */
+  [NewObject]
   VRPositionState getState(optional double timeOffset = 0.0);
 
   /* Zero this sensor, treating its current position and orientation
    * as the "origin/zero" values.
    */
   void zeroSensor();
 };