New content code adjusts to getting script objects through a factory interface
This commit is contained in:
@@ -664,7 +664,18 @@ static JSFunctionSpec HTMLFormElementMethods[] =
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
HTMLFormElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
nsIDOMHTMLFormElement *a = (nsIDOMHTMLFormElement*)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;
|
||||
}
|
||||
|
||||
|
||||
@@ -721,13 +732,15 @@ nsresult NS_InitHTMLFormElementClass(nsIScriptContext *aContext, void **aPrototy
|
||||
//
|
||||
// Method for creating a new HTMLFormElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptHTMLFormElement(nsIScriptContext *aContext, nsIDOMHTMLFormElement *aSupports, nsISupports *aParent, void **aReturn)
|
||||
extern "C" NS_DOM nsresult NS_NewScriptHTMLFormElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptHTMLFormElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMHTMLFormElement *aHTMLFormElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
@@ -747,14 +760,19 @@ extern "C" NS_DOM nsresult NS_NewScriptHTMLFormElement(nsIScriptContext *aContex
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIHTMLFormElementIID, (void **)&aHTMLFormElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &HTMLFormElementClass, 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, aHTMLFormElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aHTMLFormElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user