Backed out 12 changesets (bug 1096328) for M11 and M5 Test failures on a CLOSED TREE

Backed out changeset 12dd1ad43923 (bug 1096328)
Backed out changeset 4a067de94f22 (bug 1096328)
Backed out changeset 676112a4f092 (bug 1096328)
Backed out changeset e2e64e751ece (bug 1096328)
Backed out changeset 9ed945e9a8a5 (bug 1096328)
Backed out changeset 47be69b84be5 (bug 1096328)
Backed out changeset d6e68ba4846d (bug 1096328)
Backed out changeset 899d8cd8c4e8 (bug 1096328)
Backed out changeset 55c831086864 (bug 1096328)
Backed out changeset 6005fd357342 (bug 1096328)
Backed out changeset 0f330a5dd346 (bug 1096328)
Backed out changeset c37e10cff765 (bug 1096328)
This commit is contained in:
Carsten "Tomcat" Book 2015-01-12 14:48:15 +01:00
parent 037c6e954f
commit 4f7ac0cbcc
55 changed files with 462 additions and 498 deletions

View File

@ -129,11 +129,10 @@ AnonymousContent::GetElementById(const nsAString& aElementId)
return nullptr;
}
bool
AnonymousContent::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
AnonymousContent::WrapObject(JSContext* aCx)
{
return AnonymousContentBinding::Wrap(aCx, this, aReflector);
return AnonymousContentBinding::Wrap(aCx, this);
}
} // dom namespace

View File

@ -27,7 +27,7 @@ public:
explicit AnonymousContent(Element* aContentNode);
nsCOMPtr<Element> GetContentNode();
void SetContentNode(Element* aContentNode);
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* aCx);
// WebIDL methods
void SetTextContentForElement(const nsAString& aElementId,

View File

@ -23,11 +23,6 @@ namespace dom {
static const double radPerDegree = 2.0 * M_PI / 360.0;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrixReadOnly, mParent)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMMatrixReadOnly, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMMatrixReadOnly, Release)
already_AddRefed<DOMMatrix>
DOMMatrixReadOnly::Translate(double aTx,
double aTy,
@ -308,6 +303,11 @@ DOMMatrixReadOnly::Stringify(nsAString& aResult)
aResult = matrixStr;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrix, mParent)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMMatrix, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMMatrix, Release)
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{

View File

@ -40,9 +40,6 @@ public:
}
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMMatrixReadOnly)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMMatrixReadOnly)
#define GetMatrixMember(entry2D, entry3D, default) \
{ \
if (mMatrix3D) { \
@ -133,8 +130,9 @@ protected:
nsAutoPtr<gfx::Matrix> mMatrix2D;
nsAutoPtr<gfx::Matrix4x4> mMatrix3D;
virtual ~DOMMatrixReadOnly() {}
~DOMMatrixReadOnly()
{
}
private:
DOMMatrixReadOnly() = delete;
DOMMatrixReadOnly(const DOMMatrixReadOnly&) = delete;
@ -152,6 +150,9 @@ public:
: DOMMatrixReadOnly(aParent, other)
{}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMMatrix)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMMatrix)
static already_AddRefed<DOMMatrix>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
static already_AddRefed<DOMMatrix>
@ -245,6 +246,8 @@ public:
DOMMatrix* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv);
private:
void Ensure3DMatrix();
~DOMMatrix() {}
};
}

View File

@ -12,10 +12,10 @@
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMPointReadOnly, mParent)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMPoint, mParent)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPointReadOnly, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPointReadOnly, Release)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPoint, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPoint, Release)
already_AddRefed<DOMPoint>
DOMPoint::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,

View File

@ -33,29 +33,29 @@ public:
{
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPointReadOnly)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPointReadOnly)
double X() const { return mX; }
double Y() const { return mY; }
double Z() const { return mZ; }
double W() const { return mW; }
protected:
virtual ~DOMPointReadOnly() {}
nsCOMPtr<nsISupports> mParent;
double mX, mY, mZ, mW;
};
class DOMPoint MOZ_FINAL : public DOMPointReadOnly
{
~DOMPoint() {}
public:
explicit DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0,
double aZ = 0.0, double aW = 1.0)
: DOMPointReadOnly(aParent, aX, aY, aZ, aW)
{}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint)
static already_AddRefed<DOMPoint>
Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
ErrorResult& aRV);

View File

@ -288,10 +288,10 @@ void NodeIterator::ContentRemoved(nsIDocument *aDocument,
mWorkingPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
}
bool
NodeIterator::WrapObject(JSContext *cx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
NodeIterator::WrapObject(JSContext *cx)
{
return NodeIteratorBinding::Wrap(cx, this, aReflector);
return NodeIteratorBinding::Wrap(cx, this);
}
} // namespace dom

View File

@ -69,7 +69,7 @@ public:
}
// The XPCOM Detach() is fine for our purposes
bool WrapObject(JSContext *cx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext *cx);
private:
virtual ~NodeIterator();

View File

@ -450,10 +450,10 @@ TreeWalker::NextSiblingInternal(bool aReversed, ErrorResult& aResult)
}
}
bool
TreeWalker::WrapObject(JSContext *aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
TreeWalker::WrapObject(JSContext *cx)
{
return TreeWalkerBinding::Wrap(aCx, this, aReflector);
return TreeWalkerBinding::Wrap(cx, this);
}
} // namespace dom

View File

@ -65,7 +65,7 @@ public:
already_AddRefed<nsINode> PreviousNode(ErrorResult& aResult);
already_AddRefed<nsINode> NextNode(ErrorResult& aResult);
bool WrapObject(JSContext *aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext *cx);
private:
nsCOMPtr<nsINode> mCurrentNode;

View File

@ -46,10 +46,10 @@ URL::URL(nsIURI* aURI)
{
}
bool
URL::WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
URL::WrapObject(JSContext* aCx)
{
return URLBinding::Wrap(aCx, this, aReflector);
return URLBinding::Wrap(aCx, this);
}
/* static */ already_AddRefed<URL>

View File

@ -43,8 +43,8 @@ public:
explicit URL(nsIURI* aURI);
// WebIDL methods
bool
WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject*
WrapObject(JSContext* aCx);
static already_AddRefed<URL>
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,

View File

@ -2299,9 +2299,9 @@ CreateNativeGlobalForInner(JSContext* aCx,
uint32_t flags = needComponents ? 0 : nsIXPConnect::OMIT_COMPONENTS_OBJECT;
flags |= nsIXPConnect::DONT_FIRE_ONNEWGLOBALHOOK;
if (!WindowBinding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(aPrincipal), false, aGlobal) ||
!xpc::InitGlobalObject(aCx, aGlobal, flags)) {
aGlobal.set(WindowBinding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(aPrincipal), false));
if (!aGlobal || !xpc::InitGlobalObject(aCx, aGlobal, flags)) {
return NS_ERROR_FAILURE;
}

View File

