зеркало из https://github.com/mozilla/pjs.git
Backed out changeset 94673272aeab from bug 484764: Set up DOM prototype chain
from nsDOMClassInfo::PostCreateProto.
This commit is contained in:
Родитель
ea76deaa39
Коммит
89d2e85f54
|
@ -1465,10 +1465,10 @@ jsval nsDOMClassInfo::sJavaArray_id = JSVAL_VOID;
|
||||||
jsval nsDOMClassInfo::sJavaMember_id = JSVAL_VOID;
|
jsval nsDOMClassInfo::sJavaMember_id = JSVAL_VOID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const JSClass *sObjectClass = nsnull;
|
const JSClass *nsDOMClassInfo::sObjectClass = nsnull;
|
||||||
const JSClass *nsDOMClassInfo::sXPCNativeWrapperClass = nsnull;
|
const JSClass *nsDOMClassInfo::sXPCNativeWrapperClass = nsnull;
|
||||||
|
|
||||||
static PRBool sDoSecurityCheckInAddProperty = PR_TRUE;
|
PRBool nsDOMClassInfo::sDoSecurityCheckInAddProperty = PR_TRUE;
|
||||||
|
|
||||||
const JSClass*
|
const JSClass*
|
||||||
NS_DOMClassInfo_GetXPCNativeWrapperClass()
|
NS_DOMClassInfo_GetXPCNativeWrapperClass()
|
||||||
|
@ -1759,7 +1759,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMClassInfo)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
|
|
||||||
static JSClass sDOMConstructorProtoClass = {
|
JSClass nsDOMClassInfo::sDOMConstructorProtoClass = {
|
||||||
"DOM Constructor.prototype", 0,
|
"DOM Constructor.prototype", 0,
|
||||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||||
|
@ -2049,7 +2049,7 @@ nsDOMClassInfo::Init()
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
|
||||||
DOM_CLASSINFO_MAP_END
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
|
DOM_CLASSINFO_MAP_BEGIN(DOMPrototype, nsIDOMDOMConstructor)
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||||
DOM_CLASSINFO_MAP_END
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
|
@ -3926,6 +3926,26 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (mData->mHasClassInterface) {
|
||||||
|
nsCOMPtr<nsIInterfaceInfoManager>
|
||||||
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||||
|
|
||||||
|
if (iim) {
|
||||||
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||||
|
iim->GetInfoForIID(mData->mProtoChainInterface,
|
||||||
|
getter_AddRefs(if_info));
|
||||||
|
|
||||||
|
if (if_info) {
|
||||||
|
nsXPIDLCString name;
|
||||||
|
if_info->GetName(getter_Copies(name));
|
||||||
|
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
|
||||||
|
"Class name and proto chain interface name mismatch!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Look up the name of our constructor in the current global scope. We do
|
// Look up the name of our constructor in the current global scope. We do
|
||||||
// this because triggering this lookup can cause us to call
|
// this because triggering this lookup can cause us to call
|
||||||
// nsWindowSH::NewResolve, which will end up in nsWindowSH::GlobalResolve.
|
// nsWindowSH::NewResolve, which will end up in nsWindowSH::GlobalResolve.
|
||||||
|
@ -4176,50 +4196,6 @@ nsDOMClassInfo::InnerObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult
|
|
||||||
GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
|
|
||||||
const nsString &aName,
|
|
||||||
const nsGlobalNameStruct *aStruct,
|
|
||||||
const nsGlobalNameStruct **aResult)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aStruct->mType ==
|
|
||||||
nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
|
||||||
"Wrong type!");
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
|
||||||
NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
const nsGlobalNameStruct *name_struct;
|
|
||||||
rv = aNameSpaceManager->LookupName(aName, &name_struct);
|
|
||||||
if (NS_SUCCEEDED(rv) && name_struct &&
|
|
||||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
||||||
*aResult = name_struct;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
NS_ERROR("Couldn't get the DOM ClassInfo data.");
|
|
||||||
|
|
||||||
*aResult = nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static nsresult
|
|
||||||
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
|
||||||
JSObject *obj, JSString *str,
|
|
||||||
const nsGlobalNameStruct *name_struct,
|
|
||||||
nsScriptNameSpaceManager *nameSpaceManager,
|
|
||||||
PRBool *did_resolve);
|
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
|
nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
|
||||||
{
|
{
|
||||||
|
@ -4236,27 +4212,6 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
|
||||||
count, mData->mInterfaces)) {
|
count, mData->mInterfaces)) {
|
||||||
JS_ClearPendingException(cx);
|
JS_ClearPendingException(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (mData->mHasClassInterface) {
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager>
|
|
||||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
|
||||||
|
|
||||||
if (iim) {
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
||||||
iim->GetInfoForIID(mData->mProtoChainInterface,
|
|
||||||
getter_AddRefs(if_info));
|
|
||||||
|
|
||||||
if (if_info) {
|
|
||||||
nsXPIDLCString name;
|
|
||||||
if_info->GetName(getter_Copies(name));
|
|
||||||
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
|
|
||||||
"Class name and proto chain interface name mismatch!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5278,8 +5233,9 @@ public:
|
||||||
|
|
||||||
nsresult Install(JSContext *cx, JSObject *target, jsval thisAsVal)
|
nsresult Install(JSContext *cx, JSObject *target, jsval thisAsVal)
|
||||||
{
|
{
|
||||||
PRBool doSecurityCheckInAddProperty = sDoSecurityCheckInAddProperty;
|
PRBool doSecurityCheckInAddProperty =
|
||||||
sDoSecurityCheckInAddProperty = PR_FALSE;
|
nsDOMClassInfo::sDoSecurityCheckInAddProperty;
|
||||||
|
nsDOMClassInfo::sDoSecurityCheckInAddProperty = PR_FALSE;
|
||||||
|
|
||||||
JSBool ok =
|
JSBool ok =
|
||||||
::JS_DefineUCProperty(cx, target,
|
::JS_DefineUCProperty(cx, target,
|
||||||
|
@ -5287,7 +5243,8 @@ public:
|
||||||
nsCRT::strlen(mClassName), thisAsVal, nsnull,
|
nsCRT::strlen(mClassName), thisAsVal, nsnull,
|
||||||
nsnull, 0);
|
nsnull, 0);
|
||||||
|
|
||||||
sDoSecurityCheckInAddProperty = doSecurityCheckInAddProperty;
|
nsDOMClassInfo::sDoSecurityCheckInAddProperty =
|
||||||
|
doSecurityCheckInAddProperty;
|
||||||
return ok ? NS_OK : NS_ERROR_UNEXPECTED;
|
return ok ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5570,23 +5527,98 @@ nsDOMConstructor::ToString(nsAString &aResult)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
static nsresult
|
nsresult
|
||||||
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||||
JSObject *obj, JSString *str,
|
JSObject *obj, JSString *str, PRUint32 flags,
|
||||||
const nsGlobalNameStruct *name_struct,
|
|
||||||
nsScriptNameSpaceManager *nameSpaceManager,
|
|
||||||
PRBool *did_resolve)
|
PRBool *did_resolve)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(name_struct->mType ==
|
*did_resolve = PR_FALSE;
|
||||||
nsGlobalNameStruct::eTypeClassConstructor ||
|
|
||||||
name_struct->mType ==
|
|
||||||
nsGlobalNameStruct::eTypeExternalClassInfo ||
|
|
||||||
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
|
|
||||||
name_struct->mType ==
|
|
||||||
nsGlobalNameStruct::eTypeExternalConstructorAlias,
|
|
||||||
"Wrong type!");
|
|
||||||
|
|
||||||
|
nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
|
||||||
|
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
|
nsDependentJSString name(str);
|
||||||
|
|
||||||
|
const nsGlobalNameStruct *name_struct = nsnull;
|
||||||
|
const PRUnichar *class_name = nsnull;
|
||||||
|
|
||||||
|
nameSpaceManager->LookupName(name, &name_struct, &class_name);
|
||||||
|
|
||||||
|
if (!name_struct) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||||
|
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(name_struct->mCID, &rv));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||||
|
NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(name).get(), sof);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = nameSpaceManager->LookupName(name, &name_struct);
|
||||||
|
if (NS_FAILED(rv) || !name_struct ||
|
||||||
|
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||||
|
NS_ERROR("Couldn't get the DOM ClassInfo data.");
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
|
||||||
|
// We're resolving a name of a DOM interface for which there is no
|
||||||
|
// direct DOM class, create a constructor object...
|
||||||
|
|
||||||
|
nsRefPtr<nsDOMConstructor> constructor;
|
||||||
|
rv = nsDOMConstructor::Create(reinterpret_cast<PRUnichar *>
|
||||||
|
(::JS_GetStringChars(str)),
|
||||||
|
name_struct,
|
||||||
|
static_cast<nsPIDOMWindow*>(aWin),
|
||||||
|
getter_AddRefs(constructor));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
PRBool doSecurityCheckInAddProperty = sDoSecurityCheckInAddProperty;
|
||||||
|
sDoSecurityCheckInAddProperty = PR_FALSE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||||
|
jsval v;
|
||||||
|
|
||||||
|
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor), &v,
|
||||||
|
getter_AddRefs(holder));
|
||||||
|
|
||||||
|
sDoSecurityCheckInAddProperty = doSecurityCheckInAddProperty;
|
||||||
|
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = constructor->Install(cx, obj, v);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
JSObject *class_obj;
|
||||||
|
holder->GetJSObject(&class_obj);
|
||||||
|
NS_ASSERTION(class_obj, "The return value lied");
|
||||||
|
|
||||||
|
// ... and define the constants from the DOM interface on that
|
||||||
|
// constructor object.
|
||||||
|
|
||||||
|
rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
*did_resolve = PR_TRUE;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||||
|
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo ||
|
||||||
|
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
|
||||||
|
name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
||||||
const nsDOMClassInfoData *ci_data = nsnull;
|
const nsDOMClassInfoData *ci_data = nsnull;
|
||||||
const nsGlobalNameStruct* alias_struct = nsnull;
|
const nsGlobalNameStruct* alias_struct = nsnull;
|
||||||
|
|
||||||
|
@ -5609,7 +5641,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
const PRUnichar *name = reinterpret_cast<PRUnichar *>
|
const PRUnichar *name = reinterpret_cast<PRUnichar *>
|
||||||
(::JS_GetStringChars(str));
|
(::JS_GetStringChars(str));
|
||||||
nsRefPtr<nsDOMConstructor> constructor;
|
nsRefPtr<nsDOMConstructor> constructor;
|
||||||
nsresult rv = nsDOMConstructor::Create(name, name_struct,
|
rv = nsDOMConstructor::Create(name, name_struct,
|
||||||
static_cast<nsPIDOMWindow*>(aWin),
|
static_cast<nsPIDOMWindow*>(aWin),
|
||||||
getter_AddRefs(constructor));
|
getter_AddRefs(constructor));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
@ -5620,8 +5652,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||||
jsval v;
|
jsval v;
|
||||||
|
|
||||||
rv = nsDOMClassInfo::WrapNative(cx, obj, constructor,
|
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor), &v,
|
||||||
&NS_GET_IID(nsIDOMDOMConstructor), &v,
|
|
||||||
getter_AddRefs(holder));
|
getter_AddRefs(holder));
|
||||||
|
|
||||||
sDoSecurityCheckInAddProperty = doSecurityCheckInAddProperty;
|
sDoSecurityCheckInAddProperty = doSecurityCheckInAddProperty;
|
||||||
|
@ -5767,7 +5798,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
}
|
}
|
||||||
|
|
||||||
rv =
|
rv =
|
||||||
aXPConnect->GetWrappedNativePrototype(cx,
|
sXPConnect->GetWrappedNativePrototype(cx,
|
||||||
scopeWindow->GetGlobalJSObject(),
|
scopeWindow->GetGlobalJSObject(),
|
||||||
ci,
|
ci,
|
||||||
getter_AddRefs(proto_holder));
|
getter_AddRefs(proto_holder));
|
||||||
|
@ -5786,14 +5817,13 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||||
nsCOMPtr<nsIClassInfo> ci =
|
nsCOMPtr<nsIClassInfo> ci = GetClassInfoInstance(name_struct->mData);
|
||||||
nsDOMClassInfo::GetClassInfoInstance(name_struct->mData);
|
|
||||||
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
|
||||||
|
|
||||||
rv =
|
rv =
|
||||||
aXPConnect->GetWrappedNativePrototype(cx, obj, ci,
|
sXPConnect->GetWrappedNativePrototype(cx, obj, ci,
|
||||||
getter_AddRefs(proto_holder));
|
getter_AddRefs(proto_holder));
|
||||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
|
@ -5828,91 +5858,6 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
|
||||||
nsresult
|
|
||||||
nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
|
||||||
JSObject *obj, JSString *str, PRBool *did_resolve)
|
|
||||||
{
|
|
||||||
*did_resolve = PR_FALSE;
|
|
||||||
|
|
||||||
nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
|
|
||||||
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
|
||||||
|
|
||||||
nsDependentJSString name(str);
|
|
||||||
|
|
||||||
const nsGlobalNameStruct *name_struct = nsnull;
|
|
||||||
const PRUnichar *class_name = nsnull;
|
|
||||||
|
|
||||||
nameSpaceManager->LookupName(name, &name_struct, &class_name);
|
|
||||||
|
|
||||||
if (!name_struct) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
|
|
||||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
|
||||||
rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
|
|
||||||
&name_struct);
|
|
||||||
if (NS_FAILED(rv) || !name_struct) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
|
|
||||||
// We're resolving a name of a DOM interface for which there is no
|
|
||||||
// direct DOM class, create a constructor object...
|
|
||||||
|
|
||||||
nsRefPtr<nsDOMConstructor> constructor;
|
|
||||||
rv = nsDOMConstructor::Create(reinterpret_cast<PRUnichar *>
|
|
||||||
(::JS_GetStringChars(str)),
|
|
||||||
name_struct,
|
|
||||||
static_cast<nsPIDOMWindow*>(aWin),
|
|
||||||
getter_AddRefs(constructor));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
PRBool doSecurityCheckInAddProperty = sDoSecurityCheckInAddProperty;
|
|
||||||
sDoSecurityCheckInAddProperty = PR_FALSE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
||||||
jsval v;
|
|
||||||
|
|
||||||
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor), &v,
|
|
||||||
getter_AddRefs(holder));
|
|
||||||
|
|
||||||
sDoSecurityCheckInAddProperty = doSecurityCheckInAddProperty;
|
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = constructor->Install(cx, obj, v);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
JSObject *class_obj;
|
|
||||||
holder->GetJSObject(&class_obj);
|
|
||||||
NS_ASSERTION(class_obj, "The return value lied");
|
|
||||||
|
|
||||||
// ... and define the constants from the DOM interface on that
|
|
||||||
// constructor object.
|
|
||||||
|
|
||||||
rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
*did_resolve = PR_TRUE;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
|
||||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo ||
|
|
||||||
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
|
|
||||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
||||||
return ResolvePrototype(sXPConnect, aWin, cx, obj, str, name_struct,
|
|
||||||
nameSpaceManager, did_resolve);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||||
nsRefPtr<nsDOMConstructor> constructor;
|
nsRefPtr<nsDOMConstructor> constructor;
|
||||||
rv = nsDOMConstructor::Create(class_name, name_struct,
|
rv = nsDOMConstructor::Create(class_name, name_struct,
|
||||||
|
@ -6311,7 +6256,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||||
// which have been registered with the script namespace manager.
|
// which have been registered with the script namespace manager.
|
||||||
|
|
||||||
JSBool did_resolve = JS_FALSE;
|
JSBool did_resolve = JS_FALSE;
|
||||||
rv = GlobalResolve(win, cx, obj, str, &did_resolve);
|
rv = GlobalResolve(win, cx, obj, str, flags, &did_resolve);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (did_resolve) {
|
if (did_resolve) {
|
||||||
|
|
|
@ -148,6 +148,10 @@ public:
|
||||||
|
|
||||||
static nsresult ThrowJSException(JSContext *cx, nsresult aResult);
|
static nsresult ThrowJSException(JSContext *cx, nsresult aResult);
|
||||||
|
|
||||||
|
static nsresult InitDOMJSClass(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
|
static JSClass sDOMJSClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get our JSClass pointer for the XPCNativeWrapper class
|
* Get our JSClass pointer for the XPCNativeWrapper class
|
||||||
*/
|
*/
|
||||||
|
@ -235,6 +239,9 @@ protected:
|
||||||
id == sName_id);
|
id == sName_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static JSClass sDOMConstructorProtoClass;
|
||||||
|
static JSFunctionSpec sDOMJSClass_methods[];
|
||||||
|
|
||||||
static nsIXPConnect *sXPConnect;
|
static nsIXPConnect *sXPConnect;
|
||||||
static nsIScriptSecurityManager *sSecMan;
|
static nsIScriptSecurityManager *sSecMan;
|
||||||
|
|
||||||
|
@ -338,7 +345,11 @@ protected:
|
||||||
static jsval sJavaMember_id;
|
static jsval sJavaMember_id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const JSClass *sObjectClass;
|
||||||
static const JSClass *sXPCNativeWrapperClass;
|
static const JSClass *sXPCNativeWrapperClass;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static PRBool sDoSecurityCheckInAddProperty;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef nsDOMClassInfo nsDOMGenericSH;
|
typedef nsDOMClassInfo nsDOMGenericSH;
|
||||||
|
@ -436,7 +447,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
static nsresult GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||||
JSObject *obj, JSString *str,
|
JSObject *obj, JSString *str, PRUint32 flags,
|
||||||
PRBool *did_resolve);
|
PRBool *did_resolve);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче