New content code adjusts to getting script objects through a factory interface
This commit is contained in:
@@ -347,7 +347,18 @@ static JSFunctionSpec HTMLMetaElementMethods[] =
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
HTMLMetaElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
nsIDOMHTMLMetaElement *a = (nsIDOMHTMLMetaElement*)JS_GetPrivate(cx, obj);
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
result = object->Construct(cx, obj, argc, argv, rval);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
}
|
||||
return (result == PR_TRUE) ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -404,13 +415,15 @@ nsresult NS_InitHTMLMetaElementClass(nsIScriptContext *aContext, void **aPrototy
|
||||
//
|
||||
// Method for creating a new HTMLMetaElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptHTMLMetaElement(nsIScriptContext *aContext, nsIDOMHTMLMetaElement *aSupports, nsISupports *aParent, void **aReturn)
|
||||
extern "C" NS_DOM nsresult NS_NewScriptHTMLMetaElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptHTMLMetaElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMHTMLMetaElement *aHTMLMetaElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
@@ -430,14 +443,19 @@ extern "C" NS_DOM nsresult NS_NewScriptHTMLMetaElement(nsIScriptContext *aContex
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIHTMLMetaElementIID, (void **)&aHTMLMetaElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &HTMLMetaElementClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
|
||||
NS_ADDREF(aSupports);
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aHTMLMetaElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aHTMLMetaElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user