New content code adjusts to getting script objects through a factory interface

This commit is contained in:
vidur@netscape.com
1998-09-04 23:03:16 +00:00
parent e704c7ea9c
commit 81b2fa3fe3
196 changed files with 3030 additions and 445 deletions
+22 -4
View File
@@ -589,7 +589,18 @@ static JSFunctionSpec HTMLTableRowElementMethods[] =
PR_STATIC_CALLBACK(JSBool)
HTMLTableRowElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
nsIDOMHTMLTableRowElement *a = (nsIDOMHTMLTableRowElement*)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;
}
@@ -646,13 +657,15 @@ nsresult NS_InitHTMLTableRowElementClass(nsIScriptContext *aContext, void **aPro
//
// Method for creating a new HTMLTableRowElement JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptHTMLTableRowElement(nsIScriptContext *aContext, nsIDOMHTMLTableRowElement *aSupports, nsISupports *aParent, void **aReturn)
extern "C" NS_DOM nsresult NS_NewScriptHTMLTableRowElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptHTMLTableRowElement");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
nsresult result = NS_OK;
nsIDOMHTMLTableRowElement *aHTMLTableRowElement;
if (nsnull == aParent) {
parent = nsnull;
@@ -672,14 +685,19 @@ extern "C" NS_DOM nsresult NS_NewScriptHTMLTableRowElement(nsIScriptContext *aCo
return NS_ERROR_FAILURE;
}
result = aSupports->QueryInterface(kIHTMLTableRowElementIID, (void **)&aHTMLTableRowElement);
if (NS_OK != result) {
return result;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &HTMLTableRowElementClass, 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, aHTMLTableRowElement);
}
else {
NS_RELEASE(aHTMLTableRowElement);
return NS_ERROR_FAILURE;
}