зеркало из https://github.com/mozilla/gecko-dev.git
bug 723517 - drop cx argument from JSObject field and fixed slots infallible API. r=:Waldo
--HG-- extra : rebase_source : c461dfc0e0e0462ab262cc01c2a771d3bb0971cc
This commit is contained in:
Родитель
d6ed2294cf
Коммит
ca990d2064
|
@ -337,7 +337,7 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext)
|
||||||
JSObject *obj = global;
|
JSObject *obj = global;
|
||||||
JSObject *proto;
|
JSObject *proto;
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
while ((proto = JS_GetPrototype(cx, obj)) != nsnull)
|
while ((proto = JS_GetPrototype(obj)) != nsnull)
|
||||||
obj = proto;
|
obj = proto;
|
||||||
JSClass *objectClass = JS_GetClass(obj);
|
JSClass *objectClass = JS_GetClass(obj);
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ static void
|
||||||
XBLFinalize(JSContext *cx, JSObject *obj)
|
XBLFinalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
nsXBLDocumentInfo* docInfo =
|
nsXBLDocumentInfo* docInfo =
|
||||||
static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(cx, obj));
|
static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(obj));
|
||||||
NS_RELEASE(docInfo);
|
NS_RELEASE(docInfo);
|
||||||
|
|
||||||
nsXBLJSClass* c = static_cast<nsXBLJSClass*>(::JS_GetClass(obj));
|
nsXBLJSClass* c = static_cast<nsXBLJSClass*>(::JS_GetClass(obj));
|
||||||
|
@ -135,8 +135,7 @@ XBLResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||||
|
|
||||||
nsDependentJSString fieldName(id);
|
nsDependentJSString fieldName(id);
|
||||||
|
|
||||||
jsval slotVal;
|
jsval slotVal = ::JS_GetReservedSlot(obj, 0);
|
||||||
::JS_GetReservedSlot(cx, obj, 0, &slotVal);
|
|
||||||
NS_ASSERTION(!JSVAL_IS_VOID(slotVal), "How did that happen?");
|
NS_ASSERTION(!JSVAL_IS_VOID(slotVal), "How did that happen?");
|
||||||
|
|
||||||
nsXBLPrototypeBinding* protoBinding =
|
nsXBLPrototypeBinding* protoBinding =
|
||||||
|
@ -161,7 +160,7 @@ XBLResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectWrappedNative> xpcWrapper =
|
nsCOMPtr<nsIXPConnectWrappedNative> xpcWrapper =
|
||||||
do_QueryInterface(static_cast<nsISupports*>(::JS_GetPrivate(cx, origObj)));
|
do_QueryInterface(static_cast<nsISupports*>(::JS_GetPrivate(origObj)));
|
||||||
if (!xpcWrapper) {
|
if (!xpcWrapper) {
|
||||||
// Looks like whatever |origObj| is it's not our nsIContent. It might well
|
// Looks like whatever |origObj| is it's not our nsIContent. It might well
|
||||||
// be the proto our binding installed, however, where the private is the
|
// be the proto our binding installed, however, where the private is the
|
||||||
|
@ -1088,7 +1087,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; true; base = proto) { // Will break out on null proto
|
for ( ; true; base = proto) { // Will break out on null proto
|
||||||
proto = ::JS_GetPrototype(cx, base);
|
proto = ::JS_GetPrototype(base);
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1105,17 +1104,13 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<nsXBLDocumentInfo> docInfo =
|
nsRefPtr<nsXBLDocumentInfo> docInfo =
|
||||||
static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(cx, proto));
|
static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(proto));
|
||||||
if (!docInfo) {
|
if (!docInfo) {
|
||||||
// Not the proto we seek
|
// Not the proto we seek
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval protoBinding;
|
jsval protoBinding = ::JS_GetReservedSlot(proto, 0);
|
||||||
if (!::JS_GetReservedSlot(cx, proto, 0, &protoBinding)) {
|
|
||||||
NS_ERROR("Really shouldn't happen");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JSVAL_TO_PRIVATE(protoBinding) != mPrototypeBinding) {
|
if (JSVAL_TO_PRIVATE(protoBinding) != mPrototypeBinding) {
|
||||||
// Not the right binding
|
// Not the right binding
|
||||||
|
@ -1124,7 +1119,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||||
|
|
||||||
// Alright! This is the right prototype. Pull it out of the
|
// Alright! This is the right prototype. Pull it out of the
|
||||||
// proto chain.
|
// proto chain.
|
||||||
JSObject* grandProto = ::JS_GetPrototype(cx, proto);
|
JSObject* grandProto = ::JS_GetPrototype(proto);
|
||||||
::JS_SetPrototype(cx, base, grandProto);
|
::JS_SetPrototype(cx, base, grandProto);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1219,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
// Retrieve the current prototype of obj.
|
// Retrieve the current prototype of obj.
|
||||||
parent_proto = ::JS_GetPrototype(cx, obj);
|
parent_proto = ::JS_GetPrototype(obj);
|
||||||
if (parent_proto) {
|
if (parent_proto) {
|
||||||
// We need to create a unique classname based on aClassName and
|
// We need to create a unique classname based on aClassName and
|
||||||
// parent_proto. Append a space (an invalid URI character) to ensure that
|
// parent_proto. Append a space (an invalid URI character) to ensure that
|
||||||
|
@ -1327,16 +1322,10 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
// collection doesn't seem to work right if the private is not an
|
// collection doesn't seem to work right if the private is not an
|
||||||
// nsISupports.
|
// nsISupports.
|
||||||
nsXBLDocumentInfo* docInfo = aProtoBinding->XBLDocumentInfo();
|
nsXBLDocumentInfo* docInfo = aProtoBinding->XBLDocumentInfo();
|
||||||
::JS_SetPrivate(cx, proto, docInfo);
|
::JS_SetPrivate(proto, docInfo);
|
||||||
NS_ADDREF(docInfo);
|
NS_ADDREF(docInfo);
|
||||||
|
|
||||||
if (!::JS_SetReservedSlot(cx, proto, 0, PRIVATE_TO_JSVAL(aProtoBinding))) {
|
::JS_SetReservedSlot(proto, 0, PRIVATE_TO_JSVAL(aProtoBinding));
|
||||||
(nsXBLService::gClassTable)->Remove(&key);
|
|
||||||
|
|
||||||
// |c| will get dropped when |proto| is finalized
|
|
||||||
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
*aClassObject = proto;
|
*aClassObject = proto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JSObject *obj, jsid id, PRUin
|
||||||
// Make sure to actually operate on our object, and not some object further
|
// Make sure to actually operate on our object, and not some object further
|
||||||
// down on the proto chain.
|
// down on the proto chain.
|
||||||
while (JS_GetClass(obj) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
|
while (JS_GetClass(obj) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
|
||||||
obj = ::JS_GetPrototype(cx, obj);
|
obj = ::JS_GetPrototype(obj);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
::JS_ReportError(cx, "Invalid access to a global object property.");
|
::JS_ReportError(cx, "Invalid access to a global object property.");
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -168,7 +168,7 @@ nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSObject *obj, jsid id,
|
||||||
static void
|
static void
|
||||||
nsXBLDocGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
nsXBLDocGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj);
|
nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(obj);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
|
||||||
|
|
||||||
// Add an owning reference from JS back to us. This'll be
|
// Add an owning reference from JS back to us. This'll be
|
||||||
// released when the JSObject is finalized.
|
// released when the JSObject is finalized.
|
||||||
::JS_SetPrivate(cx, mJSObject, this);
|
::JS_SetPrivate(mJSObject, this);
|
||||||
NS_ADDREF(this);
|
NS_ADDREF(this);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ PRUint32 nsXULPrototypeDocument::gRefCnt;
|
||||||
void
|
void
|
||||||
nsXULPDGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
nsXULPDGlobalObject_finalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj);
|
nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(obj);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
|
||||||
|
|
||||||
|
@ -747,7 +747,7 @@ nsXULPDGlobalObject::EnsureScriptEnvironment(PRUint32 lang_id)
|
||||||
|
|
||||||
// Add an owning reference from JS back to us. This'll be
|
// Add an owning reference from JS back to us. This'll be
|
||||||
// released when the JSObject is finalized.
|
// released when the JSObject is finalized.
|
||||||
::JS_SetPrivate(cx, newGlob, this);
|
::JS_SetPrivate(newGlob, this);
|
||||||
NS_ADDREF(this);
|
NS_ADDREF(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4896,8 +4896,8 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
|
||||||
"Incorrect object class!");
|
"Incorrect object class!");
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(::JS_GetPrototype(cx, proto) &&
|
NS_ASSERTION(::JS_GetPrototype(proto) &&
|
||||||
JS_GetClass(::JS_GetPrototype(cx, proto)) == sObjectClass,
|
JS_GetClass(::JS_GetPrototype(proto)) == sObjectClass,
|
||||||
"Hmm, somebody did something evil?");
|
"Hmm, somebody did something evil?");
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -5204,10 +5204,10 @@ nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsHTMLDocument*
|
static nsHTMLDocument*
|
||||||
GetDocument(JSContext *cx, JSObject *obj)
|
GetDocument(JSObject *obj)
|
||||||
{
|
{
|
||||||
return static_cast<nsHTMLDocument*>(
|
return static_cast<nsHTMLDocument*>(
|
||||||
static_cast<nsIHTMLDocument*>(::JS_GetPrivate(cx, obj)));
|
static_cast<nsIHTMLDocument*>(::JS_GetPrivate(obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -5226,7 +5226,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsHTMLDocument *document = GetDocument(cx, obj);
|
nsHTMLDocument *document = GetDocument(obj);
|
||||||
|
|
||||||
if (!document ||
|
if (!document ||
|
||||||
document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
|
document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
|
||||||
|
@ -5236,7 +5236,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, obj);
|
JSObject *proto = ::JS_GetPrototype(obj);
|
||||||
JSBool hasProp;
|
JSBool hasProp;
|
||||||
|
|
||||||
if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
|
if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
|
||||||
|
@ -5286,17 +5286,17 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj)
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
while ((proto = ::JS_GetPrototype(cx, obj))) {
|
while ((proto = ::JS_GetPrototype(obj))) {
|
||||||
if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
|
if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
|
||||||
nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, proto);
|
nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(proto);
|
||||||
|
|
||||||
NS_IF_RELEASE(doc);
|
NS_IF_RELEASE(doc);
|
||||||
|
|
||||||
::JS_SetPrivate(cx, proto, nsnull);
|
::JS_SetPrivate(proto, nsnull);
|
||||||
|
|
||||||
// Pull the global scope polluter out of the prototype chain so
|
// Pull the global scope polluter out of the prototype chain so
|
||||||
// that it can be freed.
|
// that it can be freed.
|
||||||
::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(cx, proto));
|
::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(proto));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5328,7 +5328,7 @@ nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
|
||||||
// Find the place in the prototype chain where we want this global
|
// Find the place in the prototype chain where we want this global
|
||||||
// scope polluter (right before Object.prototype).
|
// scope polluter (right before Object.prototype).
|
||||||
|
|
||||||
while ((proto = ::JS_GetPrototype(cx, o))) {
|
while ((proto = ::JS_GetPrototype(o))) {
|
||||||
if (JS_GetClass(proto) == sObjectClass) {
|
if (JS_GetClass(proto) == sObjectClass) {
|
||||||
// Set the global scope polluters prototype to Object.prototype
|
// Set the global scope polluters prototype to Object.prototype
|
||||||
::JS_SplicePrototype(cx, gsp, proto);
|
::JS_SplicePrototype(cx, gsp, proto);
|
||||||
|
@ -5343,9 +5343,7 @@ nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
|
||||||
// Object.prototype to be the global scope polluter.
|
// Object.prototype to be the global scope polluter.
|
||||||
::JS_SplicePrototype(cx, o, gsp);
|
::JS_SplicePrototype(cx, o, gsp);
|
||||||
|
|
||||||
if (!::JS_SetPrivate(cx, gsp, doc)) {
|
::JS_SetPrivate(gsp, doc);
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The global scope polluter will release doc on destruction (or
|
// The global scope polluter will release doc on destruction (or
|
||||||
// invalidation).
|
// invalidation).
|
||||||
|
@ -5928,8 +5926,8 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(val));
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(val));
|
||||||
JSObject *dot_prototype = JSVAL_TO_OBJECT(val);
|
JSObject *dot_prototype = JSVAL_TO_OBJECT(val);
|
||||||
|
|
||||||
JSObject *proto = JS_GetPrototype(cx, dom_obj);
|
JSObject *proto = JS_GetPrototype(dom_obj);
|
||||||
for ( ; proto; proto = JS_GetPrototype(cx, proto)) {
|
for ( ; proto; proto = JS_GetPrototype(proto)) {
|
||||||
if (proto == dot_prototype) {
|
if (proto == dot_prototype) {
|
||||||
*bp = true;
|
*bp = true;
|
||||||
break;
|
break;
|
||||||
|
@ -6300,7 +6298,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *xpc_proto_proto = ::JS_GetPrototype(cx, dot_prototype);
|
JSObject *xpc_proto_proto = ::JS_GetPrototype(dot_prototype);
|
||||||
|
|
||||||
if (proto &&
|
if (proto &&
|
||||||
(!xpc_proto_proto ||
|
(!xpc_proto_proto ||
|
||||||
|
@ -8150,7 +8148,7 @@ nsNamedArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, realObj);
|
JSObject *proto = ::JS_GetPrototype(realObj);
|
||||||
|
|
||||||
if (proto) {
|
if (proto) {
|
||||||
JSBool hasProp;
|
JSBool hasProp;
|
||||||
|
@ -8727,12 +8725,9 @@ nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
|
||||||
// node list part (i.e. access to elements by index) not walk the
|
// node list part (i.e. access to elements by index) not walk the
|
||||||
// document each time, we create a nsContentList and hold on to it
|
// document each time, we create a nsContentList and hold on to it
|
||||||
// in a reserved slot (0) on the document.all JSObject.
|
// in a reserved slot (0) on the document.all JSObject.
|
||||||
jsval collection;
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
if (!JS_GetReservedSlot(cx, obj, 0, &collection)) {
|
jsval collection = JS_GetReservedSlot(obj, 0);
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(collection)) {
|
if (!JSVAL_IS_PRIMITIVE(collection)) {
|
||||||
// We already have a node list in our reserved slot, use it.
|
// We already have a node list in our reserved slot, use it.
|
||||||
|
@ -8768,9 +8763,7 @@ nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
|
||||||
list.forget(nodeList);
|
list.forget(nodeList);
|
||||||
|
|
||||||
// ... and store it in our reserved slot.
|
// ... and store it in our reserved slot.
|
||||||
if (!JS_SetReservedSlot(cx, obj, 0, collection)) {
|
JS_SetReservedSlot(obj, 0, collection);
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -8804,7 +8797,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsHTMLDocument *doc = GetDocument(cx, obj);
|
nsHTMLDocument *doc = GetDocument(obj);
|
||||||
nsISupports *result;
|
nsISupports *result;
|
||||||
nsWrapperCache *cache;
|
nsWrapperCache *cache;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
@ -8909,7 +8902,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||||
|
|
||||||
v = JSVAL_ONE;
|
v = JSVAL_ONE;
|
||||||
} else if (id == sTags_id) {
|
} else if (id == sTags_id) {
|
||||||
nsHTMLDocument *doc = GetDocument(cx, obj);
|
nsHTMLDocument *doc = GetDocument(obj);
|
||||||
|
|
||||||
JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
|
JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
|
||||||
::JS_GetGlobalForObject(cx, obj));
|
::JS_GetGlobalForObject(cx, obj));
|
||||||
|
@ -8917,9 +8910,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!::JS_SetPrivate(cx, tags, doc)) {
|
::JS_SetPrivate(tags, doc);
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The "tags" JSObject now also owns doc.
|
// The "tags" JSObject now also owns doc.
|
||||||
NS_ADDREF(doc);
|
NS_ADDREF(doc);
|
||||||
|
@ -8947,7 +8938,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||||
void
|
void
|
||||||
nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
|
nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, obj);
|
nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(obj);
|
||||||
|
|
||||||
NS_IF_RELEASE(doc);
|
NS_IF_RELEASE(doc);
|
||||||
}
|
}
|
||||||
|
@ -8995,10 +8986,10 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, uintN argc, jsval *vp)
|
||||||
|
|
||||||
|
|
||||||
static inline JSObject *
|
static inline JSObject *
|
||||||
GetDocumentAllHelper(JSContext *cx, JSObject *obj)
|
GetDocumentAllHelper(JSObject *obj)
|
||||||
{
|
{
|
||||||
while (obj && JS_GetClass(obj) != &sHTMLDocumentAllHelperClass) {
|
while (obj && JS_GetClass(obj) != &sHTMLDocumentAllHelperClass) {
|
||||||
obj = ::JS_GetPrototype(cx, obj);
|
obj = ::JS_GetPrototype(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -9026,7 +9017,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *helper = GetDocumentAllHelper(cx, obj);
|
JSObject *helper = GetDocumentAllHelper(obj);
|
||||||
|
|
||||||
if (!helper) {
|
if (!helper) {
|
||||||
NS_ERROR("Uh, how'd we get here?");
|
NS_ERROR("Uh, how'd we get here?");
|
||||||
|
@ -9036,7 +9027,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32 flags = PrivateToFlags(::JS_GetPrivate(cx, helper));
|
PRUint32 flags = PrivateToFlags(::JS_GetPrivate(helper));
|
||||||
|
|
||||||
if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
|
if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
|
||||||
// document.all is either being detected, e.g. if (document.all),
|
// document.all is either being detected, e.g. if (document.all),
|
||||||
|
@ -9066,9 +9057,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the JSObject take over ownership of doc.
|
// Let the JSObject take over ownership of doc.
|
||||||
if (!::JS_SetPrivate(cx, all, doc)) {
|
::JS_SetPrivate(all, doc);
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
doc.forget();
|
doc.forget();
|
||||||
|
|
||||||
|
@ -9086,7 +9075,7 @@ nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
|
||||||
{
|
{
|
||||||
if (id == nsDOMClassInfo::sAll_id) {
|
if (id == nsDOMClassInfo::sAll_id) {
|
||||||
// document.all is resolved for the first time. Define it.
|
// document.all is resolved for the first time. Define it.
|
||||||
JSObject *helper = GetDocumentAllHelper(cx, obj);
|
JSObject *helper = GetDocumentAllHelper(obj);
|
||||||
|
|
||||||
if (helper) {
|
if (helper) {
|
||||||
if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
|
if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
|
||||||
|
@ -9108,9 +9097,9 @@ nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
|
||||||
JSObject **objp)
|
JSObject **objp)
|
||||||
{
|
{
|
||||||
if (JSID_IS_STRING(id)) {
|
if (JSID_IS_STRING(id)) {
|
||||||
nsDocument *doc = GetDocument(cx, obj);
|
nsDocument *doc = GetDocument(obj);
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, obj);
|
JSObject *proto = ::JS_GetPrototype(obj);
|
||||||
if (NS_UNLIKELY(!proto)) {
|
if (NS_UNLIKELY(!proto)) {
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -9188,10 +9177,9 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
|
nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
|
||||||
|
|
||||||
if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
|
if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
|
||||||
JSObject *helper =
|
JSObject *helper = GetDocumentAllHelper(::JS_GetPrototype(obj));
|
||||||
GetDocumentAllHelper(cx, ::JS_GetPrototype(cx, obj));
|
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, helper ? helper : obj);
|
JSObject *proto = ::JS_GetPrototype(helper ? helper : obj);
|
||||||
|
|
||||||
// Check if the property all is defined on obj's (or helper's
|
// Check if the property all is defined on obj's (or helper's
|
||||||
// if obj doesn't exist) prototype, if it is, don't expose our
|
// if obj doesn't exist) prototype, if it is, don't expose our
|
||||||
|
@ -9208,7 +9196,7 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
// shadowing of the now defined "all" property.
|
// shadowing of the now defined "all" property.
|
||||||
JSObject *tmp = obj, *tmpProto;
|
JSObject *tmp = obj, *tmpProto;
|
||||||
|
|
||||||
while ((tmpProto = ::JS_GetPrototype(cx, tmp)) != helper) {
|
while ((tmpProto = ::JS_GetPrototype(tmp)) != helper) {
|
||||||
tmp = tmpProto;
|
tmp = tmpProto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9225,7 +9213,7 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
PrintWarningOnConsole(cx, "DocumentAllUsed");
|
PrintWarningOnConsole(cx, "DocumentAllUsed");
|
||||||
|
|
||||||
helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
|
helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
|
||||||
::JS_GetPrototype(cx, obj),
|
::JS_GetPrototype(obj),
|
||||||
::JS_GetGlobalForObject(cx, obj));
|
::JS_GetGlobalForObject(cx, obj));
|
||||||
|
|
||||||
if (!helper) {
|
if (!helper) {
|
||||||
|
@ -9243,10 +9231,8 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
|
|
||||||
// If we have (or just created) a helper, pass the resolve flags
|
// If we have (or just created) a helper, pass the resolve flags
|
||||||
// to the helper as its private data.
|
// to the helper as its private data.
|
||||||
if (helper && !::JS_SetPrivate(cx, helper, FlagsToPrivate(flags))) {
|
if (helper) {
|
||||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
|
::JS_SetPrivate(helper, FlagsToPrivate(flags));
|
||||||
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9791,7 +9777,7 @@ nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||||
{
|
{
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
|
JSObject *pi_obj = ::JS_GetPrototype(obj);
|
||||||
if (NS_UNLIKELY(!pi_obj)) {
|
if (NS_UNLIKELY(!pi_obj)) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -9820,7 +9806,7 @@ nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||||
{
|
{
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
|
JSObject *pi_obj = ::JS_GetPrototype(obj);
|
||||||
if (NS_UNLIKELY(!pi_obj)) {
|
if (NS_UNLIKELY(!pi_obj)) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -9899,7 +9885,7 @@ nsHTMLPluginObjElementSH::GetPluginJSObject(JSContext *cx, JSObject *obj,
|
||||||
if (plugin_inst) {
|
if (plugin_inst) {
|
||||||
plugin_inst->GetJSObject(cx, plugin_obj);
|
plugin_inst->GetJSObject(cx, plugin_obj);
|
||||||
if (*plugin_obj) {
|
if (*plugin_obj) {
|
||||||
*plugin_proto = ::JS_GetPrototype(cx, *plugin_obj);
|
*plugin_proto = ::JS_GetPrototype(*plugin_obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10298,7 +10284,7 @@ nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
|
|
||||||
// First check to see if the property is defined on our prototype.
|
// First check to see if the property is defined on our prototype.
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, realObj);
|
JSObject *proto = ::JS_GetPrototype(realObj);
|
||||||
JSBool hasProp;
|
JSBool hasProp;
|
||||||
|
|
||||||
if (proto &&
|
if (proto &&
|
||||||
|
@ -10484,7 +10470,7 @@ nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *proto = ::JS_GetPrototype(cx, realObj);
|
JSObject *proto = ::JS_GetPrototype(realObj);
|
||||||
JSBool hasProp;
|
JSBool hasProp;
|
||||||
|
|
||||||
if (proto &&
|
if (proto &&
|
||||||
|
|
|
@ -1606,7 +1606,7 @@ nsDOMWindowUtils::GetParent(const JS::Value& aObject,
|
||||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject* parent = JS_GetParent(aCx, JSVAL_TO_OBJECT(aObject));
|
JSObject* parent = JS_GetParent(JSVAL_TO_OBJECT(aObject));
|
||||||
*aParent = OBJECT_TO_JSVAL(parent);
|
*aParent = OBJECT_TO_JSVAL(parent);
|
||||||
|
|
||||||
// Outerize if necessary.
|
// Outerize if necessary.
|
||||||
|
|
|
@ -1870,7 +1870,7 @@ ReparentWaiverWrappers(JSDHashTable *table, JSDHashEntryHdr *hdr,
|
||||||
|
|
||||||
// We reparent wrappers that have as their parent an inner window whose
|
// We reparent wrappers that have as their parent an inner window whose
|
||||||
// outer has the new inner window as its current inner.
|
// outer has the new inner window as its current inner.
|
||||||
JSObject *parent = JS_GetParent(closure->mCx, value);
|
JSObject *parent = JS_GetParent(value);
|
||||||
JSObject *outer = JS_ObjectToOuterObject(closure->mCx, parent);
|
JSObject *outer = JS_ObjectToOuterObject(closure->mCx, parent);
|
||||||
if (outer) {
|
if (outer) {
|
||||||
JSObject *inner = JS_ObjectToInnerObject(closure->mCx, outer);
|
JSObject *inner = JS_ObjectToInnerObject(closure->mCx, outer);
|
||||||
|
@ -9975,7 +9975,7 @@ nsGlobalWindow::SaveWindowState(nsISupports **aState)
|
||||||
getter_AddRefs(proto));
|
getter_AddRefs(proto));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
JSObject *realProto = JS_GetPrototype(cx, mJSObject);
|
JSObject *realProto = JS_GetPrototype(mJSObject);
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> realProtoHolder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> realProtoHolder;
|
||||||
if (realProto) {
|
if (realProto) {
|
||||||
rv = xpc->HoldObject(cx, realProto, getter_AddRefs(realProtoHolder));
|
rv = xpc->HoldObject(cx, realProto, getter_AddRefs(realProtoHolder));
|
||||||
|
|
|
@ -1901,7 +1901,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
|
||||||
JSObject *obj = aHandler;
|
JSObject *obj = aHandler;
|
||||||
if (js::IsFunctionProxy(obj))
|
if (js::IsFunctionProxy(obj))
|
||||||
obj = js::UnwrapObject(obj);
|
obj = js::UnwrapObject(obj);
|
||||||
JSString *id = JS_GetFunctionId(static_cast<JSFunction *>(JS_GetPrivate(mContext, obj)));
|
JSString *id = JS_GetFunctionId(static_cast<JSFunction *>(JS_GetPrivate(obj)));
|
||||||
JSAutoByteString bytes;
|
JSAutoByteString bytes;
|
||||||
const char *name = !id ? "anonymous" : bytes.encode(mContext, id) ? bytes.ptr() : "<error>";
|
const char *name = !id ? "anonymous" : bytes.encode(mContext, id) ? bytes.ptr() : "<error>";
|
||||||
NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s)", MOZ_FUNCTION_NAME, __LINE__, name);
|
NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s)", MOZ_FUNCTION_NAME, __LINE__, name);
|
||||||
|
@ -2272,8 +2272,8 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, JSObject *aOuterGl
|
||||||
// the global object's compartment as its default compartment,
|
// the global object's compartment as its default compartment,
|
||||||
// so update that now since it might have changed.
|
// so update that now since it might have changed.
|
||||||
JS_SetGlobalObject(mContext, aOuterGlobal);
|
JS_SetGlobalObject(mContext, aOuterGlobal);
|
||||||
NS_ASSERTION(JS_GetPrototype(mContext, aOuterGlobal) ==
|
NS_ASSERTION(JS_GetPrototype(aOuterGlobal) ==
|
||||||
JS_GetPrototype(mContext, newInnerJSObject),
|
JS_GetPrototype(newInnerJSObject),
|
||||||
"outer and inner globals should have the same prototype");
|
"outer and inner globals should have the same prototype");
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2334,7 +2334,7 @@ nsJSContext::SetOuterObject(JSObject* aOuterObject)
|
||||||
JS_SetGlobalObject(mContext, aOuterObject);
|
JS_SetGlobalObject(mContext, aOuterObject);
|
||||||
|
|
||||||
// NB: JS_SetGlobalObject sets mContext->compartment.
|
// NB: JS_SetGlobalObject sets mContext->compartment.
|
||||||
JSObject *inner = JS_GetParent(mContext, aOuterObject);
|
JSObject *inner = JS_GetParent(aOuterObject);
|
||||||
|
|
||||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||||
|
@ -2344,7 +2344,7 @@ nsJSContext::SetOuterObject(JSObject* aOuterObject)
|
||||||
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
|
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
|
||||||
|
|
||||||
wrapper->RefreshPrototype();
|
wrapper->RefreshPrototype();
|
||||||
JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(mContext, inner));
|
JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(inner));
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -3099,8 +3099,8 @@ nsJSContext::ClearScope(void *aGlobalObj, bool aClearFromProtoChain)
|
||||||
nsWindowSH::InvalidateGlobalScopePolluter(mContext, obj);
|
nsWindowSH::InvalidateGlobalScopePolluter(mContext, obj);
|
||||||
|
|
||||||
// Clear up obj's prototype chain, but not Object.prototype.
|
// Clear up obj's prototype chain, but not Object.prototype.
|
||||||
for (JSObject *o = ::JS_GetPrototype(mContext, obj), *next;
|
for (JSObject *o = ::JS_GetPrototype(obj), *next;
|
||||||
o && (next = ::JS_GetPrototype(mContext, o)); o = next)
|
o && (next = ::JS_GetPrototype(o)); o = next)
|
||||||
::JS_ClearScope(mContext, o);
|
::JS_ClearScope(mContext, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ nsJSUtils::GetStaticScriptGlobal(JSContext* aContext, JSObject* aObj)
|
||||||
if (!clazz ||
|
if (!clazz ||
|
||||||
!(clazz->flags & JSCLASS_HAS_PRIVATE) ||
|
!(clazz->flags & JSCLASS_HAS_PRIVATE) ||
|
||||||
!(clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) ||
|
!(clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) ||
|
||||||
!(supports = (nsISupports*)::JS_GetPrivate(aContext, glob))) {
|
!(supports = (nsISupports*)::JS_GetPrivate(glob))) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj)
|
||||||
// obj is one of our own, its private data is the NPObject we're
|
// obj is one of our own, its private data is the NPObject we're
|
||||||
// looking for.
|
// looking for.
|
||||||
|
|
||||||
NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
|
NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
|
||||||
|
|
||||||
if (LookupNPP(npobj) == npp)
|
if (LookupNPP(npobj) == npp)
|
||||||
return _retainobject(npobj);
|
return _retainobject(npobj);
|
||||||
|
@ -1154,17 +1154,17 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static NPObject *
|
static NPObject *
|
||||||
GetNPObject(JSContext *cx, JSObject *obj)
|
GetNPObject(JSObject *obj)
|
||||||
{
|
{
|
||||||
while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
||||||
obj = ::JS_GetPrototype(cx, obj);
|
obj = ::JS_GetPrototype(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (NPObject *)::JS_GetPrivate(cx, obj);
|
return (NPObject *)::JS_GetPrivate(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1173,7 +1173,7 @@ GetNPObject(JSContext *cx, JSObject *obj)
|
||||||
static JSBool
|
static JSBool
|
||||||
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
||||||
!npobj->_class->hasMethod) {
|
!npobj->_class->hasMethod) {
|
||||||
|
@ -1214,7 +1214,7 @@ NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
static JSBool
|
static JSBool
|
||||||
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
||||||
!npobj->_class->removeProperty) {
|
!npobj->_class->removeProperty) {
|
||||||
|
@ -1245,7 +1245,7 @@ NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
static JSBool
|
static JSBool
|
||||||
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
||||||
!npobj->_class->setProperty) {
|
!npobj->_class->setProperty) {
|
||||||
|
@ -1304,7 +1304,7 @@ NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, j
|
||||||
static JSBool
|
static JSBool
|
||||||
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
||||||
!npobj->_class->hasMethod || !npobj->_class->getProperty) {
|
!npobj->_class->hasMethod || !npobj->_class->getProperty) {
|
||||||
|
@ -1393,7 +1393,7 @@ CallNPMethodInternal(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
jsval *rval, bool ctorCall)
|
jsval *rval, bool ctorCall)
|
||||||
{
|
{
|
||||||
while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
||||||
obj = ::JS_GetPrototype(cx, obj);
|
obj = ::JS_GetPrototype(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
|
@ -1402,7 +1402,7 @@ CallNPMethodInternal(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
|
NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class) {
|
if (!npobj || !npobj->_class) {
|
||||||
ThrowJSException(cx, "Bad NPObject as private data!");
|
ThrowJSException(cx, "Bad NPObject as private data!");
|
||||||
|
@ -1545,7 +1545,7 @@ static JSBool
|
||||||
NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||||
jsval *statep, jsid *idp)
|
jsval *statep, jsid *idp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
NPIdentifier *enum_value;
|
NPIdentifier *enum_value;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
NPObjectEnumerateState *state;
|
NPObjectEnumerateState *state;
|
||||||
|
@ -1625,7 +1625,7 @@ static JSBool
|
||||||
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||||
JSObject **objp)
|
JSObject **objp)
|
||||||
{
|
{
|
||||||
NPObject *npobj = GetNPObject(cx, obj);
|
NPObject *npobj = GetNPObject(obj);
|
||||||
|
|
||||||
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
|
||||||
!npobj->_class->hasMethod) {
|
!npobj->_class->hasMethod) {
|
||||||
|
@ -1714,7 +1714,7 @@ NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
|
||||||
static void
|
static void
|
||||||
NPObjWrapper_Finalize(JSContext *cx, JSObject *obj)
|
NPObjWrapper_Finalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
|
NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
|
||||||
if (npobj) {
|
if (npobj) {
|
||||||
if (sNPObjWrappers.ops) {
|
if (sNPObjWrappers.ops) {
|
||||||
PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_REMOVE);
|
PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_REMOVE);
|
||||||
|
@ -1780,11 +1780,7 @@ nsNPObjWrapper::OnDestroy(NPObject *npobj)
|
||||||
// Found a live NPObject wrapper, null out its JSObjects' private
|
// Found a live NPObject wrapper, null out its JSObjects' private
|
||||||
// data.
|
// data.
|
||||||
|
|
||||||
JSContext *cx = GetJSContext(entry->mNpp);
|
::JS_SetPrivate(entry->mJSObj, nsnull);
|
||||||
|
|
||||||
if (cx) {
|
|
||||||
::JS_SetPrivate(cx, entry->mJSObj, nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the npobj from the hash now that it went away.
|
// Remove the npobj from the hash now that it went away.
|
||||||
PL_DHashTableRawRemove(&sNPObjWrappers, entry);
|
PL_DHashTableRawRemove(&sNPObjWrappers, entry);
|
||||||
|
@ -1876,8 +1872,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
||||||
|
|
||||||
entry->mJSObj = obj;
|
entry->mJSObj = obj;
|
||||||
|
|
||||||
// JS_SetPrivate() never fails.
|
::JS_SetPrivate(obj, npobj);
|
||||||
::JS_SetPrivate(cx, obj, npobj);
|
|
||||||
|
|
||||||
// The new JSObject now holds on to npobj
|
// The new JSObject now holds on to npobj
|
||||||
_retainobject(npobj);
|
_retainobject(npobj);
|
||||||
|
@ -1960,10 +1955,7 @@ NPObjWrapperPluginDestroyedCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||||
PR_Free(npobj);
|
PR_Free(npobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSAutoEnterCompartment ac;
|
::JS_SetPrivate(entry->mJSObj, nsnull);
|
||||||
if (ac.enter(nppcx->cx, entry->mJSObj)) {
|
|
||||||
::JS_SetPrivate(nppcx->cx, entry->mJSObj, nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
table->ops = ops;
|
table->ops = ops;
|
||||||
|
|
||||||
|
@ -2074,10 +2066,10 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
|
||||||
// be only one, but remove all instances found in case the page put
|
// be only one, but remove all instances found in case the page put
|
||||||
// more than one of the plugin's scriptable objects on the prototype
|
// more than one of the plugin's scriptable objects on the prototype
|
||||||
// chain).
|
// chain).
|
||||||
while (obj && (proto = ::JS_GetPrototype(cx, obj))) {
|
while (obj && (proto = ::JS_GetPrototype(obj))) {
|
||||||
if (JS_GetClass(proto) == &sNPObjectJSWrapperClass) {
|
if (JS_GetClass(proto) == &sNPObjectJSWrapperClass) {
|
||||||
// We found an NPObject on the proto chain, get its prototype...
|
// We found an NPObject on the proto chain, get its prototype...
|
||||||
proto = ::JS_GetPrototype(cx, proto);
|
proto = ::JS_GetPrototype(proto);
|
||||||
|
|
||||||
// ... and pull it out of the chain.
|
// ... and pull it out of the chain.
|
||||||
::JS_SetPrototype(cx, obj, proto);
|
::JS_SetPrototype(cx, obj, proto);
|
||||||
|
@ -2140,7 +2132,7 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
||||||
*vp = OBJECT_TO_JSVAL(memobj);
|
*vp = OBJECT_TO_JSVAL(memobj);
|
||||||
::JS_AddValueRoot(cx, vp);
|
::JS_AddValueRoot(cx, vp);
|
||||||
|
|
||||||
::JS_SetPrivate(cx, memobj, (void *)memberPrivate);
|
::JS_SetPrivate(memobj, (void *)memberPrivate);
|
||||||
|
|
||||||
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
NPIdentifier identifier = JSIdToNPIdentifier(id);
|
||||||
|
|
||||||
|
@ -2173,7 +2165,7 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
||||||
// outlive the underlying NPObject, so make sure it points to the
|
// outlive the underlying NPObject, so make sure it points to the
|
||||||
// real JSObject wrapper for the NPObject.
|
// real JSObject wrapper for the NPObject.
|
||||||
while (JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
while (JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
|
||||||
obj = ::JS_GetPrototype(cx, obj);
|
obj = ::JS_GetPrototype(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
memberPrivate->npobjWrapper = obj;
|
memberPrivate->npobjWrapper = obj;
|
||||||
|
@ -2226,7 +2218,7 @@ NPObjectMember_Finalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
NPObjectMemberPrivate *memberPrivate;
|
NPObjectMemberPrivate *memberPrivate;
|
||||||
|
|
||||||
memberPrivate = (NPObjectMemberPrivate *)::JS_GetPrivate(cx, obj);
|
memberPrivate = (NPObjectMemberPrivate *)::JS_GetPrivate(obj);
|
||||||
if (!memberPrivate)
|
if (!memberPrivate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2246,7 +2238,7 @@ NPObjectMember_Call(JSContext *cx, uintN argc, jsval *vp)
|
||||||
if (!memberPrivate || !memberPrivate->npobjWrapper)
|
if (!memberPrivate || !memberPrivate->npobjWrapper)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
NPObject *npobj = GetNPObject(cx, memberPrivate->npobjWrapper);
|
NPObject *npobj = GetNPObject(memberPrivate->npobjWrapper);
|
||||||
if (!npobj) {
|
if (!npobj) {
|
||||||
ThrowJSException(cx, "Call on invalid member object");
|
ThrowJSException(cx, "Call on invalid member object");
|
||||||
|
|
||||||
|
@ -2319,7 +2311,7 @@ static void
|
||||||
NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
|
NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
|
||||||
{
|
{
|
||||||
NPObjectMemberPrivate *memberPrivate =
|
NPObjectMemberPrivate *memberPrivate =
|
||||||
(NPObjectMemberPrivate *)::JS_GetPrivate(trc->context, obj);
|
(NPObjectMemberPrivate *)::JS_GetPrivate(obj);
|
||||||
if (!memberPrivate)
|
if (!memberPrivate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -94,12 +94,13 @@ CTypesLazyGetter(JSContext* aCx, JSObject* aObj, jsid aId, jsval* aVp)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval ctypes;
|
jsval ctypes;
|
||||||
return JS_DeletePropertyById(aCx, aObj, aId) &&
|
if (!JS_DeletePropertyById(aCx, aObj, aId) ||
|
||||||
JS_InitCTypesClass(aCx, aObj) &&
|
!JS_InitCTypesClass(aCx, aObj) ||
|
||||||
JS_GetPropertyById(aCx, aObj, aId, &ctypes) &&
|
!JS_GetPropertyById(aCx, aObj, aId, &ctypes)) {
|
||||||
JS_SetCTypesCallbacks(aCx, JSVAL_TO_OBJECT(ctypes),
|
return false;
|
||||||
&gCTypesCallbacks) &&
|
}
|
||||||
JS_GetPropertyById(aCx, aObj, aId, aVp);
|
JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &gCTypesCallbacks);
|
||||||
|
return JS_GetPropertyById(aCx, aObj, aId, aVp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ EnsureObjectIsEventTarget(JSContext* aCx, JSObject* aObj, char* aFunctionName)
|
||||||
|
|
||||||
inline
|
inline
|
||||||
EventTarget*
|
EventTarget*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj)
|
GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
return GetJSPrivateSafeish<EventTarget>(aCx, aObj);
|
return GetJSPrivateSafeish<EventTarget>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
|
@ -149,9 +149,9 @@ EventTarget::SetEventListenerOnEventTarget(JSContext* aCx, const char* aType,
|
||||||
|
|
||||||
// static
|
// static
|
||||||
EventTarget*
|
EventTarget*
|
||||||
EventTarget::FromJSObject(JSContext* aCx, JSObject* aObj)
|
EventTarget::FromJSObject(JSObject* aObj)
|
||||||
{
|
{
|
||||||
return GetPrivate(aCx, aObj);
|
return GetPrivate(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -167,7 +167,7 @@ EventTarget::AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTarget* self = GetPrivate(aCx, obj);
|
EventTarget* self = GetPrivate(obj);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ EventTarget::RemoveEventListener(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTarget* self = GetPrivate(aCx, obj);
|
EventTarget* self = GetPrivate(obj);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ EventTarget::DispatchEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTarget* self = GetPrivate(aCx, obj);
|
EventTarget* self = GetPrivate(obj);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EventTarget*
|
static EventTarget*
|
||||||
FromJSObject(JSContext* aCx, JSObject* aObj);
|
FromJSObject(JSObject* aObj);
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp);
|
AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp);
|
||||||
|
|
|
@ -128,50 +128,41 @@ public:
|
||||||
JSObject* obj = JS_NewObject(aCx, clasp, NULL, aParent);
|
JSObject* obj = JS_NewObject(aCx, clasp, NULL, aParent);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
Event* priv = new Event();
|
Event* priv = new Event();
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv) ||
|
SetJSPrivateSafeish(obj, priv);
|
||||||
!InitEventCommon(aCx, obj, priv, aType, aBubbles, aCancelable,
|
InitEventCommon(obj, priv, aType, aBubbles, aCancelable, true);
|
||||||
true)) {
|
|
||||||
SetJSPrivateSafeish(aCx, obj, NULL);
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IsSupportedClass(JSContext* aCx, JSObject* aEvent)
|
IsSupportedClass(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
return !!GetPrivate(aCx, aEvent);
|
return !!GetPrivate(aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
SetTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget)
|
SetTarget(JSObject* aEvent, JSObject* aTarget)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsSupportedClass(aCx, aEvent));
|
JS_ASSERT(IsSupportedClass(aEvent));
|
||||||
|
|
||||||
jsval target = OBJECT_TO_JSVAL(aTarget);
|
jsval target = OBJECT_TO_JSVAL(aTarget);
|
||||||
return JS_SetReservedSlot(aCx, aEvent, SLOT_target, target) &&
|
JS_SetReservedSlot(aEvent, SLOT_target, target);
|
||||||
JS_SetReservedSlot(aCx, aEvent, SLOT_currentTarget, target);
|
JS_SetReservedSlot(aEvent, SLOT_currentTarget, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
WasCanceled(JSContext* aCx, JSObject* aEvent)
|
WasCanceled(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsSupportedClass(aCx, aEvent));
|
JS_ASSERT(IsSupportedClass(aEvent));
|
||||||
|
|
||||||
jsval canceled;
|
|
||||||
if (!GetPropertyCommon(aCx, aEvent, SLOT_defaultPrevented, &canceled)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
jsval canceled = JS_GetReservedSlot(aEvent, SLOT_defaultPrevented);
|
||||||
return JSVAL_TO_BOOLEAN(canceled);
|
return JSVAL_TO_BOOLEAN(canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent)
|
ImmediatePropagationStopped(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
Event* event = GetPrivate(aCx, aEvent);
|
Event* event = GetPrivate(aEvent);
|
||||||
return event ? event->mStopImmediatePropagationCalled : false;
|
return event ? event->mStopImmediatePropagationCalled : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +200,12 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
static Event*
|
static Event*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aEvent);
|
GetPrivate(JSObject* aEvent);
|
||||||
|
|
||||||
static Event*
|
static Event*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
Event* priv = GetPrivate(aCx, aObj);
|
Event* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
@ -224,43 +215,25 @@ protected:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static void
|
||||||
InitEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
|
InitEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
|
||||||
JSString* aType, JSBool aBubbles, JSBool aCancelable,
|
JSBool aBubbles, JSBool aCancelable, bool aIsTrusted)
|
||||||
bool aIsTrusted)
|
|
||||||
{
|
{
|
||||||
aEvent->mStopPropagationCalled = false;
|
aEvent->mStopPropagationCalled = false;
|
||||||
aEvent->mStopImmediatePropagationCalled = false;
|
aEvent->mStopImmediatePropagationCalled = false;
|
||||||
|
|
||||||
jsval now;
|
JS_SetReservedSlot(aObj, SLOT_type, STRING_TO_JSVAL(aType));
|
||||||
if (!JS_NewNumberValue(aCx, JS_Now(), &now)) {
|
JS_SetReservedSlot(aObj, SLOT_target, JSVAL_NULL);
|
||||||
return false;
|
JS_SetReservedSlot(aObj, SLOT_currentTarget, JSVAL_NULL);
|
||||||
}
|
JS_SetReservedSlot(aObj, SLOT_eventPhase, INT_TO_JSVAL(CAPTURING_PHASE));
|
||||||
|
JS_SetReservedSlot(aObj, SLOT_bubbles,
|
||||||
if (!JS_SetReservedSlot(aCx, aObj, SLOT_type, STRING_TO_JSVAL(aType)) ||
|
aBubbles ? JSVAL_TRUE : JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_target, JSVAL_NULL) ||
|
JS_SetReservedSlot(aObj, SLOT_cancelable,
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_currentTarget, JSVAL_NULL) ||
|
aCancelable ? JSVAL_TRUE : JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_eventPhase,
|
JS_SetReservedSlot(aObj, SLOT_timeStamp, JS::NumberValue(double(JS_Now())));
|
||||||
INT_TO_JSVAL(CAPTURING_PHASE)) ||
|
JS_SetReservedSlot(aObj, SLOT_defaultPrevented, JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_bubbles,
|
JS_SetReservedSlot(aObj, SLOT_isTrusted,
|
||||||
aBubbles ? JSVAL_TRUE : JSVAL_FALSE) ||
|
aIsTrusted ? JSVAL_TRUE : JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_cancelable,
|
|
||||||
aCancelable ? JSVAL_TRUE : JSVAL_FALSE) ||
|
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_timeStamp, now) ||
|
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_defaultPrevented, JSVAL_FALSE) ||
|
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_isTrusted,
|
|
||||||
aIsTrusted ? JSVAL_TRUE : JSVAL_FALSE)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSBool
|
|
||||||
GetPropertyCommon(JSContext* aCx, JSObject* aObj, int32 aSlot, jsval* aVp)
|
|
||||||
{
|
|
||||||
JS_ASSERT(aSlot >= 0 && aSlot < SLOT_COUNT);
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, aSlot, aVp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -276,7 +249,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
||||||
delete GetJSPrivateSafeish<Event>(aCx, aObj);
|
delete GetJSPrivateSafeish<Event>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -291,7 +264,8 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetPropertyCommon(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -354,14 +328,11 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval cancelableVal;
|
jsval cancelableVal = JS_GetReservedSlot(obj, SLOT_cancelable);
|
||||||
if (!GetPropertyCommon(aCx, obj, SLOT_cancelable, &cancelableVal)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSVAL_TO_BOOLEAN(cancelableVal) ?
|
if (JSVAL_TO_BOOLEAN(cancelableVal))
|
||||||
JS_SetReservedSlot(aCx, obj, SLOT_defaultPrevented, cancelableVal) :
|
JS_SetReservedSlot(obj, SLOT_defaultPrevented, cancelableVal);
|
||||||
true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -384,7 +355,8 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitEventCommon(aCx, obj, event, type, bubbles, cancelable, false);
|
InitEventCommon(obj, event, type, bubbles, cancelable, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -486,14 +458,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEvent* priv = new MessageEvent(aMainRuntime);
|
MessageEvent* priv = new MessageEvent(aMainRuntime);
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv) ||
|
SetJSPrivateSafeish(obj, priv);
|
||||||
!InitMessageEventCommon(aCx, obj, priv, type, false, false, NULL, NULL,
|
InitMessageEventCommon(aCx, obj, priv, type, false, false, NULL, NULL, NULL,
|
||||||
NULL, true)) {
|
true);
|
||||||
SetJSPrivateSafeish(aCx, obj, NULL);
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
aData.steal(&priv->mData, &priv->mDataByteCount);
|
aData.steal(&priv->mData, &priv->mDataByteCount);
|
||||||
priv->mClonedObjects.SwapElements(aClonedObjects);
|
priv->mClonedObjects.SwapElements(aClonedObjects);
|
||||||
|
|
||||||
|
@ -528,7 +495,7 @@ private:
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (IsThisClass(classPtr)) {
|
if (IsThisClass(classPtr)) {
|
||||||
return GetJSPrivateSafeish<MessageEvent>(aCx, aObj);
|
return GetJSPrivateSafeish<MessageEvent>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
|
@ -537,7 +504,7 @@ private:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static void
|
||||||
InitMessageEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
|
InitMessageEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
|
||||||
JSString* aType, JSBool aBubbles, JSBool aCancelable,
|
JSString* aType, JSBool aBubbles, JSBool aCancelable,
|
||||||
JSString* aData, JSString* aOrigin, JSObject* aSource,
|
JSString* aData, JSString* aOrigin, JSObject* aSource,
|
||||||
|
@ -545,16 +512,13 @@ private:
|
||||||
{
|
{
|
||||||
jsval emptyString = JS_GetEmptyStringValue(aCx);
|
jsval emptyString = JS_GetEmptyStringValue(aCx);
|
||||||
|
|
||||||
if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
|
Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
|
||||||
aCancelable, aIsTrusted) ||
|
aIsTrusted);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_data,
|
JS_SetReservedSlot(aObj, SLOT_data,
|
||||||
aData ? STRING_TO_JSVAL(aData) : emptyString) ||
|
aData ? STRING_TO_JSVAL(aData) : emptyString);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_origin,
|
JS_SetReservedSlot(aObj, SLOT_origin,
|
||||||
aOrigin ? STRING_TO_JSVAL(aOrigin) : emptyString) ||
|
aOrigin ? STRING_TO_JSVAL(aOrigin) : emptyString);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_source, OBJECT_TO_JSVAL(aSource))) {
|
JS_SetReservedSlot(aObj, SLOT_source, OBJECT_TO_JSVAL(aSource));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -569,7 +533,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
||||||
MessageEvent* priv = GetJSPrivateSafeish<MessageEvent>(aCx, aObj);
|
MessageEvent* priv = GetJSPrivateSafeish<MessageEvent>(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
JS_free(aCx, priv->mData);
|
JS_free(aCx, priv->mData);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -609,16 +573,17 @@ private:
|
||||||
|
|
||||||
jsval data;
|
jsval data;
|
||||||
if (!buffer.read(aCx, &data,
|
if (!buffer.read(aCx, &data,
|
||||||
WorkerStructuredCloneCallbacks(event->mMainRuntime)) ||
|
WorkerStructuredCloneCallbacks(event->mMainRuntime))) {
|
||||||
!JS_SetReservedSlot(aCx, aObj, slot, data)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
JS_SetReservedSlot(aObj, slot, data);
|
||||||
|
|
||||||
*aVp = data;
|
*aVp = data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -642,8 +607,9 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitMessageEventCommon(aCx, obj, event, type, bubbles, cancelable,
|
InitMessageEventCommon(aCx, obj, event, type, bubbles, cancelable,
|
||||||
data, origin, source, false);
|
data, origin, source, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -717,13 +683,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorEvent* priv = new ErrorEvent();
|
ErrorEvent* priv = new ErrorEvent();
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv) ||
|
SetJSPrivateSafeish(obj, priv);
|
||||||
!InitErrorEventCommon(aCx, obj, priv, type, false, true, aMessage,
|
InitErrorEventCommon(obj, priv, type, false, true, aMessage, aFilename,
|
||||||
aFilename, aLineNumber, true)) {
|
aLineNumber, true);
|
||||||
SetJSPrivateSafeish(aCx, obj, NULL);
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +715,7 @@ private:
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (IsThisClass(classPtr)) {
|
if (IsThisClass(classPtr)) {
|
||||||
return GetJSPrivateSafeish<ErrorEvent>(aCx, aObj);
|
return GetJSPrivateSafeish<ErrorEvent>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
|
@ -762,23 +724,17 @@ private:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static void
|
||||||
InitErrorEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
|
InitErrorEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
|
||||||
JSString* aType, JSBool aBubbles, JSBool aCancelable,
|
JSBool aBubbles, JSBool aCancelable,
|
||||||
JSString* aMessage, JSString* aFilename,
|
JSString* aMessage, JSString* aFilename,
|
||||||
uint32 aLineNumber, bool aIsTrusted)
|
uint32 aLineNumber, bool aIsTrusted)
|
||||||
{
|
{
|
||||||
if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
|
Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
|
||||||
aCancelable, aIsTrusted) ||
|
aIsTrusted);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_message,
|
JS_SetReservedSlot(aObj, SLOT_message, STRING_TO_JSVAL(aMessage));
|
||||||
STRING_TO_JSVAL(aMessage)) ||
|
JS_SetReservedSlot(aObj, SLOT_filename, STRING_TO_JSVAL(aFilename));
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_filename,
|
JS_SetReservedSlot(aObj, SLOT_lineno, INT_TO_JSVAL(aLineNumber));
|
||||||
STRING_TO_JSVAL(aFilename)) ||
|
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_lineno,
|
|
||||||
INT_TO_JSVAL(aLineNumber))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -793,7 +749,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
|
||||||
delete GetJSPrivateSafeish<ErrorEvent>(aCx, aObj);
|
delete GetJSPrivateSafeish<ErrorEvent>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -811,7 +767,8 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -836,8 +793,9 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitErrorEventCommon(aCx, obj, event, type, bubbles, cancelable,
|
InitErrorEventCommon(obj, event, type, bubbles, cancelable, message,
|
||||||
message, filename, lineNumber, false);
|
filename, lineNumber, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -905,13 +863,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressEvent* priv = new ProgressEvent();
|
ProgressEvent* priv = new ProgressEvent();
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv) ||
|
SetJSPrivateSafeish(obj, priv);
|
||||||
!InitProgressEventCommon(aCx, obj, priv, type, false, false,
|
InitProgressEventCommon(obj, priv, type, false, false, aLengthComputable,
|
||||||
aLengthComputable, aLoaded, aTotal, true)) {
|
aLoaded, aTotal, true);
|
||||||
SetJSPrivateSafeish(aCx, obj, NULL);
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +895,7 @@ private:
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
return GetJSPrivateSafeish<ProgressEvent>(aCx, aObj);
|
return GetJSPrivateSafeish<ProgressEvent>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
|
@ -950,21 +904,18 @@ private:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static void
|
||||||
InitProgressEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
|
InitProgressEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
|
||||||
JSString* aType, JSBool aBubbles, JSBool aCancelable,
|
JSBool aBubbles, JSBool aCancelable,
|
||||||
JSBool aLengthComputable, jsdouble aLoaded,
|
JSBool aLengthComputable, jsdouble aLoaded,
|
||||||
jsdouble aTotal, bool aIsTrusted)
|
jsdouble aTotal, bool aIsTrusted)
|
||||||
{
|
{
|
||||||
if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
|
Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
|
||||||
aCancelable, aIsTrusted) ||
|
aIsTrusted);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_lengthComputable,
|
JS_SetReservedSlot(aObj, SLOT_lengthComputable,
|
||||||
aLengthComputable ? JSVAL_TRUE : JSVAL_FALSE) ||
|
aLengthComputable ? JSVAL_TRUE : JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_loaded, DOUBLE_TO_JSVAL(aLoaded)) ||
|
JS_SetReservedSlot(aObj, SLOT_loaded, DOUBLE_TO_JSVAL(aLoaded));
|
||||||
!JS_SetReservedSlot(aCx, aObj, SLOT_total, DOUBLE_TO_JSVAL(aTotal))) {
|
JS_SetReservedSlot(aObj, SLOT_total, DOUBLE_TO_JSVAL(aTotal));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -979,7 +930,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
delete GetJSPrivateSafeish<ProgressEvent>(aCx, aObj);
|
delete GetJSPrivateSafeish<ProgressEvent>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -997,7 +948,8 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -1022,8 +974,9 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitProgressEventCommon(aCx, obj, event, type, bubbles, cancelable,
|
InitProgressEventCommon(obj, event, type, bubbles, cancelable,
|
||||||
lengthComputable, loaded, total, false);
|
lengthComputable, loaded, total, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1051,7 +1004,7 @@ JSFunctionSpec ProgressEvent::sFunctions[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
Event*
|
Event*
|
||||||
Event::GetPrivate(JSContext* aCx, JSObject* aObj)
|
Event::GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
|
@ -1059,7 +1012,7 @@ Event::GetPrivate(JSContext* aCx, JSObject* aObj)
|
||||||
MessageEvent::IsThisClass(classPtr) ||
|
MessageEvent::IsThisClass(classPtr) ||
|
||||||
ErrorEvent::IsThisClass(classPtr) ||
|
ErrorEvent::IsThisClass(classPtr) ||
|
||||||
classPtr == ProgressEvent::Class()) {
|
classPtr == ProgressEvent::Class()) {
|
||||||
return GetJSPrivateSafeish<Event>(aCx, aObj);
|
return GetJSPrivateSafeish<Event>(aObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1120,27 +1073,27 @@ CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsSupportedEventClass(JSContext* aCx, JSObject* aEvent)
|
IsSupportedEventClass(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
return Event::IsSupportedClass(aCx, aEvent);
|
return Event::IsSupportedClass(aEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetEventTarget(JSObject* aEvent, JSObject* aTarget)
|
||||||
|
{
|
||||||
|
Event::SetTarget(aEvent, aTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SetEventTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget)
|
EventWasCanceled(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
return Event::SetTarget(aCx, aEvent, aTarget);
|
return Event::WasCanceled(aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EventWasCanceled(JSContext* aCx, JSObject* aEvent)
|
EventImmediatePropagationStopped(JSObject* aEvent)
|
||||||
{
|
{
|
||||||
return Event::WasCanceled(aCx, aEvent);
|
return Event::ImmediatePropagationStopped(aEvent);
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
EventImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent)
|
|
||||||
{
|
|
||||||
return Event::ImmediatePropagationStopped(aCx, aEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -72,16 +72,16 @@ CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
|
||||||
jsdouble aLoaded, jsdouble aTotal);
|
jsdouble aLoaded, jsdouble aTotal);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsSupportedEventClass(JSContext* aCx, JSObject* aEvent);
|
IsSupportedEventClass(JSObject* aEvent);
|
||||||
|
|
||||||
|
void
|
||||||
|
SetEventTarget(JSObject* aEvent, JSObject* aTarget);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SetEventTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget);
|
EventWasCanceled(JSObject* aEvent);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EventWasCanceled(JSContext* aCx, JSObject* aEvent);
|
EventImmediatePropagationStopped(JSObject* aEvent);
|
||||||
|
|
||||||
bool
|
|
||||||
EventImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DispatchEventToTarget(JSContext* aCx, JSObject* aTarget, JSObject* aEvent,
|
DispatchEventToTarget(JSContext* aCx, JSObject* aTarget, JSObject* aEvent,
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
delete GetJSPrivateSafeish<DOMException>(aCx, aObj);
|
delete GetJSPrivateSafeish<DOMException>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -141,11 +141,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval name;
|
jsval name = JS_GetReservedSlot(obj, SLOT_name);
|
||||||
if (!JS_GetReservedSlot(aCx, obj, SLOT_name, &name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_ASSERT(JSVAL_IS_STRING(name));
|
JS_ASSERT(JSVAL_IS_STRING(name));
|
||||||
|
|
||||||
JSString* out = JS_ConcatStrings(aCx, classString, JSVAL_TO_STRING(name));
|
JSString* out = JS_ConcatStrings(aCx, classString, JSVAL_TO_STRING(name));
|
||||||
|
@ -166,14 +162,15 @@ private:
|
||||||
|
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
|
|
||||||
if (classPtr != &sClass || !GetJSPrivateSafeish<DOMException>(aCx, aObj)) {
|
if (classPtr != &sClass || !GetJSPrivateSafeish<DOMException>(aObj)) {
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
JSMSG_INCOMPATIBLE_PROTO, sClass.name,
|
JSMSG_INCOMPATIBLE_PROTO, sClass.name,
|
||||||
sProperties[slot].name, classPtr->name);
|
sProperties[slot].name, classPtr->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -269,16 +266,11 @@ DOMException::Create(JSContext* aCx, intN aCode)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_code, INT_TO_JSVAL(aCode)) ||
|
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_name, STRING_TO_JSVAL(name))) {
|
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DOMException* priv = new DOMException();
|
DOMException* priv = new DOMException();
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv)) {
|
SetJSPrivateSafeish(obj, priv);
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +322,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
delete GetJSPrivateSafeish<FileException>(aCx, aObj);
|
delete GetJSPrivateSafeish<FileException>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -342,14 +334,15 @@ private:
|
||||||
|
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
|
|
||||||
if (classPtr != &sClass || !GetJSPrivateSafeish<FileException>(aCx, aObj)) {
|
if (classPtr != &sClass || !GetJSPrivateSafeish<FileException>(aObj)) {
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
JSMSG_INCOMPATIBLE_PROTO, sClass.name,
|
JSMSG_INCOMPATIBLE_PROTO, sClass.name,
|
||||||
sProperties[slot].name, classPtr->name);
|
sProperties[slot].name, classPtr->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, slot, aVp);
|
*aVp = JS_GetReservedSlot(aObj, slot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -415,16 +408,11 @@ FileException::Create(JSContext* aCx, intN aCode)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_code, INT_TO_JSVAL(aCode)) ||
|
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_name, STRING_TO_JSVAL(name))) {
|
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileException* priv = new FileException();
|
FileException* priv = new FileException();
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv)) {
|
SetJSPrivateSafeish(obj, priv);
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,22 +86,20 @@ public:
|
||||||
|
|
||||||
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
if (!JS_SetPrivate(aCx, obj, aBlob)) {
|
JS_SetPrivate(obj, aBlob);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
NS_ADDREF(aBlob);
|
NS_ADDREF(aBlob);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsIDOMBlob*
|
static nsIDOMBlob*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj);
|
GetPrivate(JSObject* aObj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static nsIDOMBlob*
|
static nsIDOMBlob*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
nsIDOMBlob* blob = GetPrivate(aCx, aObj);
|
nsIDOMBlob* blob = GetPrivate(aObj);
|
||||||
if (blob) {
|
if (blob) {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +123,7 @@ private:
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
|
|
||||||
nsIDOMBlob* blob = GetPrivate(aCx, aObj);
|
nsIDOMBlob* blob = GetPrivate(aObj);
|
||||||
NS_IF_RELEASE(blob);
|
NS_IF_RELEASE(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,21 +258,19 @@ public:
|
||||||
|
|
||||||
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
if (!JS_SetPrivate(aCx, obj, aFile)) {
|
JS_SetPrivate(obj, aFile);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
NS_ADDREF(aFile);
|
NS_ADDREF(aFile);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsIDOMFile*
|
static nsIDOMFile*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj)
|
GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aCx, aObj));
|
nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aObj));
|
||||||
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(priv);
|
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(priv);
|
||||||
JS_ASSERT_IF(priv, file);
|
JS_ASSERT_IF(priv, file);
|
||||||
return file;
|
return file;
|
||||||
|
@ -293,7 +289,7 @@ private:
|
||||||
static nsIDOMFile*
|
static nsIDOMFile*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
nsIDOMFile* file = GetPrivate(aCx, aObj);
|
nsIDOMFile* file = GetPrivate(aObj);
|
||||||
if (file) {
|
if (file) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +313,7 @@ private:
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
|
|
||||||
nsIDOMFile* file = GetPrivate(aCx, aObj);
|
nsIDOMFile* file = GetPrivate(aObj);
|
||||||
NS_IF_RELEASE(file);
|
NS_IF_RELEASE(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,12 +382,12 @@ JSPropertySpec File::sProperties[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
nsIDOMBlob*
|
nsIDOMBlob*
|
||||||
Blob::GetPrivate(JSContext* aCx, JSObject* aObj)
|
Blob::GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass || classPtr == File::Class()) {
|
if (classPtr == &sClass || classPtr == File::Class()) {
|
||||||
nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aCx, aObj));
|
nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aObj));
|
||||||
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(priv);
|
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(priv);
|
||||||
JS_ASSERT_IF(priv, blob);
|
JS_ASSERT_IF(priv, blob);
|
||||||
return blob;
|
return blob;
|
||||||
|
@ -420,9 +416,9 @@ InitClasses(JSContext* aCx, JSObject* aGlobal)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMBlob*
|
nsIDOMBlob*
|
||||||
GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj)
|
GetDOMBlobFromJSObject(JSObject* aObj)
|
||||||
{
|
{
|
||||||
return Blob::GetPrivate(aCx, aObj);
|
return Blob::GetPrivate(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
|
@ -432,9 +428,9 @@ CreateFile(JSContext* aCx, nsIDOMFile* aFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMFile*
|
nsIDOMFile*
|
||||||
GetDOMFileFromJSObject(JSContext* aCx, JSObject* aObj)
|
GetDOMFileFromJSObject(JSObject* aObj)
|
||||||
{
|
{
|
||||||
return File::GetPrivate(aCx, aObj);
|
return File::GetPrivate(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace file
|
} // namespace file
|
||||||
|
|
|
@ -58,13 +58,13 @@ JSObject*
|
||||||
CreateBlob(JSContext* aCx, nsIDOMBlob* aBlob);
|
CreateBlob(JSContext* aCx, nsIDOMBlob* aBlob);
|
||||||
|
|
||||||
nsIDOMBlob*
|
nsIDOMBlob*
|
||||||
GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj);
|
GetDOMBlobFromJSObject(JSObject* aObj);
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
CreateFile(JSContext* aCx, nsIDOMFile* aFile);
|
CreateFile(JSContext* aCx, nsIDOMFile* aFile);
|
||||||
|
|
||||||
nsIDOMFile*
|
nsIDOMFile*
|
||||||
GetDOMFileFromJSObject(JSContext* aCx, JSObject* aObj);
|
GetDOMFileFromJSObject(JSObject* aObj);
|
||||||
|
|
||||||
} // namespace file
|
} // namespace file
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj) {
|
||||||
// aObj can be null as JS_ConvertArguments("o") successfully converts JS
|
// aObj can be null as JS_ConvertArguments("o") successfully converts JS
|
||||||
// null to a null pointer to JSObject
|
// null to a null pointer to JSObject
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aCx, aObj);
|
nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aObj);
|
||||||
if (blob) {
|
if (blob) {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static FileReaderSyncPrivate*
|
static FileReaderSyncPrivate*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj)
|
GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
FileReaderSyncPrivate* fileReader =
|
FileReaderSyncPrivate* fileReader =
|
||||||
GetJSPrivateSafeish<FileReaderSyncPrivate>(aCx, aObj);
|
GetJSPrivateSafeish<FileReaderSyncPrivate>(aObj);
|
||||||
return fileReader;
|
return fileReader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
static FileReaderSyncPrivate*
|
static FileReaderSyncPrivate*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
FileReaderSyncPrivate* fileReader = GetPrivate(aCx, aObj);
|
FileReaderSyncPrivate* fileReader = GetPrivate(aObj);
|
||||||
if (fileReader) {
|
if (fileReader) {
|
||||||
return fileReader;
|
return fileReader;
|
||||||
}
|
}
|
||||||
|
@ -149,10 +149,7 @@ private:
|
||||||
FileReaderSyncPrivate* fileReader = new FileReaderSyncPrivate();
|
FileReaderSyncPrivate* fileReader = new FileReaderSyncPrivate();
|
||||||
NS_ADDREF(fileReader);
|
NS_ADDREF(fileReader);
|
||||||
|
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, fileReader)) {
|
SetJSPrivateSafeish(obj, fileReader);
|
||||||
NS_RELEASE(fileReader);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
|
JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
|
||||||
return true;
|
return true;
|
||||||
|
@ -163,7 +160,7 @@ private:
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
FileReaderSyncPrivate* fileReader =
|
FileReaderSyncPrivate* fileReader =
|
||||||
GetJSPrivateSafeish<FileReaderSyncPrivate>(aCx, aObj);
|
GetJSPrivateSafeish<FileReaderSyncPrivate>(aObj);
|
||||||
NS_IF_RELEASE(fileReader);
|
NS_IF_RELEASE(fileReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ bool
|
||||||
ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||||
JSObject* aEvent, bool* aPreventDefaultCalled)
|
JSObject* aEvent, bool* aPreventDefaultCalled)
|
||||||
{
|
{
|
||||||
if (!events::IsSupportedEventClass(aCx, aEvent)) {
|
if (!events::IsSupportedEventClass(aEvent)) {
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
JSMSG_INCOMPATIBLE_METHOD,
|
JSMSG_INCOMPATIBLE_METHOD,
|
||||||
"EventTarget", "dispatchEvent", "Event object");
|
"EventTarget", "dispatchEvent", "Event object");
|
||||||
|
@ -407,12 +407,10 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!events::SetEventTarget(aCx, aEvent, aTarget)) {
|
events::SetEventTarget(aEvent, aTarget);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < listeners.length(); index++) {
|
for (size_t index = 0; index < listeners.length(); index++) {
|
||||||
if (events::EventImmediatePropagationStopped(aCx, aEvent)) {
|
if (events::EventImmediatePropagationStopped(aEvent)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,11 +460,9 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!events::SetEventTarget(aCx, aEvent, NULL)) {
|
events::SetEventTarget(aEvent, NULL);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*aPreventDefaultCalled = events::EventWasCanceled(aCx, aEvent);
|
*aPreventDefaultCalled = events::EventWasCanceled(aEvent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,31 +89,25 @@ public:
|
||||||
|
|
||||||
jsval empty = JS_GetEmptyStringValue(aCx);
|
jsval empty = JS_GetEmptyStringValue(aCx);
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_href,
|
JS_SetReservedSlot(obj, SLOT_href,
|
||||||
aHref ? STRING_TO_JSVAL(aHref) : empty) ||
|
aHref ? STRING_TO_JSVAL(aHref) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_protocol,
|
JS_SetReservedSlot(obj, SLOT_protocol,
|
||||||
aProtocol ? STRING_TO_JSVAL(aProtocol) : empty) ||
|
aProtocol ? STRING_TO_JSVAL(aProtocol) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_host,
|
JS_SetReservedSlot(obj, SLOT_host,
|
||||||
aHost ? STRING_TO_JSVAL(aHost) : empty) ||
|
aHost ? STRING_TO_JSVAL(aHost) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_hostname,
|
JS_SetReservedSlot(obj, SLOT_hostname,
|
||||||
aHostname ? STRING_TO_JSVAL(aHostname) : empty) ||
|
aHostname ? STRING_TO_JSVAL(aHostname) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_port,
|
JS_SetReservedSlot(obj, SLOT_port,
|
||||||
aPort ? STRING_TO_JSVAL(aPort) : empty) ||
|
aPort ? STRING_TO_JSVAL(aPort) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_pathname,
|
JS_SetReservedSlot(obj, SLOT_pathname,
|
||||||
aPathname ? STRING_TO_JSVAL(aPathname) : empty) ||
|
aPathname ? STRING_TO_JSVAL(aPathname) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_search,
|
JS_SetReservedSlot(obj, SLOT_search,
|
||||||
aSearch ? STRING_TO_JSVAL(aSearch) : empty) ||
|
aSearch ? STRING_TO_JSVAL(aSearch) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_hash,
|
JS_SetReservedSlot(obj, SLOT_hash,
|
||||||
aHash ? STRING_TO_JSVAL(aHash) : empty)) {
|
aHash ? STRING_TO_JSVAL(aHash) : empty);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location* priv = new Location();
|
Location* priv = new Location();
|
||||||
|
JS_SetPrivate(obj, priv);
|
||||||
if (!JS_SetPrivate(aCx, obj, priv)) {
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +135,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
delete static_cast<Location*>(JS_GetPrivate(aCx, aObj));
|
delete static_cast<Location*>(JS_GetPrivate(aObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -160,11 +154,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsval href = JS_GetReservedSlot(obj, SLOT_href);
|
||||||
jsval href;
|
|
||||||
if (!JS_GetReservedSlot(aCx, obj, SLOT_href, &href)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_SET_RVAL(aCx, aVp, href);
|
JS_SET_RVAL(aCx, aVp, href);
|
||||||
return true;
|
return true;
|
||||||
|
@ -184,7 +174,8 @@ private:
|
||||||
JS_ASSERT(JSID_IS_INT(aIdval));
|
JS_ASSERT(JSID_IS_INT(aIdval));
|
||||||
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
|
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, JSID_TO_INT(aIdval), aVp);
|
*aVp = JS_GetReservedSlot(aObj, JSID_TO_INT(aIdval));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,23 +108,17 @@ public:
|
||||||
|
|
||||||
jsval empty = JS_GetEmptyStringValue(aCx);
|
jsval empty = JS_GetEmptyStringValue(aCx);
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_appName,
|
JS_SetReservedSlot(obj, SLOT_appName,
|
||||||
appName ? STRING_TO_JSVAL(appName) : empty) ||
|
appName ? STRING_TO_JSVAL(appName) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_appVersion,
|
JS_SetReservedSlot(obj, SLOT_appVersion,
|
||||||
version ? STRING_TO_JSVAL(version) : empty) ||
|
version ? STRING_TO_JSVAL(version) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_platform,
|
JS_SetReservedSlot(obj, SLOT_platform,
|
||||||
platform ? STRING_TO_JSVAL(platform) : empty) ||
|
platform ? STRING_TO_JSVAL(platform) : empty);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_userAgent,
|
JS_SetReservedSlot(obj, SLOT_userAgent,
|
||||||
userAgent ? STRING_TO_JSVAL(userAgent) : empty)) {
|
userAgent ? STRING_TO_JSVAL(userAgent) : empty);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Navigator* priv = new Navigator();
|
Navigator* priv = new Navigator();
|
||||||
|
JS_SetPrivate(obj, priv);
|
||||||
if (!JS_SetPrivate(aCx, obj, priv)) {
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +146,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
delete static_cast<Navigator*>(JS_GetPrivate(aCx, aObj));
|
delete static_cast<Navigator*>(JS_GetPrivate(aObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -169,7 +163,8 @@ private:
|
||||||
JS_ASSERT(JSID_IS_INT(aIdval));
|
JS_ASSERT(JSID_IS_INT(aIdval));
|
||||||
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
|
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
|
||||||
|
|
||||||
return JS_GetReservedSlot(aCx, aObj, JSID_TO_INT(aIdval), aVp);
|
*aVp = JS_GetReservedSlot(aObj, JSID_TO_INT(aIdval));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
{
|
{
|
||||||
JS_ASSERT(!JS_IsExceptionPending(aCx));
|
JS_ASSERT(!JS_IsExceptionPending(aCx));
|
||||||
|
|
||||||
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
|
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
JS_ASSERT(worker);
|
JS_ASSERT(worker);
|
||||||
|
|
||||||
if (aSaveEventHandlers) {
|
if (aSaveEventHandlers) {
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetJSPrivateSafeish(aCx, aObj, NULL);
|
SetJSPrivateSafeish(aObj, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WorkerPrivate*
|
static WorkerPrivate*
|
||||||
|
@ -184,7 +184,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worker now owned by the JS object.
|
// Worker now owned by the JS object.
|
||||||
SetJSPrivateSafeish(aCx, obj, worker);
|
SetJSPrivateSafeish(obj, worker);
|
||||||
|
|
||||||
if (!runtimeService->RegisterWorker(aCx, worker)) {
|
if (!runtimeService->RegisterWorker(aCx, worker)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -242,7 +242,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
|
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker->FinalizeInstance(aCx, true);
|
worker->FinalizeInstance(aCx, true);
|
||||||
}
|
}
|
||||||
|
@ -252,8 +252,7 @@ private:
|
||||||
Trace(JSTracer* aTrc, JSObject* aObj)
|
Trace(JSTracer* aTrc, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
WorkerPrivate* worker =
|
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
GetJSPrivateSafeish<WorkerPrivate>(aTrc->context, aObj);
|
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker->TraceInstance(aTrc);
|
worker->TraceInstance(aTrc);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +379,7 @@ private:
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
return GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
|
return GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +396,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
|
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker->FinalizeInstance(aCx, true);
|
worker->FinalizeInstance(aCx, true);
|
||||||
}
|
}
|
||||||
|
@ -407,8 +406,7 @@ private:
|
||||||
Trace(JSTracer* aTrc, JSObject* aObj)
|
Trace(JSTracer* aTrc, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
WorkerPrivate* worker =
|
WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
GetJSPrivateSafeish<WorkerPrivate>(aTrc->context, aObj);
|
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker->TraceInstance(aTrc);
|
worker->TraceInstance(aTrc);
|
||||||
}
|
}
|
||||||
|
@ -429,7 +427,7 @@ Worker::GetInstancePrivate(JSContext* aCx, JSObject* aObj,
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass || classPtr == ChromeWorker::Class()) {
|
if (classPtr == &sClass || classPtr == ChromeWorker::Class()) {
|
||||||
return GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
|
return GetJSPrivateSafeish<WorkerPrivate>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||||
|
|
|
@ -39,19 +39,19 @@
|
||||||
BEGIN_WORKERS_NAMESPACE
|
BEGIN_WORKERS_NAMESPACE
|
||||||
|
|
||||||
inline
|
inline
|
||||||
JSBool
|
void
|
||||||
SetJSPrivateSafeish(JSContext* aCx, JSObject* aObj, PrivatizableBase* aBase)
|
SetJSPrivateSafeish(JSObject* aObj, PrivatizableBase* aBase)
|
||||||
{
|
{
|
||||||
return JS_SetPrivate(aCx, aObj, aBase);
|
JS_SetPrivate(aObj, aBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
inline
|
inline
|
||||||
Derived*
|
Derived*
|
||||||
GetJSPrivateSafeish(JSContext* aCx, JSObject* aObj)
|
GetJSPrivateSafeish(JSObject* aObj)
|
||||||
{
|
{
|
||||||
return static_cast<Derived*>(
|
return static_cast<Derived*>(
|
||||||
static_cast<PrivatizableBase*>(JS_GetPrivate(aCx, aObj)));
|
static_cast<PrivatizableBase*>(JS_GetPrivate(aObj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
END_WORKERS_NAMESPACE
|
END_WORKERS_NAMESPACE
|
||||||
|
|
|
@ -338,7 +338,7 @@ struct WorkerStructuredCloneCallbacks
|
||||||
|
|
||||||
// See if this is a File object.
|
// See if this is a File object.
|
||||||
{
|
{
|
||||||
nsIDOMFile* file = file::GetDOMFileFromJSObject(aCx, aObj);
|
nsIDOMFile* file = file::GetDOMFileFromJSObject(aObj);
|
||||||
if (file) {
|
if (file) {
|
||||||
if (JS_WriteUint32Pair(aWriter, DOMWORKER_SCTAG_FILE, 0) &&
|
if (JS_WriteUint32Pair(aWriter, DOMWORKER_SCTAG_FILE, 0) &&
|
||||||
JS_WriteBytes(aWriter, &file, sizeof(file))) {
|
JS_WriteBytes(aWriter, &file, sizeof(file))) {
|
||||||
|
@ -350,7 +350,7 @@ struct WorkerStructuredCloneCallbacks
|
||||||
|
|
||||||
// See if this is a Blob object.
|
// See if this is a Blob object.
|
||||||
{
|
{
|
||||||
nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aCx, aObj);
|
nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aObj);
|
||||||
if (blob) {
|
if (blob) {
|
||||||
nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(blob);
|
nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(blob);
|
||||||
if (mutableBlob && NS_SUCCEEDED(mutableBlob->SetMutable(false)) &&
|
if (mutableBlob && NS_SUCCEEDED(mutableBlob->SetMutable(false)) &&
|
||||||
|
|
|
@ -660,14 +660,11 @@ public:
|
||||||
InitPrivate(JSContext* aCx, JSObject* aObj, WorkerPrivate* aWorkerPrivate)
|
InitPrivate(JSContext* aCx, JSObject* aObj, WorkerPrivate* aWorkerPrivate)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
JS_ASSERT(!GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj));
|
JS_ASSERT(!GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj));
|
||||||
|
|
||||||
DedicatedWorkerGlobalScope* priv =
|
DedicatedWorkerGlobalScope* priv =
|
||||||
new DedicatedWorkerGlobalScope(aWorkerPrivate);
|
new DedicatedWorkerGlobalScope(aWorkerPrivate);
|
||||||
if (!SetJSPrivateSafeish(aCx, aObj, priv)) {
|
SetJSPrivateSafeish(aObj, priv);
|
||||||
delete priv;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +721,7 @@ private:
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
return GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj);
|
return GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
|
||||||
|
@ -759,7 +756,7 @@ private:
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
DedicatedWorkerGlobalScope* scope =
|
DedicatedWorkerGlobalScope* scope =
|
||||||
GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj);
|
GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
|
||||||
if (scope) {
|
if (scope) {
|
||||||
scope->FinalizeInstance(aCx);
|
scope->FinalizeInstance(aCx);
|
||||||
delete scope;
|
delete scope;
|
||||||
|
@ -771,7 +768,7 @@ private:
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
DedicatedWorkerGlobalScope* scope =
|
DedicatedWorkerGlobalScope* scope =
|
||||||
GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aTrc->context, aObj);
|
GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
|
||||||
if (scope) {
|
if (scope) {
|
||||||
scope->TraceInstance(aTrc);
|
scope->TraceInstance(aTrc);
|
||||||
}
|
}
|
||||||
|
@ -829,7 +826,7 @@ WorkerGlobalScope::GetInstancePrivate(JSContext* aCx, JSObject* aObj,
|
||||||
{
|
{
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass || classPtr == DedicatedWorkerGlobalScope::Class()) {
|
if (classPtr == &sClass || classPtr == DedicatedWorkerGlobalScope::Class()) {
|
||||||
return GetJSPrivateSafeish<WorkerGlobalScope>(aCx, aObj);
|
return GetJSPrivateSafeish<WorkerGlobalScope>(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||||
|
|
|
@ -108,13 +108,9 @@ public:
|
||||||
|
|
||||||
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
|
JS_SetReservedSlot(obj, SLOT_xhrParent, OBJECT_TO_JSVAL(aParentObj));
|
||||||
XMLHttpRequestUpload* priv = new XMLHttpRequestUpload();
|
XMLHttpRequestUpload* priv = new XMLHttpRequestUpload();
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_xhrParent,
|
SetJSPrivateSafeish(obj, priv);
|
||||||
OBJECT_TO_JSVAL(aParentObj)) ||
|
|
||||||
!SetJSPrivateSafeish(aCx, obj, priv)) {
|
|
||||||
delete priv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -134,12 +130,12 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
static XMLHttpRequestUpload*
|
static XMLHttpRequestUpload*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj)
|
GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
return GetJSPrivateSafeish<XMLHttpRequestUpload>(aCx, aObj);
|
return GetJSPrivateSafeish<XMLHttpRequestUpload>(aObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -148,7 +144,7 @@ private:
|
||||||
static XMLHttpRequestUpload*
|
static XMLHttpRequestUpload*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
XMLHttpRequestUpload* priv = GetPrivate(aCx, aObj);
|
XMLHttpRequestUpload* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +167,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
XMLHttpRequestUpload* priv = GetPrivate(aCx, aObj);
|
XMLHttpRequestUpload* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
priv->FinalizeInstance(aCx);
|
priv->FinalizeInstance(aCx);
|
||||||
delete priv;
|
delete priv;
|
||||||
|
@ -182,7 +178,7 @@ private:
|
||||||
Trace(JSTracer* aTrc, JSObject* aObj)
|
Trace(JSTracer* aTrc, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
XMLHttpRequestUpload* priv = GetPrivate(aTrc->context, aObj);
|
XMLHttpRequestUpload* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
priv->TraceInstance(aTrc);
|
priv->TraceInstance(aTrc);
|
||||||
}
|
}
|
||||||
|
@ -325,13 +321,11 @@ public:
|
||||||
static bool
|
static bool
|
||||||
UpdateState(JSContext* aCx, JSObject* aObj, const xhr::StateData& aNewState)
|
UpdateState(JSContext* aCx, JSObject* aObj, const xhr::StateData& aNewState)
|
||||||
{
|
{
|
||||||
JS_ASSERT(GetPrivate(aCx, aObj));
|
JS_ASSERT(GetPrivate(aObj));
|
||||||
|
|
||||||
#define HANDLE_STATE_VALUE(_member, _slot) \
|
#define HANDLE_STATE_VALUE(_member, _slot) \
|
||||||
if (aNewState. _member##Exception || !JSVAL_IS_VOID(aNewState. _member)) { \
|
if (aNewState. _member##Exception || !JSVAL_IS_VOID(aNewState. _member)) { \
|
||||||
if (!JS_SetReservedSlot(aCx, aObj, _slot, aNewState. _member)) { \
|
JS_SetReservedSlot(aObj, _slot, aNewState. _member); \
|
||||||
return false; \
|
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_STATE_VALUE(mResponseText, SLOT_responseText)
|
HANDLE_STATE_VALUE(mResponseText, SLOT_responseText)
|
||||||
|
@ -353,12 +347,12 @@ private:
|
||||||
~XMLHttpRequest();
|
~XMLHttpRequest();
|
||||||
|
|
||||||
static XMLHttpRequestPrivate*
|
static XMLHttpRequestPrivate*
|
||||||
GetPrivate(JSContext* aCx, JSObject* aObj)
|
GetPrivate(JSObject* aObj)
|
||||||
{
|
{
|
||||||
if (aObj) {
|
if (aObj) {
|
||||||
JSClass* classPtr = JS_GetClass(aObj);
|
JSClass* classPtr = JS_GetClass(aObj);
|
||||||
if (classPtr == &sClass) {
|
if (classPtr == &sClass) {
|
||||||
return GetJSPrivateSafeish<XMLHttpRequestPrivate>(aCx, aObj);
|
return GetJSPrivateSafeish<XMLHttpRequestPrivate>(aObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -367,7 +361,7 @@ private:
|
||||||
static XMLHttpRequestPrivate*
|
static XMLHttpRequestPrivate*
|
||||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||||
{
|
{
|
||||||
XMLHttpRequestPrivate* priv = GetPrivate(aCx, aObj);
|
XMLHttpRequestPrivate* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
@ -394,27 +388,21 @@ private:
|
||||||
jsval emptyString = JS_GetEmptyStringValue(aCx);
|
jsval emptyString = JS_GetEmptyStringValue(aCx);
|
||||||
jsval zero = INT_TO_JSVAL(0);
|
jsval zero = INT_TO_JSVAL(0);
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, obj, SLOT_channel, JSVAL_NULL) ||
|
JS_SetReservedSlot(obj, SLOT_channel, JSVAL_NULL);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_responseXML, JSVAL_NULL) ||
|
JS_SetReservedSlot(obj, SLOT_responseXML, JSVAL_NULL);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_responseText, emptyString) ||
|
JS_SetReservedSlot(obj, SLOT_responseText, emptyString);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_status, zero) ||
|
JS_SetReservedSlot(obj, SLOT_status, zero);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_statusText, emptyString) ||
|
JS_SetReservedSlot(obj, SLOT_statusText, emptyString);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_readyState, zero) ||
|
JS_SetReservedSlot(obj, SLOT_readyState, zero);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_multipart, JSVAL_FALSE) ||
|
JS_SetReservedSlot(obj, SLOT_multipart, JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_mozBackgroundRequest, JSVAL_FALSE) ||
|
JS_SetReservedSlot(obj, SLOT_mozBackgroundRequest, JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_withCredentials, JSVAL_FALSE) ||
|
JS_SetReservedSlot(obj, SLOT_withCredentials, JSVAL_FALSE);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_upload, JSVAL_NULL) ||
|
JS_SetReservedSlot(obj, SLOT_upload, JSVAL_NULL);
|
||||||
!JS_SetReservedSlot(aCx, obj, SLOT_responseType,
|
JS_SetReservedSlot(obj, SLOT_responseType, STRING_TO_JSVAL(textStr));
|
||||||
STRING_TO_JSVAL(textStr))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||||
XMLHttpRequestPrivate* priv = new XMLHttpRequestPrivate(obj, workerPrivate);
|
XMLHttpRequestPrivate* priv = new XMLHttpRequestPrivate(obj, workerPrivate);
|
||||||
if (!SetJSPrivateSafeish(aCx, obj, priv)) {
|
SetJSPrivateSafeish(obj, priv);
|
||||||
delete priv;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
|
JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
|
||||||
return true;
|
return true;
|
||||||
|
@ -424,7 +412,7 @@ private:
|
||||||
Finalize(JSContext* aCx, JSObject* aObj)
|
Finalize(JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
XMLHttpRequestPrivate* priv = GetPrivate(aCx, aObj);
|
XMLHttpRequestPrivate* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
priv->FinalizeInstance(aCx);
|
priv->FinalizeInstance(aCx);
|
||||||
delete priv;
|
delete priv;
|
||||||
|
@ -435,7 +423,7 @@ private:
|
||||||
Trace(JSTracer* aTrc, JSObject* aObj)
|
Trace(JSTracer* aTrc, JSObject* aObj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
XMLHttpRequestPrivate* priv = GetPrivate(aTrc->context, aObj);
|
XMLHttpRequestPrivate* priv = GetPrivate(aObj);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
priv->TraceInstance(aTrc);
|
priv->TraceInstance(aTrc);
|
||||||
}
|
}
|
||||||
|
@ -453,10 +441,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval rval;
|
jsval rval = JS_GetReservedSlot(aObj, slot);
|
||||||
if (!JS_GetReservedSlot(aCx, aObj, slot, &rval)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JSVAL_IS_VOID(rval)) {
|
if (JSVAL_IS_VOID(rval)) {
|
||||||
// Throw an exception.
|
// Throw an exception.
|
||||||
|
@ -492,10 +477,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsval uploadVal;
|
jsval uploadVal = JS_GetReservedSlot(aObj, slot);
|
||||||
if (!JS_GetReservedSlot(aCx, aObj, slot, &uploadVal)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JSVAL_IS_NULL(uploadVal)) {
|
if (JSVAL_IS_NULL(uploadVal)) {
|
||||||
JSObject* uploadObj = XMLHttpRequestUpload::Create(aCx, aObj);
|
JSObject* uploadObj = XMLHttpRequestUpload::Create(aCx, aObj);
|
||||||
|
@ -505,9 +487,7 @@ private:
|
||||||
|
|
||||||
uploadVal = OBJECT_TO_JSVAL(uploadObj);
|
uploadVal = OBJECT_TO_JSVAL(uploadObj);
|
||||||
|
|
||||||
if (!JS_SetReservedSlot(aCx, aObj, slot, uploadVal)) {
|
JS_SetReservedSlot(aObj, slot, uploadVal);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->SetUploadObject(uploadObj);
|
priv->SetUploadObject(uploadObj);
|
||||||
}
|
}
|
||||||
|
@ -533,16 +513,12 @@ private:
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
jsval oldVal; \
|
jsval oldVal = JS_GetReservedSlot(aObj, slot); \
|
||||||
if (!JS_GetReservedSlot(aCx, aObj, slot, &oldVal)) { \
|
|
||||||
return false; \
|
|
||||||
} \
|
|
||||||
\
|
\
|
||||||
jsval rval = *aVp; \
|
jsval rval = *aVp; \
|
||||||
if (!priv->Set##_name (aCx, oldVal, &rval) || \
|
if (!priv->Set##_name (aCx, oldVal, &rval)) \
|
||||||
!JS_SetReservedSlot(aCx, aObj, slot, rval)) { \
|
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
JS_SetReservedSlot(aObj, slot, rval); \
|
||||||
\
|
\
|
||||||
*aVp = rval; \
|
*aVp = rval; \
|
||||||
return true; \
|
return true; \
|
||||||
|
@ -880,10 +856,7 @@ XMLHttpRequestUpload::UpdateState(JSContext* aCx, JSObject* aObj,
|
||||||
{
|
{
|
||||||
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
JS_ASSERT(JS_GetClass(aObj) == &sClass);
|
||||||
|
|
||||||
jsval parentVal;
|
jsval parentVal = JS_GetReservedSlot(aObj, SLOT_xhrParent);
|
||||||
if (!JS_GetReservedSlot(aCx, aObj, SLOT_xhrParent, &parentVal)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(parentVal)) {
|
if (!JSVAL_IS_PRIMITIVE(parentVal)) {
|
||||||
return XMLHttpRequest::UpdateState(aCx, JSVAL_TO_OBJECT(parentVal),
|
return XMLHttpRequest::UpdateState(aCx, JSVAL_TO_OBJECT(parentVal),
|
||||||
|
|
|
@ -1694,7 +1694,7 @@ XMLHttpRequestPrivate::Send(JSContext* aCx, bool aHasBody, jsval aBody)
|
||||||
bool hasUploadListeners = false;
|
bool hasUploadListeners = false;
|
||||||
if (mUploadJSObject) {
|
if (mUploadJSObject) {
|
||||||
events::EventTarget* target =
|
events::EventTarget* target =
|
||||||
events::EventTarget::FromJSObject(aCx, mUploadJSObject);
|
events::EventTarget::FromJSObject(mUploadJSObject);
|
||||||
NS_ASSERTION(target, "This should never be null!");
|
NS_ASSERTION(target, "This should never be null!");
|
||||||
hasUploadListeners = target->HasListeners();
|
hasUploadListeners = target->HasListeners();
|
||||||
}
|
}
|
||||||
|
@ -1754,7 +1754,7 @@ XMLHttpRequestPrivate::SendAsBinary(JSContext* aCx, JSString* aBody)
|
||||||
bool hasUploadListeners = false;
|
bool hasUploadListeners = false;
|
||||||
if (mUploadJSObject) {
|
if (mUploadJSObject) {
|
||||||
events::EventTarget* target =
|
events::EventTarget* target =
|
||||||
events::EventTarget::FromJSObject(aCx, mUploadJSObject);
|
events::EventTarget::FromJSObject(mUploadJSObject);
|
||||||
NS_ASSERTION(target, "This should never be null!");
|
NS_ASSERTION(target, "This should never be null!");
|
||||||
hasUploadListeners = target->HasListeners();
|
hasUploadListeners = target->HasListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,11 +414,11 @@ static void
|
||||||
CPOW_NewEnumerateState_Finalize(JSContext* cx, JSObject* state)
|
CPOW_NewEnumerateState_Finalize(JSContext* cx, JSObject* state)
|
||||||
{
|
{
|
||||||
nsTArray<nsString>* strIds =
|
nsTArray<nsString>* strIds =
|
||||||
static_cast<nsTArray<nsString>*>(JS_GetPrivate(cx, state));
|
static_cast<nsTArray<nsString>*>(JS_GetPrivate(state));
|
||||||
|
|
||||||
if (strIds) {
|
if (strIds) {
|
||||||
delete strIds;
|
delete strIds;
|
||||||
JS_SetPrivate(cx, state, NULL);
|
JS_SetPrivate(state, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
|
||||||
|
|
||||||
for (JSObject* proto = mObj;
|
for (JSObject* proto = mObj;
|
||||||
proto;
|
proto;
|
||||||
proto = JS_GetPrototype(cx, proto))
|
proto = JS_GetPrototype(proto))
|
||||||
{
|
{
|
||||||
AutoIdArray ids(cx, JS_Enumerate(cx, proto));
|
AutoIdArray ids(cx, JS_Enumerate(cx, proto));
|
||||||
for (size_t i = 0; i < ids.length(); ++i)
|
for (size_t i = 0; i < ids.length(); ++i)
|
||||||
|
@ -474,10 +474,10 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
|
||||||
}
|
}
|
||||||
*idp = strIds->Length();
|
*idp = strIds->Length();
|
||||||
|
|
||||||
*status = (JS_SetPrivate(cx, state, strIds) &&
|
JS_SetPrivate(state, strIds);
|
||||||
JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
|
JS_SetReservedSlot(state, sNextIdIndexSlot, JSVAL_ZERO);
|
||||||
JSVAL_ZERO) &&
|
|
||||||
JSObject_to_JSVariant(cx, state, statep));
|
*status = JSObject_to_JSVariant(cx, state, statep);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,6 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
|
||||||
OperationStatus* status, JSVariant* statep, nsString* idp)
|
OperationStatus* status, JSVariant* statep, nsString* idp)
|
||||||
{
|
{
|
||||||
JSObject* state;
|
JSObject* state;
|
||||||
jsval v;
|
|
||||||
|
|
||||||
*statep = in_state;
|
*statep = in_state;
|
||||||
idp->Truncate();
|
idp->Truncate();
|
||||||
|
@ -500,11 +499,13 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfallibleTArray<nsString>* strIds =
|
InfallibleTArray<nsString>* strIds =
|
||||||
static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(cx, state));
|
static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(state));
|
||||||
|
|
||||||
if (!strIds || !JS_GetReservedSlot(cx, state, sNextIdIndexSlot, &v))
|
if (!strIds)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
jsval v = JS_GetReservedSlot(state, sNextIdIndexSlot);
|
||||||
|
|
||||||
jsuint i = JSVAL_TO_INT(v);
|
jsuint i = JSVAL_TO_INT(v);
|
||||||
NS_ASSERTION(i >= 0, "Index of next jsid negative?");
|
NS_ASSERTION(i >= 0, "Index of next jsid negative?");
|
||||||
NS_ASSERTION(i <= strIds->Length(), "Index of next jsid too large?");
|
NS_ASSERTION(i <= strIds->Length(), "Index of next jsid too large?");
|
||||||
|
@ -515,8 +516,8 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
|
||||||
}
|
}
|
||||||
|
|
||||||
*idp = strIds->ElementAt(i);
|
*idp = strIds->ElementAt(i);
|
||||||
*status = JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
|
JS_SetReservedSlot(state, sNextIdIndexSlot, INT_TO_JSVAL(i + 1));
|
||||||
INT_TO_JSVAL(i + 1));
|
*status = JS_TRUE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,47 +59,38 @@ namespace {
|
||||||
|
|
||||||
class AutoResolveFlag
|
class AutoResolveFlag
|
||||||
{
|
{
|
||||||
JSContext* mContext;
|
|
||||||
JSObject* mObj;
|
JSObject* mObj;
|
||||||
uintN mOldFlags;
|
uintN mOldFlags;
|
||||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||||
|
|
||||||
static uintN GetFlags(JSContext* cx, JSObject* obj) {
|
static uintN GetFlags(JSObject* obj) {
|
||||||
jsval v;
|
jsval v = JS_GetReservedSlot(obj, sFlagsSlot);
|
||||||
#ifdef DEBUG
|
|
||||||
JSBool ok =
|
|
||||||
#endif
|
|
||||||
JS_GetReservedSlot(cx, obj, sFlagsSlot, &v);
|
|
||||||
NS_ASSERTION(ok, "Failed to get CPOW flags");
|
|
||||||
return JSVAL_TO_INT(v);
|
return JSVAL_TO_INT(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintN SetFlags(JSContext* cx, JSObject* obj, uintN flags) {
|
static uintN SetFlags(JSObject* obj, uintN flags) {
|
||||||
uintN oldFlags = GetFlags(cx, obj);
|
uintN oldFlags = GetFlags(obj);
|
||||||
if (oldFlags != flags)
|
if (oldFlags != flags)
|
||||||
JS_SetReservedSlot(cx, obj, sFlagsSlot, INT_TO_JSVAL(flags));
|
JS_SetReservedSlot(obj, sFlagsSlot, INT_TO_JSVAL(flags));
|
||||||
return oldFlags;
|
return oldFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AutoResolveFlag(JSContext* cx,
|
AutoResolveFlag(JSObject* obj
|
||||||
JSObject* obj
|
|
||||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||||
: mContext(cx)
|
: mObj(obj)
|
||||||
, mObj(obj)
|
, mOldFlags(SetFlags(obj, GetFlags(obj) | CPOW_FLAG_RESOLVING))
|
||||||
, mOldFlags(SetFlags(cx, obj,
|
|
||||||
GetFlags(cx, obj) | CPOW_FLAG_RESOLVING))
|
|
||||||
{
|
{
|
||||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoResolveFlag() {
|
~AutoResolveFlag() {
|
||||||
SetFlags(mContext, mObj, mOldFlags);
|
SetFlags(mObj, mOldFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool IsSet(JSContext* cx, JSObject* obj) {
|
static JSBool IsSet(JSObject* obj) {
|
||||||
return GetFlags(cx, obj) & CPOW_FLAG_RESOLVING;
|
return GetFlags(obj) & CPOW_FLAG_RESOLVING;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -201,7 +192,7 @@ void
|
||||||
ObjectWrapperParent::ActorDestroy(ActorDestroyReason)
|
ObjectWrapperParent::ActorDestroy(ActorDestroyReason)
|
||||||
{
|
{
|
||||||
if (mObj) {
|
if (mObj) {
|
||||||
JS_SetPrivate(NULL, mObj, NULL);
|
JS_SetPrivate(mObj, NULL);
|
||||||
mObj = NULL;
|
mObj = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,25 +207,28 @@ ObjectWrapperParent::Manager()
|
||||||
JSObject*
|
JSObject*
|
||||||
ObjectWrapperParent::GetJSObject(JSContext* cx) const
|
ObjectWrapperParent::GetJSObject(JSContext* cx) const
|
||||||
{
|
{
|
||||||
js::Class *clasp = const_cast<js::Class *>(&ObjectWrapperParent::sCPOW_JSClass);
|
if (!mObj) {
|
||||||
if (!mObj && (mObj = JS_NewObject(cx, js::Jsvalify(clasp), NULL, NULL))) {
|
js::Class *clasp = const_cast<js::Class *>(&ObjectWrapperParent::sCPOW_JSClass);
|
||||||
JS_SetPrivate(cx, mObj, (void*)this);
|
mObj = JS_NewObject(cx, js::Jsvalify(clasp), NULL, NULL);
|
||||||
JS_SetReservedSlot(cx, mObj, sFlagsSlot, JSVAL_ZERO);
|
if (mObj) {
|
||||||
|
JS_SetPrivate(mObj, (void*)this);
|
||||||
|
JS_SetReservedSlot(mObj, sFlagsSlot, JSVAL_ZERO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mObj;
|
return mObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ObjectWrapperParent*
|
static ObjectWrapperParent*
|
||||||
Unwrap(JSContext* cx, JSObject* obj)
|
Unwrap(JSObject* obj)
|
||||||
{
|
{
|
||||||
while (js::GetObjectClass(obj) != &ObjectWrapperParent::sCPOW_JSClass)
|
while (js::GetObjectClass(obj) != &ObjectWrapperParent::sCPOW_JSClass)
|
||||||
if (!(obj = js::GetObjectProto(obj)))
|
if (!(obj = js::GetObjectProto(obj)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ObjectWrapperParent* self =
|
ObjectWrapperParent* self =
|
||||||
static_cast<ObjectWrapperParent*>(JS_GetPrivate(cx, obj));
|
static_cast<ObjectWrapperParent*>(JS_GetPrivate(obj));
|
||||||
|
|
||||||
NS_ASSERTION(!self || self->GetJSObject(cx) == obj,
|
NS_ASSERTION(!self || self->GetJSObjectOrNull() == obj,
|
||||||
"Wrapper and wrapped object disagree?");
|
"Wrapper and wrapped object disagree?");
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -259,7 +253,7 @@ ObjectWrapperParent::jsval_to_JSVariant(JSContext* cx, jsval from,
|
||||||
case JSTYPE_OBJECT:
|
case JSTYPE_OBJECT:
|
||||||
{
|
{
|
||||||
PObjectWrapperParent* powp;
|
PObjectWrapperParent* powp;
|
||||||
if (!JSObject_to_PObjectWrapperParent(cx, JSVAL_TO_OBJECT(from), &powp))
|
if (!JSObject_to_PObjectWrapperParent(JSVAL_TO_OBJECT(from), &powp))
|
||||||
return with_error(cx, false, "Cannot pass parent-created object to child");
|
return with_error(cx, false, "Cannot pass parent-created object to child");
|
||||||
*to = powp;
|
*to = powp;
|
||||||
}
|
}
|
||||||
|
@ -322,14 +316,13 @@ ObjectWrapperParent::jsval_from_JSVariant(JSContext* cx, const JSVariant& from,
|
||||||
|
|
||||||
/*static*/ bool
|
/*static*/ bool
|
||||||
ObjectWrapperParent::
|
ObjectWrapperParent::
|
||||||
JSObject_to_PObjectWrapperParent(JSContext* cx, JSObject* from,
|
JSObject_to_PObjectWrapperParent(JSObject* from, PObjectWrapperParent** to)
|
||||||
PObjectWrapperParent** to)
|
|
||||||
{
|
{
|
||||||
if (!from) {
|
if (!from) {
|
||||||
*to = NULL;
|
*to = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ObjectWrapperParent* owp = Unwrap(cx, from);
|
ObjectWrapperParent* owp = Unwrap(from);
|
||||||
if (!owp)
|
if (!owp)
|
||||||
return false;
|
return false;
|
||||||
*to = owp;
|
*to = owp;
|
||||||
|
@ -401,11 +394,11 @@ ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||||
CPOW_LOG(("Calling CPOW_AddProperty (%s)...",
|
CPOW_LOG(("Calling CPOW_AddProperty (%s)...",
|
||||||
JSVAL_TO_CSTR(cx, id)));
|
JSVAL_TO_CSTR(cx, id)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_AddProperty");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_AddProperty");
|
||||||
|
|
||||||
if (AutoResolveFlag::IsSet(cx, obj))
|
if (AutoResolveFlag::IsSet(obj))
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
AutoCheckOperation aco(cx, self);
|
AutoCheckOperation aco(cx, self);
|
||||||
|
@ -428,7 +421,7 @@ ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||||
CPOW_LOG(("Calling CPOW_GetProperty (%s)...",
|
CPOW_LOG(("Calling CPOW_GetProperty (%s)...",
|
||||||
JSVAL_TO_CSTR(cx, id)));
|
JSVAL_TO_CSTR(cx, id)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_GetProperty");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_GetProperty");
|
||||||
|
|
||||||
|
@ -455,7 +448,7 @@ ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||||
CPOW_LOG(("Calling CPOW_SetProperty (%s)...",
|
CPOW_LOG(("Calling CPOW_SetProperty (%s)...",
|
||||||
JSVAL_TO_CSTR(cx, id)));
|
JSVAL_TO_CSTR(cx, id)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_SetProperty");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_SetProperty");
|
||||||
|
|
||||||
|
@ -484,7 +477,7 @@ ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||||
CPOW_LOG(("Calling CPOW_DelProperty (%s)...",
|
CPOW_LOG(("Calling CPOW_DelProperty (%s)...",
|
||||||
JSVAL_TO_CSTR(cx, id)));
|
JSVAL_TO_CSTR(cx, id)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_DelProperty");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_DelProperty");
|
||||||
|
|
||||||
|
@ -538,7 +531,7 @@ ObjectWrapperParent::NewEnumerateNext(JSContext* cx, jsval* statep, jsid* idp)
|
||||||
jsid_from_nsString(cx, out_id, idp))
|
jsid_from_nsString(cx, out_id, idp))
|
||||||
{
|
{
|
||||||
JSObject* obj = GetJSObject(cx);
|
JSObject* obj = GetJSObject(cx);
|
||||||
AutoResolveFlag arf(cx, obj);
|
AutoResolveFlag arf(obj);
|
||||||
return JS_DefinePropertyById(cx, obj, *idp, JSVAL_VOID, NULL, NULL,
|
return JS_DefinePropertyById(cx, obj, *idp, JSVAL_VOID, NULL, NULL,
|
||||||
JSPROP_ENUMERATE);
|
JSPROP_ENUMERATE);
|
||||||
}
|
}
|
||||||
|
@ -565,7 +558,7 @@ ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSObject *obj,
|
||||||
{
|
{
|
||||||
CPOW_LOG(("Calling CPOW_NewEnumerate..."));
|
CPOW_LOG(("Calling CPOW_NewEnumerate..."));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewEnumerate");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewEnumerate");
|
||||||
|
|
||||||
|
@ -591,7 +584,7 @@ ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||||
CPOW_LOG(("Calling CPOW_NewResolve (%s)...",
|
CPOW_LOG(("Calling CPOW_NewResolve (%s)...",
|
||||||
JSVAL_TO_CSTR(cx, id)));
|
JSVAL_TO_CSTR(cx, id)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewResolve");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewResolve");
|
||||||
|
|
||||||
|
@ -612,7 +605,7 @@ ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id,
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
if (*objp) {
|
if (*objp) {
|
||||||
AutoResolveFlag arf(cx, *objp);
|
AutoResolveFlag arf(*objp);
|
||||||
JS_DefinePropertyById(cx, *objp, id, JSVAL_VOID, NULL, NULL,
|
JS_DefinePropertyById(cx, *objp, id, JSVAL_VOID, NULL, NULL,
|
||||||
JSPROP_ENUMERATE);
|
JSPROP_ENUMERATE);
|
||||||
}
|
}
|
||||||
|
@ -626,7 +619,7 @@ ObjectWrapperParent::CPOW_Convert(JSContext *cx, JSObject *obj, JSType type,
|
||||||
CPOW_LOG(("Calling CPOW_Convert (to %s)...",
|
CPOW_LOG(("Calling CPOW_Convert (to %s)...",
|
||||||
JS_GetTypeName(cx, type)));
|
JS_GetTypeName(cx, type)));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Convert");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Convert");
|
||||||
|
|
||||||
|
@ -640,7 +633,7 @@ ObjectWrapperParent::CPOW_Finalize(JSContext* cx, JSObject* obj)
|
||||||
{
|
{
|
||||||
CPOW_LOG(("Calling CPOW_Finalize..."));
|
CPOW_LOG(("Calling CPOW_Finalize..."));
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (self) {
|
if (self) {
|
||||||
self->mObj = NULL;
|
self->mObj = NULL;
|
||||||
unused << ObjectWrapperParent::Send__delete__(self);
|
unused << ObjectWrapperParent::Send__delete__(self);
|
||||||
|
@ -657,13 +650,13 @@ ObjectWrapperParent::CPOW_Call(JSContext* cx, uintN argc, jsval* vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
ObjectWrapperParent* function =
|
ObjectWrapperParent* function =
|
||||||
Unwrap(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
Unwrap(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
||||||
if (!function)
|
if (!function)
|
||||||
return with_error(cx, JS_FALSE, "Could not unwrap CPOW function");
|
return with_error(cx, JS_FALSE, "Could not unwrap CPOW function");
|
||||||
|
|
||||||
AutoCheckOperation aco(cx, function);
|
AutoCheckOperation aco(cx, function);
|
||||||
|
|
||||||
ObjectWrapperParent* receiver = Unwrap(cx, thisobj);
|
ObjectWrapperParent* receiver = Unwrap(thisobj);
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
// Substitute child global for parent global object.
|
// Substitute child global for parent global object.
|
||||||
// TODO First make sure we're really replacing the global object?
|
// TODO First make sure we're really replacing the global object?
|
||||||
|
@ -692,7 +685,7 @@ ObjectWrapperParent::CPOW_Construct(JSContext* cx, uintN argc, jsval* vp)
|
||||||
{
|
{
|
||||||
CPOW_LOG(("Calling CPOW_Construct..."));
|
CPOW_LOG(("Calling CPOW_Construct..."));
|
||||||
|
|
||||||
ObjectWrapperParent* constructor = Unwrap(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
ObjectWrapperParent* constructor = Unwrap(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
||||||
if (!constructor)
|
if (!constructor)
|
||||||
return with_error(cx, JS_FALSE, "Could not unwrap CPOW constructor function");
|
return with_error(cx, JS_FALSE, "Could not unwrap CPOW constructor function");
|
||||||
|
|
||||||
|
@ -720,7 +713,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval
|
||||||
|
|
||||||
*bp = JS_FALSE;
|
*bp = JS_FALSE;
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_HasInstance");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_HasInstance");
|
||||||
|
|
||||||
|
@ -745,14 +738,14 @@ ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v,
|
||||||
|
|
||||||
*bp = JS_FALSE;
|
*bp = JS_FALSE;
|
||||||
|
|
||||||
ObjectWrapperParent* self = Unwrap(cx, obj);
|
ObjectWrapperParent* self = Unwrap(obj);
|
||||||
if (!self)
|
if (!self)
|
||||||
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Equality");
|
return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Equality");
|
||||||
|
|
||||||
if (JSVAL_IS_PRIMITIVE(*v))
|
if (JSVAL_IS_PRIMITIVE(*v))
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
ObjectWrapperParent* other = Unwrap(cx, JSVAL_TO_OBJECT(*v));
|
ObjectWrapperParent* other = Unwrap(JSVAL_TO_OBJECT(*v));
|
||||||
if (!other)
|
if (!other)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,10 @@ public:
|
||||||
|
|
||||||
JSObject* GetJSObject(JSContext* cx) const;
|
JSObject* GetJSObject(JSContext* cx) const;
|
||||||
|
|
||||||
|
JSObject* GetJSObjectOrNull() const {
|
||||||
|
return mObj;
|
||||||
|
}
|
||||||
|
|
||||||
jsval GetJSVal(JSContext* cx) const {
|
jsval GetJSVal(JSContext* cx) const {
|
||||||
return OBJECT_TO_JSVAL(GetJSObject(cx));
|
return OBJECT_TO_JSVAL(GetJSObject(cx));
|
||||||
}
|
}
|
||||||
|
@ -133,8 +137,7 @@ private:
|
||||||
static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from,
|
static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from,
|
||||||
jsval* to);
|
jsval* to);
|
||||||
static bool
|
static bool
|
||||||
JSObject_to_PObjectWrapperParent(JSContext* cx, JSObject* from,
|
JSObject_to_PObjectWrapperParent(JSObject* from, PObjectWrapperParent** to);
|
||||||
PObjectWrapperParent** to);
|
|
||||||
static bool
|
static bool
|
||||||
JSObject_from_PObjectWrapperParent(JSContext* cx,
|
JSObject_from_PObjectWrapperParent(JSContext* cx,
|
||||||
const PObjectWrapperParent* from,
|
const PObjectWrapperParent* from,
|
||||||
|
|
|
@ -706,16 +706,7 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
|
||||||
return NULL;
|
return NULL;
|
||||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||||
return NULL;
|
return NULL;
|
||||||
JS_BeginRequest(jsdc->dumbContext);
|
proto = JS_GetPrototype(obj);
|
||||||
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
|
||||||
if(!call) {
|
|
||||||
JS_EndRequest(jsdc->dumbContext);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
proto = JS_GetPrototype(jsdc->dumbContext, obj);
|
|
||||||
JS_LeaveCrossCompartmentCall(call);
|
|
||||||
JS_EndRequest(jsdc->dumbContext);
|
|
||||||
if(!proto)
|
if(!proto)
|
||||||
return NULL;
|
return NULL;
|
||||||
jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
|
jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
|
||||||
|
@ -775,6 +766,9 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
|
||||||
return NULL;
|
return NULL;
|
||||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
proto = JS_GetPrototype(obj);
|
||||||
|
if(!proto)
|
||||||
|
return NULL;
|
||||||
JS_BeginRequest(jsdc->dumbContext);
|
JS_BeginRequest(jsdc->dumbContext);
|
||||||
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
||||||
if(!call) {
|
if(!call) {
|
||||||
|
@ -782,13 +776,6 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
proto = JS_GetPrototype(jsdc->dumbContext,obj);
|
|
||||||
if(!proto)
|
|
||||||
{
|
|
||||||
JS_LeaveCrossCompartmentCall(call);
|
|
||||||
JS_EndRequest(jsdc->dumbContext);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ctor = JS_GetConstructor(jsdc->dumbContext,proto);
|
ctor = JS_GetConstructor(jsdc->dumbContext,proto);
|
||||||
JS_LeaveCrossCompartmentCall(call);
|
JS_LeaveCrossCompartmentCall(call);
|
||||||
JS_EndRequest(jsdc->dumbContext);
|
JS_EndRequest(jsdc->dumbContext);
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -350,7 +350,7 @@ struct ClosureInfo
|
||||||
|
|
||||||
bool IsCTypesGlobal(JSObject* obj);
|
bool IsCTypesGlobal(JSObject* obj);
|
||||||
|
|
||||||
JSCTypesCallbacks* GetCallbacks(JSContext* cx, JSObject* obj);
|
JSCTypesCallbacks* GetCallbacks(JSObject* obj);
|
||||||
|
|
||||||
JSBool InitTypeClasses(JSContext* cx, JSObject* parent);
|
JSBool InitTypeClasses(JSContext* cx, JSObject* parent);
|
||||||
|
|
||||||
|
@ -456,39 +456,39 @@ namespace CType {
|
||||||
|
|
||||||
bool IsCType(JSObject* obj);
|
bool IsCType(JSObject* obj);
|
||||||
bool IsCTypeProto(JSObject* obj);
|
bool IsCTypeProto(JSObject* obj);
|
||||||
TypeCode GetTypeCode(JSContext* cx, JSObject* typeObj);
|
TypeCode GetTypeCode(JSObject* typeObj);
|
||||||
bool TypesEqual(JSContext* cx, JSObject* t1, JSObject* t2);
|
bool TypesEqual(JSObject* t1, JSObject* t2);
|
||||||
size_t GetSize(JSContext* cx, JSObject* obj);
|
size_t GetSize(JSObject* obj);
|
||||||
bool GetSafeSize(JSContext* cx, JSObject* obj, size_t* result);
|
bool GetSafeSize(JSObject* obj, size_t* result);
|
||||||
bool IsSizeDefined(JSContext* cx, JSObject* obj);
|
bool IsSizeDefined(JSObject* obj);
|
||||||
size_t GetAlignment(JSContext* cx, JSObject* obj);
|
size_t GetAlignment(JSObject* obj);
|
||||||
ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
|
ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
|
||||||
JSString* GetName(JSContext* cx, JSObject* obj);
|
JSString* GetName(JSContext* cx, JSObject* obj);
|
||||||
JSObject* GetProtoFromCtor(JSContext* cx, JSObject* obj, CTypeProtoSlot slot);
|
JSObject* GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot);
|
||||||
JSObject* GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot);
|
JSObject* GetProtoFromType(JSObject* obj, CTypeProtoSlot slot);
|
||||||
JSCTypesCallbacks* GetCallbacksFromType(JSContext* cx, JSObject* obj);
|
JSCTypesCallbacks* GetCallbacksFromType(JSObject* obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PointerType {
|
namespace PointerType {
|
||||||
JSObject* CreateInternal(JSContext* cx, JSObject* baseType);
|
JSObject* CreateInternal(JSContext* cx, JSObject* baseType);
|
||||||
|
|
||||||
JSObject* GetBaseType(JSContext* cx, JSObject* obj);
|
JSObject* GetBaseType(JSObject* obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ArrayType {
|
namespace ArrayType {
|
||||||
JSObject* CreateInternal(JSContext* cx, JSObject* baseType, size_t length,
|
JSObject* CreateInternal(JSContext* cx, JSObject* baseType, size_t length,
|
||||||
bool lengthDefined);
|
bool lengthDefined);
|
||||||
|
|
||||||
JSObject* GetBaseType(JSContext* cx, JSObject* obj);
|
JSObject* GetBaseType(JSObject* obj);
|
||||||
size_t GetLength(JSContext* cx, JSObject* obj);
|
size_t GetLength(JSObject* obj);
|
||||||
bool GetSafeLength(JSContext* cx, JSObject* obj, size_t* result);
|
bool GetSafeLength(JSObject* obj, size_t* result);
|
||||||
ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
|
ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace StructType {
|
namespace StructType {
|
||||||
JSBool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj);
|
JSBool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj);
|
||||||
|
|
||||||
const FieldInfoHash* GetFieldInfo(JSContext* cx, JSObject* obj);
|
const FieldInfoHash* GetFieldInfo(JSObject* obj);
|
||||||
const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString *name);
|
const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString *name);
|
||||||
JSObject* BuildFieldsArray(JSContext* cx, JSObject* obj);
|
JSObject* BuildFieldsArray(JSContext* cx, JSObject* obj);
|
||||||
ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
|
ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
|
||||||
|
@ -501,9 +501,8 @@ namespace FunctionType {
|
||||||
JSObject* ConstructWithObject(JSContext* cx, JSObject* typeObj,
|
JSObject* ConstructWithObject(JSContext* cx, JSObject* typeObj,
|
||||||
JSObject* refObj, PRFuncPtr fnptr, JSObject* result);
|
JSObject* refObj, PRFuncPtr fnptr, JSObject* result);
|
||||||
|
|
||||||
FunctionInfo* GetFunctionInfo(JSContext* cx, JSObject* obj);
|
FunctionInfo* GetFunctionInfo(JSObject* obj);
|
||||||
JSObject* GetLibrary(JSContext* cx, JSObject* obj);
|
void BuildSymbolName(JSString* name, JSObject* typeObj,
|
||||||
void BuildSymbolName(JSContext* cx, JSString* name, JSObject* typeObj,
|
|
||||||
AutoCString& result);
|
AutoCString& result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +515,8 @@ namespace CData {
|
||||||
JSObject* Create(JSContext* cx, JSObject* typeObj, JSObject* refObj,
|
JSObject* Create(JSContext* cx, JSObject* typeObj, JSObject* refObj,
|
||||||
void* data, bool ownResult);
|
void* data, bool ownResult);
|
||||||
|
|
||||||
JSObject* GetCType(JSContext* cx, JSObject* dataObj);
|
JSObject* GetCType(JSObject* dataObj);
|
||||||
void* GetData(JSContext* cx, JSObject* dataObj);
|
void* GetData(JSObject* dataObj);
|
||||||
bool IsCData(JSObject* obj);
|
bool IsCData(JSObject* obj);
|
||||||
bool IsCDataProto(JSObject* obj);
|
bool IsCDataProto(JSObject* obj);
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,7 @@ Library::Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks)
|
||||||
js::AutoObjectRooter root(cx, libraryObj);
|
js::AutoObjectRooter root(cx, libraryObj);
|
||||||
|
|
||||||
// initialize the library
|
// initialize the library
|
||||||
if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL)))
|
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// attach API functions
|
// attach API functions
|
||||||
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
|
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
|
||||||
|
@ -187,9 +186,7 @@ Library::Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// stash the library
|
// stash the library
|
||||||
if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY,
|
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(library));
|
||||||
PRIVATE_TO_JSVAL(library)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return libraryObj;
|
return libraryObj;
|
||||||
}
|
}
|
||||||
|
@ -201,12 +198,11 @@ Library::IsLibrary(JSObject* obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRLibrary*
|
PRLibrary*
|
||||||
Library::GetLibrary(JSContext* cx, JSObject* obj)
|
Library::GetLibrary(JSObject* obj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(IsLibrary(obj));
|
JS_ASSERT(IsLibrary(obj));
|
||||||
|
|
||||||
jsval slot;
|
jsval slot = JS_GetReservedSlot(obj, SLOT_LIBRARY);
|
||||||
JS_GetReservedSlot(cx, obj, SLOT_LIBRARY, &slot);
|
|
||||||
return static_cast<PRLibrary*>(JSVAL_TO_PRIVATE(slot));
|
return static_cast<PRLibrary*>(JSVAL_TO_PRIVATE(slot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +210,7 @@ void
|
||||||
Library::Finalize(JSContext* cx, JSObject* obj)
|
Library::Finalize(JSContext* cx, JSObject* obj)
|
||||||
{
|
{
|
||||||
// unload the library
|
// unload the library
|
||||||
PRLibrary* library = GetLibrary(cx, obj);
|
PRLibrary* library = GetLibrary(obj);
|
||||||
if (library)
|
if (library)
|
||||||
PR_UnloadLibrary(library);
|
PR_UnloadLibrary(library);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +229,7 @@ Library::Open(JSContext* cx, uintN argc, jsval *vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject* library = Create(cx, JS_ARGV(cx, vp)[0], GetCallbacks(cx, ctypesObj));
|
JSObject* library = Create(cx, JS_ARGV(cx, vp)[0], GetCallbacks(ctypesObj));
|
||||||
if (!library)
|
if (!library)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
|
@ -257,7 +253,7 @@ Library::Close(JSContext* cx, uintN argc, jsval* vp)
|
||||||
|
|
||||||
// delete our internal objects
|
// delete our internal objects
|
||||||
Finalize(cx, obj);
|
Finalize(cx, obj);
|
||||||
JS_SetReservedSlot(cx, obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
|
JS_SetReservedSlot(obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
|
||||||
|
|
||||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
@ -272,7 +268,7 @@ Library::Declare(JSContext* cx, uintN argc, jsval* vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRLibrary* library = GetLibrary(cx, obj);
|
PRLibrary* library = GetLibrary(obj);
|
||||||
if (!library) {
|
if (!library) {
|
||||||
JS_ReportError(cx, "library not open");
|
JS_ReportError(cx, "library not open");
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -322,15 +318,15 @@ Library::Declare(JSContext* cx, uintN argc, jsval* vp)
|
||||||
// Case 2).
|
// Case 2).
|
||||||
if (JSVAL_IS_PRIMITIVE(argv[1]) ||
|
if (JSVAL_IS_PRIMITIVE(argv[1]) ||
|
||||||
!CType::IsCType(JSVAL_TO_OBJECT(argv[1])) ||
|
!CType::IsCType(JSVAL_TO_OBJECT(argv[1])) ||
|
||||||
!CType::IsSizeDefined(cx, JSVAL_TO_OBJECT(argv[1]))) {
|
!CType::IsSizeDefined(JSVAL_TO_OBJECT(argv[1]))) {
|
||||||
JS_ReportError(cx, "second argument must be a type of defined size");
|
JS_ReportError(cx, "second argument must be a type of defined size");
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeObj = JSVAL_TO_OBJECT(argv[1]);
|
typeObj = JSVAL_TO_OBJECT(argv[1]);
|
||||||
if (CType::GetTypeCode(cx, typeObj) == TYPE_pointer) {
|
if (CType::GetTypeCode(typeObj) == TYPE_pointer) {
|
||||||
fnObj = PointerType::GetBaseType(cx, typeObj);
|
fnObj = PointerType::GetBaseType(typeObj);
|
||||||
isFunction = fnObj && CType::GetTypeCode(cx, fnObj) == TYPE_function;
|
isFunction = fnObj && CType::GetTypeCode(fnObj) == TYPE_function;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +336,7 @@ Library::Declare(JSContext* cx, uintN argc, jsval* vp)
|
||||||
AutoCString symbol;
|
AutoCString symbol;
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
// Build the symbol, with mangling if necessary.
|
// Build the symbol, with mangling if necessary.
|
||||||
FunctionType::BuildSymbolName(cx, nameStr, fnObj, symbol);
|
FunctionType::BuildSymbolName(nameStr, fnObj, symbol);
|
||||||
AppendString(symbol, "\0");
|
AppendString(symbol, "\0");
|
||||||
|
|
||||||
// Look up the function symbol.
|
// Look up the function symbol.
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Library
|
||||||
JSObject* Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks);
|
JSObject* Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks);
|
||||||
|
|
||||||
bool IsLibrary(JSObject* obj);
|
bool IsLibrary(JSObject* obj);
|
||||||
PRLibrary* GetLibrary(JSContext* cx, JSObject* obj);
|
PRLibrary* GetLibrary(JSObject* obj);
|
||||||
|
|
||||||
JSBool Open(JSContext* cx, uintN argc, jsval* vp);
|
JSBool Open(JSContext* cx, uintN argc, jsval* vp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ END_TEST(selfTest_NaNsAreSame)
|
||||||
|
|
||||||
BEGIN_TEST(selfTest_globalHasNoParent)
|
BEGIN_TEST(selfTest_globalHasNoParent)
|
||||||
{
|
{
|
||||||
CHECK(JS_GetParent(cx, global) == NULL);
|
CHECK(JS_GetParent(global) == NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
END_TEST(selfTest_globalHasNoParent)
|
END_TEST(selfTest_globalHasNoParent)
|
||||||
|
|
|
@ -30,8 +30,8 @@ BEGIN_TEST(testResolveRecursion)
|
||||||
CHECK(obj1);
|
CHECK(obj1);
|
||||||
obj2 = JS_NewObject(cx, &my_resolve_class, NULL, NULL);
|
obj2 = JS_NewObject(cx, &my_resolve_class, NULL, NULL);
|
||||||
CHECK(obj2);
|
CHECK(obj2);
|
||||||
CHECK(JS_SetPrivate(cx, obj1, this));
|
JS_SetPrivate(obj1, this);
|
||||||
CHECK(JS_SetPrivate(cx, obj2, this));
|
JS_SetPrivate(obj2, this);
|
||||||
|
|
||||||
CHECK(JS_DefineProperty(cx, global, "obj1", OBJECT_TO_JSVAL(obj1), NULL, NULL, 0));
|
CHECK(JS_DefineProperty(cx, global, "obj1", OBJECT_TO_JSVAL(obj1), NULL, NULL, 0));
|
||||||
CHECK(JS_DefineProperty(cx, global, "obj2", OBJECT_TO_JSVAL(obj2), NULL, NULL, 0));
|
CHECK(JS_DefineProperty(cx, global, "obj2", OBJECT_TO_JSVAL(obj2), NULL, NULL, 0));
|
||||||
|
@ -127,7 +127,7 @@ doResolve(JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
||||||
static JSBool
|
static JSBool
|
||||||
my_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
my_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
||||||
{
|
{
|
||||||
return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(cx, obj))->
|
return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(obj))->
|
||||||
doResolve(obj, id, flags, objp);
|
doResolve(obj, id, flags, objp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3156,18 +3156,17 @@ JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void *)
|
JS_PUBLIC_API(void *)
|
||||||
JS_GetPrivate(JSContext *cx, JSObject *obj)
|
JS_GetPrivate(JSObject *obj)
|
||||||
{
|
{
|
||||||
/* This function can be called by a finalizer. */
|
/* This function can be called by a finalizer. */
|
||||||
return obj->getPrivate();
|
return obj->getPrivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(void)
|
||||||
JS_SetPrivate(JSContext *cx, JSObject *obj, void *data)
|
JS_SetPrivate(JSObject *obj, void *data)
|
||||||
{
|
{
|
||||||
/* This function can be called by a finalizer. */
|
/* This function can be called by a finalizer. */
|
||||||
obj->setPrivate(data);
|
obj->setPrivate(data);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void *)
|
JS_PUBLIC_API(void *)
|
||||||
|
@ -3179,10 +3178,8 @@ JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSObject *)
|
JS_PUBLIC_API(JSObject *)
|
||||||
JS_GetPrototype(JSContext *cx, JSObject *obj)
|
JS_GetPrototype(JSObject *obj)
|
||||||
{
|
{
|
||||||
CHECK_REQUEST(cx);
|
|
||||||
assertSameCompartment(cx, obj);
|
|
||||||
return obj->getProto();
|
return obj->getProto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3196,10 +3193,9 @@ JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSObject *)
|
JS_PUBLIC_API(JSObject *)
|
||||||
JS_GetParent(JSContext *cx, JSObject *obj)
|
JS_GetParent(JSObject *obj)
|
||||||
{
|
{
|
||||||
JS_ASSERT(!obj->isScope());
|
JS_ASSERT(!obj->isScope());
|
||||||
assertSameCompartment(cx, obj);
|
|
||||||
return obj->getParent();
|
return obj->getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4405,22 +4401,23 @@ JS_ElementIteratorStub(JSContext *cx, JSObject *obj, JSBool keysonly)
|
||||||
return JS_NewElementIterator(cx, obj);
|
return JS_NewElementIterator(cx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(jsval)
|
||||||
JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp)
|
JS_GetReservedSlot(JSObject *obj, uint32_t index)
|
||||||
{
|
{
|
||||||
/* This function can be called by a finalizer. */
|
if (!obj->isNative())
|
||||||
CHECK_REQUEST(cx);
|
return UndefinedValue();
|
||||||
assertSameCompartment(cx, obj);
|
|
||||||
return js_GetReservedSlot(cx, obj, index, vp);
|
return GetReservedSlot(obj, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(void)
|
||||||
JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval v)
|
JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v)
|
||||||
{
|
{
|
||||||
AssertNoGC(cx);
|
if (!obj->isNative())
|
||||||
CHECK_REQUEST(cx);
|
return;
|
||||||
assertSameCompartment(cx, obj, v);
|
|
||||||
return js_SetReservedSlot(cx, obj, index, v);
|
SetReservedSlot(obj, index, v);
|
||||||
|
GCPoke(obj->compartment()->rt, NullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSObject *)
|
JS_PUBLIC_API(JSObject *)
|
||||||
|
|
|
@ -2773,8 +2773,8 @@ typedef struct JSCTypesCallbacks JSCTypesCallbacks;
|
||||||
* may safely be altered after calling this function and without having
|
* may safely be altered after calling this function and without having
|
||||||
* to call this function again.
|
* to call this function again.
|
||||||
*/
|
*/
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(void)
|
||||||
JS_SetCTypesCallbacks(JSContext *cx, JSObject *ctypesObj, JSCTypesCallbacks *callbacks);
|
JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef JSBool
|
typedef JSBool
|
||||||
|
@ -3620,23 +3620,23 @@ extern JS_PUBLIC_API(JSBool)
|
||||||
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(void *)
|
extern JS_PUBLIC_API(void *)
|
||||||
JS_GetPrivate(JSContext *cx, JSObject *obj);
|
JS_GetPrivate(JSObject *obj);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(void)
|
||||||
JS_SetPrivate(JSContext *cx, JSObject *obj, void *data);
|
JS_SetPrivate(JSObject *obj, void *data);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(void *)
|
extern JS_PUBLIC_API(void *)
|
||||||
JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp,
|
JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp,
|
||||||
jsval *argv);
|
jsval *argv);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSObject *)
|
extern JS_PUBLIC_API(JSObject *)
|
||||||
JS_GetPrototype(JSContext *cx, JSObject *obj);
|
JS_GetPrototype(JSObject *obj);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(JSBool)
|
||||||
JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto);
|
JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSObject *)
|
extern JS_PUBLIC_API(JSObject *)
|
||||||
JS_GetParent(JSContext *cx, JSObject *obj);
|
JS_GetParent(JSObject *obj);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(JSBool)
|
||||||
JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
|
JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
|
||||||
|
@ -4025,11 +4025,11 @@ extern JS_PUBLIC_API(JSBool)
|
||||||
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||||
jsval *vp, uintN *attrsp);
|
jsval *vp, uintN *attrsp);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(jsval)
|
||||||
JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp);
|
JS_GetReservedSlot(JSObject *obj, uint32_t index);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(void)
|
||||||
JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval v);
|
JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ GetGCKindSlots(AllocKind thingKind, Class *clasp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
GCPoke(JSContext *cx, Value oldval)
|
GCPoke(JSRuntime *rt, Value oldval)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Since we're forcing a GC from JS_GC anyway, don't bother wasting cycles
|
* Since we're forcing a GC from JS_GC anyway, don't bother wasting cycles
|
||||||
|
@ -203,15 +203,15 @@ GCPoke(JSContext *cx, Value oldval)
|
||||||
* ignored", etc.
|
* ignored", etc.
|
||||||
*/
|
*/
|
||||||
#if 1
|
#if 1
|
||||||
cx->runtime->gcPoke = JS_TRUE;
|
rt->gcPoke = true;
|
||||||
#else
|
#else
|
||||||
cx->runtime->gcPoke = oldval.isGCThing();
|
rt->gcPoke = oldval.isGCThing();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef JS_GC_ZEAL
|
#ifdef JS_GC_ZEAL
|
||||||
/* Schedule a GC to happen "soon" after a GC poke. */
|
/* Schedule a GC to happen "soon" after a GC poke. */
|
||||||
if (cx->runtime->gcZeal() >= js::gc::ZealPokeThreshold)
|
if (rt->gcZeal() >= js::gc::ZealPokeThreshold)
|
||||||
cx->runtime->gcNextScheduled = 1;
|
rt->gcNextScheduled = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3595,8 +3595,7 @@ DefineStandardSlot(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
|
||||||
const Shape *shape = obj->nativeLookup(cx, id);
|
const Shape *shape = obj->nativeLookup(cx, id);
|
||||||
if (!shape) {
|
if (!shape) {
|
||||||
uint32_t slot = 2 * JSProto_LIMIT + key;
|
uint32_t slot = 2 * JSProto_LIMIT + key;
|
||||||
if (!js_SetReservedSlot(cx, obj, slot, v))
|
SetReservedSlot(obj, slot, v);
|
||||||
return false;
|
|
||||||
if (!obj->addProperty(cx, id, JS_PropertyStub, JS_StrictPropertyStub, slot, attrs, 0, 0))
|
if (!obj->addProperty(cx, id, JS_PropertyStub, JS_StrictPropertyStub, slot, attrs, 0, 0))
|
||||||
return false;
|
return false;
|
||||||
AddTypePropertyId(cx, obj, id, v);
|
AddTypePropertyId(cx, obj, id, v);
|
||||||
|
@ -3612,15 +3611,15 @@ DefineStandardSlot(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj, JSObject *proto)
|
SetClassObject(JSObject *obj, JSProtoKey key, JSObject *cobj, JSObject *proto)
|
||||||
{
|
{
|
||||||
JS_ASSERT(!obj->getParent());
|
JS_ASSERT(!obj->getParent());
|
||||||
if (!obj->isGlobal())
|
if (!obj->isGlobal())
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
return js_SetReservedSlot(cx, obj, key, ObjectOrNullValue(cobj)) &&
|
SetReservedSlot(obj, key, ObjectOrNullValue(cobj));
|
||||||
js_SetReservedSlot(cx, obj, JSProto_LIMIT + key, ObjectOrNullValue(proto));
|
SetReservedSlot(obj, JSProto_LIMIT + key, ObjectOrNullValue(proto));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3722,8 +3721,7 @@ DefineConstructorAndPrototype(JSContext *cx, HandleObject obj, JSProtoKey key, H
|
||||||
* fail if it tries to do a reentrant reconstruction of the class.
|
* fail if it tries to do a reentrant reconstruction of the class.
|
||||||
*/
|
*/
|
||||||
if (key != JSProto_Null) {
|
if (key != JSProto_Null) {
|
||||||
if (!SetClassObject(cx, obj, key, fun, proto))
|
SetClassObject(obj, key, fun, proto);
|
||||||
goto bad;
|
|
||||||
cached = true;
|
cached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3761,8 +3759,8 @@ DefineConstructorAndPrototype(JSContext *cx, HandleObject obj, JSProtoKey key, H
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a standard class, cache its prototype. */
|
/* If this is a standard class, cache its prototype. */
|
||||||
if (!cached && key != JSProto_Null && !SetClassObject(cx, obj, key, ctor, proto))
|
if (!cached && key != JSProto_Null)
|
||||||
goto bad;
|
SetClassObject(obj, key, ctor, proto);
|
||||||
|
|
||||||
if (ctorp)
|
if (ctorp)
|
||||||
*ctorp = ctor;
|
*ctorp = ctor;
|
||||||
|
@ -5779,7 +5777,7 @@ js_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool stri
|
||||||
|
|
||||||
if (shape->hasSlot()) {
|
if (shape->hasSlot()) {
|
||||||
const Value &v = obj->nativeGetSlot(shape->slot());
|
const Value &v = obj->nativeGetSlot(shape->slot());
|
||||||
GCPoke(cx, v);
|
GCPoke(cx->runtime, v);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete is rare enough that we can take the hit of checking for an
|
* Delete is rare enough that we can take the hit of checking for an
|
||||||
|
@ -6355,31 +6353,6 @@ js_ClearNative(JSContext *cx, JSObject *obj)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t slot, Value *vp)
|
|
||||||
{
|
|
||||||
if (!obj->isNative()) {
|
|
||||||
vp->setUndefined();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_ASSERT(slot < JSSLOT_FREE(obj->getClass()));
|
|
||||||
*vp = obj->getSlot(slot);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t slot, const Value &v)
|
|
||||||
{
|
|
||||||
if (!obj->isNative())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
JS_ASSERT(slot < JSSLOT_FREE(obj->getClass()));
|
|
||||||
obj->setSlot(slot, v);
|
|
||||||
GCPoke(cx, NullValue());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ObjectElements emptyObjectHeader(0, 0);
|
static ObjectElements emptyObjectHeader(0, 0);
|
||||||
HeapValue *js::emptyObjectElements =
|
HeapValue *js::emptyObjectElements =
|
||||||
(HeapValue *) (uintptr_t(&emptyObjectHeader) + sizeof(ObjectElements));
|
(HeapValue *) (uintptr_t(&emptyObjectHeader) + sizeof(ObjectElements));
|
||||||
|
|
|
@ -1990,12 +1990,6 @@ js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
|
||||||
extern bool
|
extern bool
|
||||||
js_ClearNative(JSContext *cx, JSObject *obj);
|
js_ClearNative(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
extern bool
|
|
||||||
js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, js::Value *vp);
|
|
||||||
|
|
||||||
extern bool
|
|
||||||
js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, const js::Value &v);
|
|
||||||
|
|
||||||
extern JSBool
|
extern JSBool
|
||||||
js_ReportGetterOnlyAssignment(JSContext *cx);
|
js_ReportGetterOnlyAssignment(JSContext *cx);
|
||||||
|
|
||||||
|
|
|
@ -7718,8 +7718,7 @@ js_GetAnyName(JSContext *cx, jsid *idp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
v.setObject(*obj);
|
v.setObject(*obj);
|
||||||
if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v))
|
SetReservedSlot(global, JSProto_AnyName, v);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
*idp = OBJECT_TO_JSID(&v.toObject());
|
*idp = OBJECT_TO_JSID(&v.toObject());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -71,7 +71,7 @@ pm_construct(JSContext* cx, uintN argc, jsval* vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_SetPrivate(cx, obj, p);
|
JS_SetPrivate(obj, p);
|
||||||
*vp = OBJECT_TO_JSVAL(obj);
|
*vp = OBJECT_TO_JSVAL(obj);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ pm_construct(JSContext* cx, uintN argc, jsval* vp)
|
||||||
static void
|
static void
|
||||||
pm_finalize(JSContext* cx, JSObject* obj)
|
pm_finalize(JSContext* cx, JSObject* obj)
|
||||||
{
|
{
|
||||||
cx->delete_((PerfMeasurement*) JS_GetPrivate(cx, obj));
|
cx->delete_((PerfMeasurement*) JS_GetPrivate(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Property access
|
// Property access
|
||||||
|
|
|
@ -1630,7 +1630,7 @@ ValueToScript(JSContext *cx, jsval v, JSFunction **funp = NULL)
|
||||||
JSClass *clasp = JS_GetClass(obj);
|
JSClass *clasp = JS_GetClass(obj);
|
||||||
|
|
||||||
if (clasp == Jsvalify(&GeneratorClass)) {
|
if (clasp == Jsvalify(&GeneratorClass)) {
|
||||||
if (JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj)) {
|
if (JSGenerator *gen = (JSGenerator *) JS_GetPrivate(obj)) {
|
||||||
fun = gen->floatingFrame()->fun();
|
fun = gen->floatingFrame()->fun();
|
||||||
script = fun->script();
|
script = fun->script();
|
||||||
}
|
}
|
||||||
|
@ -2787,7 +2787,7 @@ Clone(JSContext *cx, uintN argc, jsval *vp)
|
||||||
if (!JS_ValueToObject(cx, argv[1], &parent))
|
if (!JS_ValueToObject(cx, argv[1], &parent))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
} else {
|
} else {
|
||||||
parent = JS_GetParent(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
parent = JS_GetParent(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
clone = JS_CloneFunctionObject(cx, funobj, parent);
|
clone = JS_CloneFunctionObject(cx, funobj, parent);
|
||||||
|
@ -3214,16 +3214,14 @@ CopyProperty(JSContext *cx, JSObject *obj, JSObject *referent, jsid id,
|
||||||
static JSBool
|
static JSBool
|
||||||
resolver_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
resolver_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
|
||||||
{
|
{
|
||||||
jsval v;
|
jsval v = JS_GetReservedSlot(obj, 0);
|
||||||
JS_ALWAYS_TRUE(JS_GetReservedSlot(cx, obj, 0, &v));
|
|
||||||
return CopyProperty(cx, obj, JSVAL_TO_OBJECT(v), id, flags, objp);
|
return CopyProperty(cx, obj, JSVAL_TO_OBJECT(v), id, flags, objp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
resolver_enumerate(JSContext *cx, JSObject *obj)
|
resolver_enumerate(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
jsval v;
|
jsval v = JS_GetReservedSlot(obj, 0);
|
||||||
JS_ALWAYS_TRUE(JS_GetReservedSlot(cx, obj, 0, &v));
|
|
||||||
JSObject *referent = JSVAL_TO_OBJECT(v);
|
JSObject *referent = JSVAL_TO_OBJECT(v);
|
||||||
|
|
||||||
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
|
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
|
||||||
|
@ -3254,11 +3252,11 @@ Resolver(JSContext *cx, uintN argc, jsval *vp)
|
||||||
|
|
||||||
JSObject *result = (argc > 1
|
JSObject *result = (argc > 1
|
||||||
? JS_NewObjectWithGivenProto
|
? JS_NewObjectWithGivenProto
|
||||||
: JS_NewObject)(cx, &resolver_class, proto, JS_GetParent(cx, referent));
|
: JS_NewObject)(cx, &resolver_class, proto, JS_GetParent(referent));
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JS_ALWAYS_TRUE(JS_SetReservedSlot(cx, result, 0, OBJECT_TO_JSVAL(referent)));
|
JS_SetReservedSlot(result, 0, OBJECT_TO_JSVAL(referent));
|
||||||
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
|
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3581,7 +3579,7 @@ Parent(JSContext *cx, uintN argc, jsval *vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *parent = JS_GetParent(cx, JSVAL_TO_OBJECT(v));
|
JSObject *parent = JS_GetParent(JSVAL_TO_OBJECT(v));
|
||||||
*vp = OBJECT_TO_JSVAL(parent);
|
*vp = OBJECT_TO_JSVAL(parent);
|
||||||
|
|
||||||
/* Outerize if necessary. Embrace the ugliness! */
|
/* Outerize if necessary. Embrace the ugliness! */
|
||||||
|
@ -4526,10 +4524,10 @@ its_finalize(JSContext *cx, JSObject *obj)
|
||||||
jsval *rootedVal;
|
jsval *rootedVal;
|
||||||
if (its_noisy)
|
if (its_noisy)
|
||||||
fprintf(gOutFile, "finalizing it\n");
|
fprintf(gOutFile, "finalizing it\n");
|
||||||
rootedVal = (jsval *) JS_GetPrivate(cx, obj);
|
rootedVal = (jsval *) JS_GetPrivate(obj);
|
||||||
if (rootedVal) {
|
if (rootedVal) {
|
||||||
JS_RemoveValueRoot(cx, rootedVal);
|
JS_RemoveValueRoot(cx, rootedVal);
|
||||||
JS_SetPrivate(cx, obj, NULL);
|
JS_SetPrivate(obj, NULL);
|
||||||
delete rootedVal;
|
delete rootedVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4546,7 +4544,7 @@ static JSBool
|
||||||
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||||
{
|
{
|
||||||
if (JS_GetClass(obj) == &its_class) {
|
if (JS_GetClass(obj) == &its_class) {
|
||||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
jsval *val = (jsval *) JS_GetPrivate(obj);
|
||||||
*vp = val ? *val : JSVAL_VOID;
|
*vp = val ? *val : JSVAL_VOID;
|
||||||
} else {
|
} else {
|
||||||
*vp = JSVAL_VOID;
|
*vp = JSVAL_VOID;
|
||||||
|
@ -4561,7 +4559,7 @@ its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
||||||
if (JS_GetClass(obj) != &its_class)
|
if (JS_GetClass(obj) != &its_class)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
jsval *val = (jsval *) JS_GetPrivate(obj);
|
||||||
if (val) {
|
if (val) {
|
||||||
*val = *vp;
|
*val = *vp;
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
@ -4578,11 +4576,7 @@ its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetPrivate(cx, obj, (void*)val)) {
|
JS_SetPrivate(obj, (void*)val);
|
||||||
JS_RemoveValueRoot(cx, val);
|
|
||||||
delete val;
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*val = *vp;
|
*val = *vp;
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
@ -4895,7 +4889,7 @@ env_enumerate(JSContext *cx, JSObject *obj)
|
||||||
if (reflected)
|
if (reflected)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
for (evp = (char **)JS_GetPrivate(cx, obj); (name = *evp) != NULL; evp++) {
|
for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != NULL; evp++) {
|
||||||
value = strchr(name, '=');
|
value = strchr(name, '=');
|
||||||
if (!value)
|
if (!value)
|
||||||
continue;
|
continue;
|
||||||
|
@ -5198,8 +5192,9 @@ Shell(JSContext *cx, OptionParser *op, char **envp)
|
||||||
JS_SetGlobalObject(cx, glob);
|
JS_SetGlobalObject(cx, glob);
|
||||||
|
|
||||||
JSObject *envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
|
JSObject *envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
|
||||||
if (!envobj || !JS_SetPrivate(cx, envobj, envp))
|
if (!envobj)
|
||||||
return 1;
|
return 1;
|
||||||
|
JS_SetPrivate(envobj, envp);
|
||||||
|
|
||||||
#ifdef JSDEBUGGER
|
#ifdef JSDEBUGGER
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -489,10 +489,11 @@ class ThreadPool
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, &jsClass, NULL, NULL);
|
JSObject *obj = JS_NewObject(cx, &jsClass, NULL, NULL);
|
||||||
if (!obj || !JS_SetPrivate(cx, obj, tp)) {
|
if (!obj) {
|
||||||
delete tp;
|
delete tp;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
JS_SetPrivate(obj, tp);
|
||||||
tp->obj = obj;
|
tp->obj = obj;
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +567,7 @@ class ThreadPool
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void jsTraceThreadPool(JSTracer *trc, JSObject *obj) {
|
static void jsTraceThreadPool(JSTracer *trc, JSObject *obj) {
|
||||||
ThreadPool *tp = unwrap(trc->context, obj);
|
ThreadPool *tp = unwrap(obj);
|
||||||
if (tp->mq) {
|
if (tp->mq) {
|
||||||
tp->mq->traceChildren(trc);
|
tp->mq->traceChildren(trc);
|
||||||
tp->wq->trace(trc);
|
tp->wq->trace(trc);
|
||||||
|
@ -575,14 +576,14 @@ class ThreadPool
|
||||||
|
|
||||||
|
|
||||||
static void jsFinalize(JSContext *cx, JSObject *obj) {
|
static void jsFinalize(JSContext *cx, JSObject *obj) {
|
||||||
if (ThreadPool *tp = unwrap(cx, obj))
|
if (ThreadPool *tp = unwrap(obj))
|
||||||
delete tp;
|
delete tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ThreadPool *unwrap(JSContext *cx, JSObject *obj) {
|
static ThreadPool *unwrap(JSObject *obj) {
|
||||||
JS_ASSERT(JS_GetClass(obj) == &jsClass);
|
JS_ASSERT(JS_GetClass(obj) == &jsClass);
|
||||||
return (ThreadPool *) JS_GetPrivate(cx, obj);
|
return (ThreadPool *) JS_GetPrivate(obj);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -626,10 +627,10 @@ class Worker MOZ_FINAL : public WorkerParent
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->object = obj;
|
this->object = obj;
|
||||||
lock = PR_NewLock();
|
lock = PR_NewLock();
|
||||||
return lock &&
|
if (!lock || !createRuntime(parentcx) || !createContext(parentcx, parent))
|
||||||
createRuntime(parentcx) &&
|
return false;
|
||||||
createContext(parentcx, parent) &&
|
JS_SetPrivate(obj, this);
|
||||||
JS_SetPrivate(parentcx, obj, this);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool createRuntime(JSContext *parentcx) {
|
bool createRuntime(JSContext *parentcx) {
|
||||||
|
@ -701,7 +702,7 @@ class Worker MOZ_FINAL : public WorkerParent
|
||||||
|
|
||||||
static void jsTraceWorker(JSTracer *trc, JSObject *obj) {
|
static void jsTraceWorker(JSTracer *trc, JSObject *obj) {
|
||||||
JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
|
JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
|
||||||
if (Worker *w = (Worker *) JS_GetPrivate(trc->context, obj)) {
|
if (Worker *w = (Worker *) JS_GetPrivate(obj)) {
|
||||||
w->parent->trace(trc);
|
w->parent->trace(trc);
|
||||||
w->events.trace(trc);
|
w->events.trace(trc);
|
||||||
if (w->current)
|
if (w->current)
|
||||||
|
@ -712,7 +713,7 @@ class Worker MOZ_FINAL : public WorkerParent
|
||||||
|
|
||||||
static void jsFinalize(JSContext *cx, JSObject *obj) {
|
static void jsFinalize(JSContext *cx, JSObject *obj) {
|
||||||
JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
|
JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
|
||||||
if (Worker *w = (Worker *) JS_GetPrivate(cx, obj))
|
if (Worker *w = (Worker *) JS_GetPrivate(obj))
|
||||||
delete w;
|
delete w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2637,11 +2637,9 @@ DebuggerFrame_getArguments(JSContext *cx, uintN argc, Value *vp)
|
||||||
if (!js_GetClassPrototype(cx, global, JSProto_Array, &proto))
|
if (!js_GetClassPrototype(cx, global, JSProto_Array, &proto))
|
||||||
return false;
|
return false;
|
||||||
argsobj = NewObjectWithGivenProto(cx, &DebuggerArguments_class, proto, global);
|
argsobj = NewObjectWithGivenProto(cx, &DebuggerArguments_class, proto, global);
|
||||||
if (!argsobj ||
|
if (!argsobj)
|
||||||
!js_SetReservedSlot(cx, argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj)))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
SetReservedSlot(argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj));
|
||||||
|
|
||||||
JS_ASSERT(fp->numActualArgs() <= 0x7fffffff);
|
JS_ASSERT(fp->numActualArgs() <= 0x7fffffff);
|
||||||
int32_t fargc = int32_t(fp->numActualArgs());
|
int32_t fargc = int32_t(fp->numActualArgs());
|
||||||
|
|
|
@ -825,7 +825,7 @@ Parent(JSContext *cx, uintN argc, jsval *vp)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*vp = OBJECT_TO_JSVAL(JS_GetParent(cx, JSVAL_TO_OBJECT(v)));
|
*vp = OBJECT_TO_JSVAL(JS_GetParent(JSVAL_TO_OBJECT(v)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ env_enumerate(JSContext *cx, JSObject *obj)
|
||||||
if (reflected)
|
if (reflected)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (evp = (char **)JS_GetPrivate(cx, obj); (name = *evp) != NULL; evp++) {
|
for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != NULL; evp++) {
|
||||||
value = strchr(name, '=');
|
value = strchr(name, '=');
|
||||||
if (!value)
|
if (!value)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1234,7 +1234,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
||||||
xpc_ActivateDebugMode();
|
xpc_ActivateDebugMode();
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
if (JS_GetClass(JS_GetPrototype(cx, obj)) != &global_class) {
|
if (JS_GetClass(JS_GetPrototype(obj)) != &global_class) {
|
||||||
JSObject *gobj;
|
JSObject *gobj;
|
||||||
|
|
||||||
if (!JS_DeepFreezeObject(cx, obj))
|
if (!JS_DeepFreezeObject(cx, obj))
|
||||||
|
@ -1977,11 +1977,13 @@ main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
|
envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
|
||||||
if (!envobj || !JS_SetPrivate(cx, envobj, envp)) {
|
if (!envobj) {
|
||||||
JS_EndRequest(cx);
|
JS_EndRequest(cx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_SetPrivate(envobj, envp);
|
||||||
|
|
||||||
nsAutoString workingDirectory;
|
nsAutoString workingDirectory;
|
||||||
if (GetCurrentWorkingDirectory(workingDirectory))
|
if (GetCurrentWorkingDirectory(workingDirectory))
|
||||||
gWorkingDirectory = &workingDirectory;
|
gWorkingDirectory = &workingDirectory;
|
||||||
|
|
|
@ -2625,7 +2625,7 @@ nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
|
||||||
|
|
||||||
JSObject* obj = JSVAL_TO_OBJECT(object);
|
JSObject* obj = JSVAL_TO_OBJECT(object);
|
||||||
while (obj && !js::IsWrapper(obj) && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
|
while (obj && !js::IsWrapper(obj) && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
|
||||||
obj = JS_GetPrototype(cx, obj);
|
obj = JS_GetPrototype(obj);
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||||
|
@ -3034,9 +3034,7 @@ xpc_CreateSandboxObject(JSContext * cx, jsval * vp, nsISupports *prinOrSop, JSOb
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass on ownership of sop to |sandbox|.
|
// Pass on ownership of sop to |sandbox|.
|
||||||
if (!JS_SetPrivate(cx, sandbox, sop.forget().get())) {
|
JS_SetPrivate(sandbox, sop.forget().get());
|
||||||
return NS_ERROR_XPC_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = xpc->InitClasses(cx, sandbox);
|
rv = xpc->InitClasses(cx, sandbox);
|
||||||
if (NS_SUCCEEDED(rv) &&
|
if (NS_SUCCEEDED(rv) &&
|
||||||
|
|
|
@ -999,17 +999,17 @@ DetachedWrappedNativeProtoShutdownMarker(JSDHashTable *table, JSDHashEntryHdr *h
|
||||||
XPCWrappedNativeProto* proto =
|
XPCWrappedNativeProto* proto =
|
||||||
(XPCWrappedNativeProto*)((JSDHashEntryStub*)hdr)->key;
|
(XPCWrappedNativeProto*)((JSDHashEntryStub*)hdr)->key;
|
||||||
|
|
||||||
proto->SystemIsBeingShutDown((JSContext*)arg);
|
proto->SystemIsBeingShutDown();
|
||||||
return JS_DHASH_NEXT;
|
return JS_DHASH_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XPCJSRuntime::SystemIsBeingShutDown(JSContext* cx)
|
void XPCJSRuntime::SystemIsBeingShutDown()
|
||||||
{
|
{
|
||||||
DOM_ClearInterfaces();
|
DOM_ClearInterfaces();
|
||||||
|
|
||||||
if (mDetachedWrappedNativeProtoMap)
|
if (mDetachedWrappedNativeProtoMap)
|
||||||
mDetachedWrappedNativeProtoMap->
|
mDetachedWrappedNativeProtoMap->
|
||||||
Enumerate(DetachedWrappedNativeProtoShutdownMarker, cx);
|
Enumerate(DetachedWrappedNativeProtoShutdownMarker, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSContext *
|
JSContext *
|
||||||
|
|
|
@ -152,7 +152,7 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
||||||
jsval v = js::GetFunctionNativeReserved(callee, 0);
|
jsval v = js::GetFunctionNativeReserved(callee, 0);
|
||||||
|
|
||||||
JSObject *ptrobj = JSVAL_TO_OBJECT(v);
|
JSObject *ptrobj = JSVAL_TO_OBJECT(v);
|
||||||
Op *popp = static_cast<Op *>(JS_GetPrivate(cx, ptrobj));
|
Op *popp = static_cast<Op *>(JS_GetPrivate(ptrobj));
|
||||||
|
|
||||||
v = js::GetFunctionNativeReserved(callee, 1);
|
v = js::GetFunctionNativeReserved(callee, 1);
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
||||||
static void
|
static void
|
||||||
PointerFinalize(JSContext *cx, JSObject *obj)
|
PointerFinalize(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
JSPropertyOp *popp = static_cast<JSPropertyOp *>(JS_GetPrivate(cx, obj));
|
JSPropertyOp *popp = static_cast<JSPropertyOp *>(JS_GetPrivate(obj));
|
||||||
delete popp;
|
delete popp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ GeneratePropertyOp(JSContext *cx, JSObject *obj, jsid id, uintN argc, Op pop)
|
||||||
if (!popp)
|
if (!popp)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
*popp = pop;
|
*popp = pop;
|
||||||
JS_SetPrivate(cx, ptrobj, popp);
|
JS_SetPrivate(ptrobj, popp);
|
||||||
|
|
||||||
js::SetFunctionNativeReserved(funobj, 0, OBJECT_TO_JSVAL(ptrobj));
|
js::SetFunctionNativeReserved(funobj, 0, OBJECT_TO_JSVAL(ptrobj));
|
||||||
js::SetFunctionNativeReserved(funobj, 1, js::IdToJsval(id));
|
js::SetFunctionNativeReserved(funobj, 1, js::IdToJsval(id));
|
||||||
|
|
|
@ -239,11 +239,7 @@ XPCJSContextStack::GetSafeJSContext()
|
||||||
// InitClasses
|
// InitClasses
|
||||||
nsIScriptObjectPrincipal* priv = nsnull;
|
nsIScriptObjectPrincipal* priv = nsnull;
|
||||||
sop.swap(priv);
|
sop.swap(priv);
|
||||||
if (!JS_SetPrivate(mSafeJSContext, glob, priv)) {
|
JS_SetPrivate(glob, priv);
|
||||||
// Drop the whole thing
|
|
||||||
NS_RELEASE(priv);
|
|
||||||
glob = nsnull;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// After this point either glob is null and the
|
// After this point either glob is null and the
|
||||||
|
|
|
@ -707,7 +707,7 @@ XPCWrappedNative::Morph(XPCCallContext& ccx,
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=343141 is fixed.
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=343141 is fixed.
|
||||||
#if 0
|
#if 0
|
||||||
if (proto->GetScriptableInfo()->GetFlags().WantPreCreate()) {
|
if (proto->GetScriptableInfo()->GetFlags().WantPreCreate()) {
|
||||||
JSObject* parent = JS_GetParent(ccx, existingJSObject);
|
JSObject* parent = JS_GetParent(existingJSObject);
|
||||||
JSObject* plannedParent = parent;
|
JSObject* plannedParent = parent;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
proto->GetScriptableInfo()->GetCallback()->PreCreate(identity, ccx,
|
proto->GetScriptableInfo()->GetCallback()->PreCreate(identity, ccx,
|
||||||
|
@ -1127,14 +1127,7 @@ XPCWrappedNative::Init(XPCCallContext& ccx,
|
||||||
if (!mFlatJSObject)
|
if (!mFlatJSObject)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// In the current JS engine JS_SetPrivate can't fail. But if it *did*
|
JS_SetPrivate(mFlatJSObject, this);
|
||||||
// fail then we would not receive our finalizer call and would not be
|
|
||||||
// able to properly cleanup. So, if it fails we null out mFlatJSObject
|
|
||||||
// to indicate the invalid state of this object and return false.
|
|
||||||
if (!JS_SetPrivate(ccx, mFlatJSObject, this)) {
|
|
||||||
mFlatJSObject = nsnull;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FinishInit(ccx);
|
return FinishInit(ccx);
|
||||||
}
|
}
|
||||||
|
@ -1142,18 +1135,10 @@ XPCWrappedNative::Init(XPCCallContext& ccx,
|
||||||
JSBool
|
JSBool
|
||||||
XPCWrappedNative::Init(XPCCallContext &ccx, JSObject *existingJSObject)
|
XPCWrappedNative::Init(XPCCallContext &ccx, JSObject *existingJSObject)
|
||||||
{
|
{
|
||||||
// In the current JS engine JS_SetPrivate can't fail. But if it *did*
|
JS_SetPrivate(existingJSObject, this);
|
||||||
// fail then we would not receive our finalizer call and would not be
|
|
||||||
// able to properly cleanup. So, if it fails we null out mFlatJSObject
|
|
||||||
// to indicate the invalid state of this object and return false.
|
|
||||||
if (!JS_SetPrivate(ccx, existingJSObject, this)) {
|
|
||||||
mFlatJSObject = nsnull;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Morph the existing object.
|
// Morph the existing object.
|
||||||
if (!JS_SetReservedSlot(ccx, existingJSObject, 0, JSVAL_VOID))
|
JS_SetReservedSlot(existingJSObject, 0, JSVAL_VOID);
|
||||||
return false;
|
|
||||||
|
|
||||||
mScriptableInfo = GetProto()->GetScriptableInfo();
|
mScriptableInfo = GetProto()->GetScriptableInfo();
|
||||||
mFlatJSObject = existingJSObject;
|
mFlatJSObject = existingJSObject;
|
||||||
|
@ -1260,7 +1245,7 @@ NS_IMPL_THREADSAFE_RELEASE(XPCWrappedNative)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
|
XPCWrappedNative::FlatJSObjectFinalized()
|
||||||
{
|
{
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return;
|
return;
|
||||||
|
@ -1277,7 +1262,7 @@ XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
|
||||||
JSObject* jso = to->GetJSObject();
|
JSObject* jso = to->GetJSObject();
|
||||||
if (jso) {
|
if (jso) {
|
||||||
NS_ASSERTION(JS_IsAboutToBeFinalized(jso), "bad!");
|
NS_ASSERTION(JS_IsAboutToBeFinalized(jso), "bad!");
|
||||||
JS_SetPrivate(cx, jso, nsnull);
|
JS_SetPrivate(jso, nsnull);
|
||||||
to->JSObjectFinalized();
|
to->JSObjectFinalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,7 +1317,7 @@ XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
|
XPCWrappedNative::SystemIsBeingShutDown()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_xpc_hacker
|
#ifdef DEBUG_xpc_hacker
|
||||||
{
|
{
|
||||||
|
@ -1358,13 +1343,13 @@ XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
|
||||||
// We leak mIdentity (see above).
|
// We leak mIdentity (see above).
|
||||||
|
|
||||||
// short circuit future finalization
|
// short circuit future finalization
|
||||||
JS_SetPrivate(cx, mFlatJSObject, nsnull);
|
JS_SetPrivate(mFlatJSObject, nsnull);
|
||||||
mFlatJSObject = nsnull; // This makes 'IsValid()' return false.
|
mFlatJSObject = nsnull; // This makes 'IsValid()' return false.
|
||||||
|
|
||||||
XPCWrappedNativeProto* proto = GetProto();
|
XPCWrappedNativeProto* proto = GetProto();
|
||||||
|
|
||||||
if (HasProto())
|
if (HasProto())
|
||||||
proto->SystemIsBeingShutDown(cx);
|
proto->SystemIsBeingShutDown();
|
||||||
|
|
||||||
if (mScriptableInfo &&
|
if (mScriptableInfo &&
|
||||||
(!HasProto() ||
|
(!HasProto() ||
|
||||||
|
@ -1379,7 +1364,7 @@ XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
|
||||||
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
|
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
|
||||||
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
|
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
|
||||||
if (to->GetJSObject()) {
|
if (to->GetJSObject()) {
|
||||||
JS_SetPrivate(cx, to->GetJSObject(), nsnull);
|
JS_SetPrivate(to->GetJSObject(), nsnull);
|
||||||
to->SetJSObject(nsnull);
|
to->SetJSObject(nsnull);
|
||||||
}
|
}
|
||||||
// We leak the tearoff mNative
|
// We leak the tearoff mNative
|
||||||
|
@ -1533,7 +1518,7 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx,
|
||||||
if (!newobj)
|
if (!newobj)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
JS_SetPrivate(ccx, flat, nsnull);
|
JS_SetPrivate(flat, nsnull);
|
||||||
|
|
||||||
JSObject *propertyHolder =
|
JSObject *propertyHolder =
|
||||||
JS_NewObjectWithGivenProto(ccx, NULL, NULL, aNewParent);
|
JS_NewObjectWithGivenProto(ccx, NULL, NULL, aNewParent);
|
||||||
|
@ -1585,11 +1570,11 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!JS_SetReservedSlot(ccx, flat, 0,
|
JS_SetReservedSlot(flat, 0,
|
||||||
PRIVATE_TO_JSVAL(newProto.get())) ||
|
PRIVATE_TO_JSVAL(newProto.get()));
|
||||||
!JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
|
if (!JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
|
||||||
// this is bad, very bad
|
// this is bad, very bad
|
||||||
JS_SetReservedSlot(ccx, flat, 0, JSVAL_NULL);
|
JS_SetReservedSlot(flat, 0, JSVAL_NULL);
|
||||||
NS_ERROR("JS_SetPrototype failed");
|
NS_ERROR("JS_SetPrototype failed");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -2029,9 +2014,10 @@ XPCWrappedNative::InitTearOffJSObject(XPCCallContext& ccx,
|
||||||
GetScope()->GetPrototypeJSObject(),
|
GetScope()->GetPrototypeJSObject(),
|
||||||
false, mFlatJSObject);
|
false, mFlatJSObject);
|
||||||
|
|
||||||
if (!obj || !JS_SetPrivate(ccx, obj, to))
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
JS_SetPrivate(obj, to);
|
||||||
to->SetJSObject(obj);
|
to->SetJSObject(obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3713,11 +3699,12 @@ ConstructSlimWrapper(XPCCallContext &ccx,
|
||||||
wrapper = xpc_NewSystemInheritingJSObject(ccx, jsclazz,
|
wrapper = xpc_NewSystemInheritingJSObject(ccx, jsclazz,
|
||||||
xpcproto->GetJSProtoObject(),
|
xpcproto->GetJSProtoObject(),
|
||||||
false, parent);
|
false, parent);
|
||||||
if (!wrapper ||
|
if (!wrapper)
|
||||||
!JS_SetPrivate(ccx, wrapper, identityObj) ||
|
|
||||||
!JS_SetReservedSlot(ccx, wrapper, 0, PRIVATE_TO_JSVAL(xpcproto.get())))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
JS_SetPrivate(wrapper, identityObj);
|
||||||
|
JS_SetReservedSlot(wrapper, 0, PRIVATE_TO_JSVAL(xpcproto.get()));
|
||||||
|
|
||||||
// Transfer ownership to the wrapper's private.
|
// Transfer ownership to the wrapper's private.
|
||||||
aHelper.forgetCanonical();
|
aHelper.forgetCanonical();
|
||||||
|
|
||||||
|
|
|
@ -637,7 +637,7 @@ XPC_WN_NoHelper_Finalize(JSContext *cx, JSObject *obj)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<XPCWrappedNative*>(p)->FlatJSObjectFinalized(cx);
|
static_cast<XPCWrappedNative*>(p)->FlatJSObjectFinalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1058,7 +1058,7 @@ XPC_WN_Helper_Finalize(JSContext *cx, JSObject *obj)
|
||||||
if (!wrapper)
|
if (!wrapper)
|
||||||
return;
|
return;
|
||||||
wrapper->GetScriptableCallback()->Finalize(wrapper, cx, obj);
|
wrapper->GetScriptableCallback()->Finalize(wrapper, cx, obj);
|
||||||
wrapper->FlatJSObjectFinalized(cx);
|
wrapper->FlatJSObjectFinalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
|
|
@ -128,15 +128,18 @@ XPCWrappedNativeProto::Init(XPCCallContext& ccx,
|
||||||
mScope->GetPrototypeJSObject(),
|
mScope->GetPrototypeJSObject(),
|
||||||
true, parent);
|
true, parent);
|
||||||
|
|
||||||
JSBool ok = mJSProtoObject && JS_SetPrivate(ccx, mJSProtoObject, this);
|
JSBool ok = !!mJSProtoObject;
|
||||||
|
|
||||||
if (ok && callback) {
|
if (ok) {
|
||||||
nsresult rv = callback->PostCreatePrototype(ccx, mJSProtoObject);
|
JS_SetPrivate(mJSProtoObject, this);
|
||||||
if (NS_FAILED(rv)) {
|
if (callback) {
|
||||||
JS_SetPrivate(ccx, mJSProtoObject, nsnull);
|
nsresult rv = callback->PostCreatePrototype(ccx, mJSProtoObject);
|
||||||
mJSProtoObject = nsnull;
|
if (NS_FAILED(rv)) {
|
||||||
XPCThrower::Throw(rv, ccx);
|
JS_SetPrivate(mJSProtoObject, nsnull);
|
||||||
return false;
|
mJSProtoObject = nsnull;
|
||||||
|
XPCThrower::Throw(rv, ccx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +168,7 @@ XPCWrappedNativeProto::JSProtoObjectFinalized(JSContext *cx, JSObject *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XPCWrappedNativeProto::SystemIsBeingShutDown(JSContext* cx)
|
XPCWrappedNativeProto::SystemIsBeingShutDown()
|
||||||
{
|
{
|
||||||
// Note that the instance might receive this call multiple times
|
// Note that the instance might receive this call multiple times
|
||||||
// as we walk to here from various places.
|
// as we walk to here from various places.
|
||||||
|
@ -181,7 +184,7 @@ XPCWrappedNativeProto::SystemIsBeingShutDown(JSContext* cx)
|
||||||
|
|
||||||
if (mJSProtoObject) {
|
if (mJSProtoObject) {
|
||||||
// short circuit future finalization
|
// short circuit future finalization
|
||||||
JS_SetPrivate(cx, mJSProtoObject, nsnull);
|
JS_SetPrivate(mJSProtoObject, nsnull);
|
||||||
mJSProtoObject = nsnull;
|
mJSProtoObject = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,9 +127,9 @@ XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
|
||||||
scope->SetGlobal(ccx, aGlobal);
|
scope->SetGlobal(ccx, aGlobal);
|
||||||
}
|
}
|
||||||
if (js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
|
if (js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
|
||||||
JS_ALWAYS_TRUE(JS_SetReservedSlot(ccx, aGlobal,
|
JS_SetReservedSlot(aGlobal,
|
||||||
JSCLASS_GLOBAL_SLOT_COUNT,
|
JSCLASS_GLOBAL_SLOT_COUNT,
|
||||||
PRIVATE_TO_JSVAL(scope)));
|
PRIVATE_TO_JSVAL(scope));
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,10 +555,9 @@ XPCWrappedNativeScope::KillDyingScopes()
|
||||||
|
|
||||||
struct ShutdownData
|
struct ShutdownData
|
||||||
{
|
{
|
||||||
ShutdownData(JSContext* acx)
|
ShutdownData()
|
||||||
: cx(acx), wrapperCount(0),
|
: wrapperCount(0),
|
||||||
protoCount(0) {}
|
protoCount(0) {}
|
||||||
JSContext* cx;
|
|
||||||
int wrapperCount;
|
int wrapperCount;
|
||||||
int protoCount;
|
int protoCount;
|
||||||
};
|
};
|
||||||
|
@ -571,7 +570,7 @@ WrappedNativeShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
|
||||||
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
|
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
|
||||||
|
|
||||||
if (wrapper->IsValid()) {
|
if (wrapper->IsValid()) {
|
||||||
wrapper->SystemIsBeingShutDown(data->cx);
|
wrapper->SystemIsBeingShutDown();
|
||||||
data->wrapperCount++;
|
data->wrapperCount++;
|
||||||
}
|
}
|
||||||
return JS_DHASH_REMOVE;
|
return JS_DHASH_REMOVE;
|
||||||
|
@ -583,21 +582,21 @@ WrappedNativeProtoShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
|
||||||
{
|
{
|
||||||
ShutdownData* data = (ShutdownData*) arg;
|
ShutdownData* data = (ShutdownData*) arg;
|
||||||
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->
|
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->
|
||||||
SystemIsBeingShutDown(data->cx);
|
SystemIsBeingShutDown();
|
||||||
data->protoCount++;
|
data->protoCount++;
|
||||||
return JS_DHASH_REMOVE;
|
return JS_DHASH_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
|
XPCWrappedNativeScope::SystemIsBeingShutDown()
|
||||||
{
|
{
|
||||||
DEBUG_TrackScopeTraversal();
|
DEBUG_TrackScopeTraversal();
|
||||||
DEBUG_TrackScopeShutdown();
|
DEBUG_TrackScopeShutdown();
|
||||||
|
|
||||||
int liveScopeCount = 0;
|
int liveScopeCount = 0;
|
||||||
|
|
||||||
ShutdownData data(cx);
|
ShutdownData data;
|
||||||
|
|
||||||
XPCWrappedNativeScope* cur;
|
XPCWrappedNativeScope* cur;
|
||||||
|
|
||||||
|
@ -620,12 +619,6 @@ XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
|
||||||
if (cur->mComponents)
|
if (cur->mComponents)
|
||||||
cur->mComponents->SystemIsBeingShutDown();
|
cur->mComponents->SystemIsBeingShutDown();
|
||||||
|
|
||||||
JSAutoEnterCompartment ac;
|
|
||||||
|
|
||||||
// XXX: What if we have no global in the scope???
|
|
||||||
if (cur->mGlobalJSObject)
|
|
||||||
ac.enter(cx, cur->mGlobalJSObject);
|
|
||||||
|
|
||||||
// Walk the protos first. Wrapper shutdown can leave dangling
|
// Walk the protos first. Wrapper shutdown can leave dangling
|
||||||
// proto pointers in the proto map.
|
// proto pointers in the proto map.
|
||||||
cur->mWrappedNativeProtoMap->
|
cur->mWrappedNativeProtoMap->
|
||||||
|
|
|
@ -414,7 +414,7 @@ interface_hasInstance(JSContext *cx, JSObject *obj, const JS::Value *vp, JSBool
|
||||||
} else {
|
} else {
|
||||||
JSObject *protoObj = JSVAL_TO_OBJECT(prototype);
|
JSObject *protoObj = JSVAL_TO_OBJECT(prototype);
|
||||||
JSObject *proto = other;
|
JSObject *proto = other;
|
||||||
while ((proto = JS_GetPrototype(cx, proto))) {
|
while ((proto = JS_GetPrototype(proto))) {
|
||||||
if (proto == protoObj) {
|
if (proto == protoObj) {
|
||||||
*bp = true;
|
*bp = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -759,7 +759,7 @@ ListBase<LC>::ensureExpandoObject(JSContext *cx, JSObject *obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
|
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
|
||||||
JS_SetPrivate(cx, expando, js::GetProxyPrivate(obj).toPrivate());
|
JS_SetPrivate(expando, js::GetProxyPrivate(obj).toPrivate());
|
||||||
}
|
}
|
||||||
return expando;
|
return expando;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,14 +138,10 @@ nsXPConnect::~nsXPConnect()
|
||||||
XPCPerThreadData::CleanupAllThreads();
|
XPCPerThreadData::CleanupAllThreads();
|
||||||
mShuttingDown = true;
|
mShuttingDown = true;
|
||||||
if (cx) {
|
if (cx) {
|
||||||
JS_BeginRequest(cx);
|
|
||||||
|
|
||||||
// XXX Call even if |mRuntime| null?
|
// XXX Call even if |mRuntime| null?
|
||||||
XPCWrappedNativeScope::SystemIsBeingShutDown(cx);
|
XPCWrappedNativeScope::SystemIsBeingShutDown();
|
||||||
|
|
||||||
mRuntime->SystemIsBeingShutDown(cx);
|
mRuntime->SystemIsBeingShutDown();
|
||||||
|
|
||||||
JS_EndRequest(cx);
|
|
||||||
JS_DestroyContext(cx);
|
JS_DestroyContext(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,7 +762,7 @@ public:
|
||||||
|
|
||||||
void DebugDump(PRInt16 depth);
|
void DebugDump(PRInt16 depth);
|
||||||
|
|
||||||
void SystemIsBeingShutDown(JSContext* cx);
|
void SystemIsBeingShutDown();
|
||||||
|
|
||||||
PRThread* GetThreadRunningGC() const {return mThreadRunningGC;}
|
PRThread* GetThreadRunningGC() const {return mThreadRunningGC;}
|
||||||
|
|
||||||
|
@ -1545,7 +1545,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SystemIsBeingShutDown(JSContext* cx);
|
SystemIsBeingShutDown();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TraceJS(JSTracer* trc, XPCJSRuntime* rt);
|
TraceJS(JSTracer* trc, XPCJSRuntime* rt);
|
||||||
|
@ -2281,7 +2281,7 @@ public:
|
||||||
|
|
||||||
void JSProtoObjectFinalized(JSContext *cx, JSObject *obj);
|
void JSProtoObjectFinalized(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
void SystemIsBeingShutDown(JSContext* cx);
|
void SystemIsBeingShutDown();
|
||||||
|
|
||||||
void DebugDump(PRInt16 depth);
|
void DebugDump(PRInt16 depth);
|
||||||
|
|
||||||
|
@ -2632,9 +2632,9 @@ public:
|
||||||
nsISupports* aCOMObj,
|
nsISupports* aCOMObj,
|
||||||
XPCWrappedNative** aWrapper);
|
XPCWrappedNative** aWrapper);
|
||||||
|
|
||||||
void FlatJSObjectFinalized(JSContext *cx);
|
void FlatJSObjectFinalized();
|
||||||
|
|
||||||
void SystemIsBeingShutDown(JSContext* cx);
|
void SystemIsBeingShutDown();
|
||||||
|
|
||||||
enum CallMode {CALL_METHOD, CALL_GETTER, CALL_SETTER};
|
enum CallMode {CALL_METHOD, CALL_GETTER, CALL_SETTER};
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ JSObject *
|
||||||
WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *obj)
|
WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
JSObject *wrapperObj =
|
JSObject *wrapperObj =
|
||||||
Wrapper::New(cx, obj, JS_GetPrototype(cx, obj), JS_GetGlobalForObject(cx, obj),
|
Wrapper::New(cx, obj, JS_GetPrototype(obj), JS_GetGlobalForObject(cx, obj),
|
||||||
&FilteringWrapper<SameCompartmentSecurityWrapper,
|
&FilteringWrapper<SameCompartmentSecurityWrapper,
|
||||||
OnlyIfSubjectIsSystem>::singleton);
|
OnlyIfSubjectIsSystem>::singleton);
|
||||||
return wrapperObj;
|
return wrapperObj;
|
||||||
|
|
|
@ -2022,7 +2022,7 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
||||||
|
|
||||||
args->m_cx = cx;
|
args->m_cx = cx;
|
||||||
args->m_kungFuDeathGrip = GetISupportsFromContext(cx);
|
args->m_kungFuDeathGrip = GetISupportsFromContext(cx);
|
||||||
args->m_scope = JS_GetParent(cx, script_obj);
|
args->m_scope = JS_GetParent(script_obj);
|
||||||
|
|
||||||
args->m_jsCallback.Adopt(!!jsCallback ? nsCRT::strdup(jsCallback.ptr()) : 0);
|
args->m_jsCallback.Adopt(!!jsCallback ? nsCRT::strdup(jsCallback.ptr()) : 0);
|
||||||
args->m_principals = principals;
|
args->m_principals = principals;
|
||||||
|
|
|
@ -119,10 +119,11 @@ InitAndSealCTypesClass(JSContext* cx, JSObject* global)
|
||||||
|
|
||||||
// Set callbacks for charset conversion and such.
|
// Set callbacks for charset conversion and such.
|
||||||
jsval ctypes;
|
jsval ctypes;
|
||||||
if (!JS_GetProperty(cx, global, "ctypes", &ctypes) ||
|
if (!JS_GetProperty(cx, global, "ctypes", &ctypes))
|
||||||
!JS_SetCTypesCallbacks(cx, JSVAL_TO_OBJECT(ctypes), &sCallbacks))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &sCallbacks);
|
||||||
|
|
||||||
// Seal up Object, Function, Array and Error and their prototypes. (This
|
// Seal up Object, Function, Array and Error and their prototypes. (This
|
||||||
// single object instance is shared amongst everyone who imports the ctypes
|
// single object instance is shared amongst everyone who imports the ctypes
|
||||||
// module.)
|
// module.)
|
||||||
|
|
|
@ -286,7 +286,7 @@ JSHistogram_Add(JSContext *cx, uintN argc, jsval *vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
|
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
|
||||||
if (h->histogram_type() == Histogram::BOOLEAN_HISTOGRAM)
|
if (h->histogram_type() == Histogram::BOOLEAN_HISTOGRAM)
|
||||||
h->Add(!!value);
|
h->Add(!!value);
|
||||||
else
|
else
|
||||||
|
@ -303,7 +303,7 @@ JSHistogram_Snapshot(JSContext *cx, uintN argc, jsval *vp)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
|
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
|
||||||
JSObject *snapshot = JS_NewObject(cx, NULL, NULL, NULL);
|
JSObject *snapshot = JS_NewObject(cx, NULL, NULL, NULL);
|
||||||
if (!snapshot)
|
if (!snapshot)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -338,8 +338,8 @@ WrapAndReturnHistogram(Histogram *h, JSContext *cx, jsval *ret)
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
*ret = OBJECT_TO_JSVAL(obj);
|
*ret = OBJECT_TO_JSVAL(obj);
|
||||||
return (JS_SetPrivate(cx, obj, h)
|
JS_SetPrivate(obj, h);
|
||||||
&& JS_DefineFunction (cx, obj, "add", JSHistogram_Add, 1, 0)
|
return (JS_DefineFunction (cx, obj, "add", JSHistogram_Add, 1, 0)
|
||||||
&& JS_DefineFunction (cx, obj, "snapshot", JSHistogram_Snapshot, 1, 0)) ? NS_OK : NS_ERROR_FAILURE;
|
&& JS_DefineFunction (cx, obj, "snapshot", JSHistogram_Snapshot, 1, 0)) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче