} NS_RELEASE(b); } else { rv = NS_ERROR_DOM_WRONG_TYPE_ERR; } } break; } case IMAGE_BORDER: { rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_BORDER, PR_FALSE); if (NS_SUCCEEDED(rv)) { PRInt32 prop; nsIDOMImage* b; if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) { rv = b->GetBorder(&prop); if(NS_SUCCEEDED(rv)) { *vp = INT_TO_JSVAL(prop); } NS_RELEASE(b); } else { rv = NS_ERROR_DOM_WRONG_TYPE_ERR; } } break; } case IMAGE_HEIGHT: { rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_HEIGHT, PR_FALSE); if (NS_SUCCEEDED(rv)) { PRInt32 prop; nsIDOMImage* b; if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) { rv = b->GetHeight(&prop); if(NS_SUCCEEDED(rv)) { *vp = INT_TO_JSVAL(prop); } NS_RELEASE(b); } else { rv = NS_ERROR_DOM_WRONG_TYPE_ERR; } } break; } case IMAGE_HSPACE: { rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_HSPACE, PR_FALSE); if (NS_SUCCEEDED(rv)) { PRInt32 prop; nsIDOMImage* b; if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) { rv = b->GetHspace(&prop); if(NS_SUCCEEDED(rv)) { *vp = INT_TO_JSVAL(prop); } NS_RELEASE(b); } else { rv = NS_ERROR_DOM_WRONG_TYPE_ERR; } } break; } case IMAGE_VSPACE: { rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_VSPACE, PR_FALSE); if (NS_SUCCEEDED(rv)) { PRInt32 prop; nsIDOMImage* b; if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) { rv = b->GetVspace(&prop); if(NS_SUCCEEDED(rv)) { *vp = INT_TO_JSVAL(prop); } NS_RELEASE(b); } else { rv = NS_ERROR_DOM_WRONG_TYPE_ERR; } } break; } case IMAGE_WIDTH: { rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_WIDTH, PR_FALSE); if (NS_SUCCEEDED(rv)) { PRInt32 prop; nsIDOMImage* b; if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) { rv = b->GetWidth(&prop); if(NS_SUCCEEDED(rv)) { *vp = INT_TO_JSVAL(prop);
GetHTMLImageElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){  nsIDOMHTMLImageElement *a = (nsIDOMHTMLImageElement*)nsJSUtils::nsGetNativeThis(cx, obj);  // If there's no private data, this must be the prototype, so ignore  if (nsnull == a) {    return JS_TRUE;  }  nsresult rv = NS_OK;  if (JSVAL_IS_INT(id)) {    nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);    if (!secMan)        return PR_FALSE;    switch(JSVAL_TO_INT(id)) {      case HTMLIMAGEELEMENT_LOWSRC:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_LOWSRC, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetLowSrc(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_NAME:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_NAME, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetName(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_ALIGN:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_ALIGN, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetAlign(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_ALT:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_ALT, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetAlt(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_BORDER:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_BORDER, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetBorder(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_HEIGHT:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_HEIGHT, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetHeight(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_HSPACE:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_HSPACE, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetHspace(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_ISMAP:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_ISMAP, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          PRBool prop;          rv = a->GetIsMap(&prop);          if (NS_SUCCEEDED(rv)) {            *vp = BOOLEAN_TO_JSVAL(prop);          }        }        break;      }      case HTMLIMAGEELEMENT_LONGDESC:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_LONGDESC, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetLongDesc(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_USEMAP:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_USEMAP, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetUseMap(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_VSPACE:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_VSPACE, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetVspace(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case HTMLIMAGEELEMENT_WIDTH:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIMAGEELEMENT_WIDTH, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          rv = a->GetWidth(prop);          if (NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);          }        }        break;      }      case IMAGE_LOWSRC:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_LOWSRC, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          nsAutoString prop;          nsIDOMImage* b;          if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) {            rv = b->GetLowsrc(prop);            if(NS_SUCCEEDED(rv)) {            nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);            }            NS_RELEASE(b);          }          else {            rv = NS_ERROR_DOM_WRONG_TYPE_ERR;          }        }        break;      }      case IMAGE_COMPLETE:      {        rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_IMAGE_COMPLETE, PR_FALSE);        if (NS_SUCCEEDED(rv)) {          PRBool prop;          nsIDOMImage* b;          if (NS_OK == a->QueryInterface(kIImageIID, (void **)&b)) {            rv = b->GetComplete(&prop);            if(NS_SUCCEEDED(rv)) {            *vp = BOOLEAN_TO_JSVAL(prop);            }            NS_RELEASE(b);          }          else {            rv = NS_ERROR_DOM_WRONG_TYPE_ERR;          }        }        break;      }      default:        return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);    }  }  else {    return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);  }  if (NS_FAILED(rv))      return nsJSUtils::nsReportError(cx, obj, rv);  return PR_TRUE;}