if (nsnull != obj) {
if (!obj && mInner.mDocument) { nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(mInner.mDocument); if (htmlDoc) { nsCOMPtr<nsIDOMNodeList> list; result = htmlDoc->GetElementsByName(name, getter_AddRefs(list)); if (NS_FAILED(result)) { return PR_FALSE; } if (list) { PRUint32 count; list->GetLength(&count); if (count > 0) { nsCOMPtr<nsIDOMNode> node; result = list->Item(0, getter_AddRefs(node)); if (NS_FAILED(result)) { return PR_FALSE; } if (node) { nsCOMPtr<nsIScriptObjectOwner> owner = do_QueryInterface(node); result = owner->GetScriptObject(scriptContext, (void**)&obj); if (NS_FAILED(result)) { return PR_FALSE; } } } } } }  if (obj) {
nsHTMLFormElement::Resolve(JSContext *aContext, JSObject *aObj, jsval aID){  if (!JSVAL_IS_STRING(aID)) {    return PR_TRUE;  }  PRBool ret;  JSObject* obj;  char* str = JS_GetStringBytes(JS_ValueToString(aContext, aID));  nsAutoString name; name.AssignWithConversion(str);   nsCOMPtr<nsIScriptContext> scriptContext;  nsresult result = NS_OK;  result = nsLayoutUtils::GetStaticScriptContext(aContext, aObj, getter_AddRefs(scriptContext));  // If we can't get a script context, there's nothing we can do  if (!scriptContext || NS_FAILED(result)) {    return PR_FALSE;  }    result = mControls->GetNamedObject(aContext, aID, &obj);  if (NS_FAILED(result)) {    return PR_FALSE;  }  if (nsnull != obj) {    JSObject* myObj;    result = mInner.GetScriptObject(scriptContext, (void**)&myObj);    ret = ::JS_DefineProperty(aContext, myObj,                              str, OBJECT_TO_JSVAL(obj),                              nsnull, nsnull, 0);  }  else {    ret = mInner.Resolve(aContext, aObj, aID);  }    return ret;}