if (!JS_ValueToInt32(cx, argv[0], (int32*)&index)) { return NS_ERROR_FAILURE; }  if (nsnull == mForm) { return NS_OK; }  content = do_QueryInterface(mForm); if (content) { result = content->GetDocument(*getter_AddRefs(document)); if (NS_FAILED(result)) { return result; } }  if (document) { nsCOMPtr<nsIScriptGlobalObject> globalObject; document->GetScriptGlobalObject(getter_AddRefs(globalObject)); if (globalObject) { result = globalObject->GetContext(getter_AddRefs(scriptContext)); } }   if (!scriptContext) { return NS_ERROR_FAILURE; }  result = Item((PRUint32)index, getter_AddRefs(element)); if (NS_FAILED(result)) { return result; }  if (element) { owner = do_QueryInterface(element);  if (owner) { JSObject* obj; result = owner->GetScriptObject(scriptContext, (void**)&obj); if (NS_FAILED(result)) { return result; } *aReturn = OBJECT_TO_JSVAL(obj); } }
nsFormControlList::Item(PRUint32 aIndex, nsIDOMNode** aReturn){  nsIFormControl *control = (nsIFormControl*)mElements.ElementAt(aIndex);  if (control) {    return control->QueryInterface(kIDOMNodeIID, (void**)aReturn); // keep the ref  }  *aReturn = nsnull;  return NS_OK;}