Bug 1295951 - Fix JS object rooting for WebVR DOM API classes,r=mccr8

MozReview-Commit-ID: D65U12CbRw9
This commit is contained in:
Kearwood (Kip) Gilbert 2016-08-17 13:39:54 -07:00
Родитель ca940a93d4
Коммит 8c1ddf0598
2 изменённых файлов: 116 добавлений и 93 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/VRDisplayBinding.h"
#include "Navigator.h"
#include "gfxVR.h"
@ -151,6 +152,12 @@ VREyeParameters::VREyeParameters(nsISupports* aParent,
, mRenderSize(aRenderSize)
{
mFOV = new VRFieldOfView(aParent, aFOV);
mozilla::HoldJSObjects(this);
}
VREyeParameters::~VREyeParameters()
{
mozilla::DropJSObjects(this);
}
VRFieldOfView*
@ -180,6 +187,22 @@ VREyeParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return VREyeParametersBinding::Wrap(aCx, this, aGivenProto);
}
VRStageParameters::VRStageParameters(nsISupports* aParent,
const gfx::Matrix4x4& aSittingToStandingTransform,
const gfx::Size& aSize)
: mParent(aParent)
, mSittingToStandingTransform(aSittingToStandingTransform)
, mSittingToStandingTransformArray(nullptr)
, mSize(aSize)
{
mozilla::HoldJSObjects(this);
}
VRStageParameters::~VRStageParameters()
{
mozilla::DropJSObjects(this);
}
JSObject*
VRStageParameters::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
@ -278,6 +301,12 @@ VRPose::VRPose(nsISupports* aParent, const gfx::VRHMDSensorState& aState)
{
mTimeStamp = aState.timestamp * 1000.0f; // Converting from seconds to ms
mFrameId = aState.inputFrameID;
mozilla::HoldJSObjects(this);
}
VRPose::~VRPose()
{
mozilla::DropJSObjects(this);
}
void
@ -412,16 +441,16 @@ VRDisplay::VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient)
, mDepthNear(0.01f) // Default value from WebVR Spec
, mDepthFar(10000.0f) // Default value from WebVR Spec
{
MOZ_COUNT_CTOR(VRDisplay);
mDisplayId = aClient->GetDisplayInfo().GetDisplayID();
mDisplayName = NS_ConvertASCIItoUTF16(aClient->GetDisplayInfo().GetDisplayName());
mCapabilities = new VRDisplayCapabilities(aWindow, aClient->GetDisplayInfo().GetCapabilities());
mozilla::HoldJSObjects(this);
}
VRDisplay::~VRDisplay()
{
ExitPresentInternal();
MOZ_COUNT_DTOR(VRDisplay);
mozilla::DropJSObjects(this);
}
void

Просмотреть файл

@ -130,7 +130,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
protected:
~VRPose() {}
~VRPose();
nsCOMPtr<nsISupports> mParent;
double mTimeStamp;
@ -151,13 +151,7 @@ class VRStageParameters final : public nsWrapperCache
public:
VRStageParameters(nsISupports* aParent,
const gfx::Matrix4x4& aSittingToStandingTransform,
const gfx::Size& aSize)
: mParent(aParent)
, mSittingToStandingTransform(aSittingToStandingTransform)
, mSittingToStandingTransformArray(nullptr)
, mSize(aSize)
{
}
const gfx::Size& aSize);
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRStageParameters)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRStageParameters)
@ -172,7 +166,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
protected:
~VRStageParameters() {}
~VRStageParameters();
nsCOMPtr<nsISupports> mParent;
@ -203,7 +197,7 @@ public:
nsISupports* GetParentObject() const { return mParent; }
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
protected:
~VREyeParameters() {}
~VREyeParameters();
nsCOMPtr<nsISupports> mParent;