@ -667,70 +667,47 @@ DefineWebIDLBindingPropertiesOnXPCObject(JSContext* cx,
JS::Handle<JSObject*> obj,
const NativeProperties* properties);
#define HAS_MEMBER_TYPEDEFS \
private: \
typedef char yes[1]; \
typedef char no[2]
#ifdef _MSC_VER
#define HAS_MEMBER_CHECK(_name) \
template<typename V> static yes& Check##_name(char (*)[(&V::_name == 0) + 1])
template<typename V> static yes& Check(char (*)[(&V::_name == 0) + 1])
#else
#define HAS_MEMBER_CHECK(_name) \
template<typename V> static yes& Check##_name(char (*)[sizeof(&V::_name) + 1])
template<typename V> static yes& Check(char (*)[sizeof(&V::_name) + 1])
#endif
#define HAS_MEMBER(_memberName, _valueName) \
private: \
HAS_MEMBER_CHECK(_memberName); \
template<typename V> static no& Check##_memberName(...); \
#define HAS_MEMBER(_name) \
template<typename T> \
class Has##_name##Member { \
typedef char yes[1]; \
typedef char no[2]; \
HAS_MEMBER_CHECK(_name); \
template<typename V> static no& Check(...); \
\
public: \
static bool const _valueName = \
sizeof(Check##_memberName<T>(nullptr)) == sizeof(yes)
template<class T>
struct NativeHasMember
{
HAS_MEMBER_TYPEDEFS;
HAS_MEMBER(GetParentObject, GetParentObject);
HAS_MEMBER(JSBindingFinalized, JSBindingFinalized);
HAS_MEMBER(WrapObject, WrapObject);
static bool const Value = sizeof(Check<T>(nullptr)) == sizeof(yes); \
};
template<class T>
struct IsSmartPtr
HAS_MEMBER(WrapObject)
// HasWrapObject<T>::Value will be true if T has a WrapObject member but it's
// not nsWrapperCache::WrapObject.
template<typename T>
struct HasWrapObject
{
HAS_MEMBER_TYPEDEFS;
HAS_MEMBER(get, value);
};
template<class T>
struct IsRefcounted
{
HAS_MEMBER_TYPEDEFS;
HAS_MEMBER(AddRef, HasAddref);
HAS_MEMBER(Release, HasRelease);
private:
typedef char yes[1];
typedef char no[2];
typedef JSObject* (nsWrapperCache::*WrapObject)(JSContext*,
JS::Handle<JSObject*>);
template<typename U, U> struct SFINAE;
template <typename V> static no& Check(SFINAE<WrapObject, &V::WrapObject>*);
template <typename V> static yes& Check(...);
public:
static bool const value = HasAddref && HasRelease;
private:
// This struct only works if T is fully declared (not just forward declared).
// The IsBaseOf check will ensure that, we don't really need it for any other
// reason (the static assert will of course always be true).
static_assert(!IsBaseOf<nsISupports, T>::value || IsRefcounted::value,
"Classes derived from nsISupports are refcounted!");
static bool const Value = HasWrapObjectMember<T>::Value &&
sizeof(Check<T>(nullptr)) == sizeof(yes);
};
#undef HAS_MEMBER
#undef HAS_MEMBER_CHECK
#undef HAS_MEMBER_TYPEDEFS
#ifdef DEBUG
template <class T, bool isISupports=IsBaseOf<nsISupports, T>::value>
struct
@ -999,7 +976,6 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
T* value,
JS::MutableHandle<JS::Value> rval)
{
static_assert(IsRefcounted<T>::value, "Don't pass owned classes in here.");
MOZ_ASSERT(value);
// We try to wrap in the compartment of the underlying object of "scope"
JS::Rooted<JSObject*> obj(cx);
@ -1019,9 +995,11 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
}
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value->WrapObject(cx, &obj)) {
return false;
}
obj = value->WrapObject(cx);
}
if (!obj) {
return false;
}
// We can end up here in all sorts of compartments, per above. Make
@ -1036,12 +1014,11 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
// is true if the JSObject took ownership
template <class T>
inline bool
WrapNewBindingNonWrapperCachedObject(JSContext* cx,
JS::Handle<JSObject*> scopeArg,
nsAutoPtr<T>& value,
JS::MutableHandle<JS::Value> rval)
WrapNewBindingNonWrapperCachedOwnedObject(JSContext* cx,
JS::Handle<JSObject*> scopeArg,
nsAutoPtr<T>& value,
JS::MutableHandle<JS::Value> rval)
{
static_assert(!IsRefcounted<T>::value, "Only pass owned classes in here.");
// We do a runtime check on value, because otherwise we might in
// fact end up wrapping a null and invoking methods on it later.
if (!value) {
@ -1064,12 +1041,17 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
ac.emplace(cx, scope);
}
bool tookOwnership = false;
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value->WrapObject(cx, &obj)) {
return false;
obj = value->WrapObject(cx, &tookOwnership);
MOZ_ASSERT_IF(obj, tookOwnership);
if (tookOwnership) {
value.forget();
}
}
value.forget();
if (!obj) {
return false;
}
// We can end up here in all sorts of compartments, per above. Make
@ -1078,9 +1060,8 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx,
return JS_WrapValue(cx, rval);
}
// Helper for smart pointers (nsRefPtr/nsCOMPtr).
template <template <typename> class SmartPtr, typename T,
typename U=typename EnableIf<IsRefcounted<T>::value, T>::Type>
// Helper for smart pointers (nsAutoPtr/nsRefPtr/nsCOMPtr).
template <template <typename> class SmartPtr, typename T>
inline bool
WrapNewBindingNonWrapperCachedObject(JSContext* cx, JS::Handle<JSObject*> scope,
const SmartPtr<T>& value,
@ -1119,8 +1100,9 @@ HandleNewBindingWrappingFailure(JSContext* cx, JS::Handle<JSObject*> scope,
// Helper for calling HandleNewBindingWrappingFailure with smart pointers
// (nsAutoPtr/nsRefPtr/nsCOMPtr) or references.
HAS_MEMBER(get)
template <class T, bool isSmartPtr=IsSmartPtr<T>::value>
template <class T, bool isSmartPtr=HasgetMember<T>::Value>
struct HandleNewBindingWrappingFailureHelper
{
static inline bool Wrap(JSContext* cx, JS::Handle<JSObject*> scope,
@ -1485,7 +1467,7 @@ struct WrapNativeParentFallback<T, true >
// Wrapping of our native parent, for cases when it's a WebIDL object (though
// possibly preffed off).
template<typename T, bool hasWrapObject=NativeHasMember<T>::WrapObject>
template<typename T, bool hasWrapObject=HasWrapObject<T>::Value >
struct WrapNativeParentHelper
{
static inline JSObject* Wrap(JSContext* cx, T* parent, nsWrapperCache* cache)
@ -1511,7 +1493,7 @@ struct WrapNativeParentHelper
// Wrapping of our native parent, for cases when it's not a WebIDL object. In
// this case it must be nsISupports.
template<typename T>
struct WrapNativeParentHelper<T, false>
struct WrapNativeParentHelper<T, false >
{
static inline JSObject* Wrap(JSContext* cx, T* parent, nsWrapperCache* cache)
{
@ -1569,7 +1551,9 @@ WrapNativeParent(JSContext* cx, const T& p)
return WrapNativeParent(cx, GetParentPointer(p), GetWrapperCache(p), GetUseXBLScope(p));
}
template<typename T, bool WrapperCached=NativeHasMember<T>::GetParentObject>
HAS_MEMBER(GetParentObject)
template<typename T, bool WrapperCached=HasGetParentObjectMember<T>::Value>
struct GetParentObject
{
static JSObject* Get(JSContext* cx, JS::Handle<JSObject*> obj)
@ -1648,7 +1632,7 @@ WrapCallThisObject<JS::Rooted<JSObject*>>(JSContext* cx,
// Helper for calling GetOrCreateDOMReflector with smart pointers
// (nsAutoPtr/nsRefPtr/nsCOMPtr) or references.
template <class T, bool isSmartPtr=IsSmartPtr<T>::value>
template <class T, bool isSmartPtr=HasgetMember<T>::Value>
struct GetOrCreateDOMReflectorHelper
{
static inline bool GetOrCreate(JSContext* cx, const T& value,
@ -1664,7 +1648,6 @@ struct GetOrCreateDOMReflectorHelper<T, false>
static inline bool GetOrCreate(JSContext* cx, T& value,
JS::MutableHandle<JS::Value> rval)
{
static_assert(IsRefcounted<T>::value, "Don't pass owned classes in here.");
return GetOrCreateDOMReflector(cx, &value, rval);
}
};
@ -1690,7 +1673,7 @@ GetOrCreateDOMReflector(JSContext* cx, JS::Handle<JSObject*> scope, T& value,
// Helper for calling GetOrCreateDOMReflectorNoWrap with smart pointers
// (nsAutoPtr/nsRefPtr/nsCOMPtr) or references.
template <class T, bool isSmartPtr=IsSmartPtr<T>::value>
template <class T, bool isSmartPtr=HasgetMember<T>::Value>
struct GetOrCreateDOMReflectorNoWrapHelper
{
static inline bool GetOrCreate(JSContext* cx, const T& value,
@ -1729,7 +1712,7 @@ GetCallbackFromCallbackObject(T* aObj)
// Helper for getting the callback JSObject* of a smart ptr around a
// CallbackObject or a reference to a CallbackObject or something like
// that.
template <class T, bool isSmartPtr=IsSmartPtr<T>::value>
template <class T, bool isSmartPtr=HasgetMember<T>::Value>
struct GetCallbackFromCallbackObjectHelper
{
static inline JSObject* Get(const T& aObj)
@ -2520,7 +2503,30 @@ HasConstructor(JSObject* obj)
}
#endif
template<class T, bool hasCallback=NativeHasMember<T>::JSBindingFinalized>
// Transfer reference in ptr to smartPtr.
template<class T>
inline void
Take(nsRefPtr<T>& smartPtr, T* ptr)
{
smartPtr = dont_AddRef(ptr);
}
// Transfer ownership of ptr to smartPtr.
template<class T>
inline void
Take(nsAutoPtr<T>& smartPtr, T* ptr)
{
smartPtr = ptr;
}
inline void
MustInheritFromNonRefcountedDOMObject(NonRefcountedDOMObject*)
{
}
HAS_MEMBER(JSBindingFinalized)
template<class T, bool hasCallback=HasJSBindingFinalizedMember<T>::Value>
struct JSBindingFinalized
{
static void Finalized(T* self)
@ -2747,119 +2753,11 @@ ToSupportsIsOnPrimaryInheritanceChain(T* aObject, nsWrapperCache* aCache)
aCache);
}
// The BindingJSObjectCreator class is supposed to be used by a caller that
// wants to create and initialise a binding JSObject. After initialisation has
// been successfully completed it should call ForgetObject().
// The BindingJSObjectCreator object will root the JSObject until ForgetObject()
// is called on it. If the native object for the binding is refcounted it will
// also hold a strong reference to it, that reference is transferred to the
// JSObject (which holds the native in a slot) when ForgetObject() is called. If
// the BindingJSObjectCreator object is destroyed and ForgetObject() was never
// called on it then the JSObject's slot holding the native will be set to
// undefined, and for a refcounted native the strong reference will be released.
template<class T>
class MOZ_STACK_CLASS BindingJSObjectCreator
{
public:
explicit BindingJSObjectCreator(JSContext* aCx)
: mReflector(aCx)
{
}
~BindingJSObjectCreator()
{
if (mReflector) {
js::SetReservedOrProxyPrivateSlot(mReflector, DOM_OBJECT_SLOT,
JS::UndefinedValue());
}
}
void
CreateProxyObject(JSContext* aCx, const js::Class* aClass,
const DOMProxyHandler* aHandler,
JS::Handle<JSObject*> aProto,
JS::Handle<JSObject*> aParent, T* aNative,
JS::MutableHandle<JSObject*> aReflector)
{
js::ProxyOptions options;
options.setClass(aClass);
JS::Rooted<JS::Value> proxyPrivateVal(aCx, JS::PrivateValue(aNative));
aReflector.set(js::NewProxyObject(aCx, aHandler, proxyPrivateVal, aProto,
aParent, options));
if (aReflector) {
mNative = aNative;
mReflector = aReflector;
}
}
void
CreateObject(JSContext* aCx, const JSClass* aClass,
JS::Handle<JSObject*> aProto, JS::Handle<JSObject*> aParent,
T* aNative, JS::MutableHandle<JSObject*> aReflector)
{
aReflector.set(JS_NewObject(aCx, aClass, aProto, aParent));
if (aReflector) {
js::SetReservedSlot(aReflector, DOM_OBJECT_SLOT, JS::PrivateValue(aNative));
mNative = aNative;
mReflector = aReflector;
}
}
void
InitializationSucceeded()
{
void* dummy;
mNative.forget(&dummy);
mReflector = nullptr;
}
private:
struct OwnedNative
{
// Make sure the native objects inherit from NonRefcountedDOMObject so
// that we log their ctor and dtor.
static_assert(IsBaseOf<NonRefcountedDOMObject, T>::value,
"Non-refcounted objects with DOM bindings should inherit "
"from NonRefcountedDOMObject.");
OwnedNative&
operator=(T* aNative)
{
return *this;
}
// This signature sucks, but it's the only one that will make a nsRefPtr
// just forget about its pointer without warning.
void
forget(void**)
{
}
};
JS::Rooted<JSObject*> mReflector;
typename Conditional<IsRefcounted<T>::value, nsRefPtr<T>, OwnedNative>::Type mNative;
};
template<class T,
template<class T, template <typename> class SmartPtr,
bool isISupports=IsBaseOf<nsISupports, T>::value>
class DeferredFinalizer
{
typedef typename Conditional<IsRefcounted<T>::value,
nsRefPtr<T>, nsAutoPtr<T>>::Type SmartPtr;
typedef nsTArray<SmartPtr> SmartPtrArray;
template<class U>
static inline void
AppendAndTake(nsTArray<nsRefPtr<U>>& smartPtrArray, U* ptr)
{
smartPtrArray.AppendElement(dont_AddRef(ptr));
}
template<class U>
static inline void
AppendAndTake(nsTArray<nsAutoPtr<U>>& smartPtrArray, U* ptr)
{
smartPtrArray.AppendElement(ptr);
}
typedef nsTArray<SmartPtr<T> > SmartPtrArray;
static void*
AppendDeferredFinalizePointer(void* aData, void* aObject)
@ -2868,7 +2766,11 @@ class DeferredFinalizer
if (!pointers) {
pointers = new SmartPtrArray();
}
AppendAndTake(*pointers, static_cast<T*>(aObject));
T* self = static_cast<T*>(aObject);
SmartPtr<T>* defer = pointers->AppendElement();
Take(*defer, self);
return pointers;
}
static bool
@ -2898,8 +2800,8 @@ public:
}
};
template<class T>
class DeferredFinalizer<T, true>
template<class T, template <typename> class SmartPtr>
class DeferredFinalizer<T, SmartPtr, true>
{
public:
static void
@ -2909,11 +2811,11 @@ public:
}
};
template<class T>
template<class T, template <typename> class SmartPtr>
static void
AddForDeferredFinalization(T* aObject)
{
DeferredFinalizer<T>::AddForDeferredFinalization(aObject);
DeferredFinalizer<T, SmartPtr>::AddForDeferredFinalization(aObject);
}
// This returns T's CC participant if it participates in CC or null if it
@ -3207,26 +3109,17 @@ StrongOrRawPtr(already_AddRefed<S>&& aPtr)
return aPtr.template downcast<T>();
}
template<class T,
class ReturnType=typename Conditional<IsRefcounted<T>::value, T*,
nsAutoPtr<T>>::Type>
inline ReturnType
template<class T>
inline T*
StrongOrRawPtr(T* aPtr)
{
return ReturnType(aPtr);
return aPtr;
}
template<class T, template<typename> class SmartPtr, class S>
inline void
StrongOrRawPtr(SmartPtr<S>&& aPtr) = delete;
template<class T>
struct StrongPtrForMember
{
typedef typename Conditional<IsRefcounted<T>::value,
nsRefPtr<T>, nsAutoPtr<T>>::Type Type;
};
inline
JSObject*
GetErrorPrototype(JSContext* aCx, JS::Handle<JSObject*> aForObj)

View File

@ -44,6 +44,22 @@
# Always true for worker descriptors for non-callback
# interfaces. Defaults to true for non-worker non-callback
# descriptors.
# * nativeOwnership: Describes how the native object is held. 3 possible
# types: worker object ('worker'), non-refcounted object
# ('owned'), refcounted object ('refcounted').
# Non-refcounted objects need to inherit from
# mozilla::dom::NonRefcountedDOMObject and preferably use
# MOZ_COUNT_CTOR/MOZ_COUNT_DTOR in their
# constructor/destructor so they participate in leak
# logging.
# This mostly determines how the finalizer releases the
# binding's hold on the native object. For a worker object
# it'll call Release, for a non-refcounted object it'll
# call delete through XPConnect's deferred finalization
# mechanism, for a refcounted object it'll call Release
# through XPConnect's deferred finalization mechanism.
# 'worker' opts into old style worker models. Defaults to
# 'refcounted'.
#
# The following fields are either a string, an array (defaults to an empty
# array) or a dictionary with three possible keys (all, getterOnly and
@ -1211,15 +1227,15 @@ DOMInterfaces = {
},
'TextDecoder': {
'wrapperCache': False
'nativeOwnership': 'owned',
},
'TextEncoder': {
'wrapperCache': False
'nativeOwnership': 'owned',
},
'TextMetrics': {
'wrapperCache': False
'nativeOwnership': 'owned',
},
'TimeRanges': {
@ -1255,13 +1271,8 @@ DOMInterfaces = {
'wrapperCache': False,
}],
'VRFieldOfView': {
'wrapperCache': False,
},
'VRFieldOfViewReadOnly': {
'concrete': False,
'wrapperCache': False,
'concrete': False
},
'VRDevice': {
@ -1578,6 +1589,7 @@ DOMInterfaces = {
'XPathExpression': {
'wrapperCache': False,
'nativeOwnership': 'owned',
},
'XSLTProcessor': {

View File

@ -1565,6 +1565,14 @@ class CGAddPropertyHook(CGAbstractClassHook):
""")
def DeferredFinalizeSmartPtr(descriptor):
if descriptor.nativeOwnership == 'owned':
smartPtr = 'nsAutoPtr'
else:
smartPtr = 'nsRefPtr'
return smartPtr
def finalizeHook(descriptor, hookName, freeOp):
finalize = "JSBindingFinalized<%s>::Finalized(self);\n" % descriptor.nativeType
if descriptor.wrapperCache:
@ -1573,8 +1581,8 @@ def finalizeHook(descriptor, hookName, freeOp):
finalize += "self->mExpandoAndGeneration.expando = JS::UndefinedValue();\n"
if descriptor.isGlobal():
finalize += "mozilla::dom::FinalizeGlobal(CastToJSFreeOp(%s), obj);\n" % freeOp
finalize += ("AddForDeferredFinalization<%s>(self);\n" %
descriptor.nativeType)
finalize += ("AddForDeferredFinalization<%s, %s >(self);\n" %
(descriptor.nativeType, DeferredFinalizeSmartPtr(descriptor)))
return CGIfWrapper(CGGeneric(finalize), "self")
@ -3057,35 +3065,50 @@ class CGConstructorEnabled(CGAbstractMethod):
def CreateBindingJSObject(descriptor, properties):
objDecl = "BindingJSObjectCreator<%s> creator(aCx);\n" % descriptor.nativeType
# We don't always need to root obj, but there are a variety
# of cases where we do, so for simplicity, just always root it.
objDecl = "JS::Rooted<JSObject*> obj(aCx);\n"
if descriptor.proxy:
create = dedent(
"""
creator.CreateProxyObject(aCx, &Class.mBase, DOMProxyHandler::getInstance(),
proto, global, aObject, aReflector);
if (!aReflector) {
return false;
JS::Rooted<JS::Value> proxyPrivateVal(aCx, JS::PrivateValue(aObject));
js::ProxyOptions options;
options.setClass(&Class.mBase);
obj = NewProxyObject(aCx, DOMProxyHandler::getInstance(),
proxyPrivateVal, proto, global, options);
if (!obj) {
return nullptr;
}
""")
if descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
create += dedent("""
js::SetProxyExtra(aReflector, JSPROXYSLOT_EXPANDO,
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO,
JS::PrivateValue(&aObject->mExpandoAndGeneration));
""")
else:
create = dedent(
"""
creator.CreateObject(aCx, Class.ToJSClass(), proto, global, aObject, aReflector);
if (!aReflector) {
return false;
obj = JS_NewObject(aCx, Class.ToJSClass(), proto, global);
if (!obj) {
return nullptr;
}
js::SetReservedSlot(obj, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL(aObject));
""")
return objDecl + create
create = objDecl + create
if descriptor.nativeOwnership == 'refcounted':
create += "NS_ADDREF(aObject);\n"
else:
create += dedent("""
// Make sure the native objects inherit from NonRefcountedDOMObject so that we
// log their ctor and dtor.
MustInheritFromNonRefcountedDOMObject(aObject);
*aTookOwnership = true;
""")
return create
def InitUnforgeablePropertiesOnObject(descriptor, obj, properties, failureReturnValue=""):
@ -3158,7 +3181,7 @@ def InitUnforgeableProperties(descriptor, properties):
"// by the interface prototype object.\n")
else:
unforgeableProperties = CGWrapper(
InitUnforgeablePropertiesOnObject(descriptor, "aReflector", properties, "false"),
InitUnforgeablePropertiesOnObject(descriptor, "obj", properties, "nullptr"),
pre=(
"// Important: do unforgeable property setup after we have handed\n"
"// over ownership of the C++ object to obj as needed, so that if\n"
@ -3196,9 +3219,9 @@ def InitMemberSlots(descriptor, wrapperCache):
clearWrapper = " aCache->ClearWrapper();\n"
else:
clearWrapper = ""
return ("if (!UpdateMemberSlots(aCx, aReflector, aObject)) {\n"
return ("if (!UpdateMemberSlots(aCx, obj, aObject)) {\n"
"%s"
" return false;\n"
" return nullptr;\n"
"}\n" % clearWrapper)
@ -3212,9 +3235,8 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
assert descriptor.interface.hasInterfacePrototypeObject()
args = [Argument('JSContext*', 'aCx'),
Argument(descriptor.nativeType + '*', 'aObject'),
Argument('nsWrapperCache*', 'aCache'),
Argument('JS::MutableHandle<JSObject*>', 'aReflector')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'bool', args)
Argument('nsWrapperCache*', 'aCache')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args)
self.properties = properties
def definition_body(self):
@ -3227,31 +3249,33 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
JS::Rooted<JSObject*> parent(aCx, WrapNativeParent(aCx, aObject->GetParentObject()));
if (!parent) {
return false;
return nullptr;
}
// That might have ended up wrapping us already, due to the wonders
// of XBL. Check for that, and bail out as needed.
aReflector.set(aCache->GetWrapper());
if (aReflector) {
return true;
// of XBL. Check for that, and bail out as needed. Scope so we don't
// collide with the "obj" we declare in CreateBindingJSObject.
{
JSObject* obj = aCache->GetWrapper();
if (obj) {
return obj;
}
}
JSAutoCompartment ac(aCx, parent);
JS::Rooted<JSObject*> global(aCx, js::GetGlobalForObjectCrossCompartment(parent));
JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx, global);
if (!proto) {
return false;
return nullptr;
}
$*{createObject}
$*{unforgeable}
aCache->SetWrapper(aReflector);
aCache->SetWrapper(obj);
$*{slots}
creator.InitializationSucceeded();
return true;
return obj;
""",
assertion=AssertInheritanceChain(self.descriptor),
createObject=CreateBindingJSObject(self.descriptor, self.properties),
@ -3269,10 +3293,7 @@ class CGWrapMethod(CGAbstractMethod):
inline=True, templateArgs=["class T"])
def definition_body(self):
return dedent("""
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, &reflector) ? reflector.get() : nullptr;
""")
return "return Wrap(aCx, aObject, aObject);\n"
class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
@ -3286,9 +3307,10 @@ class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
# XXX can we wrap if we don't have an interface prototype object?
assert descriptor.interface.hasInterfacePrototypeObject()
args = [Argument('JSContext*', 'aCx'),
Argument(descriptor.nativeType + '*', 'aObject'),
Argument('JS::MutableHandle<JSObject*>', 'aReflector')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'bool', args)
Argument(descriptor.nativeType + '*', 'aObject')]
if descriptor.nativeOwnership == 'owned':
args.append(Argument('bool*', 'aTookOwnership'))
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args)
self.properties = properties
def definition_body(self):
@ -3299,7 +3321,7 @@ class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx, global);
if (!proto) {
return false;
return nullptr;
}
$*{createObject}
@ -3307,8 +3329,7 @@ class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
$*{unforgeable}
$*{slots}
creator.InitializationSucceeded();
return true;
return obj;
""",
assertions=AssertInheritanceChain(self.descriptor),
createObject=CreateBindingJSObject(self.descriptor, self.properties),
@ -3330,9 +3351,8 @@ class CGWrapGlobalMethod(CGAbstractMethod):
Argument('nsWrapperCache*', 'aCache'),
Argument('JS::CompartmentOptions&', 'aOptions'),
Argument('JSPrincipals*', 'aPrincipal'),
Argument('bool', 'aInitStandardClasses'),
Argument('JS::MutableHandle<JSObject*>', 'aReflector')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'bool', args)
Argument('bool', 'aInitStandardClasses')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args)
self.descriptor = descriptor
self.properties = properties
@ -3348,7 +3368,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
if self.descriptor.workers:
fireOnNewGlobal = """// XXXkhuey can't do this yet until workers can lazy resolve.
// JS_FireOnNewGlobalObject(aCx, aReflector);
// JS_FireOnNewGlobalObject(aCx, obj);
"""
else:
fireOnNewGlobal = ""
@ -3359,6 +3379,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
JS::Rooted<JSObject*> obj(aCx);
CreateGlobal<${nativeType}, GetProtoObjectHandle>(aCx,
aObject,
aCache,
@ -3366,24 +3387,24 @@ class CGWrapGlobalMethod(CGAbstractMethod):
aOptions,
aPrincipal,
aInitStandardClasses,
aReflector);
if (!aReflector) {
return false;
&obj);
if (!obj) {
return nullptr;
}
// aReflector is a new global, so has a new compartment. Enter it
// obj is a new global, so has a new compartment. Enter it
// before doing anything with it.
JSAutoCompartment ac(aCx, aReflector);
JSAutoCompartment ac(aCx, obj);
if (!DefineProperties(aCx, aReflector, ${properties}, ${chromeProperties})) {
return false;
if (!DefineProperties(aCx, obj, ${properties}, ${chromeProperties})) {
return nullptr;
}
$*{unforgeable}
$*{slots}
$*{fireOnNewGlobal}
return true;
return obj;
""",
assertions=AssertInheritanceChain(self.descriptor),
nativeType=self.descriptor.nativeType,
@ -4683,6 +4704,12 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
isMember or
isCallbackReturnValue)
if forceOwningType and descriptor.nativeOwnership == 'owned':
raise TypeError("Interface %s has 'owned' nativeOwnership, so we "
"don't know how to keep it alive in %s" %
(descriptor.interface.identifier.name,
sourceDescription))
typeName = descriptor.nativeType
typePtr = typeName + "*"
@ -4706,8 +4733,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
declType = "NonNull<" + typeName + ">"
templateBody = ""
if forceOwningType:
templateBody += 'static_assert(IsRefcounted<%s>::value, "We can only store refcounted classes.");' % typeName
if not descriptor.skipGen and not descriptor.interface.isConsequential() and not descriptor.interface.isExternal():
if failureCode is not None:
templateBody += str(CastableObjectUnwrapper(
@ -5744,11 +5769,15 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
if not descriptor.interface.isExternal() and not descriptor.skipGen:
if descriptor.wrapperCache:
assert descriptor.nativeOwnership != 'owned'
wrapMethod = "GetOrCreateDOMReflector"
else:
if not returnsNewObject:
raise MethodNotNewObjectError(descriptor.interface.identifier.name)
wrapMethod = "WrapNewBindingNonWrapperCachedObject"
if descriptor.nativeOwnership == 'owned':
wrapMethod = "WrapNewBindingNonWrapperCachedOwnedObject"
else:
wrapMethod = "WrapNewBindingNonWrapperCachedObject"
wrap = "%s(cx, ${obj}, %s, ${jsvalHandle})" % (wrapMethod, result)
if not descriptor.hasXPConnectImpls:
# Can only fail to wrap as a new-binding object
@ -6069,8 +6098,11 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
result = CGGeneric(descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name).nativeType)
conversion = None
if isMember:
result = CGGeneric("StrongPtrForMember<%s>::Type" % result.define())
if descriptorProvider.getDescriptor(
returnType.unroll().inner.identifier.name).nativeOwnership == 'owned':
result = CGTemplatedType("nsAutoPtr", result)
elif isMember:
result = CGTemplatedType("nsRefPtr", result)
else:
conversion = CGGeneric("StrongOrRawPtr<%s>" % result.define())
result = CGGeneric("auto")
@ -6661,7 +6693,8 @@ class CGPerSignatureCall(CGThing):
returnsNewObject = memberReturnsNewObject(self.idlNode)
if (returnsNewObject and
self.returnType.isGeckoInterface()):
self.returnType.isGeckoInterface() and
not self.descriptor.getDescriptor(self.returnType.unroll().inner.identifier.name).nativeOwnership == 'owned'):
wrapCode += dedent(
"""
static_assert(!IsPointer<decltype(result)>::value,
@ -10961,17 +10994,16 @@ class CGDescriptor(CGThing):
assert not descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject()
if descriptor.nativeOwnership == 'owned' and (
descriptor.interface.hasChildInterfaces() or
descriptor.interface.parent):
raise TypeError("Owned interface cannot have a parent or children")
self._deps = descriptor.interface.getDeps()
cgThings = []
cgThings.append(CGGeneric(declare="typedef %s NativeType;\n" %
descriptor.nativeType))
parent = descriptor.interface.parent
if parent:
cgThings.append(CGGeneric("static_assert(IsRefcounted<NativeType>::value == IsRefcounted<%s::NativeType>::value,\n"
" \"Can't inherit from an interface with a different ownership model.\");\n" %
toBindingNamespace(descriptor.parentPrototypeName)))
# These are set to true if at least one non-static
# method/getter/setter or jsonifier exist on the interface.
(hasMethod, hasGetter, hasLenientGetter, hasSetter, hasLenientSetter,
@ -12181,10 +12213,7 @@ class CGBindingRoot(CGThing):
declare or define to generate header or cpp code (respectively).
"""
def __init__(self, config, prefix, webIDLFile):
bindingHeaders = dict.fromkeys((
'mozilla/dom/NonRefcountedDOMObject.h',
),
True)
bindingHeaders = {}
bindingDeclareHeaders = dict.fromkeys((
'mozilla/dom/BindingDeclarations.h',
'mozilla/dom/Nullable.h',
@ -12226,6 +12255,8 @@ class CGBindingRoot(CGThing):
bindingHeaders["mozilla/Preferences.h"] = any(
descriptorRequiresPreferences(d) for d in descriptors)
bindingHeaders["mozilla/dom/NonRefcountedDOMObject.h"] = any(
d.nativeOwnership == 'owned' for d in descriptors)
bindingHeaders["mozilla/dom/DOMJSProxyHandler.h"] = any(
d.concrete and d.proxy for d in descriptors)
@ -13035,30 +13066,40 @@ class CGExampleClass(CGBindingImplClass):
CGExampleMethod, CGExampleGetter, CGExampleSetter,
wantGetParent=descriptor.wrapperCache)
self.refcounted = descriptor.nativeOwnership == "refcounted"
self.parentIface = descriptor.interface.parent
if self.parentIface:
self.parentDesc = descriptor.getDescriptor(
self.parentIface.identifier.name)
bases = [ClassBase(self.nativeLeafName(self.parentDesc))]
else:
bases = [ ClassBase("nsISupports /* or NonRefcountedDOMObject if this is a non-refcounted object */") ]
if descriptor.wrapperCache:
bases.append(ClassBase("nsWrapperCache /* Change wrapperCache in the binding configuration if you don't want this */"))
bases = []
if self.refcounted:
bases.append(ClassBase("nsISupports /* Change nativeOwnership in the binding configuration if you don't want this */"))
if descriptor.wrapperCache:
bases.append(ClassBase("nsWrapperCache /* Change wrapperCache in the binding configuration if you don't want this */"))
else:
bases.append(ClassBase("NonRefcountedDOMObject"))
destructorVisibility = "protected"
if self.parentIface:
extradeclarations = (
"public:\n"
" NS_DECL_ISUPPORTS_INHERITED\n"
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(%s, %s)\n"
"\n" % (self.nativeLeafName(descriptor),
self.nativeLeafName(self.parentDesc)))
if self.refcounted:
destructorVisibility = "protected"
if self.parentIface:
extradeclarations = (
"public:\n"
" NS_DECL_ISUPPORTS_INHERITED\n"
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(%s, %s)\n"
"\n" % (self.nativeLeafName(descriptor),
self.nativeLeafName(self.parentDesc)))
else:
extradeclarations = (
"public:\n"
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(%s)\n"
"\n" % self.nativeLeafName(descriptor))
else:
extradeclarations = (
"public:\n"
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(%s)\n"
"\n" % self.nativeLeafName(descriptor))
destructorVisibility = "public"
extradeclarations = ""
if descriptor.interface.hasChildInterfaces():
decorators = ""
@ -13076,43 +13117,55 @@ class CGExampleClass(CGBindingImplClass):
def define(self):
# Just override CGClass and do our own thing
ctordtor = dedent("""
${nativeType}::${nativeType}()
{
// Add |MOZ_COUNT_CTOR(${nativeType});| for a non-refcounted object.
}
${nativeType}::~${nativeType}()
{
// Add |MOZ_COUNT_DTOR(${nativeType});| for a non-refcounted object.
}
""")
if self.parentIface:
ccImpl = dedent("""
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_INHERITED_0(${nativeType}, ${parentType})
NS_IMPL_ADDREF_INHERITED(${nativeType}, ${parentType})
NS_IMPL_RELEASE_INHERITED(${nativeType}, ${parentType})
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${nativeType})
NS_INTERFACE_MAP_END_INHERITING(${parentType})
if self.refcounted:
ctordtor = dedent("""
${nativeType}::${nativeType}()
{
}
${nativeType}::~${nativeType}()
{
}
""")
else:
ccImpl = dedent("""
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(${nativeType})
NS_IMPL_CYCLE_COLLECTING_ADDREF(${nativeType})
NS_IMPL_CYCLE_COLLECTING_RELEASE(${nativeType})
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${nativeType})
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
ctordtor = dedent("""
${nativeType}::${nativeType}()
{
MOZ_COUNT_CTOR(${nativeType});
}
${nativeType}::~${nativeType}()
{
MOZ_COUNT_DTOR(${nativeType});
}
""")
if self.refcounted:
if self.parentIface:
ccImpl = dedent("""
NS_IMPL_CYCLE_COLLECTION_INHERITED_0(${nativeType}, ${parentType})
NS_IMPL_ADDREF_INHERITED(${nativeType}, ${parentType})
NS_IMPL_RELEASE_INHERITED(${nativeType}, ${parentType})
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${nativeType})
NS_INTERFACE_MAP_END_INHERITING(${parentType})
""")
else:
ccImpl = dedent("""
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(${nativeType})
NS_IMPL_CYCLE_COLLECTING_ADDREF(${nativeType})
NS_IMPL_CYCLE_COLLECTING_RELEASE(${nativeType})
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${nativeType})
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
""")
else:
ccImpl = ""
classImpl = ccImpl + ctordtor + "\n" + dedent("""
JSObject*
${nativeType}::WrapObject(JSContext* aCx)

View File

@ -456,10 +456,16 @@ class Descriptor(DescriptorProvider):
iface.setUserData('hasProxyDescendant', True)
iface = iface.parent
self.nativeOwnership = desc.get('nativeOwnership', 'refcounted')
if not self.nativeOwnership in ('owned', 'refcounted'):
raise TypeError("Descriptor for %s has unrecognized value (%s) "
"for nativeOwnership" %
(self.interface.identifier.name, self.nativeOwnership))
if desc.get('wantsQI', None) != None:
self._wantsQI = desc.get('wantsQI', None)
self.wrapperCache = (not self.interface.isCallback() and
desc.get('wrapperCache', True))
(self.nativeOwnership != 'owned' and
desc.get('wrapperCache', True)))
def make_name(name):
return name + "_workers" if self.workers else name

View File

@ -12,12 +12,12 @@
namespace mozilla {
namespace dom {
// Natives for DOM classes that aren't refcounted need to inherit from this
// class.
// Natives for DOM classes with 'owned' as the value for nativeOwnership in
// Bindings.conf need to inherit from this class.
// If you're seeing objects of this class leak then natives for one of the DOM
// classes inheriting from it is leaking. If the native for that class has
// MOZ_COUNT_CTOR/DTOR in its constructor/destructor then it should show up in
// the leak log too.
// classes with 'owned' as the value for nativeOwnership in Bindings.conf is
// leaking. If the native for that class has MOZ_COUNT_CTOR/DTOR in its
// constructor/destructor then it should show up in the leak log too.
class NonRefcountedDOMObject
{
protected:

View File

@ -32,9 +32,7 @@ ReadStructuredCloneImageData(JSContext* aCx, JSStructuredCloneReader* aReader)
nsRefPtr<ImageData> imageData = new ImageData(width, height,
dataArray.toObject());
// Wrap it in a JS::Value.
if (!imageData->WrapObject(aCx, &result)) {
return nullptr;
}
result = imageData->WrapObject(aCx);
}
return result;
}

View File

@ -90,7 +90,7 @@ class TestNonWrapperCacheInterface : public nsISupports
public:
NS_DECL_ISUPPORTS
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
virtual JSObject* WrapObject(JSContext* cx);
};
class OnlyForUseInConstructor : public nsISupports,

View File

@ -108,10 +108,10 @@ ImageData::DropData()
}
}
bool
ImageData::WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
ImageData::WrapObject(JSContext* cx)
{
return ImageDataBinding::Wrap(aCx, this, aReflector);
return ImageDataBinding::Wrap(cx, this);
}
} // namespace dom

View File

@ -73,7 +73,7 @@ public:
return mData;
}
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* cx);
private:
void HoldData();

View File

@ -30,9 +30,9 @@ public:
return width;
}
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject* WrapObject(JSContext* aCx, bool* aTookOwnership)
{
return TextMetricsBinding::Wrap(aCx, this, aReflector);
return TextMetricsBinding::Wrap(aCx, this, aTookOwnership);
}
private:

View File

@ -11,11 +11,10 @@
namespace mozilla {
bool
WebGLActiveInfo::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
WebGLActiveInfo::WrapObject(JSContext* cx)
{
return dom::WebGLActiveInfoBinding::Wrap(aCx, this, aReflector);
return dom::WebGLActiveInfoBinding::Wrap(cx, this);
}
} // namespace mozilla

View File

@ -35,7 +35,7 @@ public:
retval = mName;
}
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* cx);
NS_INLINE_DECL_REFCOUNTING(WebGLActiveInfo)

View File

@ -10,11 +10,10 @@
namespace mozilla {
bool
WebGLShaderPrecisionFormat::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
WebGLShaderPrecisionFormat::WrapObject(JSContext* cx)
{
return dom::WebGLShaderPrecisionFormatBinding::Wrap(aCx, this, aReflector);
return dom::WebGLShaderPrecisionFormatBinding::Wrap(cx, this);
}
} // namespace mozilla

View File

@ -24,7 +24,7 @@ public:
, mPrecision(precision)
{ }
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* cx);
// WebIDL WebGLShaderPrecisionFormat API
GLint RangeMin() const {

View File

@ -12,11 +12,10 @@
namespace mozilla {
bool
WebGLUniformLocation::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
WebGLUniformLocation::WrapObject(JSContext* cx)
{
return dom::WebGLUniformLocationBinding::Wrap(aCx, this, aReflector);
return dom::WebGLUniformLocationBinding::Wrap(cx, this);
}
WebGLUniformLocation::WebGLUniformLocation(WebGLContext* context,

View File

@ -31,7 +31,7 @@ public:
uint32_t ProgramGeneration() const { return mProgramGeneration; }
int ElementSize() const { return mElementSize; }
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* cx);
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WebGLUniformLocation)

View File

@ -29,11 +29,10 @@ DataStoreCursor::Constructor(GlobalObject& aGlobal, ErrorResult& aRv)
return cursor.forget();
}
bool
DataStoreCursor::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
DataStoreCursor::WrapObject(JSContext* aCx)
{
return DataStoreCursorBinding::Wrap(aCx, this, aReflector);
return DataStoreCursorBinding::Wrap(aCx, this);
}
already_AddRefed<DataStore>
@ -73,4 +72,4 @@ DataStoreCursor::SetDataStoreCursorImpl(DataStoreCursorImpl& aCursor)
}
} //namespace dom
} //namespace mozilla
} //namespace mozilla

View File

@ -33,7 +33,7 @@ public:
static already_AddRefed<DataStoreCursor> Constructor(GlobalObject& aGlobal,
ErrorResult& aRv);
bool WrapObject(JSContext *aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext *aCx);
// WebIDL (public APIs)
@ -56,4 +56,4 @@ private:
} //namespace dom
} //namespace mozilla
#endif
#endif

View File

@ -49,9 +49,9 @@ public:
MOZ_COUNT_DTOR(TextDecoder);
}
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject* WrapObject(JSContext* aCx, bool* aTookOwnership)
{
return TextDecoderBinding::Wrap(aCx, this, aReflector);
return TextDecoderBinding::Wrap(aCx, this, aTookOwnership);
}
/**

View File

@ -42,9 +42,9 @@ public:
~TextEncoder()
{}
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject* WrapObject(JSContext* aCx, bool* aTookOwnership)
{
return TextEncoderBinding::Wrap(aCx, this, aReflector);
return TextEncoderBinding::Wrap(aCx, this, aTookOwnership);
}
protected:

View File

@ -166,10 +166,10 @@ TimeRanges::Find(double aTime, double aError /* = 0 */)
return NoIndex;
}
bool
TimeRanges::WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
TimeRanges::WrapObject(JSContext* aCx)
{
return TimeRangesBinding::Wrap(aCx, this, aReflector);
return TimeRangesBinding::Wrap(aCx, this);
}
} // namespace dom

View File

@ -50,7 +50,7 @@ public:
// Mutate this TimeRange to be the intersection of this and aOtherRanges.
void Intersection(const TimeRanges* aOtherRanges);
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* aCx);
uint32_t Length() const
{

View File

@ -247,10 +247,10 @@ IDBKeyRange::DropJSObjects()
mozilla::DropJSObjects(this);
}
bool
IDBKeyRange::WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
IDBKeyRange::WrapObject(JSContext* aCx)
{
return IDBKeyRangeBinding::Wrap(aCx, this, aReflector);
return IDBKeyRangeBinding::Wrap(aCx, this);
}
void

View File

@ -140,8 +140,8 @@ public:
DropJSObjects();
// WebIDL
bool
WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject*
WrapObject(JSContext* aCx);
nsISupports*
GetParentObject() const

View File

@ -17,29 +17,38 @@ using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
VRFieldOfView*
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::Constructor(const GlobalObject& aGlobal, const VRFieldOfViewInit& aParams,
ErrorResult& aRV)
{
return new VRFieldOfView(aParams.mUpDegrees, aParams.mRightDegrees,
aParams.mDownDegrees, aParams.mLeftDegrees);
nsRefPtr<VRFieldOfView> obj =
new VRFieldOfView(aGlobal.GetAsSupports(),
aParams.mUpDegrees, aParams.mRightDegrees,
aParams.mDownDegrees, aParams.mLeftDegrees);
return obj.forget();
}
VRFieldOfView*
already_AddRefed<VRFieldOfView>
VRFieldOfView::Constructor(const GlobalObject& aGlobal,
double aUpDegrees, double aRightDegrees,
double aDownDegrees, double aLeftDegrees,
ErrorResult& aRV)
{
return new VRFieldOfView(aUpDegrees, aRightDegrees, aDownDegrees,
aLeftDegrees);
nsRefPtr<VRFieldOfView> obj =
new VRFieldOfView(aGlobal.GetAsSupports(),
aUpDegrees, aRightDegrees,
aDownDegrees, aLeftDegrees);
return obj.forget();
}
bool
VRFieldOfView::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
VRFieldOfView::WrapObject(JSContext* aCx)
{
return VRFieldOfViewBinding::Wrap(aCx, this, aReflector);
return VRFieldOfViewBinding::Wrap(aCx, this);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VRPositionState, mParent)
@ -200,17 +209,17 @@ public:
return obj.forget();
}
virtual VRFieldOfView* GetCurrentEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
virtual already_AddRefed<VRFieldOfView> GetCurrentEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
{
return CopyFieldOfView(mHMD->GetEyeFOV(EyeToEye(aEye)));
}
virtual VRFieldOfView* GetRecommendedEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
virtual already_AddRefed<VRFieldOfView> GetRecommendedEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
{
return CopyFieldOfView(mHMD->GetRecommendedEyeFOV(EyeToEye(aEye)));
}
virtual VRFieldOfView* GetMaximumEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
virtual already_AddRefed<VRFieldOfView> GetMaximumEyeFieldOfView(VREye aEye) MOZ_OVERRIDE
{
return CopyFieldOfView(mHMD->GetMaximumEyeFOV(EyeToEye(aEye)));
}
@ -226,11 +235,13 @@ public:
}
protected:
VRFieldOfView*
already_AddRefed<VRFieldOfView>
CopyFieldOfView(const gfx::VRFieldOfView& aSrc)
{
return new VRFieldOfView(aSrc.upDegrees, aSrc.rightDegrees,
aSrc.downDegrees, aSrc.leftDegrees);
nsRefPtr<VRFieldOfView> obj =
new VRFieldOfView(mParent, aSrc.upDegrees, aSrc.rightDegrees,
aSrc.downDegrees, aSrc.leftDegrees);
return obj.forget();
}
};

View File

@ -26,12 +26,14 @@ namespace dom {
class Element;
class VRFieldOfViewReadOnly : public NonRefcountedDOMObject
class VRFieldOfViewReadOnly : public nsWrapperCache
{
public:
VRFieldOfViewReadOnly(double aUpDegrees, double aRightDegrees,
VRFieldOfViewReadOnly(nsISupports* aParent,
double aUpDegrees, double aRightDegrees,
double aDownDegrees, double aLeftDegrees)
: mUpDegrees(aUpDegrees)
: mParent(aParent)
, mUpDegrees(aUpDegrees)
, mRightDegrees(aRightDegrees)
, mDownDegrees(aDownDegrees)
, mLeftDegrees(aLeftDegrees)
@ -44,6 +46,7 @@ public:
double LeftDegrees() const { return mLeftDegrees; }
protected:
nsCOMPtr<nsISupports> mParent;
double mUpDegrees;
double mRightDegrees;
double mDownDegrees;
@ -52,23 +55,29 @@ protected:
class VRFieldOfView MOZ_FINAL : public VRFieldOfViewReadOnly
{
~VRFieldOfView() {}
public:
explicit VRFieldOfView(double aUpDegrees = 0.0, double aRightDegrees = 0.0,
explicit VRFieldOfView(nsISupports* aParent,
double aUpDegrees = 0.0, double aRightDegrees = 0.0,
double aDownDegrees = 0.0, double aLeftDegrees = 0.0)
: VRFieldOfViewReadOnly(aUpDegrees, aRightDegrees, aDownDegrees, aLeftDegrees)
: VRFieldOfViewReadOnly(aParent, aUpDegrees, aRightDegrees, aDownDegrees, aLeftDegrees)
{}
static VRFieldOfView*
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VRFieldOfView)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VRFieldOfView)
static already_AddRefed<VRFieldOfView>
Constructor(const GlobalObject& aGlobal, const VRFieldOfViewInit& aParams,
ErrorResult& aRv);
static VRFieldOfView*
static already_AddRefed<VRFieldOfView>
Constructor(const GlobalObject& aGlobal,
double aUpDegrees, double aRightDegrees,
double aDownDegrees, double aLeftDegrees,
ErrorResult& aRv);
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
nsISupports* GetParentObject() const { return mParent; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
void SetUpDegrees(double aVal) { mUpDegrees = aVal; }
void SetRightDegrees(double aVal) { mRightDegrees = aVal; }
@ -181,9 +190,9 @@ public:
virtual void SetFieldOfView(const VRFieldOfViewInit& aLeftFOV,
const VRFieldOfViewInit& aRightFOV,
double zNear, double zFar) = 0;
virtual VRFieldOfView* GetCurrentEyeFieldOfView(VREye aEye) = 0;
virtual VRFieldOfView* GetRecommendedEyeFieldOfView(VREye aEye) = 0;
virtual VRFieldOfView* GetMaximumEyeFieldOfView(VREye aEye) = 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 already_AddRefed<DOMRect> GetRecommendedEyeRenderRect(VREye aEye) = 0;
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;

View File

@ -81,15 +81,12 @@ interface HMDVRDevice : VRDevice {
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,
@ -122,7 +119,6 @@ interface PositionSensorVRDevice : VRDevice {
* 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

View File

@ -40,11 +40,10 @@ WorkerDataStoreCursor::Constructor(GlobalObject& aGlobal, ErrorResult& aRv)
return nullptr;
}
bool
WorkerDataStoreCursor::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
WorkerDataStoreCursor::WrapObject(JSContext* aCx)
{
return DataStoreCursorBinding_workers::Wrap(aCx, this, aReflector);
return DataStoreCursorBinding_workers::Wrap(aCx, this);
}
// A WorkerMainThreadRunnable which holds a reference to DataStoreCursor.

View File

@ -35,7 +35,7 @@ public:
static already_AddRefed<WorkerDataStoreCursor> Constructor(GlobalObject& aGlobal,
ErrorResult& aRv);
bool WrapObject(JSContext *aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext *aCx);
// WebIDL (public APIs)

View File

@ -41,11 +41,10 @@ FileReaderSync::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
return frs.forget();
}
bool
FileReaderSync::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
FileReaderSync::WrapObject(JSContext* aCx)
{
return FileReaderSyncBinding_workers::Wrap(aCx, this, aReflector);
return FileReaderSyncBinding_workers::Wrap(aCx, this);
}
void

View File

@ -41,7 +41,7 @@ public:
static already_AddRefed<FileReaderSync>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* aCx);
void ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aScopeObj,
File& aBlob, JS::MutableHandle<JSObject*> aRetval,

View File

@ -572,10 +572,10 @@ URL::~URL()
}
}
bool
URL::WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject*
URL::WrapObject(JSContext* aCx)
{
return URLBinding_workers::Wrap(aCx, this, aReflector);
return URLBinding_workers::Wrap(aCx, this);
}
void

View File

@ -45,8 +45,8 @@ public:
return nullptr;
}
bool
WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject*
WrapObject(JSContext* aCx);
// Methods for WebIDL

View File

@ -6253,10 +6253,8 @@ WorkerPrivate::CreateGlobalScope(JSContext* aCx)
globalScope = new DedicatedWorkerGlobalScope(this);
}
JS::Rooted<JSObject*> global(aCx);
if (!globalScope->WrapGlobalObject(aCx, &global)) {
return nullptr;
}
JS::Rooted<JSObject*> global(aCx, globalScope->WrapGlobalObject(aCx));
NS_ENSURE_TRUE(global, nullptr);
JSAutoCompartment ac(aCx, global);

View File

@ -362,9 +362,8 @@ DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPri
{
}
bool
DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mWorkerPrivate->IsSharedWorker());
@ -375,7 +374,7 @@ DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
return DedicatedWorkerGlobalScopeBinding_workers::Wrap(aCx, this, this,
options,
GetWorkerPrincipal(),
true, aReflector);
true);
}
void
@ -394,9 +393,8 @@ SharedWorkerGlobalScope::SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
{
}
bool
SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mWorkerPrivate->IsSharedWorker());
@ -406,7 +404,7 @@ SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
return SharedWorkerGlobalScopeBinding_workers::Wrap(aCx, this, this, options,
GetWorkerPrincipal(),
true, aReflector);
true);
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope,
@ -428,9 +426,8 @@ ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope()
{
}
bool
ServiceWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
ServiceWorkerGlobalScope::WrapGlobalObject(JSContext* aCx)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mWorkerPrivate->IsServiceWorker());
@ -440,7 +437,7 @@ ServiceWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
return ServiceWorkerGlobalScopeBinding_workers::Wrap(aCx, this, this, options,
GetWorkerPrincipal(),
true, aReflector);
true);
}
ServiceWorkerClients*

View File

@ -57,8 +57,8 @@ public:
virtual JSObject*
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
virtual bool
WrapGlobalObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) = 0;
virtual JSObject*
WrapGlobalObject(JSContext* aCx) = 0;
virtual JSObject*
GetGlobalJSObject(void) MOZ_OVERRIDE
@ -148,9 +148,8 @@ class DedicatedWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope
public:
explicit DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate);
virtual bool
WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) MOZ_OVERRIDE;
virtual JSObject*
WrapGlobalObject(JSContext* aCx) MOZ_OVERRIDE;
void
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
@ -170,9 +169,8 @@ public:
SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
const nsCString& aName);
virtual bool
WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) MOZ_OVERRIDE;
virtual JSObject*
WrapGlobalObject(JSContext* aCx) MOZ_OVERRIDE;
void GetName(DOMString& aName) const
{
@ -196,9 +194,8 @@ public:
ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope);
virtual bool
WrapGlobalObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector) MOZ_OVERRIDE;
virtual JSObject*
WrapGlobalObject(JSContext* aCx) MOZ_OVERRIDE;
void
GetScope(DOMString& aScope) const

View File

@ -158,11 +158,10 @@ XPathEvaluator::CreateExpression(const nsAString & aExpression,
return new XPathExpression(Move(expression), mRecycler, aDocument);
}
bool
XPathEvaluator::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
XPathEvaluator::WrapObject(JSContext* aCx)
{
return dom::XPathEvaluatorBinding::Wrap(aCx, this, aReflector);
return dom::XPathEvaluatorBinding::Wrap(aCx, this);
}
/* static */

View File

@ -42,7 +42,7 @@ public:
NS_DECL_NSIDOMXPATHEVALUATOR
// WebIDL API
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
JSObject* WrapObject(JSContext* aCx);
nsIDocument* GetParentObject()
{
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);

View File

@ -34,9 +34,9 @@ public:
nsIDocument *aDocument);
~XPathExpression();
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector)
JSObject* WrapObject(JSContext* aCx, bool* aTookOwnership)
{
return XPathExpressionBinding::Wrap(aCx, this, aReflector);
return XPathExpressionBinding::Wrap(aCx, this, aTookOwnership);
}
already_AddRefed<XPathResult>

View File

@ -81,7 +81,7 @@ ObjectToIdMap::ObjectToIdMap()
ObjectToIdMap::~ObjectToIdMap()
{
if (table_) {
dom::AddForDeferredFinalization<Table>(table_);
dom::AddForDeferredFinalization<Table, nsAutoPtr>(table_);
table_ = nullptr;
}
}

View File

@ -289,11 +289,10 @@ RTCStatsQuery::~RTCStatsQuery() {
NS_IMPL_ISUPPORTS0(PeerConnectionImpl)
#ifdef MOZILLA_INTERNAL_API
bool
PeerConnectionImpl::WrapObject(JSContext* aCx,
JS::MutableHandle<JSObject*> aReflector)
JSObject*
PeerConnectionImpl::WrapObject(JSContext* aCx)
{
return PeerConnectionImplBinding::Wrap(aCx, this, aReflector);
return PeerConnectionImplBinding::Wrap(aCx, this);
}
#endif

View File

@ -251,7 +251,7 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
#ifdef MOZILLA_INTERNAL_API
bool WrapObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector);
virtual JSObject* WrapObject(JSContext* cx);
#endif
static already_AddRefed<PeerConnectionImpl>